use of org.springframework.messaging.MessageHeaders in project spring-framework by spring-projects.
the class DefaultContentTypeResolverTests method resolve.
@Test
public void resolve() {
Map<String, Object> map = new HashMap<>();
map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON);
MessageHeaders headers = new MessageHeaders(map);
assertEquals(MimeTypeUtils.APPLICATION_JSON, this.resolver.resolve(headers));
}
use of org.springframework.messaging.MessageHeaders in project spring-framework by spring-projects.
the class DefaultContentTypeResolverTests method resolveStringContentType.
@Test
public void resolveStringContentType() {
Map<String, Object> map = new HashMap<>();
map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON_VALUE);
MessageHeaders headers = new MessageHeaders(map);
assertEquals(MimeTypeUtils.APPLICATION_JSON, this.resolver.resolve(headers));
}
use of org.springframework.messaging.MessageHeaders in project spring-framework by spring-projects.
the class DefaultContentTypeResolverTests method resolveDefaultMimeType.
@Test
public void resolveDefaultMimeType() {
this.resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
MessageHeaders headers = new MessageHeaders(Collections.<String, Object>emptyMap());
assertEquals(MimeTypeUtils.APPLICATION_JSON, this.resolver.resolve(headers));
}
use of org.springframework.messaging.MessageHeaders in project spring-framework by spring-projects.
the class MappingJackson2MessageConverterTests method toMessageUtf16String.
@Test
public void toMessageUtf16String() {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setSerializedPayloadClass(String.class);
MimeType contentType = new MimeType("application", "json", StandardCharsets.UTF_16BE);
Map<String, Object> map = new HashMap<>();
map.put(MessageHeaders.CONTENT_TYPE, contentType);
MessageHeaders headers = new MessageHeaders(map);
String payload = "Héllo Wörld";
Message<?> message = converter.toMessage(payload, headers);
assertEquals("\"" + payload + "\"", message.getPayload());
assertEquals(contentType, message.getHeaders().get(MessageHeaders.CONTENT_TYPE));
}
use of org.springframework.messaging.MessageHeaders in project spring-framework by spring-projects.
the class MessageHeaderAccessorTests method existingHeaders.
@Test
public void existingHeaders() throws InterruptedException {
Map<String, Object> map = new HashMap<>();
map.put("foo", "bar");
map.put("bar", "baz");
GenericMessage<String> message = new GenericMessage<>("payload", map);
MessageHeaderAccessor accessor = new MessageHeaderAccessor(message);
MessageHeaders actual = accessor.getMessageHeaders();
assertEquals(3, actual.size());
assertEquals("bar", actual.get("foo"));
assertEquals("baz", actual.get("bar"));
}
Aggregations