Search in sources :

Example 6 with BACIDispatchAction

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

Aggregations

CBDescIn (alma.ACS.CBDescIn)6 Callback (alma.ACS.Callback)6 BACIDispatchAction (alma.ACS.jbaci.BACIDispatchAction)6 Completion (alma.ACSErr.Completion)6