Search in sources :

Example 51 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class PropertyPrimTest method testCreateMonitorDouble.

public void testCreateMonitorDouble() {
    // TODO do test with null callback ;)
    // TODO implement...
    CBdoubleImpl cb = new CBdoubleImpl();
    CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
    Monitordouble monitor = ROpropertyDouble.create_monitor(cb._this(orb), descIn);
    try {
        // 10.5 sec
        Thread.sleep(10500);
    } catch (InterruptedException ie) {
    }
    synchronized (cb) {
        try {
            monitor.destroy();
            // wait for 3s
            cb.wait(3000);
        } catch (InterruptedException ie) {
        }
    }
// TODO test if done was called
}
Also used : CBDescIn(alma.ACS.CBDescIn) Monitordouble(alma.ACS.Monitordouble)

Example 52 with CBDescIn

use of alma.ACS.CBDescIn 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);
}
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 53 with CBDescIn

use of alma.ACS.CBDescIn 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);
}
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 54 with CBDescIn

use of alma.ACS.CBDescIn 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)

Example 55 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class PropertyPrimTest method testGetAsyncLongRW.

public void testGetAsyncLongRW() {
    CBlongImpl cb = new CBlongImpl();
    CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
    synchronized (cb) {
        RWpropertyLong.get_async(cb._this(orb), descIn);
        try {
            // wait for 5s
            cb.wait(5000);
        } catch (InterruptedException ie) {
        }
    }
    // only 1 response is expected
    assertEquals(1, cb.getResponseQueue().size());
    CBResponseLong response = (CBResponseLong) cb.getResponseQueue().firstElement();
    // check reponse type
    assertEquals(CBResponseLong.DONE_TYPE, response.type);
    // check value
    // TODO check value
    //assertEquals(property.default_value(), response.value, 0.0);
    // check descriptor
    assertEquals(descIn.id_tag, response.desc.id_tag);
    // check completion
    assertEquals(0, response.completion.code);
    assertEquals(0, response.completion.type);
    assertEquals(0, response.completion.previousError.length);
    // less than 5s
    assertTrue((UTCUtility.utcJavaToOmg(System.currentTimeMillis()) - response.completion.timeStamp) < 50000000);
}
Also used : CBDescIn(alma.ACS.CBDescIn)

Aggregations

CBDescIn (alma.ACS.CBDescIn)57 CompletionHolder (alma.ACSErr.CompletionHolder)11 Monitordouble (alma.ACS.Monitordouble)10 Completion (alma.ACSErr.Completion)7 Callback (alma.ACS.Callback)6 BACIDispatchAction (alma.ACS.jbaci.BACIDispatchAction)6 NO_IMPLEMENT (org.omg.CORBA.NO_IMPLEMENT)6 RWdouble (alma.ACS.RWdouble)5 Monitorfloat (alma.ACS.Monitorfloat)4 Monitorlong (alma.ACS.Monitorlong)4 ROdouble (alma.ACS.ROdouble)3 OffShoot (alma.ACS.OffShoot)2 LampUnavailable (alma.demo.LampUnavailable)2 NoPermissionEx (alma.maciErrType.NoPermissionEx)2 POAManager (org.omg.PortableServer.POAManager)2 ClientInfo (si.ijs.maci.ClientInfo)2 Manager (si.ijs.maci.Manager)2 CBDescOut (alma.ACS.CBDescOut)1 CBdouble (alma.ACS.CBdouble)1 CBlongPOA (alma.ACS.CBlongPOA)1