use of alma.ACSErr.Completion in project ACS by ACS-Community.
the class BACIDispatchActionTest method testFirstFailed.
/**
* First failed then success test.
*/
public void testFirstFailed() {
Object value = new Object();
Completion completion = CompletionUtil.generateNoErrorCompletion();
CBDescIn descIn = new CBDescIn(50000, 50000, 1234);
Callback callback = new TestCallback();
TestCallbackDispatcher dispatcher = new FirstFailedCallbackDispatcher();
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 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 testNormal.
/**
* Normal (success) test.
*/
public void testNormal() {
Object value = new Object();
Completion completion = CompletionUtil.generateNoErrorCompletion();
CBDescIn descIn = new CBDescIn(50000, 50000, 1234);
Callback callback = new TestCallback();
TestCallbackDispatcher dispatcher = new PerfectCallbackDispatcher();
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 1 response is expected
assertEquals(1, dispatcher.getResponseQueue().size());
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 CompletionEventPublisherClient method publishEvent.
/**
* Publish a {@link StructWithACompletion}.
*
* At the present this tests shall pass because of the workaround described
* in the ticket (i.e. added another typedef for for the sequence in the
* {@link Completion}).
*/
private void publishEvent() {
m_logger.info("Going to publish an event");
// Create and initialize an event with a Completion
Completion c = new Completion();
c.code = 100;
c.timeStamp = System.currentTimeMillis();
c.type = 101;
// ICT-3870 error happens also without any ErorTrace in the previuError property
// of the COmpletion but this way it is more compete
ErrorTrace event = new ErrorTrace();
event.previousError = new ErrorTrace[0];
event.errorCode = 1;
event.errorType = 2;
event.file = "filename";
event.host = "hostname";
event.lineNum = 3;
event.process = "processname";
event.routine = "reoutinename";
event.severity = Severity.Alert;
NameValue nv = new NameValue();
nv.name = "NameValue name";
nv.value = "NameValue value";
event.data = new NameValue[0];
event.shortDescription = "short desc";
event.sourceObject = "src obj";
event.thread = "thread name";
event.timeStamp = System.currentTimeMillis();
c.previousError = new ErrorTrace[1];
c.previousError[0] = event;
try {
m_supplier.publishEvent(c);
m_logger.info("Event successfull published.");
} catch (Throwable t) {
m_logger.log(AcsLogLevel.ERROR, "Error publishing the event with a Completion", t);
}
}
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, CBdouble cb, CBDescIn descIn) {
Completion completion = ResponderUtil.giveCompletion(exc);
CBDescOut cbDescOut = ResponderUtil.giveDescOut(descIn);
cb.done(-1D, completion, cbDescOut);
}
use of alma.ACSErr.Completion in project ACS by ACS-Community.
the class ResponderUtil method respond.
/**
* @param returnValue
* @param cb
* @param descIn
*/
public static void respond(double[] returnValue, CBdoubleSeq cb, CBDescIn descIn) {
Completion completion = ResponderUtil.giveCompletion();
CBDescOut cbDescOut = ResponderUtil.giveDescOut(descIn);
cb.done(returnValue, completion, cbDescOut);
}
Aggregations