use of joynr.ImmutableMessage in project joynr by bmwcarit.
the class LibJoynrMessageSenderTest method testReplyToIsSet.
@Test
public void testReplyToIsSet() {
MutableMessage message = createTestRequestMessage();
String expectedReplyTo = "expectedReplyTo";
LibJoynrMessageSender subject = new LibJoynrMessageSender(messageRouterMock);
subject.setReplyToAddress(expectedReplyTo);
subject.sendMessage(message);
ArgumentCaptor<ImmutableMessage> argCaptor = ArgumentCaptor.forClass(ImmutableMessage.class);
verify(messageRouterMock).route(argCaptor.capture());
assertEquals(expectedReplyTo, argCaptor.getValue().getReplyTo());
}
use of joynr.ImmutableMessage in project joynr by bmwcarit.
the class WebSocketMessagingSkeleton method transmit.
@Override
public void transmit(byte[] serializedMessage, FailureAction failureAction) {
try {
ImmutableMessage message = new ImmutableMessage(serializedMessage);
LOG.debug("<<< INCOMING <<< {}", message);
if (messageProcessors != null) {
for (JoynrMessageProcessor processor : messageProcessors) {
message = processor.processIncoming(message);
}
}
if (Message.VALUE_MESSAGE_TYPE_MULTICAST.equals(message.getType()) && this.isMainTransport()) {
message.setReceivedFromGlobal(true);
}
messageRouter.route(message);
} catch (Exception error) {
failureAction.execute(error);
}
}
use of joynr.ImmutableMessage in project joynr by bmwcarit.
the class MessagingTest method testPostMessageExpiryDateExpired.
@Test
public void testPostMessageExpiryDateExpired() throws Exception {
ImmutableMessage message = createJoynrMessage(ExpiryDate.fromAbsolute(1));
byte[] serializedMessage = message.getSerializedMessage();
//
Response response = //
given().contentType(ContentType.BINARY).when().body(serializedMessage).post(serverUrl + "/channels/channel-123/message");
assertEquals(400, /* Bad Request */
response.getStatusCode());
JoynrMessagingError error = objectMapper.readValue(response.getBody().asString(), JoynrMessagingError.class);
assertEquals(JOYNRMESSAGINGERROR_EXPIRYDATEEXPIRED.getCode(), error.getCode());
assertEquals(JOYNRMESSAGINGERROR_EXPIRYDATEEXPIRED.getDescription() + ": 127.0.0.1", error.getReason());
Mockito.verify(mock, Mockito.never()).passMessageToReceiver("channel-123", serializedMessage);
}
use of joynr.ImmutableMessage in project joynr by bmwcarit.
the class MessagingTest method testPostMessageWithoutExpiryDate.
// @Test
// public void testPostMessageWithMissingChannelId() throws
// JsonProcessingException {
//
// String serializedMessage = createJoynrMessage();
//
// // TODO how is the call in this case???
// Response response = //
// given(). //
// contentType(ContentType.JSON).
// when().body(serializedMessage).
// post(serverUrl + "/channels/null/message");
//
// assertEquals(201 /* Created */, response.getStatusCode());
//
// }
@Test
public void testPostMessageWithoutExpiryDate() throws Exception {
ImmutableMessage message = createJoynrMessage(ExpiryDate.fromAbsolute(0));
byte[] serializedMessage = message.getSerializedMessage();
//
Response response = //
given().contentType(ContentType.BINARY).when().body(serializedMessage).post(serverUrl + "/channels/channel-123/message");
assertEquals(400, /* Bad Request */
response.getStatusCode());
JoynrMessagingError error = objectMapper.readValue(response.getBody().asString(), JoynrMessagingError.class);
assertEquals(JOYNRMESSAGINGERROR_EXPIRYDATENOTSET.getCode(), error.getCode());
assertEquals(JOYNRMESSAGINGERROR_EXPIRYDATENOTSET.getDescription(), error.getReason());
Mockito.verify(mock, Mockito.never()).passMessageToReceiver("channel-123", serializedMessage);
}
use of joynr.ImmutableMessage in project joynr by bmwcarit.
the class MessagingTest method testPostMessage.
@Test
public void testPostMessage() throws Exception {
Mockito.when(mock.hasMessageReceiver("channel-123")).thenReturn(true);
Mockito.when(mock.isAssignedForChannel("channel-123")).thenReturn(true);
ImmutableMessage message = createJoynrMessage();
byte[] serializedMessage = message.getSerializedMessage();
//
Response response = //
given().contentType(ContentType.BINARY).when().body(serializedMessage).post(serverUrl + "/channels/channel-123/message");
assertEquals(201, /* Created */
response.getStatusCode());
assertEquals(serverUrl + "/messages/" + message.getId(), response.getHeader("Location"));
assertEquals(message.getId(), response.getHeader("msgId"));
Mockito.verify(mock).passMessageToReceiver("channel-123", serializedMessage);
}
Aggregations