Package org.apache.jdo.tck.pc.mylib

Examples of org.apache.jdo.tck.pc.mylib.VersionedPCPoint$Oid


        addTearDownClass(VersionedPCPoint.class);
        getPM().currentTransaction().begin();
        pm.currentTransaction().setNontransactionalWrite(true);
        pm.currentTransaction().setNontransactionalRead(true);
        pm.currentTransaction().setRetainValues(true);
        VersionedPCPoint instance =  new VersionedPCPoint(originalXValue, 200);
        pm.makePersistent(instance);
        oid = pm.getObjectId(instance);
        pm.currentTransaction().commit();
        instance.setX(newXValue);
        return instance;
    }
View Full Code Here


     * dirty instance.
     */
    protected void checkXValue(String location, int expectedXValue) {
        PersistenceManager pmCheck = pmf.getPersistenceManager();
        pmCheck.currentTransaction().begin();
        VersionedPCPoint instance =
                (VersionedPCPoint)pmCheck.getObjectById(oid, true);
        int actualXValue = instance.getX();
        pmCheck.currentTransaction().commit();
        cleanupPM(pmCheck);
        if (expectedXValue != actualXValue) {
            appendMessage(location + NL +
                    "expected: " + expectedXValue + NL +
View Full Code Here

     * persistence manager.
     */
    protected void conflictingUpdate() {
        PersistenceManager pmConflict = pmf.getPersistenceManager();
        pmConflict.currentTransaction().setOptimistic(false);
        VersionedPCPoint instance =
                (VersionedPCPoint)pmConflict.getObjectById(oid);
        instance.setX(conflictXValue);
        pmConflict.currentTransaction().commit();
        cleanupPM(pmConflict);
    }
View Full Code Here

           p5oid = pm1.getObjectId(p5);
           tx1.commit();
          
           // update/delete the instances in tx1
           tx1.begin();
           VersionedPCPoint p1tx1 = (VersionedPCPoint)pm1.getObjectById(p1oid, true);
           VersionedPCPoint p2tx1 = (VersionedPCPoint)pm1.getObjectById(p2oid, true);
           VersionedPCPoint p3tx1 = (VersionedPCPoint)pm1.getObjectById(p3oid, true);
           VersionedPCPoint p4tx1 = (VersionedPCPoint)pm1.getObjectById(p4oid, true);
           p1tx1.setX(101);
           p2tx1.setX(201);
           pm1.deletePersistent(p3tx1);
           pm1.deletePersistent(p4tx1);
          
           // update/delete the instances in tx2
           tx2.begin();
           VersionedPCPoint p1tx2 = (VersionedPCPoint)pm2.getObjectById(p1oid, true);
           VersionedPCPoint p2tx2 = (VersionedPCPoint)pm2.getObjectById(p2oid, true);
           VersionedPCPoint p3tx2 = (VersionedPCPoint)pm2.getObjectById(p3oid, true);
           VersionedPCPoint p4tx2 = (VersionedPCPoint)pm2.getObjectById(p4oid, true);
           VersionedPCPoint p5tx2 = (VersionedPCPoint)pm2.getObjectById(p5oid, true);
           p1tx2.setX(102);
           pm2.deletePersistent(p2tx2);
           p3tx2.setX(202);
           pm2.deletePersistent(p4tx2);
           p5tx2.setX(502); // this change must not be committed
           Set expectedFailedObjects = new HashSet();
           expectedFailedObjects.add(p1tx2);
           expectedFailedObjects.add(p2tx2);
           expectedFailedObjects.add(p3tx2);
           expectedFailedObjects.add(p4tx2);
          
           // commit tx1 (should succeed)
           tx1.commit();
           tx1 = null;
          
           // commit tx2 (should fail)
           try {
               tx2.commit();
               fail(ASSERTION_FAILED, "concurrent commit not detected");
           }
           catch (JDOOptimisticVerificationException ex) {
               // verify the correct information in the exception
               Throwable[] ts = ex.getNestedExceptions();
               int length = ts==null ? 0 : ts.length;
               int expectedFailures = expectedFailedObjects.size();
               if (length != expectedFailures) {
                   fail(ASSERTION_FAILED,
                        "Nested exceptions[] wrong size: expected " +
                        expectedFailures + ", got " + length);
               }
               for (int i = 0; i < length; ++i) {
                   Throwable t = ts[i];
                   if (t instanceof JDOOptimisticVerificationException) {
                       if (debug)
                           logger.debug("Expected exception caught " + t.toString());
                       JDOException jex = (JDOException)t;
                       Object failed = jex.getFailedObject();
                       if (failed == null) {
                           fail(ASSERTION_FAILED,
                                "Found unexpected null in failed object");
                       }
                       else {
                           if (expectedFailedObjects.remove(failed)) {
                               if (debug)
                                   logger.debug("Found expected failed instance, oid: " +
                                                JDOHelper.getObjectId(failed));
                           }
                           else {
                               fail(ASSERTION_FAILED,
                                    "Unexpected failed instance: " + failed.toString());
                           }
                       }
                   }
                   else {
                       fail(ASSERTION_FAILED,
                            "Unexpected nested exception: " + t.toString());
                   }
               }
           }
           tx2 = null;
          
           tx3.begin();
           VersionedPCPoint p1tx3 = (VersionedPCPoint)pm3.getObjectById(p1oid, true);
           VersionedPCPoint p2tx3 = (VersionedPCPoint)pm3.getObjectById(p2oid, true);
           VersionedPCPoint p5tx3 = (VersionedPCPoint)pm3.getObjectById(p5oid, true);
           verify(p1tx3, 101);
           verify(p2tx3, 201);
           verify(p5tx3, 5);
           tx3.commit();
           tx3 = null;
View Full Code Here

TOP

Related Classes of org.apache.jdo.tck.pc.mylib.VersionedPCPoint$Oid

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.