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

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


            pm.find(RuntimeTest1.class, _id);
            fail("find");
        } catch (RuntimeException re) {
        }
        try {
            pm.persist(new RuntimeTest1(20));
            fail("setUserObject");
        } catch (RuntimeException re) {
        }
        try {
            pm.setNontransactionalRead(true);
View Full Code Here


     * etc.
     */
    public void testIllegalState() {
        OpenJPAEntityManager pm = getPM();

        RuntimeTest1 a = new RuntimeTest1("foo", 14);
        RuntimeTest1 a2 = (RuntimeTest1) pm.find(RuntimeTest1.class, _id);

        try {
            pm.persist(a);
            fail("persist");
        }
View Full Code Here

     * Test that a getObjectById() returns the correct instance.
     */
    public void testGetObjectById() {
        // test with valid id
        OpenJPAEntityManager pm = getPM();
        RuntimeTest1 b = (RuntimeTest1) pm.find(RuntimeTest1.class, _id);
        assertEquals("STRING", b.getStringField());

        // invalid with possible subclasses should throw immediate exception
        Object invalidId = new Id(RuntimeTest1.class, -1L);
        try {
            pm.find(RuntimeTest1.class, invalidId);
View Full Code Here

    public void setUp() throws Exception {
        super.setUp(RuntimeTest1.class, RuntimeTest2.class, RuntimeTest3.class);
        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        RuntimeTest1 rt1 = new RuntimeTest1("TestInitialValueFetching", 10);
        pm.persist(rt1);

        rt1.setDateField(new Date());
        endTx(pm);
        endEm(pm);
    }
View Full Code Here

    }

    public void testInitialValueString() {
        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        RuntimeTest1 rt1 = getObject(pm);
        OpenJPAStateManager sm = getStateManager(rt1, pm);
        FieldMetaData fmd = sm.getMetaData().getField("stringField");
        assertEquals("TestInitialValueFetching",
            sm.fetchInitialField(fmd.getIndex()));
        rt1.setStringField("TestInitialValueFetching-2");
        assertEquals("TestInitialValueFetching",
            sm.fetchInitialField(fmd.getIndex()));
        endTx(pm);
        assertEquals("TestInitialValueFetching-2",
            sm.fetchInitialField(fmd.getIndex()));
View Full Code Here

    }

    public void testInitialValueInt() {
        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        RuntimeTest1 rt1 = getObject(pm);
        OpenJPAStateManager sm = getStateManager(rt1, pm);
        FieldMetaData fmd = sm.getMetaData().getField("intField1");
        assertEquals(10,
            ((Integer) sm.fetchInitialField(fmd.getIndex())).intValue());
        rt1.setIntField1(11);
        assertEquals(10,
            ((Integer) sm.fetchInitialField(fmd.getIndex())).intValue());
        endTx(pm);
        assertEquals(11,
            ((Integer) sm.fetchInitialField(fmd.getIndex())).intValue());
View Full Code Here

        Map props = new HashMap();
        props.put("openjpa.RestoreMutableValues", "false");
        OpenJPAEntityManagerFactory pmf = getEmf(props);

        OpenJPAEntityManager pm = pmf.createEntityManager();
        RuntimeTest1 rt1 = getObject(pm);

        rt1.getDateField();
        OpenJPAStateManager sm = getStateManager(rt1, pm);
        FieldMetaData fmd = sm.getMetaData().getField("dateField");
        try {
            sm.fetchInitialField(fmd.getIndex());
            fail("should get an exception if RestoreMutableValues is false");
View Full Code Here

        Map props = new HashMap();
        props.put("openjpa.RestoreState", "all");
        OpenJPAEntityManagerFactory pmf = getEmf(props);
        OpenJPAEntityManager pm = pmf.createEntityManager();
        startTx(pm);
        RuntimeTest1 rt1 = getObject(pm);

        Date d = rt1.getDateField();

        OpenJPAStateManager sm = getStateManager(rt1, pm);
        FieldMetaData fmd = sm.getMetaData().getField("dateField");
        assertEquals(d, sm.fetchInitialField(fmd.getIndex()));

        // == should pass here since we haven't made any modifications.
        assertTrue("mutable object fails == test; should not",
            d == sm.fetchInitialField(fmd.getIndex()));

        Date d2 = new Date();
        rt1.setDateField(d2);
        assertEquals(d, sm.fetchInitialField(fmd.getIndex()));
        endTx(pm);
        assertEquals(d2, sm.fetchInitialField(fmd.getIndex()));
        assertTrue("mutable object passes == test; should not",
            d2 != sm.fetchInitialField(fmd.getIndex()));
View Full Code Here

    public void testInitialValueExceptions() {
        OpenJPAEntityManager pm = getPM();
        pm.setRestoreState(RestoreStateType.NONE);
        startTx(pm);
        RuntimeTest1 rt1 = getObject(pm);
        OpenJPAStateManager sm = getStateManager(rt1, pm);
        FieldMetaData fmd = sm.getMetaData().getField("stringField");
        try {
            sm.fetchInitialField(fmd.getIndex());
            fail("exception should be thrown by KodoSM.fetchInitialField");
View Full Code Here

    public TestSerialize(String name) {
        super(name);
    }

    public void setUp() throws Exception {
        RuntimeTest1 a = new RuntimeTest1("1NAME", 1);
        a.setSelfOneOne(new RuntimeTest1("2NAME", 2));

        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        pm.persist(a);
        _oid = a.getIntField();

        endTx(pm);
        endEm(pm);
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.kernel.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.