Search in sources :

Example 1 with GpsPosition

use of joynr.types.Localisation.GpsPosition in project joynr by bmwcarit.

the class ConnectorTest method subscriptionMethodCallWithNoExpiryDate.

@Test
public void subscriptionMethodCallWithNoExpiryDate() throws JoynrIllegalStateException {
    ConnectorInvocationHandler connector = createConnector();
    assertNotNull(connector);
    try {
        Future<String> future = new Future<String>();
        String subscriptionId = "subscriptionId";
        PeriodicSubscriptionQos subscriptionQos = new PeriodicSubscriptionQos();
        subscriptionQos.setPeriodMs(1000).setExpiryDateMs(0).setAlertAfterIntervalMs(1000);
        AttributeSubscriptionListener<GpsPosition> listener = new AttributeSubscriptionAdapter<GpsPosition>();
        Object[] args = new Object[] { listener, subscriptionQos, subscriptionId };
        Method method = LocalisationSubscriptionInterface.class.getDeclaredMethod("subscribeToGPSPosition", String.class, AttributeSubscriptionListener.class, SubscriptionQos.class);
        AttributeSubscribeInvocation attributeSubscription = new AttributeSubscribeInvocation(method, args, future);
        connector.executeSubscriptionMethod(attributeSubscription);
        verify(subscriptionManager, times(1)).registerAttributeSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), eq(attributeSubscription));
    } catch (Exception e) {
        // This is what is supposed to happen -> no error handling
        fail("Calling a subscription method with no expiry date throws an exception.");
    }
}
Also used : AttributeSubscriptionAdapter(io.joynr.pubsub.subscription.AttributeSubscriptionAdapter) GpsPosition(joynr.types.Localisation.GpsPosition) Method(java.lang.reflect.Method) AttributeSubscribeInvocation(io.joynr.proxy.invocation.AttributeSubscribeInvocation) SubscriptionException(io.joynr.exceptions.SubscriptionException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Example 2 with GpsPosition

use of joynr.types.Localisation.GpsPosition in project joynr by bmwcarit.

the class SerializationTest method serializePublication.

@Test
public void serializePublication() throws JsonGenerationException, JsonMappingException, IOException {
    Object response = new GpsPosition(49.0065, 11.65);
    String subscriptionId = "1234";
    SubscriptionPublication publication = new SubscriptionPublication(Arrays.asList(response), subscriptionId);
    String writeValueAsString = objectMapper.writeValueAsString(publication);
    SubscriptionPublication receivedPublication = objectMapper.readValue(writeValueAsString, SubscriptionPublication.class);
    Assert.assertEquals(publication, receivedPublication);
}
Also used : SubscriptionPublication(joynr.SubscriptionPublication) GpsPosition(joynr.types.Localisation.GpsPosition) Test(org.junit.Test)

Example 3 with GpsPosition

use of joynr.types.Localisation.GpsPosition in project joynr by bmwcarit.

the class SerializationTest method serializeMulticast.

@Test
public void serializeMulticast() throws JsonGenerationException, JsonMappingException, IOException {
    Object response = new GpsPosition(49.0065, 11.65);
    String multicastId = "1234";
    MulticastPublication publication = new MulticastPublication(Arrays.asList(response), multicastId);
    String writeValueAsString = objectMapper.writeValueAsString(publication);
    MulticastPublication receivedPublication = objectMapper.readValue(writeValueAsString, MulticastPublication.class);
    Assert.assertEquals(publication, receivedPublication);
}
Also used : MulticastPublication(joynr.MulticastPublication) GpsPosition(joynr.types.Localisation.GpsPosition) Test(org.junit.Test)

Example 4 with GpsPosition

use of joynr.types.Localisation.GpsPosition in project joynr by bmwcarit.

the class SerializationTest method serializeRequest.

@Test
public void serializeRequest() throws JsonGenerationException, JsonMappingException, IOException {
    GpsPosition[] parameter = { new GpsPosition(49.0065, 11.65) };
    Object[] parameters = { parameter };
    Class<?>[] parameterTypes = { GpsPosition[].class };
    Request request = new Request("updateRoute", parameters, parameterTypes);
    String writeValueAsString = objectMapper.writeValueAsString(request);
    Request receivedRequest = objectMapper.readValue(writeValueAsString, Request.class);
    Assert.assertEquals(request, receivedRequest);
}
Also used : OneWayRequest(joynr.OneWayRequest) SubscriptionRequest(joynr.SubscriptionRequest) PersistedSubscriptionRequest(io.joynr.dispatching.subscription.PersistedSubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) Request(joynr.Request) GpsPosition(joynr.types.Localisation.GpsPosition) Test(org.junit.Test)

Example 5 with GpsPosition

use of joynr.types.Localisation.GpsPosition in project joynr by bmwcarit.

the class SerializationTest method serializeReply.

@Test
public void serializeReply() throws JsonGenerationException, JsonMappingException, IOException {
    Object response = new GpsPosition(49.0065, 11.65);
    Reply reply = new Reply(UUID.randomUUID().toString(), response);
    String writeValueAsString = objectMapper.writeValueAsString(reply);
    System.out.println(writeValueAsString);
    Reply receivedReply = objectMapper.readValue(writeValueAsString, Reply.class);
    Assert.assertEquals(reply, receivedReply);
}
Also used : Reply(joynr.Reply) GpsPosition(joynr.types.Localisation.GpsPosition) Test(org.junit.Test)

Aggregations

GpsPosition (joynr.types.Localisation.GpsPosition)5 Test (org.junit.Test)5 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 PersistedSubscriptionRequest (io.joynr.dispatching.subscription.PersistedSubscriptionRequest)1 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)1 SubscriptionException (io.joynr.exceptions.SubscriptionException)1 AttributeSubscribeInvocation (io.joynr.proxy.invocation.AttributeSubscribeInvocation)1 AttributeSubscriptionAdapter (io.joynr.pubsub.subscription.AttributeSubscriptionAdapter)1 Method (java.lang.reflect.Method)1 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)1 MulticastPublication (joynr.MulticastPublication)1 OneWayRequest (joynr.OneWayRequest)1 PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)1 Reply (joynr.Reply)1 Request (joynr.Request)1 SubscriptionPublication (joynr.SubscriptionPublication)1 SubscriptionRequest (joynr.SubscriptionRequest)1