Search in sources :

Example 46 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class SaslTest method saslSuccessfulAuthenticationWithPipelinedFrames.

@Test
@SpecificationTest(section = "2.4.2", description = "For applications that use many short-lived connections," + " it MAY be desirable to pipeline the connection negotiation process." + " A peer MAY do this by starting to send subsequent frames before receiving" + " the partner’s connection header or open frame")
public void saslSuccessfulAuthenticationWithPipelinedFrames() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin(), BrokerAdmin.PortType.AMQP).connect()) {
        final Binary initialResponse = new Binary(String.format("\0%s\0%s", _username, _password).getBytes(StandardCharsets.US_ASCII));
        final Interaction interaction = transport.newInteraction();
        interaction.protocolHeader(SASL_AMQP_HEADER_BYTES).negotiateProtocol().saslMechanism(PLAIN).saslInitialResponse(initialResponse).saslInit().protocolHeader(AMQP_HEADER_BYTES).negotiateProtocol().openContainerId("testContainerId").open();
        final byte[] saslHeaderResponse = interaction.consumeResponse().getLatestResponse(byte[].class);
        assertThat(saslHeaderResponse, is(equalTo(SASL_AMQP_HEADER_BYTES)));
        SaslMechanisms saslMechanismsResponse = interaction.consumeResponse().getLatestResponse(SaslMechanisms.class);
        assumeThat(Arrays.asList(saslMechanismsResponse.getSaslServerMechanisms()), hasItem(PLAIN));
        SaslOutcome saslOutcome = interaction.consumeResponse().getLatestResponse(SaslOutcome.class);
        assertThat(saslOutcome.getCode(), equalTo(SaslCode.OK));
        final byte[] headerResponse = interaction.consumeResponse().getLatestResponse(byte[].class);
        assertThat(headerResponse, is(equalTo(AMQP_HEADER_BYTES)));
        interaction.consumeResponse().getLatestResponse(Open.class);
        interaction.doCloseConnection();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) SaslOutcome(org.apache.qpid.server.protocol.v1_0.type.security.SaslOutcome) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) SaslMechanisms(org.apache.qpid.server.protocol.v1_0.type.security.SaslMechanisms) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 47 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testMessageIdUnsignedLongConversion.

@Test
public void testMessageIdUnsignedLongConversion() {
    final UnsignedLong messageId = UnsignedLong.valueOf(-1L);
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getMessageId()).thenReturn(messageId.toString());
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedMessageId = MessageConverter_from_1_0.getMessageId(convertedMessage);
    assertEquals("Unexpected messageId", messageId, convertedMessageId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Test(org.junit.Test)

Example 48 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testUserIdConversion.

@Test
public void testUserIdConversion() {
    final String userId = "testUserId";
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getUserId()).thenReturn(userId);
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Binary convertedUserId = MessageConverter_from_1_0.getUserId(convertedMessage);
    assertTrue("Unexpected userId", Arrays.equals(userId.getBytes(UTF_8), convertedUserId.getArray()));
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Test(org.junit.Test)

Example 49 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testExpirationConversion.

@Test
public void testExpirationConversion() throws InterruptedException {
    long ttl = 10000;
    long expiryTime = System.currentTimeMillis() + ttl;
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getExpiration()).thenReturn(expiryTime);
    InternalMessage originalMessage = createTestMessage(header);
    Thread.sleep(1L);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Long convertedTtl = MessageConverter_from_1_0.getTtl(convertedMessage);
    assertEquals("Unexpected TTL", expiryTime - originalMessage.getArrivalTime(), convertedTtl.longValue());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Test(org.junit.Test)

Example 50 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testCorrelationIdUnsignedLongConversion.

@Test
public void testCorrelationIdUnsignedLongConversion() {
    final UnsignedLong correlationId = UnsignedLong.valueOf(-1L);
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getCorrelationId()).thenReturn(correlationId.toString());
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedCorrelationId = MessageConverter_from_1_0.getCorrelationId(convertedMessage);
    assertEquals("Unexpected correlationId", correlationId, convertedCorrelationId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Test(org.junit.Test)

Aggregations

Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)45 Test (org.junit.Test)44 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)32 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)19 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)18 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)17 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)16 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)14 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)13 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)13 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)12 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)11 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)11 Date (java.util.Date)9 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)8 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 Footer (org.apache.qpid.server.protocol.v1_0.type.messaging.Footer)7 ArrayList (java.util.ArrayList)6 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)6