org.apache.qpid.proton.amqp.messaging.Header Java Examples

The following examples show how to use org.apache.qpid.proton.amqp.messaging.Header. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetTtlSynthesizedExpirationOnReceivedMessageWithTtlButNoAbsoluteExpiration() throws JMSException {
    Long ttl = 123L;

    Message message = Proton.message();
    Header header = new Header();
    header.setTtl(UnsignedInteger.valueOf(ttl));
    message.setHeader(header);

    long start = System.currentTimeMillis();
    AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);
    long end = System.currentTimeMillis();

    long expiration = amqpMessageFacade.getExpiration();

    assertTrue("Should have sythesized expiration based on current time + ttl", start + ttl <= expiration);
    assertTrue("Should have sythesized expiration based on current time + ttl", expiration <= end + ttl);

    long expiration2 = amqpMessageFacade.getExpiration();
    assertEquals("Second retrieval should return same result", expiration, expiration2);

    amqpMessageFacade = amqpMessageFacade.copy();
    long expiration3 = amqpMessageFacade.getExpiration();
    assertEquals("Thrid retrieval from copy should return same result", expiration, expiration3);
}
 
Example #2
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
/**
 * Receive message which has a header section with a priority value. Ensure the headers
 * underlying field value is cleared when the priority is set to the default priority of 4.
 */
@Test
public void testSetPriorityToDefaultOnReceivedMessageWithPriorityClearsPriorityField() {
    byte priority = 11;

    Message message = Proton.message();
    Header header = new Header();
    message.setHeader(header);
    header.setPriority(UnsignedByte.valueOf(priority));

    AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);
    amqpMessageFacade.setPriority(Message.DEFAULT_PRIORITY);

    //check the expected value is still returned
    assertEquals("expected priority value not returned", Message.DEFAULT_PRIORITY, amqpMessageFacade.getPriority());

    //check the underlying header field was actually cleared rather than set to Message.DEFAULT_PRIORITY
    assertNull("underlying header priority field was not cleared", amqpMessageFacade.getHeader());
}
 
Example #3
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetRedeliveredWhenAlreadyRedeliveredDoesNotChangeDeliveryCount() {
    Message message = Proton.message();
    Header header = new Header();
    header.setDeliveryCount(new UnsignedInteger(1));
    message.setHeader(header);

    AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);

    // Redelivered state inferred from delivery count
    assertTrue(amqpMessageFacade.isRedelivered());
    assertEquals(1, amqpMessageFacade.getRedeliveryCount());;

    amqpMessageFacade.setRedelivered(true);
    assertTrue(amqpMessageFacade.isRedelivered());
    assertEquals(1, amqpMessageFacade.getRedeliveryCount());;
}
 
Example #4
Source File: AmqpCodecTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testEncodeEmptyHeaderAndDecode() {
    Header empty = new Header();

    ByteBuf encoded = AmqpCodec.encode(empty);
    Header decoded = (Header) AmqpCodec.decode(encoded);

    assertNotNull(decoded);

    AmqpHeader header = new AmqpHeader(decoded);

    assertFalse(header.isDurable());
    assertEquals(4, header.getPriority());
    assertEquals(0, header.getTimeToLive());
    assertFalse(header.isFirstAcquirer());
    assertEquals(0, header.getDeliveryCount());
}
 
Example #5
Source File: AmqpHeaderTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetHeaderWithFirstAcquirerHeader() {
    AmqpHeader header = new AmqpHeader();

    Header protonHeader = new Header();
    protonHeader.setFirstAcquirer(true);

    header.setHeader(protonHeader);

    assertFalse(header.isDefault());
    assertFalse(header.nonDefaultDurable());
    assertFalse(header.nonDefaultPriority());
    assertFalse(header.nonDefaultTimeToLive());
    assertTrue(header.nonDefaultFirstAcquirer());
    assertFalse(header.nonDefaultDeliveryCount());

    assertEquals(false, header.isDurable());
    assertEquals(true, header.isFirstAcquirer());
    assertEquals(4, header.getPriority());
    assertEquals(0, header.getTimeToLive());
    assertEquals(0, header.getDeliveryCount());
}
 
Example #6
Source File: IncomingAmqpMetadata.java    From smallrye-reactive-messaging with Apache License 2.0 6 votes vote down vote up
public IncomingAmqpMetadata(String address, JsonObject properties, String contentType,
        String contentEncoding, String correlationId, long creationTime, int deliveryCount, long expirationTime,
        String groupId, long groupSequence, String id, boolean durable, boolean firstAcquirer, int priority,
        String subject, long ttl, Header header) {
    this.address = address;
    this.properties = properties;
    this.contentType = contentType;
    this.contentEncoding = contentEncoding;
    this.correlationId = correlationId;
    this.creationTime = creationTime;
    this.deliveryCount = deliveryCount;
    this.expirationTime = expirationTime;
    this.groupId = groupId;
    this.groupSequence = groupSequence;
    this.id = id;
    this.durable = durable;
    this.firstAcquirer = firstAcquirer;
    this.priority = priority;
    this.subject = subject;
    this.ttl = ttl;
    this.header = header;
}
 
Example #7
Source File: AmqpHeaderTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetHeaderWithDurableHeader() {
    AmqpHeader header = new AmqpHeader();

    Header protonHeader = new Header();
    protonHeader.setDurable(true);

    header.setHeader(protonHeader);

    assertFalse(header.isDefault());
    assertTrue(header.nonDefaultDurable());
    assertFalse(header.nonDefaultPriority());
    assertFalse(header.nonDefaultTimeToLive());
    assertFalse(header.nonDefaultFirstAcquirer());
    assertFalse(header.nonDefaultDeliveryCount());

    assertEquals(true, header.isDurable());
    assertEquals(false, header.isFirstAcquirer());
    assertEquals(4, header.getPriority());
    assertEquals(0, header.getTimeToLive());
    assertEquals(0, header.getDeliveryCount());
}
 
Example #8
Source File: AmqpHeaderTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateFromHeader() {
    Header protonHeader = new Header();
    protonHeader.setPriority(UnsignedByte.valueOf((byte) 9));
    protonHeader.setTtl(UnsignedInteger.valueOf(10));
    protonHeader.setDeliveryCount(UnsignedInteger.valueOf(11));
    protonHeader.setDurable(true);
    protonHeader.setFirstAcquirer(true);

    AmqpHeader header = new AmqpHeader(protonHeader);

    assertFalse(header.isDefault());
    assertTrue(header.nonDefaultDurable());
    assertTrue(header.nonDefaultPriority());
    assertTrue(header.nonDefaultTimeToLive());
    assertTrue(header.nonDefaultFirstAcquirer());
    assertTrue(header.nonDefaultDeliveryCount());

    assertEquals(true, header.isDurable());
    assertEquals(true, header.isFirstAcquirer());
    assertEquals(9, header.getPriority());
    assertEquals(10, header.getTimeToLive());
    assertEquals(11, header.getDeliveryCount());
}
 
Example #9
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetRedeliveredFalseClearsDeliveryCount() {
    Message message = Proton.message();
    Header header = new Header();
    header.setDeliveryCount(new UnsignedInteger(1));
    message.setHeader(header);

    AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);

    // Redelivered state inferred from delivery count
    assertTrue(amqpMessageFacade.isRedelivered());
    assertEquals(1, amqpMessageFacade.getRedeliveryCount());;

    amqpMessageFacade.setRedelivered(false);
    assertFalse(amqpMessageFacade.isRedelivered());
    assertEquals(0, amqpMessageFacade.getRedeliveryCount());;
}
 
Example #10
Source File: FastPathHeaderType.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
private void writeElement(Header header, int index) {
    switch (index) {
        case 0:
            getEncoder().writeBoolean(header.getDurable());
            break;
        case 1:
            getEncoder().writeUnsignedByte(header.getPriority());
            break;
        case 2:
            getEncoder().writeUnsignedInteger(header.getTtl());
            break;
        case 3:
            getEncoder().writeBoolean(header.getFirstAcquirer());
            break;
        case 4:
            getEncoder().writeUnsignedInteger(header.getDeliveryCount());
            break;
        default:
            throw new IllegalArgumentException("Unknown Header value index: " + index);
    }
}
 
Example #11
Source File: AmqpCodecTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testEncodeHeaderWithAllSetAndDecode() {
    AmqpHeader header = new AmqpHeader();
    header.setDurable(true);
    header.setDeliveryCount(43);
    header.setFirstAcquirer(true);
    header.setPriority(9);
    header.setTimeToLive(32768);

    ByteBuf encoded = AmqpCodec.encode(header.getHeader());
    AmqpHeader decoded = new AmqpHeader((Header) AmqpCodec.decode(encoded));

    assertTrue(decoded.isDurable());
    assertTrue(decoded.isFirstAcquirer());
    assertEquals(43, decoded.getDeliveryCount());
    assertEquals(9, decoded.getPriority());
    assertEquals(32768, decoded.getTimeToLive());
}
 
Example #12
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetDeliveryCountForReceivedMessageWithHeaderWithDeliveryCount() {
    Message message = Proton.message();
    Header header = new Header();
    header.setDeliveryCount(new UnsignedInteger(1));
    message.setHeader(header);

    AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);

    // JMS delivery count starts at one.
    assertEquals("expected delivery count value not found", 2, amqpMessageFacade.getDeliveryCount());

    // Redelivered state inferred from delivery count
    assertTrue(amqpMessageFacade.isRedelivered());
    assertEquals(1, amqpMessageFacade.getRedeliveryCount());;
}
 
Example #13
Source File: HeaderType.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
public Header newInstance(Object described)
{
    List l = (List) described;

    Header o = new Header();


    switch(5 - l.size())
    {

        case 0:
            o.setDeliveryCount( (UnsignedInteger) l.get( 4 ) );
        case 1:
            o.setFirstAcquirer( (Boolean) l.get( 3 ) );
        case 2:
            o.setTtl( (UnsignedInteger) l.get( 2 ) );
        case 3:
            o.setPriority( (UnsignedByte) l.get( 1 ) );
        case 4:
            o.setDurable( (Boolean) l.get( 0 ) );
    }


    return o;
}
 
Example #14
Source File: Benchmark.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
private void benchmarkHeader() throws IOException {
    Header header = new Header();
    header.setDurable(true);
    header.setFirstAcquirer(true);

    resultSet.start();
    for (int i = 0; i < ITERATIONS; i++) {
        outputBuf.byteBuffer().clear();
        encoder.writeObject(header);
    }
    resultSet.encodesComplete();

    CompositeReadableBuffer inputBuf = convertToComposite(outputBuf);
    decoder.setBuffer(inputBuf);

    resultSet.start();
    for (int i = 0; i < ITERATIONS; i++) {
        decoder.readObject();
        inputBuf.flip();
    }
    resultSet.decodesComplete();

    time("Header", resultSet);
}
 
Example #15
Source File: AMQPPersisterTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private MessageImpl createProtonMessage(String address, byte[] content) {
   MessageImpl message = (MessageImpl) Proton.message();

   Header header = new Header();
   header.setDurable(true);
   header.setPriority(UnsignedByte.valueOf((byte) 9));

   Properties properties = new Properties();
   properties.setCreationTime(new Date(System.currentTimeMillis()));
   properties.setTo(address);
   properties.setMessageId(UUID.randomUUID());

   MessageAnnotations annotations = new MessageAnnotations(new LinkedHashMap<>());
   ApplicationProperties applicationProperties = new ApplicationProperties(new LinkedHashMap<>());

   AmqpValue body = new AmqpValue(Arrays.copyOf(content, content.length));

   message.setHeader(header);
   message.setMessageAnnotations(annotations);
   message.setProperties(properties);
   message.setApplicationProperties(applicationProperties);
   message.setBody(body);

   return message;
}
 
Example #16
Source File: AmqpHeaderTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetHeaderWithNull() {
    AmqpHeader header = new AmqpHeader();

    header.setHeader((Header) null);

    assertTrue(header.isDefault());
    assertFalse(header.nonDefaultDurable());
    assertFalse(header.nonDefaultPriority());
    assertFalse(header.nonDefaultTimeToLive());
    assertFalse(header.nonDefaultFirstAcquirer());
    assertFalse(header.nonDefaultDeliveryCount());

    assertEquals(false, header.isDurable());
    assertEquals(false, header.isFirstAcquirer());
    assertEquals(4, header.getPriority());
    assertEquals(0, header.getTimeToLive());
    assertEquals(0, header.getDeliveryCount());
}
 
Example #17
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private boolean isEquals(Header left, Header right) {
   if (left == null && right == null) {
      return true;
   }
   if (!isNullnessEquals(left, right)) {
      return false;
   }

   try {
      assertEquals(left.getDurable(), right.getDurable());
      assertEquals(left.getDeliveryCount(), right.getDeliveryCount());
      assertEquals(left.getFirstAcquirer(), right.getFirstAcquirer());
      assertEquals(left.getPriority(), right.getPriority());
      assertEquals(left.getTtl(), right.getTtl());
   } catch (Throwable e) {
      return false;
   }

   return true;
}
 
Example #18
Source File: AmqpHeaderTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetHeaderWithDeliveryCountHeader() {
    AmqpHeader header = new AmqpHeader();

    Header protonHeader = new Header();
    protonHeader.setDeliveryCount(UnsignedInteger.valueOf(9));

    header.setHeader(protonHeader);

    assertFalse(header.isDefault());
    assertFalse(header.nonDefaultDurable());
    assertFalse(header.nonDefaultPriority());
    assertFalse(header.nonDefaultTimeToLive());
    assertFalse(header.nonDefaultFirstAcquirer());
    assertTrue(header.nonDefaultDeliveryCount());

    assertEquals(false, header.isDurable());
    assertEquals(false, header.isFirstAcquirer());
    assertEquals(4, header.getPriority());
    assertEquals(0, header.getTimeToLive());
    assertEquals(9, header.getDeliveryCount());
}
 
Example #19
Source File: AmqpSendReceiveInterceptorTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private boolean checkMessageProperties(AMQPMessage message, Map<String, Object> expectedProperties) {
   assertNotNull(message);
   assertNotNull(server.getNodeID());

   assertNotNull(message.getConnectionID());
   assertEquals(message.getAddress(), expectedProperties.get(ADDRESS));
   assertEquals(message.isDurable(), expectedProperties.get(DURABLE));

   Properties props = message.getProperties();
   assertEquals(props.getCorrelationId(), expectedProperties.get(CORRELATION_ID));
   assertEquals(props.getReplyTo(), expectedProperties.get(REPLY_TO));
   assertEquals(props.getMessageId(), expectedProperties.get(MESSAGE_ID));

   Header header = message.getHeader();
   assertEquals(header.getDurable(), expectedProperties.get(DURABLE));
   assertEquals(header.getTtl().toString(), expectedProperties.get(TIME_TO_LIVE).toString());
   assertEquals(header.getPriority().toString(), expectedProperties.get(PRIORITY).toString());
   return true;
}
 
Example #20
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetHeader() {
   MessageImpl protonMessage = createProtonMessage();
   AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null);

   Header decoded = message.getHeader();
   assertNotSame(decoded, protonMessage.getHeader());
   assertHeaderEquals(protonMessage.getHeader(), decoded);

   // Update the values
   decoded.setDeliveryCount(UnsignedInteger.ZERO);
   decoded.setTtl(UnsignedInteger.valueOf(255));
   decoded.setFirstAcquirer(true);

   // Check that the message is unaffected.
   assertHeaderNotEquals(protonMessage.getHeader(), decoded);
}
 
Example #21
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetExpirationToClearUpdateHeader() {
   final long ttl = 100000;

   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader(new Header());
   protonMessage.setTtl(ttl);
   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);

   assertTrue(decoded.getExpiration() > System.currentTimeMillis());

   decoded.setExpiration(-1);
   decoded.reencode();

   assertEquals(0, decoded.getExpiration());
   assertNull(decoded.getHeader().getTtl());
}
 
Example #22
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonDurableMessageReencodedToDurable() {
   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader(new Header());
   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);
   assertFalse(decoded.isDurable());

   // Underlying message data not updated yet
   assertNull(decoded.getHeader().getDurable());

   decoded.setDurable(true);
   decoded.reencode();
   assertTrue(decoded.isDurable());

   // Underlying message data now updated
   assertTrue(decoded.getHeader().getDurable());
}
 
Example #23
Source File: AmqpHeaderTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetHeaderWithTimeToLiveHeader() {
    AmqpHeader header = new AmqpHeader();

    Header protonHeader = new Header();
    protonHeader.setTtl(UnsignedInteger.valueOf(9));

    header.setHeader(protonHeader);

    assertFalse(header.isDefault());
    assertFalse(header.nonDefaultDurable());
    assertFalse(header.nonDefaultPriority());
    assertTrue(header.nonDefaultTimeToLive());
    assertFalse(header.nonDefaultFirstAcquirer());
    assertFalse(header.nonDefaultDeliveryCount());

    assertEquals(false, header.isDurable());
    assertEquals(false, header.isFirstAcquirer());
    assertEquals(4, header.getPriority());
    assertEquals(9, header.getTimeToLive());
    assertEquals(0, header.getDeliveryCount());
}
 
Example #24
Source File: AmqpHeaderTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetHeaderWithPriorityHeader() {
    AmqpHeader header = new AmqpHeader();

    Header protonHeader = new Header();
    protonHeader.setPriority(UnsignedByte.valueOf((byte) 9));

    header.setHeader(protonHeader);

    assertFalse(header.isDefault());
    assertFalse(header.nonDefaultDurable());
    assertTrue(header.nonDefaultPriority());
    assertFalse(header.nonDefaultTimeToLive());
    assertFalse(header.nonDefaultFirstAcquirer());
    assertFalse(header.nonDefaultDeliveryCount());

    assertEquals(false, header.isDurable());
    assertEquals(false, header.isFirstAcquirer());
    assertEquals(9, header.getPriority());
    assertEquals(0, header.getTimeToLive());
    assertEquals(0, header.getDeliveryCount());
}
 
Example #25
Source File: AmqpCodecTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncodeHeaderWithDurableAndDecode() {
    AmqpHeader header = new AmqpHeader();
    header.setDurable(true);

    ByteBuf encoded = AmqpCodec.encode(header.getHeader());
    AmqpHeader decoded = new AmqpHeader((Header) AmqpCodec.decode(encoded));

    assertTrue(decoded.isDurable());
    assertEquals(4, decoded.getPriority());
    assertEquals(0, decoded.getTimeToLive());
    assertFalse(decoded.isFirstAcquirer());
    assertEquals(0, decoded.getDeliveryCount());
}
 
Example #26
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPriorityFromMessageWithNoPrioritySet() {
   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader(new Header());
   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);

   assertEquals(AMQPStandardMessage.DEFAULT_MESSAGE_PRIORITY, decoded.getPriority());
}
 
Example #27
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testPartialDecodeIgnoresBodyByDefault() {
   Header header = new Header();
   header.setDurable(true);
   header.setPriority(UnsignedByte.valueOf((byte) 6));

   ByteBuf encodedBytes = Unpooled.buffer(1024);
   NettyWritable writable = new NettyWritable(encodedBytes);

   EncoderImpl encoder = TLSEncode.getEncoder();
   encoder.setByteBuffer(writable);
   encoder.writeObject(header);

   // Signal body of AmqpValue but write corrupt underlying type info
   encodedBytes.writeByte(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
   encodedBytes.writeByte(EncodingCodes.SMALLULONG);
   encodedBytes.writeByte(AMQPVALUE_DESCRIPTOR.byteValue());
   // Use bad encoding code on underlying type
   encodedBytes.writeByte(255);

   ReadableBuffer readable = new NettyReadable(encodedBytes);

   AMQPStandardMessage message = null;
   try {
      message = new AMQPStandardMessage(0, readable, null, null);
   } catch (Exception decodeError) {
      fail("Should not have encountered an exception on partial decode: " + decodeError.getMessage());
   }

   assertTrue(message.isDurable());

   try {
      // This will decode the body section if present in order to present it as a Proton Message object
      message.getBody();
      fail("Should have thrown an error when attempting to decode the body which is malformed.");
   } catch (Exception ex) {
      // Expected decode to fail when building full message.
   }
}
 
Example #28
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetExpirationFromMessageAbsoluteExpirationOVerrideTTL() {
   final Date expirationTime = new Date(System.currentTimeMillis());
   final long ttl = 100000;

   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader(new Header());
   protonMessage.setTtl(ttl);
   Properties properties = new Properties();
   properties.setAbsoluteExpiryTime(expirationTime);
   protonMessage.setProperties(properties);
   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);

   assertEquals(expirationTime.getTime(), decoded.getExpiration());
}
 
Example #29
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetTimestampFromMessage() {
   Date timestamp = new Date(System.currentTimeMillis());

   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader(new Header());
   Properties properties = new Properties();
   properties.setCreationTime(timestamp);
   protonMessage.setProperties(properties);
   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);

   assertEquals(timestamp.getTime(), decoded.getTimestamp());
}
 
Example #30
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetExpirationFromMessageWithNoTTLInHeader() {
   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader(new Header());
   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);

   assertEquals(0, decoded.getExpiration());
}