Package org.apache.jdo.tck.pc.instancecallbacks

Examples of org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass


       
        InstanceCallbackClass.initializeStaticsForTest();

        InstanceCallbackClass.performPreDeleteTests = true; // enabling PreDelete tests
        t.begin();
        InstanceCallbackClass a = new InstanceCallbackClass(null, null, 1, 1.0, (short)-1, '1', null);
        InstanceCallbackClass b = new InstanceCallbackClass(null, null, 2, 2.0, (short)-1, '2', null);
        pm.makePersistent(a);
        pm.makePersistent(b);
        Object aId  = pm.getObjectId(a);
        Object bId  = pm.getObjectId(b);
        t.commit();
       
        t.begin();
        try {
            a = (InstanceCallbackClass)pm.getObjectById(aId, true);
        } catch (JDOUserException e) {
            fail(ASSERTION_FAILED, "CallingJdoPredelete: Failed to find object a created in previous transaction, got JDOUserException " + e);
            return;
        }
        try {
            b = (InstanceCallbackClass)pm.getObjectById(bId, true);
        } catch (JDOException e) {
            fail(ASSERTION_FAILED, "CallingJdoPredelete: Failed to find object b created in previous transaction, got JDOUserException " + e);
            return;
        }
       
        int getfld = a.intValue;    // cause instance to be persistent-clean 
        int getfld2 = a.childToDelete;
        b.childToDelete++;          // make second object dirty
        InstanceCallbackClass c = new InstanceCallbackClass(null, null, 3, 3.0, (short)-1, '3', null);
        pm.makePersistent(c);       // create persistent-new object
       
        InstanceCallbackClass.preDeleteCalled = false;
        pm.deletePersistent(a);
        if(!InstanceCallbackClass.preDeleteCalled) {
View Full Code Here


        InstanceCallbackClass.initializeStaticsForTest();
       
        t.begin();
        // make intValue outside the range of zero to arraySize-1 to skip most jdoPreDelete() code.
        InstanceCallbackClass a = new InstanceCallbackClass("object a", null, InstanceCallbackClass.arraySize, 6.0, (short)-1, '6', null);
        pm.makePersistent(a);
        Object aId = pm.getObjectId(a);
        t.commit();
       
        t.begin();
        // relocte object.
        try {
            a = (InstanceCallbackClass)pm.getObjectById(aId, true);
        } catch (JDOUserException e) {
            fail(ASSERTION_FAILED, "NoAccessToFieldsAfterPredelete:  Could not locate persistent object created in previous transaction, got " + e);
            return;
        } catch (JDODataStoreException e) {
            fail(ASSERTION_FAILED, "NoAccessToFieldsAfterPredelete:  Could not locate persistent object created in previous transaction, got " + e);
            return;
        }
       
        pm.deletePersistent(a);
        performAccessFieldTests("Object in state persistent-deleted:  ", a);
       
        InstanceCallbackClass b = new InstanceCallbackClass("object b", null, InstanceCallbackClass.arraySize + 1, 7.0, (short)-1, '7', null);
        pm.makePersistent(b);
        pm.deletePersistent(b);
        performAccessFieldTests("Object in state persistent-new-deleted:  ", b);
       
        t.rollback();
View Full Code Here

        } catch (JDOUserException e) {
            // expected
        }
       
        try {
            InstanceCallbackClass x7 = o.nextObj;
            // http://issues.apache.org/jira/browse/JDO-413
            // fail(ASSERTION_FAILED, title + "Accessed persistent InstanceCallbackClass reference field nextObj--should have gotten JDOUserException");
        } catch (JDOUserException e) {
            // expected
        }
View Full Code Here

        InstanceCallbackClass.initializeStaticsForTest();

        InstanceCallbackClass.performPreDeleteTests = true;
        t.begin();
        Date createTime = new Date();
        InstanceCallbackClass secondaryObj = new InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short)-1, '2', null);
        InstanceCallbackClass primaryObj = new InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short)3, '1', secondaryObj);
        InstanceCallbackClass childA = new InstanceCallbackClass("childA", createTime, 3, 3.0, (short)-2, '3', null);
        InstanceCallbackClass childB = new InstanceCallbackClass("childB", createTime, 4, 4.0, (short)-3, '4', null);
        pm.makePersistent(primaryObj);
        pm.makePersistent(secondaryObj);
        pm.makePersistent(childA);
        pm.makePersistent(childB);
        primaryObj.addChild(childA);
View Full Code Here

        InstanceCallbackClass.performPreStoreTests = true;
        t.begin();
        //  Create primaryObj which has a collection (children) of two objects and references another (nextObj).
        //  None of the other objects have a non-empty collection.  The also all have nextObj set to null.
        Date createTime = new Date();
        InstanceCallbackClass secondaryObj = new InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short)-1, '2', null);
        InstanceCallbackClass primaryObj = new InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short)3, '1', secondaryObj);
        InstanceCallbackClass childA = new InstanceCallbackClass("childA", createTime, 3, 3.0, (short)-2, '3', null);
        InstanceCallbackClass childB = new InstanceCallbackClass("childB", createTime, 4, 4.0, (short)-3, '4', null);
        pm.makePersistent(primaryObj);
        primaryObj.addChild(childA);
        primaryObj.addChild(childB);
        t.commit();
View Full Code Here

        Calendar cal = Calendar.getInstance();
        cal.set(1999, 1, 15, 12, 0);
        Date createTime = cal.getTime();
        cal.set(2002, 1, 15, 12, 0);
        Date laterDate = cal.getTime();
        InstanceCallbackClass secondaryObj =
            new InstanceCallbackClass("secondaryObj", createTime, 2, 2.2,
                    (short)-20, '2', null);
        InstanceCallbackClass primaryObj =
            new InstanceCallbackClass("primaryObj", laterDate, 1, 1.1,
                    (short)-10, '1', secondaryObj);
        pm.makePersistent(primaryObj);
        pm.makePersistent(secondaryObj);
        Object secondaryObjId = pm.getObjectId(secondaryObj);
        Object primaryObjId = pm.getObjectId(primaryObj);
        t.commit();

        InstanceCallbackClass.performPreClearTests = true;
        t.setOptimistic(false);
        t.begin();
        try {
            primaryObj = (InstanceCallbackClass)pm.getObjectById(primaryObjId,
                    true);
            pm.retrieve(primaryObj); // load fields (make it persistent-clean)
       
        } catch (JDOUserException e) {
            fail(ASSERTION_FAILED, "Failed to find primaryObj created in "
                    + "previous transaction.  Got JDOUserException " + e);
            return;
        } catch (JDODataStoreException e) {
            fail(ASSERTION_FAILED, "Failed to find primaryObj created in "
                    + "previous transaction.  Got JDODataStoreException " + e);
           return;
        }
       
        secondaryObj = primaryObj.nextObj;
        if(secondaryObj == null) {
            fail(ASSERTION_FAILED, "Failed to find secondaryObj created in "
                    + "previous transaction using reference from primaryObj.");
            return;
        }
        pm.retrieve(secondaryObj);
       
        // primaryObj contains one child;  secondaryObj contains none
        primaryObj.addChild(secondaryObj); // primaryObj is now dirty
       
        cal.set(2005, 6, 28, 0, 0);
        Date stillLaterDate = cal.getTime();
        InstanceCallbackClass ternaryObj =
            new InstanceCallbackClass("ternaryObj", stillLaterDate, 3, 3.3,
                    (short)-30, '3', null);
        pm.makePersistent(ternaryObj);
        ternaryObj.addChild(primaryObj);
        t.commit();
       
        // verify attributes in what was persistent-clean object--secondaryObj
        checkFieldValues(ASSERTION_FAILED, "jdoPreClear attribute access:  ",
                2"secondaryObj", createTime, 2.2, (short)-20, '2');
View Full Code Here

       
        InstanceCallbackClass.initializeStaticsForTest();

        InstanceCallbackClass.performPreDeleteTests = true; // enabling PreDelete tests
        t.begin();
        InstanceCallbackClass a = new InstanceCallbackClass(null, null, 1, 1.0, (short)-1, '1', null);
        InstanceCallbackClass b = new InstanceCallbackClass(null, null, 2, 2.0, (short)-1, '2', null);
        pm.makePersistent(a);
        pm.makePersistent(b);
        Object aId  = pm.getObjectId(a);
        Object bId  = pm.getObjectId(b);
        t.commit();
       
        t.begin();
        try {
            a = (InstanceCallbackClass)pm.getObjectById(aId, true);
        } catch (JDOUserException e) {
            fail(ASSERTION_FAILED, "CallingJdoPredelete: Failed to find object a created in previous transaction, got JDOUserException " + e);
            return;
        }
        try {
            b = (InstanceCallbackClass)pm.getObjectById(bId, true);
        } catch (JDOException e) {
            fail(ASSERTION_FAILED, "CallingJdoPredelete: Failed to find object b created in previous transaction, got JDOUserException " + e);
            return;
        }
       
        int getfld = a.intValue;    // cause instance to be persistent-clean 
        int getfld2 = a.childToDelete;
        b.childToDelete++;          // make second object dirty
        InstanceCallbackClass c = new InstanceCallbackClass(null, null, 3, 3.0, (short)-1, '3', null);
        pm.makePersistent(c);       // create persistent-new object
       
        InstanceCallbackClass.preDeleteCalled = false;
        pm.deletePersistent(a);
        if(!InstanceCallbackClass.preDeleteCalled) {
View Full Code Here

        InstanceCallbackClass.initializeStaticsForTest();
       
        t.begin();
        // make intValue outside the range of zero to arraySize-1 to skip most jdoPreDelete() code.
        InstanceCallbackClass a = new InstanceCallbackClass("object a", null, InstanceCallbackClass.arraySize, 6.0, (short)-1, '6', null);
        pm.makePersistent(a);
        Object aId = pm.getObjectId(a);
        t.commit();
       
        t.begin();
        // relocte object.
        try {
            a = (InstanceCallbackClass)pm.getObjectById(aId, true);
        } catch (JDOUserException e) {
            fail(ASSERTION_FAILED, "NoAccessToFieldsAfterPredelete:  Could not locate persistent object created in previous transaction, got " + e);
            return;
        } catch (JDODataStoreException e) {
            fail(ASSERTION_FAILED, "NoAccessToFieldsAfterPredelete:  Could not locate persistent object created in previous transaction, got " + e);
            return;
        }
       
        pm.deletePersistent(a);
        performAccessFieldTests("Object in state persistent-deleted:  ", a);
       
        InstanceCallbackClass b = new InstanceCallbackClass("object b", null, InstanceCallbackClass.arraySize + 1, 7.0, (short)-1, '7', null);
        pm.makePersistent(b);
        pm.deletePersistent(b);
        performAccessFieldTests("Object in state persistent-new-deleted:  ", b);
       
        t.rollback();
View Full Code Here

        } catch (JDOUserException e) {
            // expected
        }
       
        try {
            InstanceCallbackClass x7 = o.nextObj;
            fail(ASSERTION_FAILED, title + "Accessed persistent InstanceCallbackClass reference field nextObj--should have gotten JDOUserException");
        } catch (JDOUserException e) {
            // expected
        }
    }
View Full Code Here

        InstanceCallbackClass.initializeStaticsForTest();

        InstanceCallbackClass.performPreDeleteTests = true;
        t.begin();
        Date createTime = new Date();
        InstanceCallbackClass secondaryObj = new InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short)-1, '2', null);
        InstanceCallbackClass primaryObj = new InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short)3, '1', secondaryObj);
        InstanceCallbackClass childA = new InstanceCallbackClass("childA", createTime, 3, 3.0, (short)-2, '3', null);
        InstanceCallbackClass childB = new InstanceCallbackClass("childB", createTime, 4, 4.0, (short)-3, '4', null);
        pm.makePersistent(primaryObj);
        pm.makePersistent(secondaryObj);
        pm.makePersistent(childA);
        pm.makePersistent(childB);
        primaryObj.addChild(childA);
View Full Code Here

TOP

Related Classes of org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass

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.