Examples of PersistenceManagerFactory


Examples of javax.jdo.PersistenceManagerFactory

    pm.close();
    pmf.close();
  }

  public void testIllegalWrites() throws Exception {
    PersistenceManagerFactory pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.transactional.name());
    PersistenceManager pm = pmf.getPersistenceManager();
    testIllegalWritePermutation(pm, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED);
    pm.close();
    pmf.close();
    pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.nontransactional.name());
    pm = pmf.getPersistenceManager();
    testIllegalWritePermutation(pm, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED);
    pm.close();
    pmf.close();
  }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

    pm.close();
    pmf.close();
  }

  public void testIllegalUpdates() throws Exception {
    PersistenceManagerFactory pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.transactional.name());
    testIllegalUpdatePermutation(pmf, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED);
    pmf.close();
    pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.nontransactional.name());
    testIllegalUpdatePermutation(pmf, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED);
    pmf.close();
  }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

    testIllegalUpdatePermutation(pmf, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED);
    pmf.close();
  }

  public void testIllegalReads() throws Exception {
    PersistenceManagerFactory pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.transactional.name());
    PersistenceManager pm = pmf.getPersistenceManager();
    testIllegalReadPermutation(pm, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED);
    pm.close();
    pmf.close();
    pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.nontransactional.name());
    pm = pmf.getPersistenceManager();
    testIllegalReadPermutation(pm, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED);
    pm.close();
    pmf.close();
  }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

    }
  };

  @Inner("TODO -- see if we can avoid this tx mock check")
  public void testQueriesWithDatastoreTxn() throws Exception {
    PersistenceManagerFactory pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.transactional.name());
    PersistenceManager pm = pmf.getPersistenceManager();
    testQueryPermutationWithExpectedDatastoreTxn(pm, EXPLICIT_DEMARCATION, NON_TXN_OP_ALLOWED, ANCESTOR);
    testQueryPermutationWithExpectedDatastoreTxn(pm, EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED, ANCESTOR);
    testQueryPermutationWithExpectedDatastoreTxn(pm, EXPLICIT_DEMARCATION, NON_TXN_OP_ALLOWED, NON_ANCESTOR);
    testQueryPermutationWithExpectedDatastoreTxn(pm, EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED, NON_ANCESTOR);
    pm.close();
    pmf.close();
  }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

    pm.close();
    pmf.close();
  }

  public void testQueriesWithoutDatastoreTxn() throws Exception {
    PersistenceManagerFactory pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.transactional.name());
    PersistenceManager pm = pmf.getPersistenceManager();
    testQueryPermutationWithoutExpectedDatastoreTxn(pm, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_ALLOWED, ANCESTOR);
    pm.close();
    pmf.close();

    pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.nontransactional.name());
    pm = pmf.getPersistenceManager();
    testQueryPermutationWithoutExpectedDatastoreTxn(pm, EXPLICIT_DEMARCATION, NON_TXN_OP_ALLOWED, ANCESTOR);
    testQueryPermutationWithoutExpectedDatastoreTxn(pm, EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED, ANCESTOR);
    testQueryPermutationWithoutExpectedDatastoreTxn(pm, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_ALLOWED, ANCESTOR);
    testQueryPermutationWithoutExpectedDatastoreTxn(pm, EXPLICIT_DEMARCATION, NON_TXN_OP_ALLOWED, NON_ANCESTOR);
    testQueryPermutationWithoutExpectedDatastoreTxn(pm, EXPLICIT_DEMARCATION, NON_TXN_OP_NOT_ALLOWED, NON_ANCESTOR);
    testQueryPermutationWithoutExpectedDatastoreTxn(pm, NO_EXPLICIT_DEMARCATION, NON_TXN_OP_ALLOWED, NON_ANCESTOR);

    pm.close();
    pmf.close();
  }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

    pm.close();
    pmf.close();
  }

  public void testEmptyTxnBlock_Txn() {
    PersistenceManagerFactory pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.transactional.name());
    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      EasyMock.expect(mockDatastoreService.beginTransaction(EasyMock.isA(TransactionOptions.class))).andReturn(mockTxn);
      EasyMock.expect(mockTxn.getId()).andAnswer(txnIdAnswer);
      EasyMock.expect(mockTxn.getId()).andAnswer(txnIdAnswer);
      mockTxn.commit();
      EasyMock.expectLastCall();
      EasyMock.replay(mockDatastoreService, mockTxn);
      pm.currentTransaction().begin();
      pm.currentTransaction().commit();
      EasyMock.verify(mockDatastoreService, mockTxn);
    } finally {
      if (pm.currentTransaction().isActive()) {
        pm.currentTransaction().rollback();
      }
      pm.close();
      pmf.close();
    }
  }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

      pmf.close();
    }
  }

  public void testEmptyTxnBlock_NoTxn() {
    PersistenceManagerFactory pmf = getPersistenceManagerFactory(
        JDOTestCase.PersistenceManagerFactoryName.nontransactional.name());
    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      EasyMock.replay(mockDatastoreService, mockTxn);
      pm.currentTransaction().begin();
      pm.currentTransaction().commit();
      EasyMock.verify(mockDatastoreService, mockTxn);
    } finally {
      if (pm.currentTransaction().isActive()) {
        pm.currentTransaction().rollback();
      }
      pm.close();
      pmf.close();
    }
  }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

* @author Max Ross <maxr@google.com>
*/
public class JDOPersistenceManagerFactoryTest extends TestCase {

  public void testAllocationOfDuplicateNamedPMFAsSingleton() {
    PersistenceManagerFactory pmf1 = null;
    PersistenceManagerFactory pmf2 = null;
    try {
      pmf1 = JDOHelper.getPersistenceManagerFactory("nontransactional-singleton");

      pmf2 = JDOHelper.getPersistenceManagerFactory("nontransactional-singleton");

      assertTrue(pmf1 == pmf2);
    }
    catch (Exception e) {
      fail("Exception thrown during allocation of two PMFs with same name requiring singleton");
    }
    finally {
      if (pmf1 != pmf2) {
        if (pmf1 != null) {
          pmf1.close();
        }
        if (pmf2 != null) {
          pmf2.close();
        }
      }
      else {
        if (pmf1 != null) {
          pmf1.close();
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

      }
    }
  }

  public void testAllocationOfDuplicateNamedPMF() {
    PersistenceManagerFactory pmf1 = null;
    PersistenceManagerFactory pmf2 = null;
    try {
      pmf1 = JDOHelper.getPersistenceManagerFactory("nontransactional");

      pmf2 = JDOHelper.getPersistenceManagerFactory("nontransactional");

      assertTrue(pmf1 != pmf2);
    }
    catch (Exception e) {
      fail("Exception thrown during allocation of two PMFs with same name");
    }
    finally {
      if (pmf1 != pmf2) {
        if (pmf1 != null) {
          pmf1.close();
        }
        if (pmf2 != null) {
          pmf2.close();
        }
      }
      else {
        if (pmf1 != null) {
          pmf1.close();
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

@Inner("Solve the problem of lazy loading of classes; e.g. no SuperclassTableInheritanceJDO#ChildToParentWithoutDiscriminator")
public class MigratorTest extends JDOTestCase {

  public void testMigrateOneToOneUni() {
    // Persist Parent+Child (1-1 relation) to old storage version
    PersistenceManagerFactory oldPMF = JDOHelper.getPersistenceManagerFactory("originalStorageVersion");
    PersistenceManager oldPM = oldPMF.getPersistenceManager();
    MigratorOneToOneParent p = new MigratorOneToOneParent();
    p.setName("First Parent");
    MigratorOneToOneChild c = new MigratorOneToOneChild();
    c.setName("Child 1");
    p.setChild(c);
    beginTxn();
    oldPM.makePersistent(p);
    commitTxn();
    ObjectIdentity pId = (ObjectIdentity)oldPM.getObjectId(p);
    ObjectIdentity cId = (ObjectIdentity)oldPM.getObjectId(c);
    Key pIdKey = (Key)pId.getKey();
    Key cIdKey = (Key)cId.getKey();
    oldPM.close();

    // Migrate the data
    Migrator migrator = new Migrator(((JDOPersistenceManagerFactory)oldPMF).getNucleusContext());
    try {
      // Migrate the parent
      Entity pEntity = ds.get(pIdKey);
      boolean changed = migrator.migrate(pEntity, MigratorOneToOneParent.class);
      assertTrue("Parent entity should have been changed but wasnt", changed);
      if (changed) {
        ds.put(pEntity);
      }

      // Migrate the child
      Entity cEntity = ds.get(cIdKey);
      changed = migrator.migrate(cEntity, MigratorOneToOneChild.class);
      assertFalse("Child entity shouldnt have been changed but was", changed);
      if (changed) {
        ds.put(cEntity);
      }

      assertTrue("Child keys property not added to parent", pEntity.hasProperty("child_id_OID"));
      Object propValue = pEntity.getProperty("child_id_OID");
      assertNotNull(propValue);
      assertEquals("Child key property value is not the same as the child key", cIdKey, propValue);
    } catch (EntityNotFoundException enfe) {
      fail("Some entity was not found");
    }

    oldPMF.close();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.