@Test(expected = MessageConversionException.class) public void convertAndSendNoMatchingConverter() { MessageConverter converter = new CompositeMessageConverter( Arrays.<MessageConverter>asList(new MappingJackson2MessageConverter())); this.template.setMessageConverter(converter); this.headers.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_XML); this.template.convertAndSend("home", "payload", new MessageHeaders(this.headers)); }
@Test public void convertAndSendPayloadAndHeadersToDestination() { this.template.convertAndSend("somewhere", "payload", headers); assertEquals("somewhere", this.template.destination); assertNotNull(this.template.message); assertEquals("value", this.template.message.getHeaders().get("key")); assertEquals("payload", this.template.message.getPayload()); }
@Test public void convertAndSendPayloadToDestination() { this.template.convertAndSend("somewhere", "payload"); assertEquals("somewhere", this.template.destination); assertNotNull(this.template.message); assertEquals("expected 'id' and 'timestamp' headers only", 2, this.template.message.getHeaders().size()); assertEquals("payload", this.template.message.getPayload()); }
@Test public void convertAndSendPayload() { this.template.setDefaultDestination("home"); this.template.convertAndSend("payload"); assertEquals("home", this.template.destination); assertNotNull(this.template.message); assertEquals("expected 'id' and 'timestamp' headers only", 2, this.template.message.getHeaders().size()); assertEquals("payload", this.template.message.getPayload()); }
@Test public void convertAndSend() { this.template.convertAndSend("somewhere", "payload", headers, this.postProcessor); assertEquals("somewhere", this.template.destination); assertNotNull(this.template.message); assertEquals("value", this.template.message.getHeaders().get("key")); assertEquals("payload", this.template.message.getPayload()); assertNotNull(this.postProcessor.getMessage()); assertSame(this.template.message, this.postProcessor.getMessage()); }
@Test public void convertAndSendPayloadAndMutableHeadersToDestination() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("foo", "bar"); accessor.setLeaveMutable(true); MessageHeaders messageHeaders = accessor.getMessageHeaders(); this.template.setMessageConverter(new StringMessageConverter()); this.template.convertAndSend("somewhere", "payload", messageHeaders); MessageHeaders actual = this.template.message.getHeaders(); assertSame(messageHeaders, actual); assertEquals(new MimeType("text", "plain", StandardCharsets.UTF_8), actual.get(MessageHeaders.CONTENT_TYPE)); assertEquals("bar", actual.get("foo")); }
@Test public void convertAndSendPayloadWithPostProcessorToDestination() { this.template.convertAndSend("somewhere", "payload", this.postProcessor); assertEquals("somewhere", this.template.destination); assertNotNull(this.template.message); assertEquals("expected 'id' and 'timestamp' headers only", 2, this.template.message.getHeaders().size()); assertEquals("payload", this.template.message.getPayload()); assertNotNull(this.postProcessor.getMessage()); assertSame(this.template.message, this.postProcessor.getMessage()); }
@Test public void convertAndSendPayloadWithPostProcessor() { this.template.setDefaultDestination("home"); this.template.convertAndSend((Object) "payload", this.postProcessor); assertEquals("home", this.template.destination); assertNotNull(this.template.message); assertEquals("expected 'id' and 'timestamp' headers only", 2, this.template.message.getHeaders().size()); assertEquals("payload", this.template.message.getPayload()); assertNotNull(this.postProcessor.getMessage()); assertSame(this.template.message, this.postProcessor.getMessage()); }