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

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


    public void testMapDeletion() {
        OpenJPAEntityManager pm;
        pm = getPM();
        startTx(pm);
        SCOTest test = new SCOTest();
        pm.persist(test);
        Map map = new HashMap();
        map.put("foo", new Integer(1));
        map.put("bar", new Integer(2));
        for (int i = 0; i < 10; i++)
            map.put("baz#" + i, new Integer(i));

        test.setStrIntMap(map);
        Object id = pm.getObjectId(test);
        endTx(pm);

        startTx(pm);
        test = (SCOTest) pm.find(SCOTest.class, id);
        assertNotNull(test);
        map = test.getStrIntMap();
        assertEquals(12, map.size());
        assertEquals(new Integer(1), map.get("foo"));
        assertEquals(new Integer(2), map.get("bar"));
        map.remove("bar");
        endTx(pm);

        startTx(pm);
        test = (SCOTest) pm.find(SCOTest.class, id);
        assertNotNull(test);
        map = test.getStrIntMap();
        assertEquals(11, map.size());
        assertEquals(new Integer(1), map.get("foo"));
        assertTrue(map.get("bar") == null);

        map.clear();

        endTx(pm);

        startTx(pm);
        test = (SCOTest) pm.find(SCOTest.class, id);
        assertNotNull(test);
        map = test.getStrIntMap();
        assertEquals(0, map.size());
        endTx(pm);
    }
View Full Code Here


     * deletes each element of both maps in turn and re-validates
     * each time to make sure updating of the map is working correctly.
     */
    private void saveSecondClassMapInternal(HashMap map) throws Exception {
        begin();
        SCOTest test = new SCOTest();
        pm.persist(test);
        int testID = test.getId();
        assertNotNull("Passed Map is null", map);
        Map smap = setGetMap(test, map, true);
        assertNotNull("Map is null in setGetMap", smap);
        commit();

        for (Iterator mapKey = ((HashMap) map.clone()).keySet().iterator();
            mapKey.hasNext();) {
            Object keyToDelete = mapKey.next();

            begin();
            SCOTest retrievedObject =
                (SCOTest) pm.find(SCOTest.class, testID);

            assertNotNull(
                "retrievedObject Obj is null - saveSecondClassMapInternal",
                retrievedObject);
View Full Code Here

            Collections.sort(collection);

        OpenJPAEntityManager pm1 = getPM();
        startTx(pm1);

        SCOTest test = new SCOTest();
        pm1.persist(test);
        int testID = test.getId();

        Collection storedCollection = setGetCollection(test,
            (Collection) ((ArrayList) collection).clone(), true);

        assertNotNull("retrieved storedCollection is null", storedCollection);

        // make sure the pre-commit collections are identical!
        assertEquals("Pre-commit collections were not equal: " + newline
            + dump(collection) + newline + "!=" + newline
            + dump(storedCollection),
            collection.size(), storedCollection.size());

        endTx(pm1);

        int deletionIndex = 0;

        OpenJPAEntityManager pm2 = getPM();

        while (collection.size() > 0) {
            deletionIndex++;

            startTx(pm2);
            SCOTest retrievedObject =
                (SCOTest) pm2.find(SCOTest.class, testID);

            assertNotNull(
                "retrieved obj is null saveSecondClassCollectionInternal",
                retrievedObject);
View Full Code Here

    public void testMapDeletion() {
        OpenJPAEntityManager pm;
        pm = getPM();
        startTx(pm);
        SCOTest test = new SCOTest();
        pm.persist(test);
        Map map = new HashMap();
        map.put("foo", new Integer(1));
        map.put("bar", new Integer(2));
        for (int i = 0; i < 10; i++)
            map.put("baz#" + i, new Integer(i));

        test.setStrIntMap(map);
        Object id = pm.getObjectId(test);
        endTx(pm);

        startTx(pm);
        test = (SCOTest) pm.find(SCOTest.class, id);
        assertNotNull(test);
        map = test.getStrIntMap();
        assertEquals(12, map.size());
        assertEquals(new Integer(1), map.get("foo"));
        assertEquals(new Integer(2), map.get("bar"));
        map.remove("bar");
        endTx(pm);

        startTx(pm);
        test = (SCOTest) pm.find(SCOTest.class, id);
        assertNotNull(test);
        map = test.getStrIntMap();
        assertEquals(11, map.size());
        assertEquals(new Integer(1), map.get("foo"));
        assertTrue(map.get("bar") == null);

        map.clear();

        endTx(pm);

        startTx(pm);
        test = (SCOTest) pm.find(SCOTest.class, id);
        assertNotNull(test);
        map = test.getStrIntMap();
        assertEquals(0, map.size());
        endTx(pm);
    }
View Full Code Here

     * deletes each element of both maps in turn and re-validates
     * each time to make sure updating of the map is working correctly.
     */
    private void saveSecondClassMapInternal(HashMap map) throws Exception {
        begin();
        SCOTest test = new SCOTest();
        pm.persist(test);
        int testID = test.getId();
        assertNotNull("Passed Map is null", map);
        Map smap = setGetMap(test, map, true);
        assertNotNull("Map is null in setGetMap", smap);
        commit();

        for (Iterator mapKey = ((HashMap) map.clone()).keySet().iterator();
            mapKey.hasNext();) {
            Object keyToDelete = mapKey.next();

            begin();
            SCOTest retrievedObject =
                (SCOTest) pm.find(SCOTest.class, testID);

            assertNotNull(
                "retrievedObject Obj is null - saveSecondClassMapInternal",
                retrievedObject);
View Full Code Here

            Collections.sort(collection);

        OpenJPAEntityManager pm1 = getPM();
        startTx(pm1);

        SCOTest test = new SCOTest();
        pm1.persist(test);
        int testID = test.getId();

        Collection storedCollection = setGetCollection(test,
            (Collection) ((ArrayList) collection).clone(), true);

        assertNotNull("retrieved storedCollection is null", storedCollection);

        // make sure the pre-commit collections are identical!
        assertEquals("Pre-commit collections were not equal: " + newline
            + dump(collection) + newline + "!=" + newline
            + dump(storedCollection),
            collection.size(), storedCollection.size());

        endTx(pm1);

        int deletionIndex = 0;

        OpenJPAEntityManager pm2 = getPM();

        while (collection.size() > 0) {
            deletionIndex++;

            startTx(pm2);
            SCOTest retrievedObject =
                (SCOTest) pm2.find(SCOTest.class, testID);

            assertNotNull(
                "retrieved obj is null saveSecondClassCollectionInternal",
                retrievedObject);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.kernel.common.apps.SCOTest

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.