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

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


        timeToAMD.start();

        // create objects
        RuntimeTest1[] persistables = new RuntimeTest1[numObjects];
        for (int i = 0; i < persistables.length; i++) {
            persistables[i] = new RuntimeTest1("foo #" + i, i);
        }

        // add them
        for (int i = 0; i < persistables.length; i++) {
            startTx(pm);
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

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.