Package com.sleepycat.bdb.bind.serial.test

Examples of com.sleepycat.bdb.bind.serial.test.MarshalledObject


    }

    private void writeAndRead()
        throws Exception {

        MarshalledObject o1 = new MarshalledObject("data1", "pk1", "ik1", "");
        assertNull(storeMap1.put(null, o1));

        assertEquals(o1, storeMap1.get("pk1"));
        assertEquals(o1, indexMap1.get("ik1"));

        MarshalledObject o2 = new MarshalledObject("data2", "pk2", "", "pk1");
        assertNull(storeMap2.put(null, o2));

        assertEquals(o2, storeMap2.get("pk2"));
        assertEquals(o2, indexMap2.get("pk1"));
View Full Code Here


    private void writeAndRead()
        throws Exception {

        // write records: Data, PrimaryKey, IndexKey1, IndexKey2
        assertNull(storeMap.put(null,
            new MarshalledObject("d1", "k1", "no""yes")));
        assertNull(storeMap.put(null,
            new MarshalledObject("d2", "k2", "no""no")));
        assertNull(storeMap.put(null,
            new MarshalledObject("d3", "k3", "no""yes")));
        assertNull(storeMap.put(null,
            new MarshalledObject("d4", "k4", "yes", "yes")));
        assertNull(storeMap.put(null,
            new MarshalledObject("d5", "k5", "yes", "no")));

        Object o;
        Map.Entry e;

        // join values with index maps
View Full Code Here

    }

    private void writeAndRead()
        throws Exception {

        MarshalledObject o1 = new MarshalledObject("data1", "pk1", "ik1", "");
        assertNull(storeMap1.put(null, o1));

        assertEquals(o1, storeMap1.get("pk1"));
        assertEquals(o1, indexMap1.get("ik1"));

        MarshalledObject o2 = new MarshalledObject("data2", "pk2", "", "pk1");
        assertNull(storeMap2.put(null, o2));

        assertEquals(o2, storeMap2.get("pk2"));
        assertEquals(o2, indexMap2.get("pk1"));

        /*
         * store1 contains o1 with primary key "pk1" and index key "ik1"
         * store2 contains o2 with primary key "pk2" and foreign key "pk1"
         * which is the primary key of store1
         */

        switch (onDelete) {

        case ForeignKeyIndex.ON_DELETE_ABORT:
            try {
                storeMap1.remove("pk1");
                fail();
            }
            catch (IntegrityConstraintException expected) {}
            o2 = new MarshalledObject("data2", "pk2", "", "");
            assertNotNull(storeMap2.put(null, o2));
            assertEquals(o2, storeMap2.get("pk2"));
            assertNull(indexMap2.get("pk1"));
            storeMap1.remove("pk1");
            assertNull(storeMap1.get("pk1"));
            assertNull(indexMap1.get("ik1"));
            break;
        case ForeignKeyIndex.ON_DELETE_CLEAR:
            storeMap1.remove("pk1");
            assertNull(storeMap1.get("pk1"));
            assertNull(indexMap1.get("ik1"));
            o2 = (MarshalledObject) storeMap2.get("pk2");
            assertNotNull(o2);
            assertEquals("data2", o2.getData());
            assertEquals("pk2", o2.getPrimaryKey());
            assertEquals("", o2.getIndexKey1());
            assertEquals("", o2.getIndexKey2());
            break;
        case ForeignKeyIndex.ON_DELETE_CASCADE:
            storeMap1.remove("pk1");
            assertNull(storeMap1.get("pk1"));
            assertNull(indexMap1.get("ik1"));
View Full Code Here

TOP

Related Classes of com.sleepycat.bdb.bind.serial.test.MarshalledObject

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.