Revision: 14963
http://datanucleus.svn.sourceforge.net/datanucleus/?rev=14963&view=rev
Author: andy_jefferson
Date: 2012-06-27 05:36:45 +0000 (Wed, 27 Jun 2012)
Log Message:
-----------
Further test
Modified Paths:
--------------
test/accessplatform/trunk/test.jdo.hbase/src/test/org/datanucleus/tests/ApplicationIdPersistenceTest.java
Modified: test/accessplatform/trunk/test.jdo.hbase/src/test/org/datanucleus/tests/ApplicationIdPersistenceTest.java
===================================================================
--- test/accessplatform/trunk/test.jdo.hbase/src/test/org/datanucleus/tests/ApplicationIdPersistenceTest.java 2012-06-26 13:02:48 UTC (rev 14962)
+++ test/accessplatform/trunk/test.jdo.hbase/src/test/org/datanucleus/tests/ApplicationIdPersistenceTest.java 2012-06-27 05:36:45 UTC (rev 14963)
@@ -717,6 +717,147 @@
}
/**
+ * Test persistence of an enum as a numeric.
+ */
+ public void testEnumAsNumeric()
+ {
+ Palette p;
+ Object id = null;
+
+ try
+ {
+ // ---------------------
+ // RED
+ // ---------------------
+ PersistenceManager pm = pmf.getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try
+ {
+ tx.begin();
+ p = new Palette();
+ p.setAmount(100);
+ p.setColourOrdinal(Colour.RED);
+ pm.makePersistent(p);
+ id = JDOHelper.getObjectId(p);
+ tx.commit();
+ }
+ finally
+ {
+ if (tx.isActive())
+ {
+ tx.rollback();
+ }
+ pm.close();
+ }
+ pm = pmf.getPersistenceManager();
+ tx = pm.currentTransaction();
+ try
+ {
+ tx.begin();
+ p = (Palette) pm.getObjectById(id, true);
+ assertEquals(100, p.getAmount());
+ assertEquals(Colour.RED, p.getColourOrdinal());
+ tx.commit();
+ }
+ finally
+ {
+ if (tx.isActive())
+ {
+ tx.rollback();
+ }
+ pm.close();
+ }
+
+ // ---------------------
+ // null
+ // ---------------------
+ pm = pmf.getPersistenceManager();
+ tx = pm.currentTransaction();
+ try
+ {
+ tx.begin();
+ p = new Palette();
+ p.setAmount(101);
+ p.setColourOrdinal(null);
+ pm.makePersistent(p);
+ id = JDOHelper.getObjectId(p);
+ tx.commit();
+ }
+ finally
+ {
+ if (tx.isActive())
+ {
+ tx.rollback();
+ }
+ pm.close();
+ }
+ pm = pmf.getPersistenceManager();
+ tx = pm.currentTransaction();
+ try
+ {
+ tx.begin();
+ p = (Palette) pm.getObjectById(id, true);
+ assertEquals(101, p.getAmount());
+ assertNull(p.getColourOrdinal());
+ tx.commit();
+ }
+ finally
+ {
+ if (tx.isActive())
+ {
+ tx.rollback();
+ }
+ pm.close();
+ }
+ // ---------------------
+ // GREEN
+ // ---------------------
+ pm = pmf.getPersistenceManager();
+ tx = pm.currentTransaction();
+ try
+ {
+ tx.begin();
+ p = new Palette();
+ p.setAmount(102);
+ p.setColourOrdinal(Colour.GREEN);
+ pm.makePersistent(p);
+ id = JDOHelper.getObjectId(p);
+ tx.commit();
+ }
+ finally
+ {
+ if (tx.isActive())
+ {
+ tx.rollback();
+ }
+ pm.close();
+ }
+ pm = pmf.getPersistenceManager();
+ tx = pm.currentTransaction();
+ try
+ {
+ tx.begin();
+ p = (Palette) pm.getObjectById(id, true);
+ assertEquals(102, p.getAmount());
+ assertEquals(Colour.GREEN, p.getColourOrdinal());
+ tx.commit();
+ }
+ finally
+ {
+ if (tx.isActive())
+ {
+ tx.rollback();
+ }
+ pm.close();
+ }
+ }
+ finally
+ {
+ clean(Palette.class);
+ }
+ }
+
+ /**
* Test persistence of Date field (using StringConverter).
*/
public void testDate()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|