use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class AtomicObject2 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);
AtomicWorker2.init();
AtomicWorker2.atomicObject_1 = new AtomicObject();
AtomicWorker2.atomicObject_2 = new AtomicObject();
System.out.println(AtomicWorker2.atomicObject_1.get_uid());
System.out.println(AtomicWorker2.atomicObject_2.get_uid());
assertTrue(AtomicWorker2.atomicObject_1.set(START_VALUE_1));
assertTrue(AtomicWorker2.atomicObject_2.set(START_VALUE_2));
ThreadObject2 thr1 = new ThreadObject2('1');
ThreadObject2 thr2 = new ThreadObject2('2');
thr1.start();
thr2.start();
try {
thr1.join();
thr2.join();
} catch (InterruptedException e) {
System.err.println(e);
}
AtomicWorker2.get12('m', 0);
AtomicWorker2.get21('m', 0);
try {
int value1 = AtomicWorker2.get1();
int value2 = AtomicWorker2.get2();
assertEquals(EXPECTED_VALUE, (value1 + value2));
} catch (Exception e) {
e.printStackTrace(System.err);
fail();
}
myOA.destroy();
myORB.shutdown();
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class AtomicObject3 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);
AtomicWorker3.init();
AtomicWorker3.atomicObject_1 = new AtomicObject();
AtomicWorker3.atomicObject_2 = new AtomicObject();
logger.info(AtomicWorker3.atomicObject_1.get_uid());
logger.info(AtomicWorker3.atomicObject_2.get_uid());
assertTrue(AtomicWorker3.atomicObject_1.set(START_VALUE_1));
assertTrue(AtomicWorker3.atomicObject_2.set(START_VALUE_2));
Thread thr1 = new ThreadObject3b(1);
Thread thr2 = new ThreadObject3b(2);
thr1.start();
thr2.start();
try {
thr1.join();
thr2.join();
} catch (InterruptedException e) {
fail(e.toString());
}
AtomicWorker3.get12(0, 0);
AtomicWorker3.get21(0, 0);
try {
int value1 = AtomicWorker3.get1();
int value2 = AtomicWorker3.get2();
assertEquals(EXPECTED_VALUE, (value1 + value2));
} catch (Exception e) {
logger.warn(e.getMessage(), e);
fail();
}
myOA.destroy();
myORB.shutdown();
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class ORBSetupTest method test.
@Test
public void test() {
boolean staticSet = false;
ORB myORB = null;
RootOA myOA = null;
Map<String, String> properties = opPropertyManager.getOrbPortabilityEnvironmentBean().getOrbInitializationProperties();
properties.put(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_NAME), "com.arjuna.ats.jts.utils.ORBSetup");
opPropertyManager.getOrbPortabilityEnvironmentBean().setOrbInitializationProperties(properties);
try {
myORB = ORB.getInstance(ORB_NAME);
myOA = OA.getRootOA(myORB);
if (staticSet) {
ORBManager.setORB(myORB);
}
try {
myORB.initORB(new String[] {}, null);
myOA.initOA();
assertEquals(myORB, ORBManager.getORB());
} catch (FatalError e) {
if (staticSet) {
System.out.println("FatalError thrown as expected");
} else {
fail("Error: " + e);
e.printStackTrace(System.err);
}
}
myOA.destroy();
myORB.destroy();
} catch (Throwable e) {
fail("Error: " + e);
e.printStackTrace(System.err);
}
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class SynchTest method test.
@Test
public void test() {
org.omg.CosTransactions.Status status = Status.StatusUnknown;
tranobject_i localObject = null;
demosync sync = null;
ORB myORB = null;
RootOA myOA = null;
try {
ServerORB orb = new ServerORB();
myORB = orb.getORB();
myOA = orb.getOA();
Control myControl = null;
org.omg.CosTransactions.Current current = OTSManager.get_current();
Coordinator coord = null;
sync = new demosync();
localObject = new tranobject_i();
current.begin();
myControl = current.get_control();
coord = myControl.get_coordinator();
coord.register_resource(localObject.getReference());
coord.register_synchronization(sync.getReference());
try {
current.commit(true);
} catch (TRANSACTION_ROLLEDBACK e1) {
System.out.println("Transaction rolledback");
}
try {
status = coord.get_status();
} catch (SystemException ex) {
// assume reference no longer valid!
status = Status.StatusUnknown;
}
} catch (UserException e1) {
fail("Caught UserException: " + e1);
e1.printStackTrace();
} catch (SystemException e2) {
fail("Caught SystemException: " + e2);
e2.printStackTrace();
}
System.out.print("Final action status: " + com.arjuna.ats.jts.utils.Utility.stringStatus(status));
System.out.println("\nTest completed successfully.");
myOA.shutdownObject(sync);
myOA.shutdownObject(localObject);
myOA.destroy();
myORB.shutdown();
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class DefaultTimeout method test.
@Test
public void test() {
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);
int sleepTime = arjPropertyManager.getCoordinatorEnvironmentBean().getDefaultTimeout();
System.out.println("Thread " + Thread.currentThread() + " starting transaction.");
OTSManager.get_current().begin();
Thread.sleep(sleepTime * 1000 * 2, 0);
System.out.println("Thread " + Thread.currentThread() + " committing transaction.");
OTSManager.get_current().commit(false);
System.out.println("Transaction committed. Timeout did not go off.");
System.out.println("Test did not complete successfully.");
} catch (Exception e) {
System.out.println("Caught exception: " + e);
System.out.println("Timeout went off.");
System.out.println("Test completed successfully.");
}
myOA.destroy();
myORB.shutdown();
}
Aggregations