Package com.mobixess.jodb.tests.testobjects

Examples of com.mobixess.jodb.tests.testobjects.ObjectA


        File testFileDir = new File(TEST_DATA_DIR);
        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA = new ObjectA((byte)2,(byte)3,null);
        ObjectA objectA1 = new ObjectA((byte)4,(byte)3,null);
        ObjectB objectB = new ObjectB();
        objectB._val3 = objectA;
        sessionContainer.set(objectA);
        sessionContainer.set(objectA1);
        sessionContainer.set(objectB);
        sessionContainer.commit();
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        ObjectA pattern = new ObjectA((byte)4,(short)3,null);
        List list = sessionContainer.get(pattern);
        if(list.size()!=1){
            throw new RuntimeException(""+list.size());
        }
        ObjectA fromDb = (ObjectA) list.get(0);
        if(fromDb.getVal1()!=pattern.getVal1() || fromDb.getVal2()!=pattern.getVal2()|| fromDb.getVal3()!=pattern.getVal3()){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        pattern = null;
        list = sessionContainer.get(pattern);
        if(list.size()!=3){
            throw new RuntimeException(""+list.size());
        }

        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        Query query = sessionContainer.query();
        pattern = new ObjectA((byte)4,(short)3,null);
        query.constrain(pattern);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException(""+list.size());
        }
        fromDb = (ObjectA) list.get(0);
        if(fromDb.getVal1()!=pattern.getVal1() || fromDb.getVal2()!=pattern.getVal2()|| fromDb.getVal3()!=pattern.getVal3()){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
       
        query = sessionContainer.query();
        pattern = new ObjectA((byte)2,(short)0,null);
        query.constrain(pattern);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException(""+list.size());
        }
        fromDb = (ObjectA) list.get(0);
        if(fromDb.getVal1()!=objectA.getVal1() || fromDb.getVal2()!=objectA.getVal2()|| fromDb.getVal3()!=objectA.getVal3()){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        pattern = new ObjectA((byte)0,(short)3,null);
        query.constrain(pattern);
        list = query.execute();
        if(list.size()!=2){
            throw new RuntimeException(""+list.size());
        }
View Full Code Here


        File testFileDir = new File(TEST_DATA_DIR);
        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA = new ObjectA((byte)2,(byte)3,null);
        ObjectB objectB = new ObjectB();
        objectB._val3 = objectA;
        sessionContainer.set(objectA);
        sessionContainer.set(objectB);
View Full Code Here

        File testFileDir = new File(TEST_DATA_DIR);
        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA = new ObjectA((byte)2, (short)3,null);
        ObjectB objectB = new ObjectB();
        objectB._val3 = objectA;
        sessionContainer.set(objectA);
        sessionContainer.set(objectB);
View Full Code Here

        File testFileDir = new File(TEST_DATA_DIR);
        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA = new ObjectA((byte)2, (short)3,null);
        ObjectB objectB = new ObjectB();
        objectB._val3 = objectA;
        sessionContainer.set(objectA);
        sessionContainer.set(objectB);
View Full Code Here

        File testFileDir = new File(TEST_DATA_DIR);
        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA = new ObjectA((byte)0,(short)1,null);
        ObjectB objectB = new ObjectB();
       
        sessionContainer.set(objectA);
        sessionContainer.set(objectB);
       
View Full Code Here

        File testFileDir = new File(TEST_DATA_DIR);
        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA1 = new ObjectA((byte)0,(short)2,null);
        ObjectA objectA2 = new ObjectA((byte)0,(short)1,null);
        ObjectA objectA3 = new ObjectA((byte)0,(short)3,null);
       
        sessionContainer.set(objectA1);
        sessionContainer.set(objectA2);
        sessionContainer.set(objectA3);
       
        sessionContainer.commit();
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
        Query query = sessionContainer.query();
        if(ascending){
            query.descend("_val1").orderAscending();
        }else{
            query.descend("_val1").orderDescending();
        }
        if(ascending){
            query.descend("_val2").orderAscending();
        }else{
            query.descend("_val2").orderDescending();
        }
        JODBConfig.setCacheOnSortOperations(false);
        List list = query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        ObjectA prev = null;
        for (int i = 0; i < list.size(); i++) {
            ObjectA current = (ObjectA) list.get(i);
            if(prev!=null){
                if(ascending){
                    if( prev.getVal2() > current.getVal2() ){
                        throw new RuntimeException();
                    }
                }else if(prev.getVal2() < current.getVal2() ){
                    throw new RuntimeException();
                }
            }
            prev = current;
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
            query = sessionContainer.query();
            if(ascending){
                query.descend("_val2").orderAscending();
            }else{
                query.descend("_val2").orderDescending();
            }
        }
       
        JODBConfig.setCacheOnSortOperations(true);
        list = query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        prev = null;
        for (int i = 0; i < list.size(); i++) {
            ObjectA current = (ObjectA) list.get(i);
            if(prev!=null){
                if(ascending){
                    if( prev.getVal2() > current.getVal2() ){
                        throw new RuntimeException();
                    }
                }else if(prev.getVal2() < current.getVal2() ){
                    throw new RuntimeException();
                }
            }
            prev = current;
        }
View Full Code Here

        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
       
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA = new ObjectA((byte)1,(short)2,null);
        ObjectB objectB = new ObjectB();
        Object[] array = new Object[]{objectA,objectB};
       
        sessionContainer.set(objectB);
        sessionContainer.set(array);
        sessionContainer.set(objectA);
       
       
        sessionContainer.commit();
        sessionContainer.close();
       
        sessionContainer = getContainerForFile(testFile);
        //sessionContainer.printFileMap();
        List classes = sessionContainer.getAllObjects();
        if(classes.size()!=3){
            throw new RuntimeException();
        }
        Object arrayObj = null;
        for (int i = 0; i < classes.size(); i++) {
            if(classes.get(i).getClass().isArray()){
                arrayObj = classes.get(i);
            }
        }
        Object[] array1 = (Object[]) arrayObj;
        List<Object> list = Arrays.asList(array1);
        int index = list.indexOf(objectA);
        if(index !=0){
            throw new RuntimeException();
        }
       
        ObjectA objectA2 = (ObjectA) array1[index];
       
       
        index = list.indexOf(objectB);
        if(index != 1){
            throw new RuntimeException();
        }
       
        ObjectB objectB2 = (ObjectB) array1[index];
       
       
        objectA2.setVal3(objectB2);
        objectB2._val3 = objectA2;
       
        sessionContainer.set(objectB2);
        sessionContainer.set(objectA2);
        sessionContainer.set(arrayObj);
       
        sessionContainer.close();
       
        sessionContainer = getContainerForFile(testFile);
        //sessionContainer.printFileMap();
        //sessionContainer.close();
       
        objectA = new ObjectA((byte)2,(short)3,null);
        objectB = new ObjectB();
       
        classes = sessionContainer.getAllObjects();
        if(classes.size()!=3){
            throw new RuntimeException();
View Full Code Here

        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
       
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA = new ObjectA((byte)1,(short)2,null);
        ObjectB objectB = new ObjectB();
        int[] array = new int[]{10,20,30};
       
        sessionContainer.set(objectB);
        sessionContainer.set(array);
        sessionContainer.set(objectA);
       
       
        sessionContainer.commit();
        sessionContainer.close();
       
        sessionContainer = getContainerForFile(testFile);
        sessionContainer.printFileMap();
        List classes = sessionContainer.getAllObjects();
        if(classes.size()!=3){
            throw new RuntimeException();
        }
        Object arrayObj = null;
        for (int i = 0; i < classes.size(); i++) {
            if(classes.get(i).getClass().isArray()){
                arrayObj = classes.get(i);
            }
        }
        int[] array1 = (int[]) arrayObj;

        if(!Arrays.equals(array, array1)){
            throw new RuntimeException();
        }
        int index = classes.indexOf(objectA);
        if(index == -1){
            throw new RuntimeException();
        }
        ObjectA objectA2 = (ObjectA) classes.get(index);
       
       
        index = classes.indexOf(objectB);
        if(index == -1){
            throw new RuntimeException();
        }
       
        ObjectB objectB2 = (ObjectB) classes.get(index);
       
        array1[0] = 100;
       
        objectA2.setVal3(objectB2);
        objectB2._val3 = objectA2;
       
        sessionContainer.set(objectB2);
        sessionContainer.set(objectA2);
        sessionContainer.set(arrayObj);
View Full Code Here

        JODBConfig.setRandomAccessBufferFactory(factory);
        factory.intersectionInit(null, Integer.MAX_VALUE, false);
       
        sessionContainer = getContainerForFile(testFile);
        //factory.setIntersectEnabled(true);
        ObjectA objectA = new ObjectA((byte)1,(short)2,null);
        ObjectB objectB = new ObjectB();
        int[] array = new int[]{10,20,30};
       
       
        sessionContainer.set(objectB);
        //sessionContainer.set(array);
        sessionContainer.set(objectA);
        sessionContainer.close();
       
        sessionContainer = getContainerForFile(testFile);
        factory.setIntersectEnabled(true);
        sessionContainer.set(array);
        sessionContainer.close();
       
        Vector verificationObjects = new Vector();
        verificationObjects.add(objectA);
        verificationObjects.add(objectB);
       
        int maxOperationsCount = factory.getCounter();
       
        testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
       
        for (int i = 0; i < maxOperationsCount; i++) {
            System.err.println("Iteration ="+i);
            //System.gc();
//            try {
//                Thread.sleep(200);
//            } catch (InterruptedException e1) {
//            }
            factory.intersectionInit(null, i, true);
            testFile.delete();
            if(testFile.exists()){
                throw new RuntimeException();
            }
           
            sessionContainer = getContainerForFile(testFile);
            sessionContainer.set(objectB);
            sessionContainer.set(objectA);
           
            sessionContainer.close();
           
//            testFile.delete();
//            if(testFile.exists()){
//                System.err.println();
//            }
           
            factory.setIntersectEnabled(true);
            sessionContainer = getContainerForFile(testFile);
           
            sessionContainer.set(array);
           
            try {
                sessionContainer.close();
                throw new RuntimeException("Test Framework Error");
            } catch (Exception e) {
//                if(i==25){
//                    factory.printUnclosedBuffers();
//                }
                e.printStackTrace();
            }
           
//            testFile.delete();
//            if(testFile.exists()){
//                System.err.println();
//            }
           
            factory.setIntersectEnabled(false);
            if (factory._bufferedType == BUFFER_TYPE.MAIN) {
                byte[] incompleteTransaction = factory.getBuffer();
                verifyDataReadable(incompleteTransaction, verificationObjects,2,3);
            }           
            sessionContainer = getContainerForFile(testFile);
           
            List classes = sessionContainer.getAllObjects();
            if(classes.size()!=2){
                throw new RuntimeException(""+classes.size()+"  "+i);
            }
//            Object arrayObj = null;
//            for (int j = 0; j < classes.size(); j++) {
//                if(classes.get(j).getClass().isArray()){
//                    arrayObj = classes.get(j);
//                }
//            }
//            int[] array1 = (int[]) arrayObj;
//
//            if(!Arrays.equals(array, array1)){
//                throw new RuntimeException();
//            }
            int index = classes.indexOf(objectA);
            if(index == -1){
                throw new RuntimeException();
            }
            ObjectA objectA2 = (ObjectA) classes.get(index);
           
           
            index = classes.indexOf(objectB);
            if(index == -1){
                throw new RuntimeException();
View Full Code Here

        testFileDir.mkdirs();
        File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
        testFile.delete();
       
        JODBSessionContainer sessionContainer = getContainerForFile(testFile);
        ObjectA objectA = new ObjectA((byte)1,(short)2,null);
        sessionContainer.set(objectA);
        sessionContainer.commit();
        sessionContainer.close();
       
        sessionContainer = getContainerForFile(testFile);
        List classes = sessionContainer.getAllObjects();
        if(classes.size()!=1){
            throw new RuntimeException();
        }
        Object obj = classes.get(0);
        if(obj.getClass() != objectA.getClass()){
            throw new RuntimeException();
        }
        ObjectA objA = (ObjectA) obj;
        if(objA.getVal1() != objectA.getVal1() || objA.getVal2() != objectA.getVal2() || objA.getVal3() != objectA.getVal3() ){
            throw new RuntimeException("objA="+objA+" objectA="+objectA);
        }
        sessionContainer.close();
    }
View Full Code Here

TOP

Related Classes of com.mobixess.jodb.tests.testobjects.ObjectA

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.