Package org.objectweb.speedo.pobjects.userid

Examples of org.objectweb.speedo.pobjects.userid.StringUserId


            String name = "testStringId1";
            int f1 = 12;
            Object id;
            String strid;
            PersistenceManager pm = pmf.getPersistenceManager();
            StringUserId sui = new StringUserId(name, f1);
            pm.makePersistent(sui);
            id = pm.getObjectId(sui);
            Assert.assertNotNull("identifier is null", id);
            strid = id.toString();
            id = null;
            pm.close();
            sui = null; // garbage object
            pm = pmf.getPersistenceManager();
            id = pm.newObjectIdInstance(StringUserId.class, strid);
            sui = (StringUserId) pm.getObjectById(id, false);
            Assert.assertNotNull("returned object is null", sui);
            Assert.assertEquals("Bad field 'name' value", name, sui.getName());
            Assert.assertEquals("Bad field 'f1' value", f1, sui.getF1());
            pm.currentTransaction().begin();
            pm.deletePersistent(sui);
            pm.currentTransaction().commit();
            pm.close();
        } catch (Exception e) {
View Full Code Here


        try {
            String name = "testStringId2";
            int f1 = 12;
            Object id;
            PersistenceManager pm = pmf.getPersistenceManager();
            StringUserId sui = new StringUserId(name, f1);
            pm.makePersistent(sui);
            id = pm.getObjectId(sui);
            Assert.assertNotNull("identifier is null", id);
            id = null;
            pm.close();
            sui = null; // garbage object
            pm = pmf.getPersistenceManager();
            id = pm.newObjectIdInstance(StringUserId.class, name);
            sui = (StringUserId) pm.getObjectById(id, false);
            Assert.assertNotNull("returned object is null", sui);
            Assert.assertEquals("Bad field 'name' value", name, sui.getName());
            Assert.assertEquals("Bad field 'f1' value", f1, sui.getF1());
            pm.currentTransaction().begin();
            pm.deletePersistent(sui);
            pm.currentTransaction().commit();
            pm.close();
        } catch (Exception e) {
View Full Code Here

  public void testTwiceMakePersistent() {
        try {
            String name = "testTwiceMakePersistent";
            String strid;
            PersistenceManager pm = pmf.getPersistenceManager();
            StringUserId sui = new StringUserId(name, 123456);
            pm.currentTransaction().begin();
            pm.makePersistent(sui);
            pm.currentTransaction().commit();

            StringUserId sui2 = new StringUserId(name, 654321);
            pm.currentTransaction().begin();
            try {
                pm.makePersistent(sui2);
                fail("Same identifier not detected");
            } catch (JDOException e) {
                assertTrue("Object becomes persistent", !JDOHelper.isPersistent(sui2));
                assertEquals("Bad f1 value in non peristent object", 654321, sui2.getF1());
            }
            pm.currentTransaction().commit();
 
            sui = null;
            pm.evictAll();
            pm.currentTransaction().begin();
            try {
                pm.makePersistent(sui2);
                pm.currentTransaction().commit();
              fail("Same identifier not detected with empty cache");
            } catch (JDOException e) {
                if (pm.currentTransaction().isActive()) {
                    pm.currentTransaction().rollback();
                }
                assertTrue("Object becomes persistent", !JDOHelper.isPersistent(sui2));
                assertEquals("Bad f1 value in non peristent object with empty cache",
                        654321, sui2.getF1());
            }

            pm.currentTransaction().begin();
            sui = (StringUserId) pm.getObjectById(
                    pm.newObjectIdInstance(StringUserId.class, name), false);
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.userid.StringUserId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.