Package org.springframework.messaging.converter

Examples of org.springframework.messaging.converter.CompositeMessageConverter


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

    CompositeMessageConverter compositeMessageConverter = this.appContext.getBean(CompositeMessageConverter.class);
    assertNotNull(compositeMessageConverter);

    SimpMessagingTemplate simpMessagingTemplate = this.appContext.getBean(SimpMessagingTemplate.class);
    assertNotNull(simpMessagingTemplate);
    assertEquals("/personal/", simpMessagingTemplate.getUserDestinationPrefix());

    List<MessageConverter> converters = compositeMessageConverter.getConverters();
    assertThat(converters.size(), Matchers.is(3));
    assertThat(converters.get(0), Matchers.instanceOf(StringMessageConverter.class));
    assertThat(converters.get(1), Matchers.instanceOf(ByteArrayMessageConverter.class));
    assertThat(converters.get(2), Matchers.instanceOf(MappingJackson2MessageConverter.class));
View Full Code Here


  @Test
  public void messageConverters() {
    loadBeanDefinitions("websocket-config-broker-converters.xml");

    CompositeMessageConverter compositeConverter = this.appContext.getBean(CompositeMessageConverter.class);
    assertNotNull(compositeConverter);

    assertEquals(4, compositeConverter.getConverters().size());
    assertEquals(StringMessageConverter.class, compositeConverter.getConverters().iterator().next().getClass());
  }
View Full Code Here

  @Test
  public void messageConvertersDefaultsOff() {
    loadBeanDefinitions("websocket-config-broker-converters-defaults-off.xml");

    CompositeMessageConverter compositeConverter = this.appContext.getBean(CompositeMessageConverter.class);
    assertNotNull(compositeConverter);

    assertEquals(1, compositeConverter.getConverters().size());
    assertEquals(StringMessageConverter.class, compositeConverter.getConverters().iterator().next().getClass());
  }
View Full Code Here

  }

  @Test
  public void configureMessageConvertersDefault() {
    AbstractMessageBrokerConfiguration config = new AbstractMessageBrokerConfiguration() {};
    CompositeMessageConverter compositeConverter = config.brokerMessageConverter();

    List<MessageConverter> converters = compositeConverter.getConverters();
    assertThat(converters.size(), Matchers.is(3));
    assertThat(converters.get(0), Matchers.instanceOf(StringMessageConverter.class));
    assertThat(converters.get(1), Matchers.instanceOf(ByteArrayMessageConverter.class));
    assertThat(converters.get(2), Matchers.instanceOf(MappingJackson2MessageConverter.class));
View Full Code Here

        messageConverters.add(testConverter);
        return false;
      }
    };

    CompositeMessageConverter compositeConverter = config.brokerMessageConverter();
    assertThat(compositeConverter.getConverters().size(), Matchers.is(1));
    Iterator<MessageConverter> iterator = compositeConverter.getConverters().iterator();
    assertThat(iterator.next(), Matchers.is(testConverter));
  }
View Full Code Here

      protected boolean configureMessageConverters(List<MessageConverter> messageConverters) {
        messageConverters.add(testConverter);
        return true;
      }
    };
    CompositeMessageConverter compositeConverter = config.brokerMessageConverter();

    assertThat(compositeConverter.getConverters().size(), Matchers.is(4));
    Iterator<MessageConverter> iterator = compositeConverter.getConverters().iterator();
    assertThat(iterator.next(), Matchers.is(testConverter));
    assertThat(iterator.next(), Matchers.instanceOf(StringMessageConverter.class));
    assertThat(iterator.next(), Matchers.instanceOf(ByteArrayMessageConverter.class));
    assertThat(iterator.next(), Matchers.instanceOf(MappingJackson2MessageConverter.class));
  }
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

        MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
        converter.setContentTypeResolver(resolver);
        converters.add(converter);
      }
    }
    return new CompositeMessageConverter(converters);
  }
View Full Code Here

    this.brokerTemplate = brokerTemplate;

    Collection<MessageConverter> converters = new ArrayList<MessageConverter>();
    converters.add(new StringMessageConverter());
    converters.add(new ByteArrayMessageConverter());
    this.messageConverter = new CompositeMessageConverter(converters);
  }
View Full Code Here

    try {
      MimeType contentType = resolveContentType(contentTypeString, module);

      AbstractMessageChannel channel = getChannel(module, isInput);

      CompositeMessageConverter converters = null;
      try {
        converters = converterFactory.newInstance(contentType);
      }
      catch (ConversionException e) {
        throw new ModuleConfigurationException(e.getMessage() +
View Full Code Here

TOP

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

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.