use of joynr.types.Localisation.GpsLocation in project joynr by bmwcarit.
the class AbstractBroadcastEnd2EndTest method subscribeToBroadcastOneOutput.
@Ignore
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeToBroadcastOneOutput() throws InterruptedException {
final Semaphore broadcastReceived = new Semaphore(0);
proxy.subscribeToLocationUpdateBroadcast(new testBroadcastInterface.LocationUpdateBroadcastAdapter() {
@Override
public void onReceive(GpsLocation location) {
assertEquals(expectedLocation, location);
broadcastReceived.release();
}
}, new MulticastSubscriptionQos());
Thread.sleep(300);
provider.fireLocationUpdate(expectedLocation);
broadcastReceived.acquire();
}
use of joynr.types.Localisation.GpsLocation in project joynr by bmwcarit.
the class AbstractBroadcastEnd2EndTest method subscribeToSelectiveBroadcast_FilterFalse.
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeToSelectiveBroadcast_FilterFalse() throws InterruptedException {
final Semaphore broadcastReceived = new Semaphore(0);
final LocationUpdateSelectiveBroadcastFilterParameters testFilterParameters = new LocationUpdateSelectiveBroadcastFilterParameters();
testFilterParameters.setCountry("Germany");
testFilterParameters.setStartTime("4.00 pm");
testLocationUpdateSelectiveBroadcastFilter filter1 = new testLocationUpdateSelectiveBroadcastFilter() {
@Override
public boolean filter(GpsLocation location, LocationUpdateSelectiveBroadcastFilterParameters filterParameters) {
assertEquals(testFilterParameters, filterParameters);
return true;
}
};
testLocationUpdateSelectiveBroadcastFilter filter2 = new testLocationUpdateSelectiveBroadcastFilter() {
@Override
public boolean filter(GpsLocation location, LocationUpdateSelectiveBroadcastFilterParameters filterParameters) {
assertEquals(testFilterParameters, filterParameters);
return false;
}
};
getSubscriptionTestsPublisher().addBroadcastFilter(filter1);
getSubscriptionTestsPublisher().addBroadcastFilter(filter2);
OnChangeSubscriptionQos subscriptionQos = createDefaultOnChangeSubscriptionQos();
proxy.subscribeToLocationUpdateSelectiveBroadcast(new testBroadcastInterface.LocationUpdateSelectiveBroadcastAdapter() {
@Override
public void onReceive(GpsLocation location) {
assertEquals(expectedLocation, location);
broadcastReceived.release();
}
}, subscriptionQos, testFilterParameters);
Thread.sleep(300);
provider.fireLocationUpdateSelective(expectedLocation);
assertFalse(broadcastReceived.tryAcquire(500, TimeUnit.MILLISECONDS));
}
use of joynr.types.Localisation.GpsLocation in project joynr by bmwcarit.
the class AbstractProviderProxyEnd2EndTest method calledMethodReturnsMultipleOutputParametersAsyncFuture.
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void calledMethodReturnsMultipleOutputParametersAsyncFuture() throws Exception {
ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
Future<MethodWithMultipleOutputParametersReturned> future = proxy.methodWithMultipleOutputParameters(new MethodWithMultipleOutputParametersCallback() {
@Override
public void onFailure(JoynrRuntimeException error) {
logger.error("error in calledMethodReturnsMultipleOutputParametersAsyncCallback", error);
}
@Override
public void onSuccess(String aString, Integer aNumber, GpsLocation aComplexDataType, TestEnum anEnumResult) {
assertEquals(TEST_INTEGER, aNumber);
assertEquals(TEST_STRING, aString);
assertEquals(TEST_COMPLEXTYPE, aComplexDataType);
assertEquals(TEST_ENUM, anEnumResult);
}
});
MethodWithMultipleOutputParametersReturned reply = future.get();
assertEquals(TEST_INTEGER, reply.aNumber);
assertEquals(TEST_STRING, reply.aString);
assertEquals(TEST_COMPLEXTYPE, reply.aComplexDataType);
assertEquals(TEST_ENUM, reply.anEnumResult);
}
use of joynr.types.Localisation.GpsLocation in project joynr by bmwcarit.
the class RpcStubbingTest method setUp.
@Before
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_NULL_PARAM_DEREF", justification = "NPE in test would fail test")
public void setUp() throws JoynrCommunicationException, JoynrSendBufferFullException, JsonGenerationException, JsonMappingException, IOException, JoynrMessageNotSentException {
Deferred<GpsLocation> deferredGpsLocation = new Deferred<GpsLocation>();
deferredGpsLocation.resolve(gpsValue);
when(testMock.returnsGpsLocation()).thenReturn(new Promise<Deferred<GpsLocation>>(deferredGpsLocation));
Deferred<List<GpsLocation>> deferredGpsLocationList = new Deferred<List<GpsLocation>>();
deferredGpsLocationList.resolve(gpsList);
when(testMock.returnsGpsLocationList()).thenReturn(new Promise<Deferred<List<GpsLocation>>>(deferredGpsLocationList));
DeferredVoid deferredVoid = new DeferredVoid();
deferredVoid.resolve();
when(testMock.noParamsNoReturnValue()).thenReturn(new Promise<DeferredVoid>(deferredVoid));
when(testMock.takesTwoSimpleParams(any(Integer.class), any(String.class))).thenReturn(new Promise<DeferredVoid>(deferredVoid));
fromParticipantId = UUID.randomUUID().toString();
toParticipantId = UUID.randomUUID().toString();
toDiscoveryEntry = new DiscoveryEntryWithMetaInfo();
toDiscoveryEntry.setParticipantId(toParticipantId);
// required to inject static members of JoynMessagingConnectorFactory
injector = Guice.createInjector(new JoynrPropertiesModule(PropertyLoader.loadProperties(MessagingPropertyKeys.DEFAULT_MESSAGING_PROPERTIES_FILE)), new JsonMessageSerializerModule(), new AbstractModule() {
@Override
protected void configure() {
requestStaticInjection(RpcUtils.class);
install(new JoynrMessageScopeModule());
MapBinder<Class<? extends Address>, AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>> messagingStubFactory;
messagingStubFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
}, new TypeLiteral<AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>>() {
}, Names.named(MessagingStubFactory.MIDDLEWARE_MESSAGING_STUB_FACTORIES));
messagingStubFactory.addBinding(InProcessAddress.class).to(InProcessMessagingStubFactory.class);
}
});
final RequestInterpreter requestInterpreter = injector.getInstance(RequestInterpreter.class);
final RequestCallerFactory requestCallerFactory = injector.getInstance(RequestCallerFactory.class);
when(requestReplyManager.sendSyncRequest(eq(fromParticipantId), eq(toDiscoveryEntry), any(Request.class), any(SynchronizedReplyCaller.class), eq(messagingQos))).thenAnswer(new Answer<Reply>() {
@Override
public Reply answer(InvocationOnMock invocation) throws Throwable {
RequestCaller requestCaller = requestCallerFactory.create(testMock);
Object[] args = invocation.getArguments();
Request request = null;
for (Object arg : args) {
if (arg instanceof Request) {
request = (Request) arg;
break;
}
}
final Future<Reply> future = new Future<Reply>();
ProviderCallback<Reply> callback = new ProviderCallback<Reply>() {
@Override
public void onSuccess(Reply result) {
future.onSuccess(result);
}
@Override
public void onFailure(JoynrException error) {
future.onFailure(error);
}
};
requestInterpreter.execute(callback, requestCaller, request);
return future.get();
}
});
JoynrMessagingConnectorFactory joynrMessagingConnectorFactory = new JoynrMessagingConnectorFactory(requestReplyManager, replyCallerDirectory, subscriptionManager);
connector = joynrMessagingConnectorFactory.create(fromParticipantId, Sets.newHashSet(toDiscoveryEntry), messagingQos);
}
use of joynr.types.Localisation.GpsLocation in project joynr by bmwcarit.
the class SerializationTest method serializeAndDeserializeRequestWithVariousTypesTest.
@Test
public void serializeAndDeserializeRequestWithVariousTypesTest() throws Exception {
String methodName = "methodName";
GpsLocation gpsLocation = new GpsLocation(1.0d, 2.0d, 0d, GpsFixEnum.MODE2D, 0d, 0d, 0d, 0d, 0l, 0l, 0);
GpsLocation[] gpsLocations = { new GpsLocation(1.0d, 2.0d, 0d, GpsFixEnum.MODE2D, 0d, 0d, 0d, 0d, 0l, 0l, 0), new GpsLocation(1.0d, 2.0d, 0d, GpsFixEnum.MODE2D, 0d, 0d, 0d, 0d, 0l, 0l, 0), new GpsLocation(1.0d, 2.0d, 0d, GpsFixEnum.MODE2D, 0d, 0d, 0d, 0d, 0l, 0l, 0) };
TestClass testObject = new TestClass();
testObject.setMyByte((byte) 4);
testObject.setObjects(new Object[] { gpsLocation, "hello" });
String[][] stringArray = new String[][] { { "test1", "test2", "test3" }, { "test4", "test5", "test6" } };
Boolean[] booleanArray = { true, false };
Boolean[] emptyArray = {};
Object[] mixedArray = new Object[] { "one", gpsLocation, stringArray };
Object[] params = new Object[] { true, Integer.MAX_VALUE, Long.MAX_VALUE, Double.MAX_VALUE, gpsLocation, "param1", gpsLocations, stringArray, booleanArray, emptyArray, mixedArray };
String[] paramDatatypes = new String[params.length];
for (int i = 0; i < params.length; i++) {
paramDatatypes[i] = ReflectionUtils.toDatatypeNames(params[i].getClass())[0];
}
Request request = new Request(methodName, params, paramDatatypes, null);
String valueAsString = objectMapper.writeValueAsString(request);
System.out.println(valueAsString);
Request request2 = objectMapper.readValue(valueAsString, Request.class);
assertEquals(request, request2);
}
Aggregations