use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Client18 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
int expectedResult = Integer.parseInt(args[args.length - 1]);
int numberOfCalls = Integer.parseInt(args[args.length - 2]);
String counterIOR = ServerIORStore.loadIOR(args[args.length - 3]);
Counter counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
int index = 0;
boolean expectingFailure;
/* Remove 2 from the number of calls and the expected result
* two transactions occur other than in this loop
* one in the implementation within the server and one
* at the end to return the number from the object
*/
numberOfCalls -= 2;
expectedResult -= 2;
expectingFailure = (numberOfCalls != expectedResult);
System.err.println("expectingFailure = " + expectingFailure);
try {
for (index = 0; index < numberOfCalls; index++) {
AtomicTransaction atomicTransaction = new AtomicTransaction();
atomicTransaction.begin();
counter.increase(OTS.current().get_control());
atomicTransaction.commit(true);
}
} catch (org.omg.CORBA.TRANSACTION_ROLLEDBACK e) {
/*
* If the number of transactions created is equal to the
* expected result then we are not expecting this exception
* to be thrown therefore the test has failed
*/
System.err.println("Performed " + index + " calls when exception thrown");
if (!expectingFailure) {
System.err.println("Got unexpected org.omg.CORBA.TRANSACTION_ROLLEDBACK exception");
throw e;
} else {
System.err.println("Got expected org.omg.CORBA.TRANSACTION_ROLLEDBACK exception");
}
} catch (Exception e) {
System.err.println("Performed " + index + " calls when exception thrown");
throw e;
}
AtomicTransaction atomicTransaction = new AtomicTransaction();
atomicTransaction.begin();
IntHolder value = new IntHolder();
counter.get(value, OTS.current().get_control());
try {
atomicTransaction.commit(true);
} catch (org.omg.CORBA.TRANSACTION_ROLLEDBACK e) {
if (!expectingFailure) {
System.err.println("Got unexpected org.omg.CORBA.TRANSACTION_ROLLEDBACK exception");
throw e;
} else {
System.err.println("Got expected org.omg.CORBA.TRANSACTION_ROLLEDBACK exception");
}
}
if (((!expectingFailure) && (value.value == expectedResult)) || ((expectingFailure) && (value.value != expectedResult))) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client18.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client18.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Client05 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
String pingPongIOR = ServerIORStore.loadIOR(args[args.length - 1]);
PingPong pingPong = PingPongHelper.narrow(ORBInterface.orb().string_to_object(pingPongIOR));
int numberOfCalls = 10;
for (int index = 0; index < numberOfCalls; index++) {
pingPong.hit(index, pingPong, pingPong, null);
}
IntHolder pingPongValue = new IntHolder();
pingPong.get(pingPongValue, null);
if (pingPongValue.value == numberOfCalls) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client05.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client05.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Outcome02 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
int expectedValue = Integer.parseInt(args[args.length - 3]);
String counterIOR1 = ServerIORStore.loadIOR(args[args.length - 2]);
Counter counter1 = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR1));
String counterIOR2 = ServerIORStore.loadIOR(args[args.length - 1]);
Counter counter2 = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR2));
IntHolder value1 = new IntHolder();
counter1.get(value1, null);
IntHolder value2 = new IntHolder();
counter2.get(value2, null);
if ((value1.value == expectedValue) && (value2.value == expectedValue)) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Outcome02.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Outcome02.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Client16 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
String counterIOR = ServerIORStore.loadIOR(args[args.length - 3]);
Counter counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
int numberOfWorkers = Integer.parseInt(args[args.length - 2]);
int numberOfCalls = Integer.parseInt(args[args.length - 1]);
Worker[] workers = new Worker[numberOfWorkers];
for (int index = 0; index < workers.length; index++) {
workers[index] = new Worker(numberOfCalls, counter);
}
for (int index = 0; index < workers.length; index++) {
workers[index].start();
}
boolean correct = true;
for (int index = 0; index < workers.length; index++) {
workers[index].join();
correct = correct && workers[index].isCorrect();
}
IntHolder value = new IntHolder();
AtomicTransaction atomicTransaction = new AtomicTransaction();
atomicTransaction.begin();
counter.get(value);
atomicTransaction.commit(true);
correct = correct && (value.value == (numberOfWorkers * numberOfCalls));
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client16.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client16.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Outcome01 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
int expectedValue = Integer.parseInt(args[args.length - 2]);
String counterIOR = ServerIORStore.loadIOR(args[args.length - 1]);
Counter counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
IntHolder value = new IntHolder();
counter.get(value);
if (value.value == expectedValue) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Outcome01.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Outcome01.main: " + exception);
exception.printStackTrace(System.err);
}
}
Aggregations