Package org.springframework.messaging.converter

Examples of org.springframework.messaging.converter.MessageConverter


    SimpAnnotationMethodMessageHandler annotationMethodMessageHandler =
        this.appContext.getBean(SimpAnnotationMethodMessageHandler.class);

    assertNotNull(annotationMethodMessageHandler);
    MessageConverter messageConverter = annotationMethodMessageHandler.getMessageConverter();
    assertNotNull(messageConverter);
    assertTrue(messageConverter instanceof CompositeMessageConverter);

    CompositeMessageConverter compositeMessageConverter = this.appContext.getBean(CompositeMessageConverter.class);
    assertNotNull(compositeMessageConverter);
View Full Code Here


   * @param targetClass the target class to convert the payload to
   * @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

    assertEquals(1, executor.getMaxPoolSize());
  }

  @Test
  public void configureMessageConvertersCustom() {
    final MessageConverter testConverter = mock(MessageConverter.class);
    AbstractMessageBrokerConfiguration config = new AbstractMessageBrokerConfiguration() {
      @Override
      protected boolean configureMessageConverters(List<MessageConverter> messageConverters) {
        messageConverters.add(testConverter);
        return false;
View Full Code Here

    assertThat(iterator.next(), Matchers.is(testConverter));
  }

  @Test
  public void configureMessageConvertersCustomAndDefault() {
    final MessageConverter testConverter = mock(MessageConverter.class);

    AbstractMessageBrokerConfiguration config = new AbstractMessageBrokerConfiguration() {
      @Override
      protected boolean configureMessageConverters(List<MessageConverter> messageConverters) {
        messageConverters.add(testConverter);
View Full Code Here

  }

  @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));
View Full Code Here

  }

  @Test
  public void customMessageConverterFailure() throws Exception {
    DefaultMessageHandlerMethodFactory instance = createInstance();
    MessageConverter messageConverter = new ByteArrayMessageConverter();
    instance.setMessageConverter(messageConverter);
    instance.afterPropertiesSet();

    InvocableHandlerMethod invocableHandlerMethod =
        createInvocableHandlerMethod(instance, "simpleString", String.class);
View Full Code Here

TOP

Related Classes of org.springframework.messaging.converter.MessageConverter

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.