use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class BDBMessageStoreTest method createContentHeaderProperties_0_8.
private BasicContentHeaderProperties createContentHeaderProperties_0_8() {
BasicContentHeaderProperties props = new BasicContentHeaderProperties();
props.setDeliveryMode(Integer.valueOf(BasicContentHeaderProperties.PERSISTENT).byteValue());
props.setContentType("text/html");
props.getHeaders().setString("Test", "MST");
return props;
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class LargeHeadersTest method headersFillContentHeaderFrame.
@Test
public /**
* Tests boundary case where headers exactly fill the content header frame
*/
void headersFillContentHeaderFrame() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
String consumerTag = "A";
ConnectionTuneBody connTune = interaction.negotiateProtocol().consumeResponse(ConnectionStartBody.class).connection().startOkMechanism("ANONYMOUS").startOk().consumeResponse(ConnectionTuneBody.class).getLatestResponse(ConnectionTuneBody.class);
final String headerName = "test";
final int headerValueSize = (int) (connTune.getFrameMax() - calculateContentHeaderFramingOverhead(headerName));
final String headerValue = generateLongString(headerValueSize);
final Map<String, Object> messageHeaders = Collections.singletonMap(headerName, headerValue);
interaction.connection().tuneOk().connection().open().consumeResponse(ConnectionOpenOkBody.class).channel().open().consumeResponse(ChannelOpenOkBody.class).basic().qosPrefetchCount(1).qos().consumeResponse(BasicQosOkBody.class).basic().consumeConsumerTag(consumerTag).consumeQueue(BrokerAdmin.TEST_QUEUE_NAME).consumeNoAck(true).consume().consumeResponse(BasicConsumeOkBody.class).channel().flow(true).consumeResponse(ChannelFlowOkBody.class).basic().contentHeaderPropertiesHeaders(messageHeaders).publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).publishMessage().consumeResponse(BasicDeliverBody.class);
BasicDeliverBody delivery = interaction.getLatestResponse(BasicDeliverBody.class);
assertThat(delivery.getConsumerTag(), is(equalTo(AMQShortString.valueOf(consumerTag))));
ContentHeaderBody header = interaction.consumeResponse(ContentHeaderBody.class).getLatestResponse(ContentHeaderBody.class);
assertThat(header.getBodySize(), is(equalTo(0L)));
BasicContentHeaderProperties properties = header.getProperties();
Map<String, Object> receivedHeaders = new HashMap<>(FieldTable.convertToMap(properties.getHeaders()));
assertThat(receivedHeaders, is(equalTo(new HashMap<>(messageHeaders))));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_v0_8 method convertMetaData.
private MessageMetaData convertMetaData(final InternalMessage serverMsg, final NamedAddressSpace addressSpace, final String bodyMimeType, final int size) {
MessagePublishInfo publishInfo = createMessagePublishInfo(serverMsg, addressSpace);
final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
props.setAppId(serverMsg.getMessageHeader().getAppId());
props.setContentType(bodyMimeType);
props.setCorrelationId(convertToShortStringForProperty("correlation-id", serverMsg.getMessageHeader().getCorrelationId()));
props.setDeliveryMode(serverMsg.isPersistent() ? BasicContentHeaderProperties.PERSISTENT : BasicContentHeaderProperties.NON_PERSISTENT);
props.setExpiration(serverMsg.getExpiration());
props.setMessageId(convertToOptionalAMQPShortString(serverMsg.getMessageHeader().getMessageId()));
props.setPriority(serverMsg.getMessageHeader().getPriority());
props.setReplyTo(convertToShortStringForProperty("reply-to", getReplyTo(serverMsg, addressSpace)));
props.setTimestamp(serverMsg.getMessageHeader().getTimestamp());
props.setUserId(convertToOptionalAMQPShortString(serverMsg.getMessageHeader().getUserId()));
props.setEncoding(convertToShortStringForProperty("encoding", serverMsg.getMessageHeader().getEncoding()));
Map<String, Object> headerProps = new LinkedHashMap<String, Object>();
for (String headerName : serverMsg.getMessageHeader().getHeaderNames()) {
headerProps.put(headerName, serverMsg.getMessageHeader().getHeader(headerName));
}
try {
props.setHeaders(FieldTable.convertToFieldTable(headerProps));
} catch (IllegalArgumentException | AMQPInvalidClassException e) {
throw new MessageConversionException("Could not convert message from internal to 0-8 because headers conversion failed.", e);
}
final ContentHeaderBody chb = new ContentHeaderBody(props);
chb.setBodySize(size);
return new MessageMetaData(publishInfo, chb, serverMsg.getArrivalTime());
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_v0_8_to_InternalTest method testReplyToNonBurl.
public void testReplyToNonBurl() {
final String replyTo = "test/routing";
BasicContentHeaderProperties header = new BasicContentHeaderProperties();
header.setReplyTo(replyTo);
final AMQMessage originalMessage = createTestMessage(header);
InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected replyTo", replyTo, convertedMessage.getMessageHeader().getReplyTo());
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class AMQChannelTest method testOversizedMessageClosesChannel.
public void testOversizedMessageClosesChannel() throws Exception {
when(_virtualHost.getDefaultDestination()).thenReturn(mock(MessageDestination.class));
long maximumMessageSize = 1024l;
when(_amqConnection.getMaxMessageSize()).thenReturn(maximumMessageSize);
AMQChannel channel = new AMQChannel(_amqConnection, 1, _virtualHost.getMessageStore());
BasicContentHeaderProperties properties = new BasicContentHeaderProperties();
channel.receiveBasicPublish(AMQShortString.EMPTY_STRING, AMQShortString.EMPTY_STRING, false, false);
channel.receiveMessageHeader(properties, maximumMessageSize + 1);
verify(_amqConnection).closeChannelAndWriteFrame(eq(channel), eq(ErrorCodes.MESSAGE_TOO_LARGE), eq("Message size of 1025 greater than allowed maximum of 1024"));
}
Aggregations