Java Code Examples for org.apache.qpid.proton.amqp.messaging.Properties#setGroupSequence()

The following examples show how to use org.apache.qpid.proton.amqp.messaging.Properties#setGroupSequence() . 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: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetProperties() {
   MessageImpl protonMessage = createProtonMessage();
   AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null);

   Properties decoded = message.getProperties();
   assertNotSame(decoded, protonMessage.getProperties());
   assertPropertiesEquals(protonMessage.getProperties(), decoded);

   // Update the values
   decoded.setAbsoluteExpiryTime(new Date(System.currentTimeMillis()));
   decoded.setGroupSequence(UnsignedInteger.valueOf(255));
   decoded.setSubject(UUID.randomUUID().toString());

   // Check that the message is unaffected.
   assertPropertiesNotEquals(protonMessage.getProperties(), decoded);
}
 
Example 2
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetGroupSequenceOnReceivedMessageWithGroupSequenceJustAboveSignedIntRange() {
    Message message = Proton.message();

    Properties props = new Properties();
    props.setGroupSequence(UnsignedInteger.valueOf(1L + Integer.MAX_VALUE));
    message.setProperties(props);

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

    // The unsigned int value >= 2^31 will be represented as a negative, and so should begin from minimum signed int value
    assertEquals("GroupSequence not as expected", Integer.MIN_VALUE, amqpMessageFacade.getGroupSequence());
}
 
Example 3
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetGroupSequenceOnReceivedMessageWithGroupSequenceMaxUnsignedIntValue() {
    Message message = Proton.message();

    Properties props = new Properties();
    props.setGroupSequence(UnsignedInteger.valueOf(MAX_UINT));
    message.setProperties(props);

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

    // The unsigned int value 2^32-1 will be represented as a negative, and should be the largest such value, -1
    assertEquals("GroupSequence not as expected", -1, amqpMessageFacade.getGroupSequence());
}
 
Example 4
Source File: FastPathPropertiesType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public Properties readValue() {
    DecoderImpl decoder = getDecoder();
    ReadableBuffer buffer = decoder.getBuffer();
    byte typeCode = decoder.getBuffer().get();

    @SuppressWarnings("unused")
    int size = 0;
    int count = 0;

    switch (typeCode) {
        case EncodingCodes.LIST0:
            break;
        case EncodingCodes.LIST8:
            size = buffer.get() & 0xff;
            count = buffer.get() & 0xff;
            break;
        case EncodingCodes.LIST32:
            size = buffer.getInt();
            count = buffer.getInt();
            break;
        default:
            throw new DecodeException("Incorrect type found in Properties encoding: " + typeCode);
    }

    Properties properties = new Properties();

    for (int index = 0; index < count; ++index) {
        switch (index) {
            case 0:
                properties.setMessageId(decoder.readObject());
                break;
            case 1:
                properties.setUserId(decoder.readBinary(null));
                break;
            case 2:
                properties.setTo(decoder.readString(null));
                break;
            case 3:
                properties.setSubject(decoder.readString(null));
                break;
            case 4:
                properties.setReplyTo(decoder.readString(null));
                break;
            case 5:
                properties.setCorrelationId(decoder.readObject());
                break;
            case 6:
                properties.setContentType(decoder.readSymbol(null));
                break;
            case 7:
                properties.setContentEncoding(decoder.readSymbol(null));
                break;
            case 8:
                properties.setAbsoluteExpiryTime(decoder.readTimestamp(null));
                break;
            case 9:
                properties.setCreationTime(decoder.readTimestamp(null));
                break;
            case 10:
                properties.setGroupId(decoder.readString(null));
                break;
            case 11:
                properties.setGroupSequence(decoder.readUnsignedInteger(null));
                break;
            case 12:
                properties.setReplyToGroupId(decoder.readString(null));
                break;
            default:
                throw new IllegalStateException("To many entries in Properties encoding");
        }
    }

    return properties;
}
 
Example 5
Source File: PropertiesType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public Properties newInstance(Object described)
{
    List l = (List) described;

    Properties o = new Properties();


    switch(13 - l.size())
    {

        case 0:
            o.setReplyToGroupId( (String) l.get( 12 ) );
        case 1:
            o.setGroupSequence( (UnsignedInteger) l.get( 11 ) );
        case 2:
            o.setGroupId( (String) l.get( 10 ) );
        case 3:
            o.setCreationTime( (Date) l.get( 9 ) );
        case 4:
            o.setAbsoluteExpiryTime( (Date) l.get( 8 ) );
        case 5:
            o.setContentEncoding( (Symbol) l.get( 7 ) );
        case 6:
            o.setContentType( (Symbol) l.get( 6 ) );
        case 7:
            o.setCorrelationId( (Object) l.get( 5 ) );
        case 8:
            o.setReplyTo( (String) l.get( 4 ) );
        case 9:
            o.setSubject( (String) l.get( 3 ) );
        case 10:
            o.setTo( (String) l.get( 2 ) );
        case 11:
            o.setUserId( (Binary) l.get( 1 ) );
        case 12:
            o.setMessageId( (Object) l.get( 0 ) );
    }


    return o;
}
 
Example 6
Source File: PropertiesCodecTest.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
private void doTestDecodePropertiesSeries(int size) throws IOException {
    Properties properties = new Properties();

    Date timeNow = new Date(System.currentTimeMillis());

    properties.setMessageId("ID:Message-1:1:1:0");
    properties.setUserId(new Binary(new byte[1]));
    properties.setTo("queue:work");
    properties.setSubject("help");
    properties.setReplyTo("queue:temp:me");
    properties.setContentEncoding(Symbol.valueOf("text/UTF-8"));
    properties.setContentType(Symbol.valueOf("text"));
    properties.setCorrelationId("correlation-id");
    properties.setAbsoluteExpiryTime(timeNow);
    properties.setCreationTime(timeNow);
    properties.setGroupId("group-1");
    properties.setGroupSequence(UnsignedInteger.valueOf(1));
    properties.setReplyToGroupId("group-1");

    for (int i = 0; i < size; ++i) {
        encoder.writeObject(properties);
    }

    buffer.clear();

    for (int i = 0; i < size; ++i) {
        final Object result = decoder.readObject();

        assertNotNull(result);
        assertTrue(result instanceof Properties);

        Properties decoded = (Properties) result;

        assertNotNull(decoded.getAbsoluteExpiryTime());
        assertEquals(timeNow, decoded.getAbsoluteExpiryTime());
        assertEquals(Symbol.valueOf("text/UTF-8"), decoded.getContentEncoding());
        assertEquals(Symbol.valueOf("text"), decoded.getContentType());
        assertEquals("correlation-id", decoded.getCorrelationId());
        assertEquals(timeNow, decoded.getCreationTime());
        assertEquals("group-1", decoded.getGroupId());
        assertEquals(UnsignedInteger.valueOf(1), decoded.getGroupSequence());
        assertEquals("ID:Message-1:1:1:0", decoded.getMessageId());
        assertEquals("queue:temp:me", decoded.getReplyTo());
        assertEquals("group-1", decoded.getReplyToGroupId());
        assertEquals("help", decoded.getSubject());
        assertEquals("queue:work", decoded.getTo());
        assertTrue(decoded.getUserId() instanceof Binary);
    }
}