Examples of fromMessage()


Examples of org.springframework.messaging.converter.CompositeMessageConverter.fromMessage()

    assertEquals(MimeType.valueOf("application/x-java-serialized-object"),
        result.getHeaders().get(MessageHeaders.CONTENT_TYPE));

    // Now convert back
    converter = converterFactory.newInstance(MimeType.valueOf("application/x-java-object"));
    result = (Message<?>) converter.fromMessage(result, Foo.class);
    assertNotNull(result);
    assertTrue(result.getPayload() instanceof Foo);
    assertEquals(MimeType.valueOf("application/x-java-object;type=" + Foo.class.getName()),
        result.getHeaders().get(MessageHeaders.CONTENT_TYPE));
  }
View Full Code Here

Examples of org.springframework.messaging.converter.CompositeMessageConverter.fromMessage()

  @Test
  public void testStringToByteArray() throws UnsupportedEncodingException {
    CompositeMessageConverter converter = converterFactory.newInstance(MimeType.valueOf("application/octet-stream"));
    Message<String> msg = MessageBuilder.withPayload("hello").copyHeaders(
        Collections.singletonMap(MessageHeaders.CONTENT_TYPE, MimeType.valueOf("text/plain;charset=UTF-8"))).build();
    byte[] result = (byte[]) converter.fromMessage(msg, byte[].class);
    assertEquals("hello", new String(result, "UTF-8"));
  }
}

View Full Code Here

Examples of org.springframework.messaging.converter.MessageConverter.fromMessage()

   * @return the converted payload of the reply message (never {@code null})
   */
  @SuppressWarnings("unchecked")
  protected <T> T doConvert(Message<?> message, Class<T> targetClass) {
    MessageConverter messageConverter = getMessageConverter();
    T value = (T) messageConverter.fromMessage(message, targetClass);
    if (value == null) {
      throw new MessageConversionException(message, "Unable to convert payload [" + message.getPayload() +
          "] to type [" + targetClass + "] using converter [" + messageConverter + "]");
    }
    return value;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.