use of alma.ACSErr.Completion in project ACS by ACS-Community.
the class ResponderUtil method respond.
/**
* @param exc
* @param cb
* @param descIn
*/
public static void respond(Exception exc, CBstringSeq cb, CBDescIn descIn) {
Completion completion = ResponderUtil.giveCompletion(exc);
CBDescOut cbDescOut = ResponderUtil.giveDescOut(descIn);
cb.done(new String[] {}, completion, cbDescOut);
}
use of alma.ACSErr.Completion in project ACS by ACS-Community.
the class ResponderUtil method giveCompletion.
// ========================================================
// ===================== Response =======================
// ========================================================
public static Completion giveCompletion(Exception exc) {
Completion ret;
// wrap Exception in a AcsJException
AcsJException acsJExc = new MyAcsJException(exc);
// wrap AcsJException in a AcsJCompletion
MyAcsJCompletion c = new MyAcsJCompletion(acsJExc);
// transform AcsJCompletion to a Completion
ret = c.toCorbaCompletion();
return ret;
}
use of alma.ACSErr.Completion in project ACS by ACS-Community.
the class BACIDispatchActionTest method testOverrideBlockingFailsNoneToOverrideTest.
/**
* Override policy test (blocking fails, none to override).
*/
public void testOverrideBlockingFailsNoneToOverrideTest() {
Object value = new Object();
Completion completion = CompletionUtil.generateNoErrorCompletion();
CBDescIn descIn = new CBDescIn(50000, 50000, 1234);
Callback callback = new TestCallback();
TestCallbackDispatcher dispatcher = new OverrideTestCallbackDispatcher(true);
BACIDispatchAction action = new BACIDispatchAction(callback, descIn, dispatcher);
action.setOverridePolicy(true);
synchronized (dispatcher) {
// blocking request
action.dispatchDoneRequest(completion, value);
try {
// wait
dispatcher.wait(RESPONSE_WAIT_TIME);
} catch (InterruptedException ie) {
}
}
synchronized (dispatcher) {
// notift blocking request
dispatcher.notify();
}
// dummy wait (just in case there is a bug and more responses will come)
dummyWait();
// only 2 (failed and successful) responses are expected
assertEquals(2, dispatcher.getResponseQueue().size());
// should be the same
assertEquals(dispatcher.getResponseQueue().get(0), dispatcher.getResponseQueue().get(1));
DispatchAction response = (DispatchAction) dispatcher.getResponseQueue().firstElement();
// check response
checkResponse(value, completion, descIn, callback, response);
}
use of alma.ACSErr.Completion in project ACS by ACS-Community.
the class BACIDispatchActionTest method testAlwaysFails.
/**
* Always fails test.
*/
public void testAlwaysFails() {
Object value = new Object();
Completion completion = CompletionUtil.generateNoErrorCompletion();
CBDescIn descIn = new CBDescIn(50000, 50000, 1234);
Callback callback = new TestCallback();
TestCallbackDispatcher dispatcher = new DisasterCallbackDispatcher();
BACIDispatchAction action = new BACIDispatchAction(callback, descIn, dispatcher);
synchronized (dispatcher) {
action.dispatchDoneRequest(completion, value);
try {
// wait
dispatcher.wait(RESPONSE_WAIT_TIME);
} catch (InterruptedException ie) {
}
}
// dummy wait (just in case there is a bug and more responses will come)
dummyWait();
// only 3 responses (retries) are expected
assertEquals(3, dispatcher.getResponseQueue().size());
// should be the same
assertEquals(dispatcher.getResponseQueue().get(0), dispatcher.getResponseQueue().get(1));
DispatchAction response = (DispatchAction) dispatcher.getResponseQueue().firstElement();
// check response
checkResponse(value, completion, descIn, callback, response);
}
use of alma.ACSErr.Completion in project ACS by ACS-Community.
the class BACIDispatchActionTest method noErrorOverrideTest.
/**
* No error override policy test.
*/
public void noErrorOverrideTest(boolean blockingFails) {
Object value = new Object();
Completion completion = CompletionUtil.generateNoErrorCompletion();
Completion completion2 = CompletionUtil.generateNoErrorCompletion();
CBDescIn descIn = new CBDescIn(50000, 50000, 1234);
Callback callback = new TestCallback();
TestCallbackDispatcher dispatcher = new OverrideTestCallbackDispatcher(blockingFails);
BACIDispatchAction action = new BACIDispatchAction(callback, descIn, dispatcher);
action.setOverridePolicy(true);
synchronized (dispatcher) {
// blocking request
action.dispatchDoneRequest(completion, value);
try {
// wait
dispatcher.wait(RESPONSE_WAIT_TIME);
} catch (InterruptedException ie) {
}
}
synchronized (dispatcher) {
// to be overriden
action.dispatchDoneRequest(completion, value);
action.dispatchDoneRequest(completion, value);
action.dispatchDoneRequest(completion, value);
// to survive ;)
action.dispatchDoneRequest(completion2, value);
// release blocking request
dispatcher.notify();
try {
// wait
dispatcher.wait(RESPONSE_WAIT_TIME);
} catch (InterruptedException ie) {
}
}
// dummy wait (just in case there is a bug and more responses will come)
dummyWait();
// only 2 responses are expected
assertEquals(2, dispatcher.getResponseQueue().size());
DispatchAction response = (DispatchAction) dispatcher.getResponseQueue().firstElement();
DispatchAction response2 = (DispatchAction) dispatcher.getResponseQueue().get(1);
// check response
checkResponse(value, completion, descIn, callback, response);
checkResponse(value, completion2, descIn, callback, response2);
}
Aggregations