Package com.google.appengine.datanucleus

Examples of com.google.appengine.datanucleus.CollisionDatastoreDelegate


    ds.put(e);
    beginTxn();
    Flight f = pm.detachCopy(pm.getObjectById(Flight.class, e.getKey()));
    commitTxn();

    CollisionDatastoreDelegate dd = new CollisionDatastoreDelegate(getDelegateForThread());
    setDelegateForThread(dd);

    try {
      // update detached object
      f.setYou(12);
      beginTxn();

      // reattach
      pm.makePersistent(f);
      try {
        commitTxn();
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
      assertFalse(pm.currentTransaction().isActive());
      // now verify that the new value is still in the detached version.
      assertEquals(f, "harold", "bos", "mia", 12, 24, 88);
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here


  }

  public void testDeleteCollides() {
    Entity e = Flight.newFlightEntity("harold", "bos", "mia", 23, 24, 88);
    ds.put(e);
    CollisionDatastoreDelegate dd = new CollisionDatastoreDelegate(getDelegateForThread());
    setDelegateForThread(dd);

    try {
      beginTxn();
      Flight f = pm.getObjectById(Flight.class, e.getKey());

      try {
        pm.deletePersistent(f);
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
      assertTrue(pm.currentTransaction().isActive());
      rollbackTxn();
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

    }
  }

  public void testInsertCollides_NoTxn() {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    CollisionDatastoreDelegate dd = new CollisionDatastoreDelegate(getDelegateForThread());
    setDelegateForThread(dd);
    try {
      Flight flight = new Flight();
      flight.setName("harold");
      flight.setOrigin("bos");
      flight.setDest("mia");
      flight.setYou(23);
      flight.setMe(24);
      flight.setFlightNumber(88);
      try {
        pm.makePersistent(flight);
        fail("expected exception");
      } catch (JDODataStoreException e) {
        // good
        assertTrue(e.getCause() instanceof ConcurrentModificationException);
      }
      assertEquals(flight, "harold", "bos", "mia", 23, 24, 88);
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

  public void testUpdateCollides_NoTxn() {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    Entity e = Flight.newFlightEntity("harold", "bos", "mia", 23, 24, 88);
    ds.put(e);
    CollisionDatastoreDelegate dd = new CollisionDatastoreDelegate(getDelegateForThread());
    setDelegateForThread(dd);

    try {
      try {
        Flight f = pm.getObjectById(Flight.class, e.getKey());
        f.setYou(12);
        pm.close();
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      } catch (NucleusDataStoreException ex) {
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

    ds.put(e);
    Flight f = pm.detachCopy(pm.getObjectById(Flight.class, e.getKey()));
    pm.close();
    pm = pmf.getPersistenceManager();

    CollisionDatastoreDelegate dd = new CollisionDatastoreDelegate(getDelegateForThread());
    setDelegateForThread(dd);

    try {
      // update detached object
      f.setYou(12);

      // reattach
      try {
        pm.makePersistent(f);
        pm.close();
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
      // now verify that the new value is still in the detached version.
      assertEquals(f, "harold", "bos", "mia", 12, 24, 88);
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

  public void testDeleteCollides_NoTxn() {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);

    Entity e = Flight.newFlightEntity("harold", "bos", "mia", 23, 24, 88);
    ds.put(e);
    CollisionDatastoreDelegate dd = new CollisionDatastoreDelegate(getDelegateForThread());
    setDelegateForThread(dd);

    try {
      Flight f = pm.getObjectById(Flight.class, e.getKey());

      try {
        pm.deletePersistent(f);
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
      pm.close();
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.CollisionDatastoreDelegate

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.