Package org.springframework.xd.dirt.integration.bus

Examples of org.springframework.xd.dirt.integration.bus.EmbeddedHeadersMessageConverter


*/
public class MessageConverterTests {

  @Test
  public void testHeaderEmbedding() throws Exception {
    EmbeddedHeadersMessageConverter converter = new EmbeddedHeadersMessageConverter();
    Message<byte[]> message = MessageBuilder.withPayload("Hello".getBytes())
        .setHeader("foo", "bar")
        .setHeader("baz", "quxx")
        .build();
    Message<byte[]> converted = converter.embedHeaders(message, "foo", "baz");
    assertEquals("\u0002\u0003foo\u0003bar\u0003baz\u0004quxxHello", new String(converted.getPayload()));

    converted = converter.extractHeaders(converted);
    assertEquals("Hello", new String(converted.getPayload()));
    assertEquals("bar", converted.getHeaders().get("foo"));
    assertEquals("quxx", converted.getHeaders().get("baz"));
  }
View Full Code Here


    assertEquals("quxx", converted.getHeaders().get("baz"));
  }

  @Test
  public void testHeaderEmbeddingMissingHeader() throws Exception {
    EmbeddedHeadersMessageConverter converter = new EmbeddedHeadersMessageConverter();
    Message<byte[]> message = MessageBuilder.withPayload("Hello".getBytes())
        .setHeader("foo", "bar")
        .build();
    Message<byte[]> converted = converter.embedHeaders(message, "foo", "baz");
    assertEquals("\u0001\u0003foo\u0003barHello", new String(converted.getPayload()));
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.dirt.integration.bus.EmbeddedHeadersMessageConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.