Search in sources :

Example 1 with JeeMessagingEndpoint

use of io.joynr.jeeintegration.messaging.JeeMessagingEndpoint in project joynr by bmwcarit.

the class JeeMessagingEndpointTest method testStatus.

@Test
public void testStatus() {
    JeeMessagingEndpoint subject = createSubject().subject;
    Response result = subject.status();
    assertNotNull(result);
    assertEquals(200, result.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) JeeMessagingEndpoint(io.joynr.jeeintegration.messaging.JeeMessagingEndpoint) Test(org.junit.Test)

Example 2 with JeeMessagingEndpoint

use of io.joynr.jeeintegration.messaging.JeeMessagingEndpoint in project joynr by bmwcarit.

the class JeeMessagingEndpointTest method callPostMethod.

private void callPostMethod(PostMethodCaller postMethodCaller) throws Exception {
    SubjectData subjectData = createSubject();
    JeeMessagingEndpoint subject = subjectData.subject;
    byte[] payload = new byte[] { 1, 2, 3 };
    UriInfo uriInfo = mock(UriInfo.class);
    UriBuilder uriBuilder = mock(UriBuilder.class);
    UriBuilder pathBuilder = mock(UriBuilder.class);
    MutableMessage mutableMessage = new MutableMessage();
    mutableMessage.setSender("testSender");
    mutableMessage.setRecipient("testRecipient");
    mutableMessage.setTtlAbsolute(true);
    mutableMessage.setTtlMs(ExpiryDate.fromRelativeTtl(1000L).getValue());
    mutableMessage.setPayload(payload);
    when(uriBuilder.path("messages/" + mutableMessage.getId())).thenReturn(pathBuilder);
    when(uriInfo.getBaseUriBuilder()).thenReturn(uriBuilder);
    postMethodCaller.call(subject, "channel-1", mutableMessage.getImmutableMessage().getSerializedMessage(), uriInfo);
    Mockito.verify(subjectData.messageReceiver).receive(Mockito.any());
}
Also used : JeeMessagingEndpoint(io.joynr.jeeintegration.messaging.JeeMessagingEndpoint) MutableMessage(joynr.MutableMessage) UriBuilder(javax.ws.rs.core.UriBuilder) UriInfo(javax.ws.rs.core.UriInfo)

Example 3 with JeeMessagingEndpoint

use of io.joynr.jeeintegration.messaging.JeeMessagingEndpoint in project joynr by bmwcarit.

the class JeeMessagingEndpointTest method createSubject.

private SubjectData createSubject() {
    SubjectData result = new SubjectData();
    JoynrIntegrationBean joynrIntegrationBean = mock(JoynrIntegrationBean.class);
    result.injector = mock(Injector.class);
    when(joynrIntegrationBean.getJoynrInjector()).thenReturn(result.injector);
    result.objectMapper = mock(ObjectMapper.class);
    when(result.injector.getInstance(ObjectMapper.class)).thenReturn(result.objectMapper);
    result.messageReceiver = mock(ServletMessageReceiver.class);
    when(result.injector.getInstance(ServletMessageReceiver.class)).thenReturn(result.messageReceiver);
    result.subject = new JeeMessagingEndpoint(joynrIntegrationBean);
    return result;
}
Also used : JeeMessagingEndpoint(io.joynr.jeeintegration.messaging.JeeMessagingEndpoint) Injector(com.google.inject.Injector) JoynrIntegrationBean(io.joynr.jeeintegration.JoynrIntegrationBean) ServletMessageReceiver(io.joynr.dispatcher.ServletMessageReceiver) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JeeMessagingEndpoint (io.joynr.jeeintegration.messaging.JeeMessagingEndpoint)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Injector (com.google.inject.Injector)1 ServletMessageReceiver (io.joynr.dispatcher.ServletMessageReceiver)1 JoynrIntegrationBean (io.joynr.jeeintegration.JoynrIntegrationBean)1 Response (javax.ws.rs.core.Response)1 UriBuilder (javax.ws.rs.core.UriBuilder)1 UriInfo (javax.ws.rs.core.UriInfo)1 MutableMessage (joynr.MutableMessage)1 Test (org.junit.Test)1