use of com.arjuna.orbportability.ORB 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.ORB 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.ORB 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.ORB 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.ORB in project narayana by jbosstm.
the class PropertyInitTest method test.
@Test
public void test() {
Properties testProps = System.getProperties();
testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"), "com.hp.mwtests.orbportability.initialisation.preinit.AllPreInitialisation");
testProps.setProperty(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"), "com.hp.mwtests.orbportability.initialisation.postinit.AllPostInitialisation");
testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME), "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation");
testProps.setProperty(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME), "com.hp.mwtests.orbportability.initialisation.postinit.PostInitialisation");
testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME_2), "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation2");
testProps.setProperty(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME_2), "com.hp.mwtests.orbportability.initialisation.postinit.PostInitialisation2");
System.setProperties(testProps);
ORB orb = ORB.getInstance(ORB_INSTANCE_NAME);
orb.initORB(new String[] {}, null);
assertTrue(PreInitialisation._called);
assertTrue(PostInitialisation._called);
assertTrue(PreInitialisation2._called);
assertTrue(PostInitialisation2._called);
assertTrue(AllPreInitialisation._called);
assertTrue(AllPostInitialisation._called);
try {
/**
* Reset called flags on All ORB instance pre-initialisation
*/
AllPreInitialisation._called = false;
AllPostInitialisation._called = false;
orb = ORB.getInstance(ORB_INSTANCE_NAME_2);
System.out.println("Initialising Second ORB Instance");
orb.initORB(new String[] {}, null);
} catch (Exception e) {
e.printStackTrace(System.err);
fail("ERROR - " + e);
}
assertTrue(PreInitialisation2._called);
assertTrue(PostInitialisation2._called);
assertTrue(AllPreInitialisation._called);
assertTrue(AllPostInitialisation._called);
try {
orb.destroy();
} catch (Exception e) {
fail("ERROR - " + e);
e.printStackTrace(System.err);
}
}
Aggregations