Search in sources :

Example 1 with VolatileStore

use of com.arjuna.ats.internal.arjuna.objectstore.VolatileStore in project narayana by jbosstm.

the class ObjectStoreTest method testVolatileStore.

@Test
public void testVolatileStore() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setLocalOSRoot("tmp");
    VolatileStore as = new VolatileStore(objectStoreEnvironmentBean);
    final OutputObjectState buff = new OutputObjectState();
    final String tn = "/StateManager/junit";
    for (int i = 0; i < 100; i++) {
        Uid u = new Uid();
        InputObjectState ios = new InputObjectState();
        try {
            as.allObjUids("", ios);
        } catch (final Exception ex) {
        }
        try {
            assertTrue(as.read_uncommitted(u, tn) == null);
        } catch (final Exception ex) {
        }
        try {
            as.commit_state(u, tn);
        } catch (final Exception ex) {
        }
        as.write_committed(u, tn, buff);
        assertTrue(as.currentState(u, tn) == StateStatus.OS_COMMITTED);
        as.read_committed(u, tn);
        try {
            assertTrue(as.remove_uncommitted(u, tn));
        } catch (final Exception ex) {
        }
        as.remove_committed(u, tn);
        try {
            assertTrue(as.hide_state(u, tn));
        } catch (final Exception ex) {
        }
        try {
            assertTrue(as.reveal_state(u, tn));
        } catch (final Exception ex) {
        }
    }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) VolatileStore(com.arjuna.ats.internal.arjuna.objectstore.VolatileStore) TwoPhaseVolatileStore(com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore) Test(org.junit.Test)

Example 2 with VolatileStore

use of com.arjuna.ats.internal.arjuna.objectstore.VolatileStore in project narayana by jbosstm.

the class OtherObjectStoreAPIJMXTest method testVolatileStore.

@Test
public void testVolatileStore() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setLocalOSRoot("tmp");
    VolatileStore as = new VolatileStore(objectStoreEnvironmentBean);
    final OutputObjectState buff = new OutputObjectState();
    final String tn = "/StateManager/junit";
    createMBeans(as, as);
    for (int i = 0; i < 10; i++) {
        Uid u = new Uid();
        InputObjectState ios = new InputObjectState();
        try {
            rsProxy.allObjUids("", ios);
        } catch (final Exception ex) {
        }
        try {
            assertTrue(psProxy.read_uncommitted(u, tn) == null);
        } catch (final Exception ex) {
        }
        try {
            psProxy.commit_state(u, tn);
        } catch (final Exception ex) {
        }
        rsProxy.write_committed(u, tn, buff);
        assertTrue(rsProxy.currentState(u, tn) == StateStatus.OS_COMMITTED);
        rsProxy.read_committed(u, tn);
        try {
            assertTrue(psProxy.remove_uncommitted(u, tn));
        } catch (final Exception ex) {
        }
        rsProxy.remove_committed(u, tn);
        try {
            assertTrue(rsProxy.hide_state(u, tn));
        } catch (final Exception ex) {
        }
        try {
            assertTrue(rsProxy.reveal_state(u, tn));
        } catch (final Exception ex) {
        }
    }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) VolatileStore(com.arjuna.ats.internal.arjuna.objectstore.VolatileStore) Test(org.junit.Test)

Example 3 with VolatileStore

use of com.arjuna.ats.internal.arjuna.objectstore.VolatileStore in project narayana by jbosstm.

the class ObjectStoreTest method testTypedVolatileStore.

@Test
public void testTypedVolatileStore() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setLocalOSRoot("tmp");
    objectStoreEnvironmentBean.setVolatileStoreSupportAllObjUids(true);
    typedVolatileStoreCommon(new VolatileStore(objectStoreEnvironmentBean));
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) VolatileStore(com.arjuna.ats.internal.arjuna.objectstore.VolatileStore) TwoPhaseVolatileStore(com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore) Test(org.junit.Test)

Example 4 with VolatileStore

use of com.arjuna.ats.internal.arjuna.objectstore.VolatileStore in project narayana by jbosstm.

the class ObjectStoreTest method testTwoVolatileStores.

@Test
public void testTwoVolatileStores() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean1 = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean1.setLocalOSRoot("tmp");
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean2 = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean2.setLocalOSRoot("tmp2");
    objectStoreEnvironmentBean2.setVolatileStoreSupportAllObjUids(true);
    VolatileStore as1 = new VolatileStore(objectStoreEnvironmentBean1);
    VolatileStore as2 = new VolatileStore(objectStoreEnvironmentBean2);
    final OutputObjectState buff = new OutputObjectState();
    final String tn = "/StateManager/junit";
    try {
        as1.allObjUids("", new InputObjectState());
        fail("testTwoVolatileStores: allObjUids should have failed");
    } catch (final Exception ex) {
    }
    try {
        as1.allTypes(new InputObjectState());
        fail("testTwoVolatileStores: allTypes should have failed");
    } catch (final Exception ex) {
    }
    try {
        as2.allObjUids("", new InputObjectState());
    } catch (final Exception ex) {
        fail("testTwoVolatileStores: allObjUids should have passed");
    }
    try {
        as2.allTypes(new InputObjectState());
    } catch (final Exception ex) {
        fail("testTwoVolatileStores: allTypes should have passed");
    }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) VolatileStore(com.arjuna.ats.internal.arjuna.objectstore.VolatileStore) TwoPhaseVolatileStore(com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore) Test(org.junit.Test)

Aggregations

ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)4 VolatileStore (com.arjuna.ats.internal.arjuna.objectstore.VolatileStore)4 Test (org.junit.Test)4 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)3 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)3 TwoPhaseVolatileStore (com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)2 IOException (java.io.IOException)2