use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class MultipleORBInstances method test.
@Test
public void test() {
ORB[] orbInstance = new ORB[NUMBER_OF_ORBOAS];
RootOA[] oaInstance = new RootOA[NUMBER_OF_ORBOAS];
for (int count = 0; count < NUMBER_OF_ORBOAS; count++) {
System.out.println("Creating ORB and OA #" + count);
orbInstance[count] = ORB.getInstance("orb_" + count);
oaInstance[count] = RootOA.getRootOA(orbInstance[count]);
assertTrue(initialiseORBandOA(new String[] {}, orbInstance[count], oaInstance[count]));
}
assertTrue(ensureAllORBReferencesAreUnique(orbInstance, oaInstance));
System.out.println("Retrieving all ORBs and OAs");
for (int count = 0; count < NUMBER_OF_ORBOAS; count++) {
System.out.println("Retrieving ORB and OA #" + count);
ORB orb = ORB.getInstance("orb_" + count);
assertNotNull(orb);
assertNotNull(OA.getRootOA(orb));
}
System.out.println("Destroying all ORBs and OAs");
for (int count = 0; count < NUMBER_OF_ORBOAS; count++) {
orbInstance[count].destroy();
oaInstance[count].destroy();
}
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class OAPrePostShutdownTest method testOAShutdownCalled.
@Test
public void testOAShutdownCalled() throws Exception {
ORB orb = ORB.getInstance("main_orb");
RootOA oa = RootOA.getRootOA(orb);
System.out.println("Initialising ORB and OA");
orb.initORB(new String[] {}, null);
oa.initOA();
_currentState = NONE;
/**
* Register pre and post shutdown handlers
*/
oa.addPreShutdown(new TestPreShutdown("PreShutdown", this));
oa.addPostShutdown(new TestPostShutdown("PostShutdown", this));
System.out.println("Shutting down ORB (expecting OA to also be destroyed)");
orb.shutdown();
/*
* Ensure final state is correct
*/
System.out.println("Final state: " + PrettyPrintState(_currentState));
assertEquals(POSTSHUTDOWN, _currentState);
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class OAPrePostShutdownTest method test.
@Test
public void test() throws Exception {
ORB orb = ORB.getInstance("main_orb");
RootOA oa = RootOA.getRootOA(orb);
System.out.println("Initialising ORB and OA");
orb.initORB(new String[] {}, null);
oa.initOA();
_currentState = NONE;
/**
* Register pre and post shutdown handlers
*/
oa.addPreShutdown(new TestPreShutdown("PreShutdown", this));
oa.addPostShutdown(new TestPostShutdown("PostShutdown", this));
System.out.println("Shutting down ORB and OA");
oa.destroy();
orb.shutdown();
/*
* Ensure final state is correct
*/
System.out.println("Final state: " + PrettyPrintState(_currentState));
assertEquals(POSTSHUTDOWN, _currentState);
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class ORBInitialisationTest method test.
@Test
public void test() {
ORB orb = ORB.getInstance("main_orb");
RootOA oa = RootOA.getRootOA(orb);
try {
_currentState = NONE;
/*
* Registering attributes with ORB
*/
orb.addAttribute(new PreTestAttribute(this));
orb.addAttribute(new PostTestAttribute(this));
/*
* Initialise the ORB and OA
*/
System.out.println("Initialising ORB and OA");
orb.initORB(new String[] {}, null);
oa.initOA();
assertEquals(POSTINIT, _currentState);
} catch (Exception e) {
fail("Initialisation failed: " + e);
}
oa.destroy();
orb.shutdown();
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class Client01 method main.
public static void main(String[] args) {
int crashIn = Resource01.NOCRASH;
;
if (args.length >= 1) {
if (args[0].startsWith("p") || args[0].startsWith("P")) {
crashIn = Resource01.PREPARE;
}
if (args[0].startsWith("c") || args[0].startsWith("C")) {
crashIn = Resource01.COMMIT;
}
if (args[0].startsWith("r") || args[0].startsWith("R")) {
crashIn = Resource01.ROLLBACK;
}
}
if (args.length >= 2) {
resultsFile = args[1];
}
try {
ORB myORB = ORB.getInstance("Client01");
RootOA myOA = OA.getRootOA(myORB);
myORB.initORB(args, null);
myOA.initOA();
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed");
}
System.out.println("Ready");
try {
UserTransaction ut = com.arjuna.ats.jta.UserTransaction.userTransaction();
ut.begin();
TransactionImple txImple = (TransactionImple) TransactionManager.transactionManager().getTransaction();
txImple.enlistResource(new Resource01(crashIn, resultsFile));
txImple.enlistResource(new Resource02());
ut.commit();
System.out.println("Passed");
} catch (javax.transaction.RollbackException rbx) {
System.out.println("Passed");
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed");
}
}
Aggregations