Search in sources :

Example 11 with Completion

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);
}
Also used : BACIDispatchAction(alma.ACS.jbaci.BACIDispatchAction) Completion(alma.ACSErr.Completion) Callback(alma.ACS.Callback) BACIDispatchAction(alma.ACS.jbaci.BACIDispatchAction) CBDescIn(alma.ACS.CBDescIn)

Example 12 with Completion

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);
}
Also used : BACIDispatchAction(alma.ACS.jbaci.BACIDispatchAction) Completion(alma.ACSErr.Completion) Callback(alma.ACS.Callback) BACIDispatchAction(alma.ACS.jbaci.BACIDispatchAction) CBDescIn(alma.ACS.CBDescIn)

Example 13 with Completion

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);
    }
}
Also used : NameValue(alma.ACSErr.NameValue) ErrorTrace(alma.ACSErr.ErrorTrace) Completion(alma.ACSErr.Completion)

Example 14 with Completion

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);
}
Also used : Completion(alma.ACSErr.Completion) MyAcsJCompletion(alma.acs.callbacks.Objects.MyAcsJCompletion) CBDescOut(alma.ACS.CBDescOut)

Example 15 with Completion

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);
}
Also used : Completion(alma.ACSErr.Completion) MyAcsJCompletion(alma.acs.callbacks.Objects.MyAcsJCompletion) CBDescOut(alma.ACS.CBDescOut)

Aggregations

Completion (alma.ACSErr.Completion)27 MyAcsJCompletion (alma.acs.callbacks.Objects.MyAcsJCompletion)14 CBDescOut (alma.ACS.CBDescOut)13 CBDescIn (alma.ACS.CBDescIn)7 Callback (alma.ACS.Callback)6 BACIDispatchAction (alma.ACS.jbaci.BACIDispatchAction)6 ErrorTrace (alma.ACSErr.ErrorTrace)2 AcsJCompletion (alma.acs.exceptions.AcsJCompletion)2 AcsJException (alma.acs.exceptions.AcsJException)2 CBlongPOA (alma.ACS.CBlongPOA)1 CompletionHolder (alma.ACSErr.CompletionHolder)1 NameValue (alma.ACSErr.NameValue)1 ACSErrTest1AcsJCompletion (alma.ACSErrTypeTest.wrappers.ACSErrTest1AcsJCompletion)1 ACSErrTest2AcsJCompletion (alma.ACSErrTypeTest.wrappers.ACSErrTest2AcsJCompletion)1 ACSErrTest3AcsJCompletion (alma.ACSErrTypeTest.wrappers.ACSErrTest3AcsJCompletion)1 ACSErrTestOKAcsJCompletion (alma.ACSErrTypeTest.wrappers.ACSErrTestOKAcsJCompletion)1 AcsJACSErrTest1Ex (alma.ACSErrTypeTest.wrappers.AcsJACSErrTest1Ex)1 AcsJACSErrTest2Ex (alma.ACSErrTypeTest.wrappers.AcsJACSErrTest2Ex)1 AcsJACSErrTest3Ex (alma.ACSErrTypeTest.wrappers.AcsJACSErrTest3Ex)1 MyAcsJException (alma.acs.callbacks.Objects.MyAcsJException)1