Package com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop


  }

  void testAddAlreadyPersistedChildToParent_NoTxnSamePm(HasOneToManyJDO pojo,
      UnidirLevel unidirLevel, int count) {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    UnidirTop unidir = newUnidir(unidirLevel);
    pm.makePersistent(unidir);
    pojo.addUnidirChild(unidir);
    try {
      pm.makePersistent(pojo);
      fail("expected exception");
View Full Code Here


  }

  void testAddAlreadyPersistedChildToParent_NoTxnDifferentPm(HasOneToManyJDO pojo,
      UnidirLevel unidirLevel, int count) {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    UnidirTop unidir1 = newUnidir(unidirLevel);
    pm.makePersistent(unidir1);
    unidir1 = pm.detachCopy(unidir1);
    pm.close();
    pm = pmf.getPersistenceManager();
    unidir1 = pm.makePersistent(unidir1);
View Full Code Here

    pm.makePersistent(pojo);
    startEnd.end();

    startEnd.start();
    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
    UnidirTop unidir = newUnidir(unidirLevel);
    pojo.addUnidirChild(unidir);
    pojo.addBidirChild(bidirChild);
    startEnd.end();
    Entity unidirEntity = ds.get(KeyFactory.stringToKey(unidir.getId()));
    Entity bidirEntity = ds.get(KeyFactory.stringToKey(bidirChild.getId()));
    Entity pojoEntity = ds.get(KeyFactory.createKey(getEntityKind(pojo.getClass()), pojo.getId()));
    assertEquals(pojoEntity.getKey(), unidirEntity.getParent());
    assertEquals(pojoEntity.getKey(), bidirEntity.getParent());
  }
View Full Code Here

    pm.makePersistent(pojo);
    startEnd.end();

    startEnd.start();
    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
    UnidirTop unidir = newUnidir(unidirLevel);
    pojo.addUnidirChild(unidir);
    pojo.addBidirChild(bidirChild);
    startEnd.end();
    Entity unidirEntity = ds.get(KeyFactory.stringToKey(unidir.getId()));
    Entity bidirEntity = ds.get(KeyFactory.stringToKey(bidirChild.getId()));
    Entity pojoEntity = ds.get(KeyFactory.createKey(getEntityKind(pojo.getClass()), pojo.getId()));
    assertEquals(pojoEntity.getKey(), unidirEntity.getParent());
    assertEquals(pojoEntity.getKey(), bidirEntity.getParent());
  }
View Full Code Here

    PutPolicy policy = new PutPolicy();
    DatastoreServiceInterceptor.install(getStoreManager(), policy);
    try {
      pmf.close();
      switchDatasource(startEnd.getPmfName());
      UnidirTop unidir = new UnidirTop();
      pojo.addUnidirChild(unidir);
      pojo.addBidirChild(bidir);

      startEnd.start();
      pm.makePersistent(pojo);
View Full Code Here

    }
  }

  void testNonTxnAddOfChildToParentFailsPartwayThrough(HasOneToManyJDO pojo)
      throws Throwable {
    UnidirTop unidir1 = new UnidirTop();
    pojo.addUnidirChild(unidir1);
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    final String kind = kindForObject(pojo);
    DatastoreServiceInterceptor.Policy policy = new DatastoreServiceInterceptor.Policy() {
      public void intercept(Object o, Method method, Object[] params) {
        if (method.getName().equals("put") && ((Entity) params[0]).getKind().equals(kind)) {
          throw new ConcurrentModificationException("kaboom");
        }
      }
    };
    DatastoreServiceInterceptor.install(getStoreManager(), policy);
    UnidirTop unidir2 = new UnidirBottom();
    try {
      pmf.close();
      switchDatasource(PersistenceManagerFactoryName.nontransactional);
      pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
      pojo.addUnidirChild(unidir2);
      pm.close();
      fail("expected exception");
    } catch (ConcurrentModificationException cme) {
      // good
    } finally {
      DatastoreServiceInterceptor.uninstall();
    }
    // prove that the book entity exists
    ds.get(KeyFactory.stringToKey(unidir2.getId()));
    Entity pojoEntity = ds.get(KeyFactory.stringToKey(pojo.getId()));
    // the parent has a reference to the first book that was already there
    // but no reference to the second book
    assertEquals(
        Collections.singletonList(KeyFactory.stringToKey(unidir1.getId())),
View Full Code Here

  }
 
  UnidirTop newUnidir(UnidirLevel level) {
    switch (level) {
    case Top:
      UnidirTop top = new UnidirTop();
      top.setStr("top");
      top.setName("top name");
      return top;

    case Middle:
      UnidirMiddle middle = new UnidirMiddle();
      middle.setStr("middle");
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

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.