use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class TransactionFactoryUnitTest method testContext.
@Test
public void testContext() throws Exception {
TransactionFactoryImple factory = new TransactionFactoryImple("test");
ControlImple tx = factory.createLocal(1000);
org.omg.CosTransactions.otid_t txId = Utility.uidToOtid(tx.get_uid());
Uid theUid = Utility.otidToUid(txId);
assertEquals(theUid, tx.get_uid());
// no state in OS yet!
assertEquals(factory.getOSStatus(tx.get_uid()), org.omg.CosTransactions.Status.StatusNoTransaction);
PropagationContext ctx = tx.get_coordinator().get_txcontext();
Control cont = factory.recreate(ctx);
String toString = Utility.getHierarchy(ctx);
System.out.println(toString);
assertTrue(toString != null);
assertTrue(toString.length() > 1);
assertTrue(Utility.getUid(cont).equals(tx.get_uid()));
try {
tx.getImplHandle().rollback();
} catch (final Throwable ex) {
}
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class TransactionTest3 method test.
@Test
public void test() throws Exception {
ORB myORB = null;
RootOA myOA = null;
myORB = ORB.getInstance("test");
myOA = OA.getRootOA(myORB);
myORB.initORB(new String[] {}, null);
myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
try {
OTSManager.get_current().begin();
Control cont = OTSManager.get_current().get_control();
OTSManager.get_current().commit(true);
OTSManager.get_current().resume(cont);
System.out.println("\nPassed.");
} catch (Throwable e) {
fail("caught: " + e);
e.printStackTrace();
}
myOA.destroy();
myORB.shutdown();
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class TransactionTest4 method test.
@Test
public void test() throws Exception {
ORB myORB = null;
RootOA myOA = null;
myORB = ORB.getInstance("test");
myOA = OA.getRootOA(myORB);
myORB.initORB(new String[] {}, null);
myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
try {
OTSManager.get_current().begin();
Control cont = OTSManager.get_current().get_control();
OTSManager.get_current().commit(true);
OTSManager.get_current().resume(cont);
cont = OTSManager.get_current().suspend();
System.out.println("\nPassed.");
} catch (Throwable e) {
fail("caught: " + e);
e.printStackTrace();
}
myOA.destroy();
myORB.shutdown();
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class TransactionTest5 method test.
@Test
public void test() throws Exception {
ORB myORB = null;
RootOA myOA = null;
try {
myORB = ORB.getInstance("test");
myOA = OA.getRootOA(myORB);
myORB.initORB(new String[] {}, null);
myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
} catch (Exception e) {
System.err.println("Initialisation failed: " + e);
}
try {
OTSManager.get_current().begin();
Control cont = OTSManager.get_current().get_control();
OTSManager.get_current().commit(true);
OTSManager.get_current().resume(cont);
OTSManager.get_current().rollback_only();
System.out.println("\nFailed.");
} catch (org.omg.CosTransactions.NoTransaction ex) {
System.out.println("\nPassed.");
} catch (Throwable e) {
fail("caught: " + e);
e.printStackTrace();
}
myOA.destroy();
myORB.shutdown();
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class OSIInterpositionUnitTest method test.
@Test
public void test() throws Exception {
OTSImpleManager.current().begin();
PropagationContext ctx = OTSImpleManager.current().get_control().get_coordinator().get_txcontext();
OSIInterpositionCreator creator = new OSIInterpositionCreator();
Control cnt = creator.recreate(ctx);
ControlImple impl = creator.recreateLocal(ctx);
assertTrue(cnt != null);
assertTrue(impl != null);
OTSImpleManager.current().rollback();
}
Aggregations