Package org.apache.jdo.tck.pc.lifecycle

Examples of org.apache.jdo.tck.pc.lifecycle.StateTransitionObj


            // verify that old value is still there
            PersistenceManager pm2 = null;
            try {
                pm2 = getPMF().getPersistenceManager();
                pm2.currentTransaction().begin();
                StateTransitionObj object2 =
                    (StateTransitionObj)pm2.getObjectById(oid,true);
                if (object2 == null){
                    fail(ASSERTION_FAILED,
                         "Failed to read instance from datastore via pm.getObjectById(...)");
                }
               
                int value2 = object2.readField();
                if (value2 != originalValue){
                    fail(ASSERTION_FAILED,
                         "Value has been changed with setNontransactionalWrite==true. " +
                         "New value is " + value2 + " ... Old value was " + originalValue);
                }
View Full Code Here


            // iterate the extent and use the object in a new datastore transaction
            pm.currentTransaction().setOptimistic(false);
            pm.currentTransaction().begin();
            Extent e = pm.getExtent(StateTransitionObj.class, false);
            for (Iterator i = e.iterator(); i.hasNext();) {
                StateTransitionObj next = (StateTransitionObj)i.next();
                if (oid.equals(pm.getObjectId(next))) {
                    // found instance
                    int value = next.readField();
                    if (value != originalValue){
                        fail(ASSERTION_FAILED,
                             "Value has been changed with setNontransactionalWrite==true. " +
                             "New value is " + value + " ... Old value was " + originalValue);
                    }
View Full Code Here

        object.writeField(999);
    }

    /** */
    private StateTransitionObj getPersistentNewInstance() {
        StateTransitionObj obj = new StateTransitionObj();
        pm.makePersistent(obj); // obj should transition to PERSISTENT_NEW
        int curr = currentState(obj);
        if (curr != PERSISTENT_NEW) {
            fail(ASSERTION_FAILED,
                 "Unable to create persistent-new instance " +
View Full Code Here

        if( doPersistentInstancesExist() ) return;
        int i;
        Transaction t = pm.currentTransaction();
        t.begin();
        for( i = 0; i < 50; ++i ){
            StateTransitionObj sto = new StateTransitionObj(i);
            sto.writeField(i);
            pm.makePersistent(sto);
        }
        t.commit();
        if( !doPersistentInstancesExist() )
            if (debug)
View Full Code Here

                        if( !transaction.isActive() )
                            if (debug)
                                logger.debug("StateTransitions: Transaction should be active, but it is not");
                    }

                    StateTransitionObj obj = getInstanceInState(current_state);
                    if( obj == null ){  // could not get object in state
                        if( transaction.isActive() ) transaction.rollback();
                        continue;
                    }
View Full Code Here

    }

    /** */
    void applyOperation(int operation, StateTransitionObj stobj)
    {
        StateTransitionObj obj = (StateTransitionObj) stobj;
        switch( operation ){
        case MAKEPERSISTENT:
        {
            pm.makePersistent(obj);
            break;
        }
        case DELETEPERSISTENT:
        {
            pm.deletePersistent(obj);
            break;
        }
        case MAKETRANSACTIONAL:
        {
            pm.makeTransactional(obj);
            break;
        }
        case MAKENONTRANSACTIONAL:
        {
            pm.makeNontransactional(obj);
            break;
        }
        case MAKETRANSIENT:
        {
            pm.makeTransient(obj);
            break;
        }
        case COMMITNORETAINVALUES:
        {
            pm.currentTransaction().commit();
            break;
        }
        case COMMITRETAINVALUES:
        {
            pm.currentTransaction().commit();
            break;
        }
        case ROLLBACKNORESTOREVALUES:
        {
            pm.currentTransaction().rollback();
            break;
        }
        case ROLLBACKRESTOREVALUES:
        {
            pm.currentTransaction().rollback();
            break;
        }
        case REFRESHDATASTORE:
        {
            pm.refresh(obj);
            break;
        }
        case REFRESHOPTIMISTIC:
        {
            pm.refresh(obj);
            break;
        }
        case EVICT:
        {
            pm.evict(obj);
            break;
        }
        case READOUTSIDETX:
        {
            int val = obj.readField();
            break;
        }
        case READOPTIMISTIC:
        {
            int val = obj.readField();
            break;
        }
        case READDATASTORE:
        {
            int val = obj.readField();
            break;
        }
        case WRITEOUTSIDETX:
        {
            obj.writeField(42);
            break;
        }
        case WRITEINSIDETX:
        {
            obj.writeField(42);
            break;
        }
        case RETRIEVEOUTSIDETX:
        {
            pm.retrieve(obj);
View Full Code Here

    }

    /** */
    private StateTransitionObj getTransientInstance()
    {
        StateTransitionObj obj = new StateTransitionObj(23);
        int curr = currentState(obj);
        if( curr != TRANSIENT ) {
            if (debug) {
                logger.debug("StateTransitions: Unable to create transient instance, state is " +
                             states[curr]);
View Full Code Here

    }

    /** */
    private StateTransitionObj getPersistentNewInstance()
    {
        StateTransitionObj obj = getTransientInstance();
        if( obj == null ) return null;
        pm.makePersistent(obj); // should transition to persistent-new
        int curr = currentState(obj);
        if( curr != PERSISTENT_NEW ) {
            if (debug) {
View Full Code Here

    }
   
    /** */
    public StateTransitionObj getPersistentCleanInstance()
    {
        StateTransitionObj obj = getHollowInstance();
        if( obj == null ) return null;
        StateTransitionObj sto = (StateTransitionObj) obj;
        int val = sto.readField();
        int curr = currentState(sto);
        if( curr != PERSISTENT_CLEAN ) {
            if (debug) {
                logger.debug("StateTransition: Unable to create persistent-clean instance" +
                             " from a hollow instance by reading a field, state is " +
View Full Code Here

    }
   
    /** */
    public StateTransitionObj getPersistentDirtyInstance()
    {
        StateTransitionObj obj = getHollowInstance();
        if( obj == null ) return null;
        StateTransitionObj pcobj = (StateTransitionObj) obj;
        pcobj.writeField(23);
        int curr = currentState(obj);
        if( curr != PERSISTENT_DIRTY ) {
            if (debug) {
                logger.debug("StateTransition: Unable to create persistent-dirty instance" +
                             " from a hollow instance by writing a field, state is " +
View Full Code Here

TOP

Related Classes of org.apache.jdo.tck.pc.lifecycle.StateTransitionObj

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.