Package org.apache.openjpa.persistence.event.common.apps

Examples of org.apache.openjpa.persistence.event.common.apps.RuntimeTest1


        BufferedLogFactory logFactory = (BufferedLogFactory)
            ((OpenJPAEntityManagerSPI) pm).getConfiguration().getLogFactory();
        logFactory.clear();

        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);
        assertNull(pc.getSelfOneOne());
        logFactory.assertNoLogMessage("*orphan*");
        endEm(pm);
        pmf.close();
    }
View Full Code Here


        ((OpenJPAEntityManagerSPI) pm)
            .addTransactionListener(transactionListener);

        assertEquals(0, transactionListener.status);

        RuntimeTest1 t1 = new RuntimeTest1("foo", 5);
        startTx(pm);
        assertEquals(TransactionEventListenerTestImpl.STARTED,
            transactionListener.status);

        pm.persist(t1);
View Full Code Here

        ((OpenJPAEntityManagerSPI) pm)
            .addTransactionListener(transactionListener);

        assertEquals(0, transactionListener.status);

        RuntimeTest1 t1 = new RuntimeTest1("foo", 5);
        startTx(pm);
        assertEquals(TransactionEventListenerTestImpl.STARTED,
            transactionListener.status);

        pm.persist(t1);
View Full Code Here

            (OpenJPAEntityManager) currentEntityManager();
        ((OpenJPAEntityManagerSPI) pm)
            .addTransactionListener(transactionListener);

        // add a couple new object
        RuntimeTest1 t1 = new RuntimeTest1("t1", 0);
        RuntimeTest1 t2 = new RuntimeTest1("t2", 1);
        startTx(pm);
        pm.persist(t1);
        pm.persist(t2);
        endTx(pm);

        // now do some modifications
        transactionListener.status = 0;
        startTx(pm);
        RuntimeTest1 t3 = new RuntimeTest1("t3", 3);
        pm.persist(t3);
        t1.setStringField("baz");
        pm.remove(t2);
        endTx(pm);
View Full Code Here

        //FIXME need to find an alternative
        ((OpenJPAEntityManagerSPI) pm)
            .setTransactionListenerCallbackMode(CallbackMode.IGNORE);
        transactionListener.exception = transactionListener.EXCEPTION;

        RuntimeTest1 t1 = new RuntimeTest1("foo", 5);
        startTx(pm);
        assertEquals(TransactionEventListenerTestImpl.STARTED,
            transactionListener.status);
        pm.persist(t1);
        endTx(pm);
View Full Code Here

            (OpenJPAEntityManager) currentEntityManager();
        ((OpenJPAEntityManagerSPI) pm)
            .addTransactionListener(transactionListener);
        transactionListener.exception = transactionListener.EXCEPTION;

        RuntimeTest1 t1 = new RuntimeTest1("foo", 5);
        startTx(pm);
        assertEquals(TransactionEventListenerTestImpl.STARTED,
            transactionListener.status);
        pm.persist(t1);
View Full Code Here

            (OpenJPAEntityManager) currentEntityManager();
        ((OpenJPAEntityManagerSPI) pm)
            .addTransactionListener(transactionListener);
        transactionListener.exception = transactionListener.EXCEPTION_AFTER;

        RuntimeTest1 t1 = new RuntimeTest1("foo", 5);
        startTx(pm);
        assertEquals(TransactionEventListenerTestImpl.STARTED,
            transactionListener.status);
        pm.persist(t1);
View Full Code Here

        OpenJPAEntityManager pm =
            (OpenJPAEntityManager) factory1.createEntityManager();
        datacatch = pm.getEntityManagerFactory().getStoreCache();
        // get an object id
        RuntimeTest1 t1 = new RuntimeTest1("foo", 5);
        startTx(pm);
        pm.persist(t1);
        Object oid = pm.getObjectId(t1);
        roid = Id.newInstance(RuntimeTest1.class, oid);
        endTx(pm);

        try {
            Thread.currentThread().sleep(250);
        }
        catch (InterruptedException ie) {
        }

        // ensure that the commit info was not propagated to factory1.
        assertFalse(listener1.commitNotificationReceived);

        // ensure that the commit info propagated to the
        // factories correctly.
        assertNotNull(listener2.added);
        assertNotNull(listener2.updated);
        assertNotNull(listener2.deleted);

        boolean pass = false;
        for (Iterator iter = listener2.added.iterator(); iter.hasNext();) {
            Id roid = Id.newInstance(RuntimeTest1.class, oid);
            Id it = (Id) iter.next();
            //FixMe --det. why it.equals(roid) fails when the are actually equal
            if (it.toString().equals(roid.toString())) {
                pass = true;
                break;
            }
        }
        assertTrue("pass = " + pass, pass);
        assertTrue(listener2.updated.size() == 0);
        assertTrue(listener2.deleted.size() == 0);

        // modify an object
        startTx(pm);
        t1.setStringField("baz");
        endTx(pm);

        try {
            Thread.currentThread().sleep(250);
        }
View Full Code Here

        assertEquals(2, listener.load);
        assertEquals(0, listener.store);
        assertEquals(2, listener2.load);
        assertEquals(0, listener2.store);

        mgr.fireEvent(new RuntimeTest1(), meta, LifecycleEvent.AFTER_LOAD);
        assertEquals(3, listener.load);
        assertEquals(0, listener.store);
        assertEquals(2, listener2.load);
        assertEquals(0, listener2.store);
View Full Code Here

        OpenJPAEntityManager pm =
            (OpenJPAEntityManager) factory1.createEntityManager();
        datacatch = pm.getEntityManagerFactory().getStoreCache();
        // get an object id
        RuntimeTest1 t1 = new RuntimeTest1("foo", 5);
        startTx(pm);
        pm.persist(t1);
        Object oid = pm.getObjectId(t1);
        roid = Id.newInstance(RuntimeTest1.class, oid);
        endTx(pm);

        try {
            Thread.currentThread().sleep(250);
        }
        catch (InterruptedException ie) {
        }

        // ensure that the commit info was not propagated to factory1.
        assertFalse(listener1.commitNotificationReceived);

        // ensure that the commit info propagated to the
        // factories correctly.
        assertNotNull(listener2.added);
        assertNotNull(listener2.updated);
        assertNotNull(listener2.deleted);

        boolean pass = false;
        for (Iterator iter = listener2.added.iterator(); iter.hasNext();) {
            Id roid = Id.newInstance(RuntimeTest1.class, oid);
            Id it = (Id) iter.next();
            System.out.println("===ROID: " + roid.getId() + " +++== ITER: " +
                it.getId() + " Content: " + listener2.added + "ROID Cont: " +
                roid);
            System.out.println("Result of COMP " + it.equals(roid));
            //FixMe --det. why it.equals(roid) fails when the are actually equal
            if (it.toString().equals(roid.toString())) {
                pass = true;
                break;
            }
        }
        assertTrue("pass = " + pass, pass);
        assertTrue(listener2.updated.size() == 0);
        assertTrue(listener2.deleted.size() == 0);

        // modify an object
        startTx(pm);
        t1.setStringField("baz");
        endTx(pm);

        try {
            Thread.currentThread().sleep(250);
        }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.event.common.apps.RuntimeTest1

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.