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

Examples of org.apache.jdo.tck.pc.mylib.PrimitiveTypes


    void runTestNewInstance(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        tx.begin();
       
        // create new instance
        PrimitiveTypes newInstance = new PrimitiveTypes();
        newInstance.setId(98L);
        newInstance.setIntNotNull(98);
        pm.makePersistent(newInstance);
       
        Collection result = (Collection)pm.newQuery(
            PrimitiveTypes.class, "intNotNull == 98").execute();
        // check result
        if (result.isEmpty())
            fail(ASSERTION_FAILED,
                 "Query should find new instance, but query result is empty");
        Iterator i = result.iterator();
        PrimitiveTypes p = (PrimitiveTypes)i.next();
        if (p.getId() != 98L)
            fail(ASSERTION_FAILED,
                 "Query returned wrong instance with id " + p.getId());
        if (i.hasNext())
            fail(ASSERTION_FAILED,
                 "Query returned more than one instance");
       
        if (debug)
View Full Code Here


        Transaction tx = pm.currentTransaction();
        tx.begin();
       
        Collection tmp = (Collection)pm.newQuery(
            PrimitiveTypes.class, "id == 3").execute();
        PrimitiveTypes instance3 = (PrimitiveTypes)tmp.iterator().next();
        pm.deletePersistent(instance3);
               
        Collection result = (Collection)pm.newQuery(
            PrimitiveTypes.class, "intNotNull == 3").execute();
        // check result
        if (result.isEmpty()) {
            if (debug)
                logger.debug("deleted instance not part of query result.");
        }
        else {
            // query result not empty => problem
            PrimitiveTypes p = (PrimitiveTypes)result.iterator().next();
            if (JDOHelper.isDeleted(p))
                fail(ASSERTION_FAILED,
                     "query result should not include deleted instance");
            else
                fail(ASSERTION_FAILED,
View Full Code Here

        Transaction tx = pm.currentTransaction();
        tx.begin();
       
        Collection tmp = (Collection)pm.newQuery(
            PrimitiveTypes.class, "id == 5").execute();
        PrimitiveTypes instance5 = (PrimitiveTypes)tmp.iterator().next();
        instance5.setIntNotNull(99);
               
        Collection result = (Collection)pm.newQuery(
            PrimitiveTypes.class, "intNotNull == 99").execute();
        // check result
        if (result.isEmpty()) {
            fail(ASSERTION_FAILED,
                 "Query should find modified instance, but query result is empty");
        }
        Iterator i = result.iterator();
        PrimitiveTypes p = (PrimitiveTypes)i.next();
        if (p.getId() != 5L)
            fail(ASSERTION_FAILED,
                 "Query returned wrong instance with id " + p.getId());
        if (p.getIntNotNull() != 99)
            fail(ASSERTION_FAILED,
                 "Query returned instance with wrong intNotNull field value " +
                 p.getIntNotNull());
        if (i.hasNext())
            fail(ASSERTION_FAILED,
                 "Query returned more than one instance");
       
        if (debug)
View Full Code Here

TOP

Related Classes of org.apache.jdo.tck.pc.mylib.PrimitiveTypes

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.