use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class BACIDispatchActionTest method testException.
/**
* Always throws exception.
*/
public void testException() {
Object value = new Object();
Completion completion = CompletionUtil.generateNoErrorCompletion();
CBDescIn descIn = new CBDescIn(50000, 50000, 1234);
Callback callback = new TestCallback();
TestCallbackDispatcher dispatcher = new ExceptionCallbackDispatcher();
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.ACS.CBDescIn 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.ACS.CBDescIn in project ACS by ACS-Community.
the class PropertyPrimTest method testSetAsyncFloatRW.
public void testSetAsyncFloatRW() {
CBvoidImpl cb = new CBvoidImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
synchronized (cb) {
RWpropertyFloat.set_async((float) 500.0, cb._this(orb), descIn);
try {
// wait for 5s
cb.wait(5000);
} catch (InterruptedException ie) {
}
}
// only 1 response is expected
//assertEquals(1, cb.getResponseQueue().size());
//CBResponse response = (CBResponse)cb.getResponseQueue().firstElement();
// check reponse type
//assertEquals(CBResponse.DONE_TYPE, response.type);
// check value
// TODO check value
CompletionHolder completionHolder = new CompletionHolder();
double value = RWpropertyFloat.get_sync(completionHolder);
assertEquals(500.0, value, 0.001);
}
use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class PropertyPrimTest method testGetAsyncDoubleRW.
public void testGetAsyncDoubleRW() {
CBdoubleImpl cb = new CBdoubleImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
synchronized (cb) {
RWpropertyDouble.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());
CBResponse response = (CBResponse) cb.getResponseQueue().firstElement();
// check reponse type
assertEquals(CBResponse.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);
}
use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class PropertyPrimTest method testGetAsyncFloatRW.
public void testGetAsyncFloatRW() {
CBfloatImpl cb = new CBfloatImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
synchronized (cb) {
RWpropertyFloat.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());
CBResponseFloat response = (CBResponseFloat) cb.getResponseQueue().firstElement();
// check reponse type
assertEquals(CBResponseFloat.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);
}
Aggregations