use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_0_8Test method testReplyToConversionWhenResultExceeds255.
public void testReplyToConversionWhenResultExceeds255() {
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setReplyTo(new ReplyTo(generateLongString(255), generateLongString(255)));
MessageTransferMessage message = createTestMessage(messageProperties);
try {
_messageConverter.convert(message, _namedAddressSpace);
fail("expected exception not thrown");
} catch (MessageConversionException e) {
// pass
}
}
use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8 method convertMetaData.
private MessageMetaData convertMetaData(final Message_1_0 serverMsg, final String bodyMimeType, final int size, final NamedAddressSpace addressSpace) {
final MessageMetaData_1_0.MessageHeader_1_0 header = serverMsg.getMessageHeader();
final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
props.setAppId(serverMsg.getMessageHeader().getAppId());
props.setContentType(bodyMimeType);
props.setEncoding(convertToShortStringForProperty("content-encoding", serverMsg.getMessageHeader().getEncoding()));
props.setCorrelationId(getCorrelationIdAsShortString(serverMsg));
props.setDeliveryMode(serverMsg.isPersistent() ? BasicContentHeaderProperties.PERSISTENT : BasicContentHeaderProperties.NON_PERSISTENT);
final Date absoluteExpiryTime = getAbsoluteExpiryTime(serverMsg);
if (absoluteExpiryTime != null) {
props.setExpiration(absoluteExpiryTime.getTime());
} else {
Long ttl = getTtl(serverMsg);
if (ttl != null) {
props.setExpiration(ttl + serverMsg.getArrivalTime());
}
}
props.setMessageId(getMessageIdAsShortString(serverMsg));
props.setPriority(serverMsg.getMessageHeader().getPriority());
props.setReplyTo(getReplyTo(serverMsg, addressSpace));
Date timestamp = getCreationTime(serverMsg);
if (timestamp != null) {
props.setTimestamp(timestamp.getTime());
} else {
props.setTimestamp(serverMsg.getArrivalTime());
}
props.setUserId(getUserIdAsShortString(serverMsg));
Map<String, Object> headerProps = new LinkedHashMap<>();
if (header.getSubject() != null) {
headerProps.put("qpid.subject", header.getSubject());
props.setType(convertToShortStringForProperty("subject", header.getSubject()));
}
String groupId = getGroupId(serverMsg);
if (groupId != null) {
headerProps.put("JMSXGroupID", groupId);
}
UnsignedInteger groupSequence = getGroupSequence(serverMsg);
if (groupSequence != null) {
headerProps.put("JMSXGroupSeq", groupSequence.intValue());
}
for (String headerName : serverMsg.getMessageHeader().getHeaderNames()) {
headerProps.put(headerName, convertValue(serverMsg.getMessageHeader().getHeader(headerName)));
}
final FieldTable headers;
try {
headers = FieldTable.convertToFieldTable(headerProps);
} catch (IllegalArgumentException e) {
throw new MessageConversionException("Could not convert message from 1.0 to 0-8 because conversion of 'application-properties' failed.", e);
}
props.setHeaders(headers);
final ContentHeaderBody chb = new ContentHeaderBody(props);
chb.setBodySize(size);
MessagePublishInfo publishInfo = createMessagePublishInfo(header, addressSpace);
return new MessageMetaData(publishInfo, chb, serverMsg.getArrivalTime());
}
use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.
the class AbstractConsumerTargetTest method testConversionExceptionPolicyWhenOwningResourceIsNotMessageSource.
public void testConversionExceptionPolicyWhenOwningResourceIsNotMessageSource() throws Exception {
final TransactionLogResource owningResource = mock(TransactionLogResource.class);
when(_messageInstance.getOwningResource()).thenReturn(owningResource);
try {
_consumerTarget.sendNextMessage();
fail("exception not thrown");
} catch (ConnectionScopedRuntimeException e) {
assertTrue(String.format("ConnectionScopedRuntimeException has unexpected cause '%s'", e.getCause().getClass().getSimpleName()), e.getCause() instanceof MessageConversionException);
}
assertTrue("message credit was not restored", _consumerTarget.isCreditRestored());
verify(_messageInstance, never()).routeToAlternate(any(Action.class), any(ServerTransaction.class));
}
use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testToConversionWhenRoutingKeyLengthExceeds255.
public void testToConversionWhenRoutingKeyLengthExceeds255() throws Exception {
final String testExchange = "testExchange";
final String testRoutingKey = generateLongString();
String to = testExchange + "/" + testRoutingKey;
InternalMessage message = createTestMessage(to);
try {
_messageConverter.convert(message, _addressSpace);
fail("Exception is not thrown");
} catch (MessageConversionException e) {
// pass
}
}
use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testLongContentEncodingConversion.
public void testLongContentEncodingConversion() throws IOException {
String contentEncoding = generateLongString();
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getEncoding()).thenReturn(contentEncoding);
InternalMessage originalMessage = createTestMessage(header);
try {
_messageConverter.convert(originalMessage, _addressSpace);
fail("Expected exception is not thrown");
} catch (MessageConversionException e) {
// pass
}
}
Aggregations