Package org.springframework.jms.support.converter

Examples of org.springframework.jms.support.converter.SimpleMessageConverter


   * @see #setMessageConverter
   * @see org.springframework.jms.support.destination.DynamicDestinationResolver
   * @see org.springframework.jms.support.converter.SimpleMessageConverter
   */
  protected void initDefaultStrategies() {
    setMessageConverter(new SimpleMessageConverter());
  }
View Full Code Here


    given(session.createMapMessage()).willReturn(message);

    final Map<Integer, String> content = new HashMap<Integer, String>(1);
    content.put(1, "value1");

    final SimpleMessageConverter converter = new SimpleMessageConverter();
    try {
      converter.toMessage(content, session);
      fail("expected MessageConversionException");
    } catch (MessageConversionException ex) { /* expected */ }
  }
View Full Code Here

    given(session.createMapMessage()).willReturn(message);

    final Map<Object, String> content = new HashMap<Object, String>(1);
    content.put(null, "value1");

    final SimpleMessageConverter converter = new SimpleMessageConverter();
    try {
      converter.toMessage(content, session);
      fail("expected MessageConversionException");
    } catch (MessageConversionException ex) { /* expected */ }
  }
View Full Code Here

  @Test
  public void testConverter() throws Exception {
    JmsTemplate template = createTemplate();
    template.setConnectionFactory(connectionFactory);
    template.setMessageConverter(new SimpleMessageConverter());
    String s = "Hello world";

    MessageProducer messageProducer = mock(MessageProducer.class);
    TextMessage textMessage = mock(TextMessage.class);
View Full Code Here

  }

  protected void doTestJmsException(JMSException original, Class<? extends JmsException> thrownExceptionClass) throws Exception {
    JmsTemplate template = createTemplate();
    template.setConnectionFactory(connectionFactory);
    template.setMessageConverter(new SimpleMessageConverter());
    String s = "Hello world";

    MessageProducer messageProducer = mock(MessageProducer.class);
    TextMessage textMessage = mock(TextMessage.class);
View Full Code Here

    messagingTemplate.convertAndSend("my Payload");
  }

  @Test
  public void convertAndSendCustomJmsMessageConverter() throws JMSException {
    messagingTemplate.setJmsMessageConverter(new SimpleMessageConverter() {
      @Override
      public javax.jms.Message toMessage(Object object, Session session)
          throws JMSException, org.springframework.jms.support.converter.MessageConversionException {
        throw new org.springframework.jms.support.converter.MessageConversionException("Test exception");
      }
View Full Code Here

    String content = "test";

    given(session.createTextMessage(content)).willReturn(message);
    given(message.getText()).willReturn(content);

    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message msg = converter.toMessage(content, session);
    assertEquals(content, converter.fromMessage(msg));
  }
View Full Code Here

      public Integer answer(InvocationOnMock invocation) throws Throwable {
        return byteArrayInputStream.read((byte[]) invocation.getArguments()[0]);
      }
    });

    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message msg = converter.toMessage(content, session);
    assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);

    verify(message).writeBytes(content);
  }
View Full Code Here

    given(session.createMapMessage()).willReturn(message);
    given(message.getMapNames()).willReturn(Collections.enumeration(content.keySet()));
    given(message.getObject("key1")).willReturn("value1");
    given(message.getObject("key2")).willReturn("value2");

    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message msg = converter.toMessage(content, session);
    assertEquals(content, converter.fromMessage(msg));

    verify(message).setObject("key1", "value1");
    verify(message).setObject("key2", "value2");
  }
View Full Code Here

    Integer content = new Integer(5);

    given(session.createObjectMessage(content)).willReturn(message);
    given(message.getObject()).willReturn(content);

    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message msg = converter.toMessage(content, session);
    assertEquals(content, converter.fromMessage(msg));
  }
View Full Code Here

TOP

Related Classes of org.springframework.jms.support.converter.SimpleMessageConverter

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.