Examples of ModRuntimeTest1


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

        throws Exception {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);

        ModRuntimeTest2 b = pm.find(ModRuntimeTest2.class, _id);
        ModRuntimeTest1 parent = b.getSelfOneOne();
        assertNotNull("parent is null", parent);
        pm.remove(b);

        endTx(pm);

        // parent should be valid
        assertEquals("PARENT", parent.getStringField());

        // 'b' should be cleared
        assertNull(b.getStringField());
        assertEquals(0, b.getIntField());
        assertNull(b.getSelfOneOne());
View Full Code Here

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

        throws Exception {
        OpenJPAEntityManager pm = getPM(true, true);
        startTx(pm);

        ModRuntimeTest2 b = pm.find(ModRuntimeTest2.class, _id);
        ModRuntimeTest1 parent = b.getSelfOneOne();

        assertNotNull("parent is null", parent);
        pm.remove(b);

        endTx(pm);

        // parent should be valid
        assertEquals("PARENT", parent.getStringField());

        // 'b' should be cleared
        assertNull(b.getStringField());
        assertEquals(0, b.getIntField());
        assertNull(b.getSelfOneOne());
View Full Code Here

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

        OpenJPAEntityManager pm = getPM(false, true);
        startTx(pm);

        ModRuntimeTest2 b = pm.find(ModRuntimeTest2.class, _id);
        ModRuntimeTest1 parent = b.getSelfOneOne();
        assertNotNull("parent is null", parent);
        pm.remove(b);

        endTx(pm);

        // parent should be valid
        assertEquals("PARENT", parent.getStringField());

        // 'b' should be cleared
        assertNull(b.getStringField());
        assertEquals(0, b.getIntField());
        assertNull(b.getSelfOneOne());
View Full Code Here

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

    private ModRuntimeTest2 createTest2(String str, int i) {
        return createTest2(new ModRuntimeTest2(str, i));
    }

    private ModRuntimeTest2 createTest2(ModRuntimeTest2 b) {
        ModRuntimeTest1 parent = new ModRuntimeTest1("PARENT", 70);
        b.setSelfOneOne(parent);
        return b;
    }
View Full Code Here

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

        doSimpleTest(false, 0, 2);
    }

    private void doSimpleTest(boolean newPC, int before, int after) {
        OpenJPAEntityManager pm = getPM();
        ModRuntimeTest1 pc = new ModRuntimeTest1();
        startTx(pm);
        pc.setStringField("orig");
        pc.setIntField(-11);
        //FIXME jthomas - setDateField
        //pc.setDateField(randomDate());
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);

        if (!newPC) {
            endTx(pm);
            pm = getPM();
            startTx(pm);
            pc = pm.find(ModRuntimeTest1.class, oid);
        }
        for (int i = 0; i < before; i++) {
            pc.setStringField("before" + i);
            pc.setIntField(i);
            //FIXME jthomas - setDateField
            //pc.setDateField(randomDate());
            pm.setSavepoint("before" + i);
        }

        pc.setStringField("value");
        pc.setIntField(333);
        //FIXME jthomas - setDateField
        //pc.setDateField(randomDate());
        //Date date = (Date) pc.getDateField().clone();
        pm.setSavepoint("test");

        for (int i = 0; i < after; i++) {
            pc.setStringField("after" + i);
            pc.setIntField(i * 10);
            //FIXME jthomas - setDateField
            //pc.setDateField(randomDate());
            pm.setSavepoint("after" + i);
        }

        pm.rollbackToSavepoint("test");
        assertEquals("value", pc.getStringField());
        assertEquals(333, pc.getIntField());
        //FIXME jthomas - setDateField
        //assertEquals(date, pc.getDateField());
        endTx(pm);
        endEm(pm);

        pm = getPM();
        pc = pm.find(ModRuntimeTest1.class, oid);
        assertEquals("value", pc.getStringField());
        assertEquals(333, pc.getIntField());
        //FIXME jthomas - setDateField
        //assertEquals(date, pc.getDateField());
        endEm(pm);
    }
View Full Code Here

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

        endEm(pm);
    }

    public void testCleanOrdering() {
        OpenJPAEntityManager pm = getPM();
        ModRuntimeTest1 pc = new ModRuntimeTest1("orig", 1);
        startTx(pm);
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);
        endTx(pm);
        endEm(pm);

        pm = getPM();
        pm.setOptimistic(false);
        startTx(pm);
        ModRuntimeTest1 pc2 = new ModRuntimeTest1("foo", 2);
        pm.persist(pc2);
        pm.setSavepoint("s1");
        pc = pm.find(ModRuntimeTest1.class, oid);
        assertTrue(pm.isTransactional(pc));
        pm.setSavepoint("s2");
View Full Code Here

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

        endEm(pm);
    }

    public void testLastSavepoint() {
        OpenJPAEntityManager pm = getPM();
        ModRuntimeTest1 pc = new ModRuntimeTest1("orig", 1);
        startTx(pm);
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);
        endTx(pm);
        endEm(pm);

        pm = getPM();
        pm.setOptimistic(false);
        startTx(pm);
        pc = pm.find(ModRuntimeTest1.class, oid);
        pc.setStringField("s1");
        pm.setSavepoint("s1");
        pc.setStringField("s2");
        pm.setSavepoint("s2");
        pc.setStringField("diff");
        pm.rollbackToSavepoint();
        assertEquals("s2", pc.getStringField());
        pm.releaseSavepoint();
        try {
            pm.rollbackToSavepoint("s1");
            fail("Exhausted.");
        } catch (Exception e) {
View Full Code Here

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

        OpenJPAEntityManager pm = getPM();
        pm.setRetainState(restore);
        startTx(pm);

        for (int i = 0; i < before; i++) {
            pm.persist(new ModRuntimeTest1("s" + i, i));
            //pm.setSavepoint("before" + i);
        }
        pm.setSavepoint("test");

        ModRuntimeTest1 pc = new ModRuntimeTest1();
        pc.setStringField("orig");
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);

        for (int i = 0; i < after; i++) {
            pm.persist(new ModRuntimeTest1());
            pm.setSavepoint("after" + i);
        }

        pm.rollbackToSavepoint("test");
        assertEquals("orig", pc.getStringField());
        assertFalse(pm.isPersistent(pc));
        assertEquals(before, pm.getTransactionalObjects().size());
        endTx(pm);
        endEm(pm);
View Full Code Here

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

    public void doNewRelationTest(boolean nullRel, int before, int after) {
        deleteAll(ModRuntimeTest1.class);

        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        ModRuntimeTest1 pc = new ModRuntimeTest1();
        pc.setStringField("orig");
        if (!nullRel)
            pc.setSelfOneOne(new ModRuntimeTest1("one", 1));
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);
        endTx(pm);
        endEm(pm);

        pm = getPM();
        pm.setRetainState(true);
        startTx(pm);
        pc = pm.find(ModRuntimeTest1.class, oid);

        for (int i = 0; i < before; i++) {
            pc.setSelfOneOne(new ModRuntimeTest1("before" + i, i));
            pm.setSavepoint("before" + i);
        }

        pm.setSavepoint("test");
        pc.setSelfOneOne(new ModRuntimeTest1("new", 2));
        ModRuntimeTest1 pc2 = pc.getSelfOneOne();

        for (int i = 0; i < after; i++) {
            pc.setSelfOneOne(new ModRuntimeTest1());
            pm.setSavepoint("after" + i);
        }

        pm.rollbackToSavepoint("test");
        assertEquals("orig", pc.getStringField());
View Full Code Here

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

    }

    public void doNullRelationTest(boolean retain, int before, int after) {
        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        ModRuntimeTest1 pc = new ModRuntimeTest1();
        pc.setStringField("orig");
        pc.setSelfOneOne(new ModRuntimeTest1("one", 1));
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);
        endTx(pm);
        endEm(pm);

        pm = getPM();
        pm.setRetainState(true);
        startTx(pm);
        pc = pm.find(ModRuntimeTest1.class, oid);

        for (int i = 0; i < before; i++) {
            pc.setSelfOneOne(new ModRuntimeTest1("before" + i, i));
            pm.setSavepoint("before" + i);
        }

        pm.setSavepoint("test");
        pc.setSelfOneOne(null);

        for (int i = 0; i < after; i++) {
            pc.setSelfOneOne(new ModRuntimeTest1());
            pm.setSavepoint("after" + i);
        }

        pm.rollbackToSavepoint("test");
        assertEquals("orig", pc.getStringField());
        if (before > 0)
            assertEquals("before" + (before - 1),
                pc.getSelfOneOne().getStringField());
        else
            assertEquals("one", pc.getSelfOneOne().getStringField());
        endTx(pm);
        endEm(pm);

        pm = getPM();
        pc = pm.find(ModRuntimeTest1.class, oid);
        assertEquals("orig", pc.getStringField());
        if (before > 0)
            assertEquals("before" + (before - 1),
                pc.getSelfOneOne().getStringField());
        else
            assertEquals("one", pc.getSelfOneOne().getStringField());
        endEm(pm);
    }
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.