Package org.openengsb.core.edb.api

Examples of org.openengsb.core.edb.api.EDBCommit


    @Before
    public void setUp() throws Exception {
        Locale.setDefault(Locale.ENGLISH);
        edbService = mock(EngineeringDatabaseService.class);
        EDBCommit commit = mock(EDBCommit.class);
        when(commit.getCommitter()).thenReturn("adams");
        when(commit.getTimestamp()).thenReturn(TIMESTAMP);
        final EDBLogEntry logEntry = mock(EDBLogEntry.class);
        when(logEntry.getCommit()).thenReturn(commit);
        when(edbService.getLog(eq("null/null/42"), eq(0L), any(Long.class))).thenReturn(Arrays.asList(logEntry));
        context.putBean("edbService", edbService);
    }
View Full Code Here


        assertThat(edbService, notNullValue());
    }

    @Test
    public void testInsert_shouldWork() throws Exception {
        EDBCommit commit = edbService.createEDBCommit(null, null, null);
        EDBObject testObject = new EDBObject("testobject");
        testObject.putEDBObjectEntry("testkey", "testvalue");
        commit.insert(testObject);
        Long testtime = edbService.commit(commit);
        assertThat(testtime.longValue(), not(0L));
    }
View Full Code Here

        assertThat(testtime.longValue(), not(0L));
    }

    @Test(expected = EDBException.class)
    public void testDoubleCommit_shouldThrowException() throws Exception {
        EDBCommit commit = edbService.createEDBCommit(null, null, null);
        edbService.commit(commit);
        edbService.commit(commit);
    }
View Full Code Here

        edbService.commit(commit);
    }

    @Test
    public void testRetrieveObject_shouldWork() throws Exception {
        EDBCommit commit = edbService.createEDBCommit(null, null, null);
        EDBObject testObject = new EDBObject("newtestobject");
        testObject.putEDBObjectEntry("newtestkey", "newtestvalue");
        commit.insert(testObject);

        edbService.commit(commit);

        EDBObject obj = edbService.getObject("newtestobject");
        assertThat(obj, notNullValue());
View Full Code Here

        assertThat(obj, notNullValue());
    }

    @Test
    public void testQueryForObject_shouldWork() throws Exception {
        EDBCommit commit = edbService.createEDBCommit(null, null, null);
        EDBObject testObject = new EDBObject("newtestobject1");
        testObject.putEDBObjectEntry("newtestkey1", "newtestvalue1");
        commit.insert(testObject);

        edbService.commit(commit);

        List<EDBObject> objects = edbService.query(QueryRequest.query("newtestkey1", "newtestvalue1"));
        assertThat(objects, notNullValue());
View Full Code Here

        assertThat(result.size(), is(3));
    }

    @Test(expected = EDBException.class)
    public void testConflictDetection_shouldThrowException() throws Exception {
        EDBCommit commit = edbService.createEDBCommit(null, null, null);
        EDBObject testObject = new EDBObject("newtestobject2");
        testObject.putEDBObjectEntry("newtestkey2", "newtestvalue2");
        commit.insert(testObject);

        edbService.commit(commit);

        commit = edbService.createEDBCommit(null, null, null);

        EDBObject obj = edbService.getObject("newtestobject2");
        obj.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(0));
        obj.putEDBObjectEntry("test", "test");

        commit.update(obj);
        edbService.commit(commit);
    }
View Full Code Here

        assertThat(version2, is(2));
    }

    @Test
    public void testIfLoadingOfCommitsWork_shouldWork() throws Exception {
        EDBCommit commit = edbService.createEDBCommit(null, null, null);
        EDBObject testObject = new EDBObject("commitload/1");
        testObject.putEDBObjectEntry("testkey", "testvalue");
        commit.insert(testObject);
        Long testtime = edbService.commit(commit);
        EDBCommit result = edbService.getCommit(testtime);
        assertThat(result.getInserts().size(), is(1));
    }
View Full Code Here

        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("A", "B", data1);
        putValue("Cow", "Milk", data1);
        putValue("Dog", "Food", data1);
        EDBObject v1 = new EDBObject("/test/query1", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v1);
        long time1 = db.commit(ci);

        Map<String, EDBObjectEntry> data2 = new HashMap<String, EDBObjectEntry>();
        putValue("Cow", "Milk", data2);
        putValue("House", "Garden", data2);
        v1 = new EDBObject("/test/query2", data2);
        ci = getEDBCommit();
        ci.insert(v1);
        long time2 = db.commit(ci);

        QueryRequest req = QueryRequest.query("A", "B");
        List<EDBObject> list1 = db.query(req);
        req = QueryRequest.query("A", "B").addParameter("Dog", "Food");
View Full Code Here

    public void testQueryOfOldVersion_shouldWork() throws Exception {
        Map<String, EDBObjectEntry> data1v1 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 1", data1v1);
        putValue("pre:KeyB", "pre:Value A 1", data1v1);
        EDBObject v11 = new EDBObject("pre:/test/object1", data1v1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v11);
        Map<String, EDBObjectEntry> data2v1 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 2", data2v1);
        putValue("pre:KeyB", "pre:Value A 1", data2v1);
        EDBObject v12 = new EDBObject("pre:/test/object2", data2v1);
        ci.insert(v12);
        Map<String, EDBObjectEntry> data3v1 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 3", data3v1);
        putValue("pre:KeyB", "pre:Value A 1", data3v1);
        EDBObject v13 = new EDBObject("pre:/test/object3", data3v1);
        ci.insert(v13);

        long time1 = db.commit(ci);

        Map<String, EDBObjectEntry> data1v2 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 1", data1v2);
        putValue("pre:KeyB", "pre:Value A 1", data1v2);
        EDBObject v21 = new EDBObject("pre:/test/object1", data1v2);
        ci = getEDBCommit();
        ci.update(v21);
        Map<String, EDBObjectEntry> data2v2 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 2", data2v2);
        putValue("pre:KeyB", "pre:Value A 1", data2v2);
        EDBObject v22 = new EDBObject("pre:/test/object2", data2v2);
        ci.update(v22);
        Map<String, EDBObjectEntry> data4v1 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 4", data4v1);
        putValue("pre:KeyB", "pre:Value A 1", data4v1);
        EDBObject v23 = new EDBObject("pre:/test/object4", data4v1);
        ci.update(v23);

        long time2 = db.commit(ci);

        Map<String, EDBObjectEntry> data1v3 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 1", data1v3);
        putValue("pre:KeyB", "pre:Value A 1", data1v3);
        EDBObject v31 = new EDBObject("pre:/test/object1", data1v3);
        ci = getEDBCommit();
        ci.update(v31);
        Map<String, EDBObjectEntry> data2v3 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 2a", data2v3);
        putValue("pre:KeyB", "pre:Value A 1", data2v3);
        EDBObject v32 = new EDBObject("pre:/test/object2", data2v3);
        ci.update(v32);
        Map<String, EDBObjectEntry> data4v2 = new HashMap<String, EDBObjectEntry>();
        putValue("pre:KeyA", "pre:Value A 4", data4v2);
        putValue("pre:KeyB", "pre:Value A 1", data4v2);
        EDBObject v33 = new EDBObject("pre:/test/object4", data4v2);
        ci.update(v33);

        long time3 = db.commit(ci);
        List<EDBObject> result = db.query(QueryRequest.query("pre:KeyB", "pre:Value A 1")
            .setTimestamp(time2));
View Full Code Here

        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("K", "B", data1);
        putValue("Cow", "Milk", data1);
        putValue("Dog", "Food", data1);
        EDBObject v1 = new EDBObject("/test/querynew1", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v1);
        db.commit(ci);

        data1 = new HashMap<String, EDBObjectEntry>();
        putValue("Dog", "Food", data1);
        v1 = new EDBObject("/test/querynew1", data1);
        ci = getEDBCommit();
        ci.update(v1);
        db.commit(ci);

        data1 = new HashMap<String, EDBObjectEntry>();
        putValue("K", "B", data1);
        putValue("Dog", "Food", data1);
        v1 = new EDBObject("/test/querynew2", data1);
        ci = getEDBCommit();
        ci.insert(v1);
        db.commit(ci);
        List<EDBObject> result = db.query(QueryRequest.query("K", "B"));
        assertThat(result.size(), is(1));
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.edb.api.EDBCommit

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.