Examples of CalendarFields


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

    public void setUp() {
        deleteAll(CalendarFields.class);
    }

    public void testFieldDefaultTimeZone() {
        CalendarFields cal = new CalendarFields();

        OpenJPAEntityManager pm;

        pm = getPM();
        startTx(pm);
        cal.setSingapore(Calendar.
            getInstance(TimeZone.getTimeZone("America/New_York")));
        pm.persist(cal);
        int id = cal.getId();
        endTx(pm);
        endEm(pm);

        pm = getPM();
        cal = (CalendarFields) pm.find(CalendarFields.class, id);
        assertEquals(TimeZone.getTimeZone("Asia/Singapore"),
            cal.getSingapore().getTimeZone());
        endEm(pm);
    }
View Full Code Here

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

            cal.getSingapore().getTimeZone());
        endEm(pm);
    }

    public void testTimeZoneEquals() {
        CalendarFields c1 = new CalendarFields();
        CalendarFields c2 = new CalendarFields();
        assertTimeZonesEquals(c1, c2);

        OpenJPAEntityManager pm;

        pm = getPM();
        startTx(pm);
        pm.persist(c2);
        int id2 = c2.getId();
        assertTimeZonesEquals(c1, c2);
        endTx(pm);
        assertTimeZonesEquals(c1, c2);
        endEm(pm);
View Full Code Here

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

    }

    public void testCalendarQuery() {
        long time = 1136660560572L;

        CalendarFields cal = new CalendarFields();

        OpenJPAEntityManager pm;

        pm = getPM();
        startTx(pm);
        cal.getSingapore().setTime(new Date(time));
        pm.persist(cal);
        int id = cal.getId();
        endTx(pm);
        endEm(pm);

        pm = getPM();
View Full Code Here

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

        cal.setTime(date);
        return cal;
    }

    public void testMutateCalendarDirties() {
        CalendarFields c1 = new CalendarFields();

        OpenJPAEntityManager pm;

        pm = getPM();
        startTx(pm);
        pm.persist(c1);
        int id = c1.getId();
        endTx(pm);
        endEm(pm);

        pm = getPM();
        c1 = pm.find(CalendarFields.class, id);

        startTx(pm);

        OpenJPAStateManager sm = getStateManager(c1, pm);

        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("gmt").getIndex()));

        // test setting to same value doesn't dirty the field
        /*
        setTimeInMillis(c1.getGmtc1.getGmt().getTime().getTime());
        c1.getGmt().setTime(c1.getGmt().getTime());
        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("gmt").getIndex()));
        */

        // test changing time
        setTimeInMillis(c1.getGmt(), 12345);
        assertTrue(sm.getDirty().get(sm.getMetaData().
            getField("gmt").getIndex()));

        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("newYork").getIndex()));
        // test mutate via "add()" method
        c1.getNewYork().add(Calendar.SECOND, -1);
        assertTrue(sm.getDirty().get(sm.getMetaData().
            getField("newYork").getIndex()));

        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("berlin").getIndex()));
        // test mutate via "setTimeZone()" method
        c1.getBerlin().setTimeZone(TimeZone.getTimeZone("GMT"));
        assertTrue(sm.getDirty().get(sm.getMetaData().
            getField("berlin").getIndex()));

        // Calendar.set can only be subclassed in JDK 1.4+ (it is final in
        // 1.3), so we only run this test in JDK 1.4+
        if (JavaVersions.VERSION >= 4) {
            assertFalse(sm.getDirty().get(sm.getMetaData().
                getField("singapore").getIndex()));
            // test mutate via "set()" method
            c1.getSingapore().set(Calendar.YEAR, 1998);
            assertTrue(sm.getDirty().get(sm.getMetaData().
                getField("singapore").getIndex()));
        }

        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("pacific").getIndex()));
        // test mutate via "roll()" method
        c1.getPacific().roll(Calendar.YEAR, 5);
        assertTrue(sm.getDirty().get(sm.getMetaData().
            getField("pacific").getIndex()));

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

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

    public void setUp() throws Exception {
        super.setUp(CalendarFields.class);
    }

    public void testFieldDefaultTimeZone() {
        CalendarFields cal = new CalendarFields();

        OpenJPAEntityManager pm;

        pm = getPM();
        startTx(pm);
        cal.setSingapore(Calendar.
            getInstance(TimeZone.getTimeZone("America/New_York")));
        pm.persist(cal);
        int id = cal.getId();
        endTx(pm);
        endEm(pm);

        pm = getPM();
        cal = pm.find(CalendarFields.class, id);
        assertEquals(TimeZone.getTimeZone("Asia/Singapore"),
            cal.getSingapore().getTimeZone());
        endEm(pm);
    }
View Full Code Here

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

            cal.getSingapore().getTimeZone());
        endEm(pm);
    }

    public void testTimeZoneEquals() {
        CalendarFields c1 = new CalendarFields();
        CalendarFields c2 = new CalendarFields();
        assertTimeZonesEquals(c1, c2);

        OpenJPAEntityManager pm;

        pm = getPM();
        startTx(pm);
        pm.persist(c2);
        int id2 = c2.getId();
        assertTimeZonesEquals(c1, c2);
        endTx(pm);
        assertTimeZonesEquals(c1, c2);
        endEm(pm);
View Full Code Here

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

    }

    public void testCalendarQuery() {
        long time = 1136660560572L;

        CalendarFields cal = new CalendarFields();

        OpenJPAEntityManager pm;

        pm = getPM();
        startTx(pm);
        cal.getSingapore().setTime(new Date(time));
        pm.persist(cal);
        int id = cal.getId();
        endTx(pm);
        endEm(pm);

        pm = getPM();
View Full Code Here

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

        cal.setTime(date);
        return cal;
    }

    public void testMutateCalendarDirties() {
        CalendarFields c1 = new CalendarFields();

        OpenJPAEntityManager pm;

        pm = getPM();
        startTx(pm);
        pm.persist(c1);
        int id = c1.getId();
        endTx(pm);
        endEm(pm);

        pm = getPM();
        c1 = pm.find(CalendarFields.class, id);

        startTx(pm);

        OpenJPAStateManager sm = getStateManager(c1, pm);

        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("gmt").getIndex()));

        // test setting to same value doesn't dirty the field
        /*
        setTimeInMillis(c1.getGmtc1.getGmt().getTime().getTime());
        c1.getGmt().setTime(c1.getGmt().getTime());
        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("gmt").getIndex()));
        */

        // test changing time
        setTimeInMillis(c1.getGmt(), 12345);
        assertTrue(sm.getDirty().get(sm.getMetaData().
            getField("gmt").getIndex()));

        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("newYork").getIndex()));
        // test mutate via "add()" method
        c1.getNewYork().add(Calendar.SECOND, -1);
        assertTrue(sm.getDirty().get(sm.getMetaData().
            getField("newYork").getIndex()));

        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("berlin").getIndex()));
        // test mutate via "setTimeZone()" method
        c1.getBerlin().setTimeZone(TimeZone.getTimeZone("GMT"));
        assertTrue(sm.getDirty().get(sm.getMetaData().
            getField("berlin").getIndex()));

        // Calendar.set can only be subclassed in JDK 1.4+ (it is final in
        // 1.3), so we only run this test in JDK 1.4+
        if (JavaVersions.VERSION >= 4) {
            assertFalse(sm.getDirty().get(sm.getMetaData().
                getField("singapore").getIndex()));
            // test mutate via "set()" method
            c1.getSingapore().set(Calendar.YEAR, 1998);
            assertTrue(sm.getDirty().get(sm.getMetaData().
                getField("singapore").getIndex()));
        }

        assertFalse(sm.getDirty().get(sm.getMetaData().
            getField("pacific").getIndex()));
        // test mutate via "roll()" method
        c1.getPacific().roll(Calendar.YEAR, 5);
        assertTrue(sm.getDirty().get(sm.getMetaData().
            getField("pacific").getIndex()));

        endTx(pm);
        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.