Package org.springframework.jms

Examples of org.springframework.jms.StubTextMessage


  @Test
  public void validateJmsHeaders() throws JMSException {
    Destination destination = new Destination() {};
    Destination replyTo = new Destination() {};

    StubTextMessage jmsMessage = new StubTextMessage("test");

    jmsMessage.setJMSCorrelationID("correlation-1234");
    jmsMessage.setJMSPriority(9);
    jmsMessage.setJMSDestination(destination);
    jmsMessage.setJMSDeliveryMode(1);
    jmsMessage.setJMSExpiration(1234L);
    jmsMessage.setJMSMessageID("abcd-1234");
    jmsMessage.setJMSPriority(9);
    jmsMessage.setJMSReplyTo(replyTo);
    jmsMessage.setJMSRedelivered(true);
    jmsMessage.setJMSType("type");
    jmsMessage.setJMSTimestamp(4567L);

    Map<String, Object> mappedHeaders = new SimpleJmsHeaderMapper().toHeaders(jmsMessage);
    Message<String> message = MessageBuilder.withPayload("test").copyHeaders(mappedHeaders).build();
    JmsMessageHeaderAccessor headerAccessor = JmsMessageHeaderAccessor.wrap(message);
    assertEquals("correlation-1234", headerAccessor.getCorrelationId());
View Full Code Here


  public void jmsReplyToMappedFromHeader() throws JMSException {
    Destination replyTo = new Destination() {};
    Message<String> message = initBuilder()
        .setHeader(JmsHeaders.REPLY_TO, replyTo).build();

    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    assertNotNull(jmsMessage.getJMSReplyTo());
    assertSame(replyTo, jmsMessage.getJMSReplyTo());
  }
View Full Code Here

  @Test
  public void JmsReplyToIgnoredIfIncorrectType() throws JMSException {
    Message<String> message = initBuilder()
        .setHeader(JmsHeaders.REPLY_TO, "not-a-destination").build();
    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    assertNull(jmsMessage.getJMSReplyTo());
  }
View Full Code Here

  @Test
  public void jmsCorrelationIdMappedFromHeader() throws JMSException {
    String jmsCorrelationId = "ABC-123";
    Message<String> message = initBuilder()
        .setHeader(JmsHeaders.CORRELATION_ID, jmsCorrelationId).build();
    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    assertNotNull(jmsMessage.getJMSCorrelationID());
    assertEquals(jmsCorrelationId, jmsMessage.getJMSCorrelationID());
  }
View Full Code Here

  @Test
  public void jmsCorrelationIdNumberConvertsToString() throws JMSException {
    Message<String> message = initBuilder()
        .setHeader(JmsHeaders.CORRELATION_ID, 123).build();
    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    assertEquals("123", jmsMessage.getJMSCorrelationID());
  }
View Full Code Here

  @Test
  public void jmsCorrelationIdIgnoredIfIncorrectType() throws JMSException {
    Message<String> message = initBuilder()
        .setHeader(JmsHeaders.CORRELATION_ID, new Date()).build();
    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    assertNull(jmsMessage.getJMSCorrelationID());
  }
View Full Code Here

  @Test
  public void jmsTypeMappedFromHeader() throws JMSException {
    String jmsType = "testing";
    Message<String> message = initBuilder()
        .setHeader(JmsHeaders.TYPE, jmsType).build();
    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    assertNotNull(jmsMessage.getJMSType());
    assertEquals(jmsType, jmsMessage.getJMSType());
  }
View Full Code Here

  @Test
  public void jmsTypeIgnoredIfIncorrectType() throws JMSException {
    Message<String> message = initBuilder()
        .setHeader(JmsHeaders.TYPE, 123).build();
    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    assertNull(jmsMessage.getJMSType());
  }
View Full Code Here

        .setHeader(JmsHeaders.MESSAGE_ID, "abc-123")
        .setHeader(JmsHeaders.PRIORITY, 9)
        .setHeader(JmsHeaders.REDELIVERED, true)
        .setHeader(JmsHeaders.TIMESTAMP, System.currentTimeMillis())
        .build();
    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    assertNull(jmsMessage.getJMSDestination());
    assertEquals(DeliveryMode.PERSISTENT, jmsMessage.getJMSDeliveryMode());
    assertEquals(0, jmsMessage.getJMSExpiration());
    assertNull(jmsMessage.getJMSMessageID());
    assertEquals(javax.jms.Message.DEFAULT_PRIORITY, jmsMessage.getJMSPriority());
    assertFalse(jmsMessage.getJMSRedelivered());
    assertEquals(0, jmsMessage.getJMSTimestamp());
  }
View Full Code Here

  @Test
  public void contentTypePropertyMappedFromHeader() throws JMSException {
    Message<String> message = initBuilder()
        .setHeader(MessageHeaders.CONTENT_TYPE, "foo")
        .build();
    javax.jms.Message jmsMessage = new StubTextMessage();
    mapper.fromHeaders(message.getHeaders(), jmsMessage);
    Object value = jmsMessage.getObjectProperty(JmsHeaderMapper.CONTENT_TYPE_PROPERTY);
    assertNotNull(value);
    assertEquals("foo", value);
  }
View Full Code Here

TOP

Related Classes of org.springframework.jms.StubTextMessage

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.