Examples of ModInstanceCallbackTests


Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

    }

    public void testBasicJdoPreStore() {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);
        pm.flush();
        assertTrue(a.preStoreCalled);
        endTx(pm);
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

    }

    public void testNoFlush() {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);
        endTx(pm);
        assertTrue(a.preStoreCalled);
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

    }

    public void testFlushNoChange() {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);
        pm.flush();
        endTx(pm);
        assertTrue(a.preStoreCalled);
        assertEquals(10, a.getIntField());
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

    private void basicHelper(boolean update, boolean multi, boolean dfg,
        boolean nonDFG) {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);

        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);
        if (update) {
            endTx(pm);
            Object oid = pm.getObjectId(a);
            endEm(pm);
            pm = getPM(true, false);
            startTx(pm);
            a = (ModInstanceCallbackTests) pm
                .find(ModInstanceCallbackTests.class, oid);
        } else {
            pm.flush();
        }

        if (dfg)
            a.setIntField(11);
        if (nonDFG)
            a.setNonDFGField(11);

        if (multi) {
            pm.flush();

            if (dfg)
                a.setIntField(12);
            if (nonDFG)
                a.setNonDFGField(12);
        }

        endTx(pm);

        // if no changes were made and we're in update mode, then this
        // object won't have had jdoPreStore() called.
//        if (!(update && (!dfg && !nonDFG)))
//            assertTrue("a.prestoreCalled is false", a.preStoreCalled);

        if (multi) {
            if (dfg)
                assertEquals("a.getIntField is not 12", 12, a.getIntField());
            if (nonDFG)
                assertEquals("a.getNonDFGField is not 12", 12,
                    a.getNonDFGField());
        } else {
            if (dfg)
                assertEquals("a.getIntField is not 12", 11, a.getIntField());
            if (nonDFG)
                assertEquals("a.getNonDFGField is not 12", 11,
                    a.getNonDFGField());
        }
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

        // set retainvalues to false so that we can ensure that the
        // data in the database is correct, and that we're not just
        // testing that the JVM data is correct.
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);

        // by setting the name to 'bar', the jdoPreStore() invocation
        // will set the parent to a new object. This ensures that new
        // objects created in jdoPreStore() make their way into the DB
        // during commit.
        if (before) {
            a.setStringField("bar");
            pm.flush();
        } else {
            pm.flush();
            a.setStringField("bar");
        }
        endTx(pm);
        assertTrue("a.preStoreCalled is false", a.preStoreCalled);
        assertNotNull("a.getOneOne is null", a.getOneOne());
        assertTrue("getOneOne().getstrngfld.equals(jdoPrestore) is false",
            a.getOneOne().getStringField().equals("jdoPreStore"));
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

        // set retainvalues to false so that we can ensure that the
        // data in the database is correct, and that we're not just
        // testing that the JVM data is correct.
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);

        ModRuntimeTest1 parent = new ModRuntimeTest1("baz", 11);
        if (!before)
            pm.flush();

        if (persist)
            pm.persist(parent);

        a.setOneOne(parent);

        if (before)
            pm.flush();

        ModRuntimeTest1 oldParent = null;
        if (multi) {
            oldParent = parent;
            parent = new ModRuntimeTest1("newParent", 12);

            if (!before)
                pm.flush();

            if (persist)
                pm.persist(parent);

            a.setOneOne(parent);

            if (before)
                pm.flush();
        }

        endTx(pm);
        assertTrue("a.preStoreCalled is false", a.preStoreCalled);
        assertNotNull("a.getOneOne is null", a.getOneOne());
        if (!multi)
            assertTrue("a.getOneOne().getStringField().equals(baz) is false",
                a.getOneOne().getStringField().equals("baz"));
        else {
            assertTrue(
                "a.getOneOne().getStringField().equals(newParent) is false",
                a.getOneOne().getStringField().equals("newParent"));

            // if multi, then we really should delete the baz
            // parent. This isn't happening right now.
            // ### should be a bug
            //assertTrue (JDOHelper.isDeleted (oldParent));
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

    }

    public void testBasicJdoPreStore() {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);
        pm.flush();
        assertTrue(a.preStoreCalled);
        endTx(pm);
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

    }

    public void testNoFlush() {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);
        endTx(pm);
        assertTrue(a.preStoreCalled);
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

    }

    public void testFlushNoChange() {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);
        pm.flush();
        endTx(pm);
        assertTrue(a.preStoreCalled);
        assertEquals(10, a.getIntField());
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.ModInstanceCallbackTests

    private void basicHelper(boolean update, boolean multi, boolean dfg,
        boolean nonDFG) {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);

        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);
        if (update) {
            endTx(pm);
            Object oid = pm.getObjectId(a);
            endEm(pm);
            pm = getPM(true, false);
            startTx(pm);
            a = (ModInstanceCallbackTests) pm
                .find(ModInstanceCallbackTests.class, oid);
        } else {
            pm.flush();
        }

        if (dfg)
            a.setIntField(11);
        if (nonDFG)
            a.setNonDFGField(11);

        if (multi) {
            pm.flush();

            if (dfg)
                a.setIntField(12);
            if (nonDFG)
                a.setNonDFGField(12);
        }

        endTx(pm);

        // if no changes were made and we're in update mode, then this
        // object won't have had jdoPreStore() called.
//        if (!(update && (!dfg && !nonDFG)))
//            assertTrue("a.prestoreCalled is false", a.preStoreCalled);

        if (multi) {
            if (dfg)
                assertEquals("a.getIntField is not 12", 12, a.getIntField());
            if (nonDFG)
                assertEquals("a.getNonDFGField is not 12", 12,
                    a.getNonDFGField());
        } else {
            if (dfg)
                assertEquals("a.getIntField is not 12", 11, a.getIntField());
            if (nonDFG)
                assertEquals("a.getNonDFGField is not 12", 11,
                    a.getNonDFGField());
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.