Search in sources :

Example 6 with OneWayRequest

use of joynr.OneWayRequest in project joynr by bmwcarit.

the class OneWayRequestDeserializer method deserialize.

/* (non-Javadoc)
     * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser,
     * com.fasterxml.jackson.databind.DeserializationContext)
     */
@Override
public OneWayRequest deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);
    String methodName = node.get("methodName").asText();
    ParamsAndParamDatatypesHolder paramsAndParamDatatypes = DeserializerUtils.deserializeParams(objectMapper, node, logger);
    return new OneWayRequest(methodName, paramsAndParamDatatypes.params, paramsAndParamDatatypes.paramDatatypes);
}
Also used : OneWayRequest(joynr.OneWayRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 7 with OneWayRequest

use of joynr.OneWayRequest in project joynr by bmwcarit.

the class SerializationTest method serializeAndDeserializeOneWayTest.

@Test
public void serializeAndDeserializeOneWayTest() throws Exception {
    GpsLocation gpsLocation = new GpsLocation(1.0d, 2.0d, 0d, GpsFixEnum.MODE2D, 0d, 0d, 0d, 0d, 0l, 0l, 0);
    OneWayRequest oneway = new OneWayRequest("methodName", new Object[] { gpsLocation }, new Class<?>[] { GpsLocation.class });
    String valueAsString = objectMapper.writeValueAsString(oneway);
    LOG.debug(valueAsString);
    OneWayRequest oneway2 = objectMapper.readValue(valueAsString, OneWayRequest.class);
    assertEquals(oneway, oneway2);
}
Also used : OneWayRequest(joynr.OneWayRequest) GpsLocation(joynr.types.Localisation.GpsLocation) Test(org.junit.Test)

Example 8 with OneWayRequest

use of joynr.OneWayRequest in project joynr by bmwcarit.

the class DispatcherImplTest method testHandleOneWayRequest.

@Test
public void testHandleOneWayRequest() throws Exception {
    OneWayRequest request = new OneWayRequest("method", new Object[0], new Class<?>[0]);
    String toParticipantId = "toParticipantId";
    MessagingQos messagingQos = new MessagingQos(1000L);
    MutableMessage joynrMessage = messageFactory.createOneWayRequest("fromParticipantId", toParticipantId, request, messagingQos);
    fixture.messageArrived(joynrMessage.getImmutableMessage());
    verify(requestReplyManagerMock).handleOneWayRequest(toParticipantId, request, joynrMessage.getTtlMs());
    verify(messageSenderMock, never()).sendMessage(any(MutableMessage.class));
}
Also used : OneWayRequest(joynr.OneWayRequest) MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with OneWayRequest

use of joynr.OneWayRequest in project joynr by bmwcarit.

the class RequestInterpreterTest method setup.

@Before
public void setup() {
    RequestCallerFactory requestCallerFactory = new RequestCallerFactory();
    requestCaller = requestCallerFactory.create(new DefaulttestProvider());
    subject = new RequestInterpreter(joynrMessageScope, joynrMessageCreatorProvider, joynrMessageContextProvider);
    request = new OneWayRequest("getTestAttribute", new Object[0], new Class[0]);
    request.setCreatorUserId("creator");
    Mockito.when(joynrMessageCreatorProvider.get()).thenReturn(joynrMessageCreator);
    Mockito.when(joynrMessageContextProvider.get()).thenReturn(joynrMessageContext);
}
Also used : OneWayRequest(joynr.OneWayRequest) DefaulttestProvider(joynr.tests.DefaulttestProvider) RequestCallerFactory(io.joynr.dispatching.RequestCallerFactory) Before(org.junit.Before)

Aggregations

OneWayRequest (joynr.OneWayRequest)9 Test (org.junit.Test)3 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)2 MessagingQos (io.joynr.messaging.MessagingQos)2 Method (java.lang.reflect.Method)2 Request (joynr.Request)2 Before (org.junit.Before)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 TypeLiteral (com.google.inject.TypeLiteral)1 JoynrMessageScopeModule (io.joynr.context.JoynrMessageScopeModule)1 RequestCallerFactory (io.joynr.dispatching.RequestCallerFactory)1 ReplyCallerDirectory (io.joynr.dispatching.rpc.ReplyCallerDirectory)1 RpcUtils (io.joynr.dispatching.rpc.RpcUtils)1 SubscriptionException (io.joynr.exceptions.SubscriptionException)1 FailureAction (io.joynr.messaging.FailureAction)1