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();
}
}
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);
}
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()));
}
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());
}
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);
}
Aggregations