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

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


    protected void makePersistent() {
        addTearDownClass(PCPoint.class);
        pm = pmf.getPersistenceManager();
        Transaction tx = pm.currentTransaction();
        tx.begin();
        PCPoint comp = new PCPoint(1, 2);
        pm.makePersistent(comp);
        tx.commit();
    }
View Full Code Here


    protected void makePersistent() {
        addTearDownClass(PCPoint.class);
        privatePm = privatePmf.getPersistenceManager();
        Transaction tx = privatePm.currentTransaction();
        tx.begin();
        PCPoint comp = new PCPoint(1, 2);
        privatePm.makePersistent(comp);
        tx.commit();
    }
View Full Code Here

        }
        Properties pmfProperties = loadPMF2Properties();
        PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory(pmfProperties);
        PersistenceManager pm2 = pmf2.getPersistenceManager();
        Transaction tx2 = pm2.currentTransaction();
        PCPoint p21 = null;
        PCPoint p22 = null;
        PCRect rect2 = null;

        pm = getPM();
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            tx2.begin();
           
            PCPoint p11 = new PCPoint(110, 120);
            PCPoint p12 = new PCPoint(120, 140);
            PCRect rect1 = new PCRect (0, p11, p12);
            pm.makePersistent (rect1);
           
            p21 = new PCPoint(210, 220);
            p22 = new PCPoint(220, 240);
            rect2 = new PCRect (0, p21, p22);
            pm2.makePersistent (rect2);
           
            tx.commit();
            tx2.commit();
       
            tx.begin();
            tx2.begin();
           
            PCPoint p11a = findPoint (pm, 110, 120);
            if (p11a != p11) {
                fail(ASSERTION_FAILED,
                     "unexpected PCPoint instance, expected: 110, 120, found: " + p11a.getX() + ", " + p11a.getY());
            }
           
            PCPoint p21a = findPoint (pm2, 210, 220);
            if (p21a != p21) {
                fail(ASSERTION_FAILED,
                     "unexpected PCPoint instance, expected: 210, 220, found: " + p21a.getX() + ", " + p21a.getY());
            }
           
            tx.commit();
            tx = null;
            tx2.commit();
View Full Code Here

        Query q = pm.newQuery (PCPoint.class);
        q.declareParameters ("int px, int py");
        q.setFilter ("x == px & y == py");
        Collection results = (Collection)q.execute (new Integer(x), new Integer(y));
        Iterator it = results.iterator();
        PCPoint ret = (PCPoint)it.next();
        return ret;
    }
View Full Code Here

    protected void insertPCPoints(PersistenceManager pm, int numInsert) {
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            for(int i = 0; i<numInsert; i++) {
                Object pc = new PCPoint(i, i);
                pm.makePersistent(pc);
                inserted.add(pc);
            }
            tx.commit();
            tx = null;
View Full Code Here

    protected void printOutput(Object results, Collection expected) {
        if (!debug)
            return;

        Iterator iter = null;
        PCPoint pcp = null;
        if (results == null) {
            logger.debug("Query returns null");
        }
        if (!(results instanceof Collection)) {
            logger.debug("Query result is not a collection: " +
                         results.getClass().getName());
        }
        logger.debug("Retrived Objects are:");
        iter = ((Collection)results).iterator();
        while (iter.hasNext()) {
            pcp = (PCPoint)iter.next();
            logger.debug("X = " + pcp.getX() + "\tY = " + pcp.getY());
        }
           
        logger.debug("Expected Objects are:");
        iter = ((Collection)expected).iterator();
        while (iter.hasNext()) {
            pcp = (PCPoint)iter.next();
            logger.debug("X = " + pcp.getX() + "\tY = " + pcp.getY());
        }
    }
View Full Code Here

            Query query = pm.newQuery(pm.getExtent(PCPoint.class, false), "x == 1");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object pcp1 = new PCPoint(1, 1);
            expected.add(pcp1);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1",
                    results, expected);
View Full Code Here

    /** test transactions.setSynchronization() */
    void runTestRollback(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            PCPoint p1 = new PCPoint(1,3);
            pm.makePersistent(p1);
            tx.commit();
         
            tx.begin();
            p1.setX(55);
                   
            if (!JDOHelper.isDirty(p1)) {
                fail(ASSERTION_FAILED,
                     "JDOHelper.isDirty returns false when called for dirty instance.");
            }
         
            tx.setSynchronization(this);
            beforeCompletionCalled = false;
            afterCompletionCalled = false ;
            tx.rollback();
        
            if (JDOHelper.isDirty(p1)) {
                fail(ASSERTION_FAILED,
                     "P-NEW instance should transition to HOLLOW or P-NONTX and then it should not be dirty, JDOHelper.isDirty returns true.");
            }
            tx.setSynchronization(null);
            tx.begin();
            int x = p1.getX();
            tx.commit();
            if (x != 1) {
                fail(ASSERTION_FAILED,
                     "tx.rollback should rollback change of ip1.x, expected 1, got " + x);
            }
View Full Code Here

        // execute first query
        Object results = query.execute();
       
        // check query result of first query
        List expected = new ArrayList();
        expected.add(new PCPoint(0, 0));
        expected.add(new PCPoint(1, 1));
        expected.add(new PCPoint(2, 2));
        expected.add(new PCPoint(3, 3));
        expected.add(new PCPoint(4, 4));
        expected = getFromInserted(expected);
        checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 0",
                results, expected);
       
        // execute second query
        Object results2 = query2.execute();
       
        // check query result of second query
        List expected2 = new ArrayList();
        expected2.add(new PCPoint(0, 0));
        expected2 = getFromInserted(expected2);
        checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 0",
                results2, expected2);
        pm.currentTransaction().commit();
    }
View Full Code Here

            actualParams.put("param", new Integer(2) );
            Object results = query.executeWithMap(actualParams);

            // check query result
            List expected = new ArrayList();
            Object p3 = new PCPoint(2, 2);
            expected.add(p3);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param",
                    results, expected);
View Full Code Here

TOP

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

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.