Search in sources :

Example 6 with Header

use of org.apache.qpid.server.protocol.v0_10.transport.Header in project qpid-broker-j by apache.

the class ProtocolTest method versionNegotiation.

@Test
@SpecificationTest(section = "4.3. Version Negotiation", description = "When the client opens a new socket connection to an AMQP server," + " it MUST send a protocol header with the client's preferred protocol version." + "If the requested protocol version is supported, the server MUST send its own protocol" + " header with the requested version to the socket, and then implement the protocol accordingly")
public void versionNegotiation() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        Response<?> response = interaction.negotiateProtocol().consumeResponse().getLatestResponse();
        assertThat(response, is(instanceOf(HeaderResponse.class)));
        assertThat(response.getBody(), is(IsEqual.equalTo(transport.getProtocolHeader())));
        ConnectionStart connectionStart = interaction.consumeResponse().getLatestResponse(ConnectionStart.class);
        assertThat(connectionStart.getMechanisms(), is(notNullValue()));
        assertThat(connectionStart.getMechanisms(), contains(ConnectionInteraction.SASL_MECHANISM_ANONYMOUS));
        assertThat(connectionStart.getLocales(), is(notNullValue()));
        assertThat(connectionStart.getLocales(), contains(DEFAULT_LOCALE));
    }
}
Also used : ConnectionStart(org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 7 with Header

use of org.apache.qpid.server.protocol.v0_10.transport.Header in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testExpirationConversion.

public void testExpirationConversion() {
    long timestamp = System.currentTimeMillis();
    int ttl = 100000;
    final long expiration = timestamp + ttl;
    final DeliveryProperties deliveryProperties = new DeliveryProperties();
    deliveryProperties.setExpiration(expiration);
    MessageTransferMessage message = createTestMessage(deliveryProperties, new MessageProperties(), null, timestamp);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertNull("Unexpected expiration", properties.getAbsoluteExpiryTime());
    Header header = convertedMessage.getHeaderSection().getValue();
    assertEquals("Unexpected TTL", ttl, header.getTtl().intValue());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 8 with Header

use of org.apache.qpid.server.protocol.v0_10.transport.Header in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testGroupIdDoesNotReplaceApplicationPropertiesJMSXGroupID.

public void testGroupIdDoesNotReplaceApplicationPropertiesJMSXGroupID() {
    String testGroupId = "group1";
    Properties properties = new Properties();
    properties.setGroupId(testGroupId);
    final String JMSXGroupID = "group2";
    Map<String, Object> applicationPropertiesMap = Collections.singletonMap("JMSXGroupID", JMSXGroupID);
    ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap);
    Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, applicationProperties, 0, null);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    final Map<String, Object> applicationHeaders = messageProperties.getApplicationHeaders();
    assertEquals("Unexpected group-id", JMSXGroupID, applicationHeaders.get("JMSXGroupID"));
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 9 with Header

use of org.apache.qpid.server.protocol.v0_10.transport.Header in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testSubjectDoesNoReplaceApplicationPropertyQpidSubject.

public void testSubjectDoesNoReplaceApplicationPropertyQpidSubject() {
    final String subject = "testSubject";
    Properties properties = new Properties();
    properties.setSubject(subject);
    final String qpidSubject = "testSubject2";
    Map<String, Object> applicationPropertiesMap = Collections.singletonMap("qpid.subject", qpidSubject);
    ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap);
    Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, applicationProperties, 0, null);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    final Map<String, Object> headers = messageProperties.getApplicationHeaders();
    assertEquals("Unexpected qpid.subject is missing from headers", qpidSubject, headers.get("qpid.subject"));
    assertEquals("Unexpected type", subject, headers.get("x-jms-type"));
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected routing-key", subject, deliveryProperties.getRoutingKey());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 10 with Header

use of org.apache.qpid.server.protocol.v0_10.transport.Header in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testCreationTimeConversion.

public void testCreationTimeConversion() {
    final long timestamp = System.currentTimeMillis() - 10000;
    final long arrivalTime = timestamp + 1;
    Properties properties = new Properties();
    properties.setCreationTime(new Date(timestamp));
    Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, new ApplicationProperties(Collections.emptyMap()), arrivalTime, null);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected timestamp", timestamp, deliveryProperties.getTimestamp());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Date(java.util.Date)

Aggregations

DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)28 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)22 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)19 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)19 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)17 Header (org.apache.qpid.server.protocol.v0_10.transport.Header)12 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)10 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)8 Struct (org.apache.qpid.server.protocol.v0_10.transport.Struct)8 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)8 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)8 Matchers.anyString (org.mockito.Matchers.anyString)8 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)7 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)6 ProtocolHeader (org.apache.qpid.server.protocol.v0_10.transport.ProtocolHeader)6 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)6 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)5 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)5 Date (java.util.Date)4 MessageMetaData_0_10 (org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10)4