You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/04/01 20:26:16 UTC
[09/30] qpid-broker-j git commit: QPID-8151: [Broker-J] [Unit tests]
Factor out QpidTestCase
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java
index fea4a40..98ecbca 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java
@@ -20,6 +20,10 @@
package org.apache.qpid.server.protocol.converter.v0_10_v1_0;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.AdditionalAnswers.returnsFirstArg;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
@@ -34,6 +38,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import org.junit.Before;
+import org.junit.Test;
+
import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.NamedAddressSpace;
@@ -60,22 +67,22 @@ import org.apache.qpid.server.protocol.v1_0.type.messaging.Header;
import org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations;
import org.apache.qpid.server.protocol.v1_0.type.messaging.Properties;
import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
+public class PropertyConverter_1_0_to_0_10Test extends UnitTestBase
{
private NamedAddressSpace _namedAddressSpace;
private MessageConverter_1_0_to_v0_10 _messageConverter;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
_namedAddressSpace = mock(NamedAddressSpace.class);
when(_namedAddressSpace.getLocalAddress(anyString())).then(returnsFirstArg());
_messageConverter = new MessageConverter_1_0_to_v0_10();
}
+ @Test
public void testContentEncodingConversion()
{
@@ -91,6 +98,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected content encoding", contentEncoding, messageProperties.getContentEncoding());
}
+ @Test
public void testContentEncodingConversionWhenLengthExceeds255()
{
String contentEncoding = generateLongString();
@@ -109,6 +117,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
}
}
+ @Test
public void testApplicationPropertiesConversion()
{
Map<String, Object> properties = new HashMap<>();
@@ -125,6 +134,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected headers", properties, new HashMap<>(headers));
}
+ @Test
public void testSubjectConversion()
{
final String subject = "testSubject";
@@ -144,6 +154,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing-key", subject, deliveryProperties.getRoutingKey());
}
+ @Test
public void testSubjectDoesNoReplaceApplicationPropertyQpidSubject()
{
final String subject = "testSubject";
@@ -173,6 +184,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing-key", subject, deliveryProperties.getRoutingKey());
}
+ @Test
public void testSubjectDoesNoReplaceApplicationPropertyXJMSType()
{
final String subject = "testSubject";
@@ -202,6 +214,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing-key", subject, deliveryProperties.getRoutingKey());
}
+ @Test
public void testSubjectConversionWhenSubjectExceeds255()
{
final String subject = generateLongString();
@@ -220,6 +233,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
}
}
+ @Test
public void testDurableConversion()
{
final Header header = new Header();
@@ -230,9 +244,12 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
- assertEquals("Unexpected deliveryMode", MessageDeliveryMode.PERSISTENT, deliveryProperties.getDeliveryMode());
+ assertEquals("Unexpected deliveryMode",
+ MessageDeliveryMode.PERSISTENT,
+ deliveryProperties.getDeliveryMode());
}
+ @Test
public void testNonDurableConversion()
{
final Header header = new Header();
@@ -244,10 +261,11 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected deliveryMode",
- MessageDeliveryMode.NON_PERSISTENT,
- deliveryProperties.getDeliveryMode());
+ MessageDeliveryMode.NON_PERSISTENT,
+ deliveryProperties.getDeliveryMode());
}
+ @Test
public void testPriorityConversion()
{
final Header header = new Header();
@@ -259,9 +277,10 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
- assertEquals("Unexpected priority", priority, deliveryProperties.getPriority().getValue());
+ assertEquals("Unexpected priority", (long) priority, (long) deliveryProperties.getPriority().getValue());
}
+ @Test
public void testCorrelationIdStringConversion()
{
final String correlationId = "testCorrelationId";
@@ -274,9 +293,11 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertTrue("Unexpected correlationId",
- Arrays.equals(correlationId.getBytes(), messageProperties.getCorrelationId()));
+ Arrays.equals(correlationId.getBytes(), messageProperties.getCorrelationId()));
+
}
+ @Test
public void testCorrelationIdLongStringConversion()
{
final String correlationId = generateLongLongString();
@@ -295,6 +316,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
}
}
+ @Test
public void testCorrelationIdULongConversion()
{
final UnsignedLong correlationId = UnsignedLong.valueOf(-1);
@@ -307,9 +329,10 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertTrue("Unexpected correlationId",
- Arrays.equals(longToBytes(correlationId.longValue()), messageProperties.getCorrelationId()));
+ Arrays.equals(longToBytes(correlationId.longValue()), messageProperties.getCorrelationId()));
}
+ @Test
public void testCorrelationIdUUIDConversion()
{
final UUID correlationId = UUID.randomUUID();
@@ -323,9 +346,11 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
final byte[] expectedBytes =
longToBytes(correlationId.getMostSignificantBits(), correlationId.getLeastSignificantBits());
- assertTrue("Unexpected correlationId", Arrays.equals(expectedBytes, messageProperties.getCorrelationId()));
+ assertTrue("Unexpected correlationId",
+ Arrays.equals(expectedBytes, messageProperties.getCorrelationId()));
}
+ @Test
public void testCorrelationIdBinaryConversion()
{
final String testCorrelationId = "testCorrelationId";
@@ -339,9 +364,10 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertTrue("Unexpected correlationId",
- Arrays.equals(testCorrelationId.getBytes(), messageProperties.getCorrelationId()));
+ Arrays.equals(testCorrelationId.getBytes(), messageProperties.getCorrelationId()));
}
+ @Test
public void testReplyToConversionWhenResultExceeds255()
{
final String replyTo = generateLongString() + "/" + generateLongString();
@@ -360,6 +386,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
}
}
+ @Test
public void testReplyToConversionWhenQueueIsSpecified() throws IOException
{
final String replyTo = "myTestQueue";
@@ -379,6 +406,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", replyTo, convertedReplyTo.getRoutingKey());
}
+ @Test
public void testReplyToConversionWhenExchangeIsSpecified() throws IOException
{
final String replyTo = "myTestExchange";
@@ -398,6 +426,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", "", convertedReplyTo.getRoutingKey());
}
+ @Test
public void testReplyToConversionWhenExchangeAndRoutingKeyAreSpecified() throws IOException
{
final String exchangeName = "testExchnageName";
@@ -419,6 +448,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", routingKey, convertedReplyTo.getRoutingKey());
}
+ @Test
public void testReplyToConversionWhenExchangeAndRoutingKeyAreSpecifiedAndGlobalPrefixIsUsed() throws IOException
{
final String exchangeName = "testExchnageName";
@@ -442,6 +472,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", routingKey, convertedReplyTo.getRoutingKey());
}
+ @Test
public void testReplyToConversionWhenReplyToCannotBeResolved() throws IOException
{
final String replyTo = "direct://amq.direct//test?routingkey='test'";
@@ -458,6 +489,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", replyTo, convertedReplyTo.getRoutingKey());
}
+ @Test
public void testTTLConversion()
{
long ttl = 10000;
@@ -475,6 +507,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected expiration", expectedExpiration, deliveryProperties.getExpiration());
}
+ @Test
public void testAbsoluteExpiryTimeConversion()
{
long ttl = 10000;
@@ -492,6 +525,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected expiration", expiryTime, deliveryProperties.getExpiration());
}
+ @Test
public void testConversionOfTtlTakesPrecedenceOverAbsoluteExpiryTime()
{
long ttl = 10000;
@@ -521,6 +555,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected expiration", arrivalTime + ttl, deliveryProperties.getExpiration());
}
+ @Test
public void testMessageIdStringConversion()
{
final String messageId = "testMessageId";
@@ -533,10 +568,11 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected messageId",
- UUID.nameUUIDFromBytes(messageId.getBytes(UTF_8)),
- messageProperties.getMessageId());
+ UUID.nameUUIDFromBytes(messageId.getBytes(UTF_8)),
+ messageProperties.getMessageId());
}
+ @Test
public void testMessageIdUuidAsStringConversion()
{
final UUID messageId = UUID.randomUUID();
@@ -551,6 +587,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected messageId", messageId, messageProperties.getMessageId());
}
+ @Test
public void testMessageIdUUIDConversion()
{
final UUID messageId = UUID.randomUUID();
@@ -565,6 +602,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected messageId", messageId, messageProperties.getMessageId());
}
+ @Test
public void testMessageIdUnsignedLongConversion()
{
final UnsignedLong messageId = UnsignedLong.valueOf(-1);
@@ -577,10 +615,11 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected messageId",
- UUID.nameUUIDFromBytes(longToBytes(messageId.longValue())),
- messageProperties.getMessageId());
+ UUID.nameUUIDFromBytes(longToBytes(messageId.longValue())),
+ messageProperties.getMessageId());
}
+ @Test
public void testMessageIdBinaryConversion()
{
final String messageId = "testMessageId";
@@ -593,10 +632,11 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected messageId",
- UUID.nameUUIDFromBytes(messageId.getBytes(UTF_8)),
- messageProperties.getMessageId());
+ UUID.nameUUIDFromBytes(messageId.getBytes(UTF_8)),
+ messageProperties.getMessageId());
}
+ @Test
public void testMessageIdByteArrayConversion()
{
final byte[] messageId = "testMessageId".getBytes(UTF_8);
@@ -611,6 +651,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected messageId", UUID.nameUUIDFromBytes(messageId), messageProperties.getMessageId());
}
+ @Test
public void testMessageIdBinaryConversionWhenNonUtf8()
{
final byte[] messageId = new byte[]{(byte) 0xc3, 0x28};
@@ -625,6 +666,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected messageId", UUID.nameUUIDFromBytes(messageId), messageProperties.getMessageId());
}
+ @Test
public void testCreationTimeConversion()
{
final long timestamp = System.currentTimeMillis() - 10000;
@@ -646,6 +688,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected timestamp", timestamp, deliveryProperties.getTimestamp());
}
+ @Test
public void testArrivalTimeConversion()
{
final long arrivalTime = System.currentTimeMillis() - 10000;
@@ -658,6 +701,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected timestamp", arrivalTime, deliveryProperties.getTimestamp());
}
+ @Test
public void testUserIdConversion()
{
final String userId = "test-userId";
@@ -672,6 +716,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertTrue("Unexpected user-id", Arrays.equals(userId.getBytes(UTF_8), messageProperties.getUserId()));
}
+ @Test
public void testUserIdConversionWhenLengthExceeds16Bit()
{
final String userId = generateLongLongString();
@@ -686,6 +731,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertNull("Unexpected user-id", messageProperties.getUserId());
}
+ @Test
public void testGroupIdConversion()
{
String testGroupId = generateLongString();
@@ -701,6 +747,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected group-id", testGroupId, applicationHeaders.get("JMSXGroupID"));
}
+ @Test
public void testGroupIdDoesNotReplaceApplicationPropertiesJMSXGroupID()
{
String testGroupId = "group1";
@@ -726,6 +773,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected group-id", JMSXGroupID, applicationHeaders.get("JMSXGroupID"));
}
+ @Test
public void testGroupSequenceConversion()
{
int testGroupSequence = 1;
@@ -741,6 +789,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected group-id", testGroupSequence, applicationHeaders.get("JMSXGroupSeq"));
}
+ @Test
public void testGroupSequenceDoesNotReplaceApplicationPropertiesJMSXGroupSeq()
{
int testGroupSequence = 1;
@@ -768,6 +817,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
}
+ @Test
public void testApplicationPropertiesConversionWhenKeyLengthExceeds255()
{
Map<String, Object> properties = Collections.singletonMap("testProperty-" + generateLongString(), "testValue");
@@ -785,6 +835,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
}
}
+ @Test
public void testToConversionWhenExchangeAndRoutingKeyIsSpecified()
{
final String testExchange = "testExchange";
@@ -807,6 +858,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", testRoutingKey, deliveryProperties.getRoutingKey());
}
+ @Test
public void testToConversionWhenExchangeIsSpecified()
{
final String testExchange = "testExchange";
@@ -826,6 +878,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", "", deliveryProperties.getRoutingKey());
}
+ @Test
public void testToConversionWhenExchangeIsSpecifiedAndSubjectIsSet()
{
final String testExchange = "testExchange";
@@ -847,6 +900,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", testRoutingKey, deliveryProperties.getRoutingKey());
}
+ @Test
public void testToConversionWhenQueueIsSpecified()
{
final String testQueue = "testQueue";
@@ -866,6 +920,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", testQueue, deliveryProperties.getRoutingKey());
}
+ @Test
public void testToConversionWhenGlobalAddressIsUnknown()
{
final String queueName = "testQueue";
@@ -887,6 +942,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", globalAddress, deliveryProperties.getRoutingKey());
}
+ @Test
public void testToConversionWhenGlobalAddressIsKnown()
{
final String queueName = "testQueue";
@@ -908,6 +964,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", queueName, deliveryProperties.getRoutingKey());
}
+ @Test
public void testToConversionWhenExchangeLengthExceeds255()
{
final String testExchange = generateLongString();
@@ -929,6 +986,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
}
}
+ @Test
public void testToConversionWhenRoutingKeyLengthExceeds255()
{
final String testExchange = "testExchange";
@@ -950,6 +1008,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
}
}
+ @Test
public void testToConversionWhenDestinationIsSpecifiedButDoesNotExists()
{
final String testDestination = "testDestination";
@@ -965,6 +1024,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing key", testDestination, deliveryProperties.getRoutingKey());
}
+ @Test
public void testContentToContentLengthConversion()
{
final byte[] content = new byte[]{0x31, 0x00, 0x10};
@@ -980,7 +1040,7 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
- assertEquals("Unexpected content length", content.length, messageProperties.getContentLength());
+ assertEquals("Unexpected content length", (long) content.length, messageProperties.getContentLength());
}
private Message_1_0 createTestMessage(final Header header)
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_10_to_0_8Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_10_to_0_8Test.java b/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_10_to_0_8Test.java
index 645d102..a25398a 100644
--- a/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_10_to_0_8Test.java
+++ b/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_10_to_0_8Test.java
@@ -21,6 +21,11 @@
package org.apache.qpid.server.protocol.converter.v0_8_v0_10;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -30,6 +35,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import org.junit.Before;
+import org.junit.Test;
+
import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
import org.apache.qpid.server.model.NamedAddressSpace;
import org.apache.qpid.server.protocol.converter.MessageConversionException;
@@ -46,21 +54,21 @@ import org.apache.qpid.server.protocol.v0_8.FieldTable;
import org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties;
import org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo;
import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
+public class PropertyConverter_0_10_to_0_8Test extends UnitTestBase
{
private NamedAddressSpace _namedAddressSpace;
private MessageConverter_0_10_to_0_8 _messageConverter;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
_namedAddressSpace = mock(NamedAddressSpace.class);
_messageConverter = new MessageConverter_0_10_to_0_8();
}
+ @Test
public void testContentTypeConversion()
{
String contentType = "test-content-type";
@@ -75,6 +83,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected content type", contentType, properties.getContentType().toString());
}
+ @Test
public void testContentEncodingConversion()
{
String contentEncoding = "my-test-encoding";
@@ -88,6 +97,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected content encoding", contentEncoding, properties.getEncoding().toString());
}
+ @Test
public void testApplicationHeadersConversion()
{
Map<String, Object> headers = new HashMap<>();
@@ -104,6 +114,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected headers", headers, new HashMap<>(applicationProperties));
}
+ @Test
public void testApplicationHeadersConversionWhenQpidSubjectIsPresent()
{
String testSubject = "testSubject";
@@ -117,9 +128,13 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
Map<String, Object> applicationProperties = FieldTable.convertToMap(properties.getHeaders());
- assertEquals("Unexpected subject in application properties", testSubject, applicationProperties.get("qpid.subject"));
+ assertEquals("Unexpected subject in application properties",
+ testSubject,
+ applicationProperties.get("qpid.subject"));
+
}
+ @Test
public void testPersistentDeliveryModeConversion()
{
MessageDeliveryMode deliveryMode = MessageDeliveryMode.PERSISTENT;
@@ -130,9 +145,13 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
- assertEquals("Unexpected deliveryMode", deliveryMode.getValue(), properties.getDeliveryMode());
+ assertEquals("Unexpected deliveryMode",
+ (long) deliveryMode.getValue(),
+ (long) properties.getDeliveryMode());
+
}
+ @Test
public void testNonPersistentDeliveryModeConversion()
{
MessageDeliveryMode deliveryMode = MessageDeliveryMode.NON_PERSISTENT;
@@ -143,9 +162,12 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
- assertEquals("Unexpected deliveryMode", deliveryMode.getValue(), properties.getDeliveryMode());
+ assertEquals("Unexpected deliveryMode",
+ (long) deliveryMode.getValue(),
+ (long) properties.getDeliveryMode());
}
+ @Test
public void testPriorityConversion()
{
final byte priority = 5;
@@ -156,9 +178,10 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
- assertEquals("Unexpected priority", priority, properties.getPriority());
+ assertEquals("Unexpected priority", (long) priority, (long) properties.getPriority());
}
+ @Test
public void testCorrelationIdConversion()
{
final String correlationId = "testCorrelationId";
@@ -172,6 +195,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected correlationId", correlationId, properties.getCorrelationId().toString());
}
+ @Test
public void testCorrelationIdConversionWhenLengthExceeds255()
{
final String correlationId = generateLongString();
@@ -190,6 +214,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
}
}
+ @Test
public void testCorrelationIdConversionWhenNotString()
{
final byte[] correlationId = new byte[] {(byte) 0xc3, 0x28};
@@ -200,9 +225,12 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
- assertTrue("Unexpected correlationId", Arrays.equals(correlationId, properties.getCorrelationId().getBytes()));
+ assertTrue("Unexpected correlationId",
+ Arrays.equals(correlationId, properties.getCorrelationId().getBytes()));
+
}
+ @Test
public void testReplyToConversionWhenExchangeAndRoutingKeySpecified()
{
final String exchangeName = "amq.direct";
@@ -218,6 +246,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected reply-to", expectedReplyTo, properties.getReplyTo().toString());
}
+ @Test
public void testReplyToConversionWhenExchangeSpecified()
{
final String exchangeName = "amq.direct";
@@ -232,6 +261,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected reply-to", expectedReplyTo, properties.getReplyTo().toString());
}
+ @Test
public void testReplyToConversionWhenRoutingKeySpecified()
{
final String routingKey = "test_routing_key";
@@ -247,6 +277,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected reply-to", expectedReplyTo, properties.getReplyTo().toString());
}
+ @Test
public void testReplyToConversionWhenExchangeIsEmptyStringAndRoutingKeySpecified()
{
final String routingKey = "test_routing_key";
@@ -261,6 +292,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected reply-to", expectedReplyTo, properties.getReplyTo().toString());
}
+ @Test
public void testReplyToConversionWhenExchangeAndRoutingKeyAreNull()
{
final MessageProperties messageProperties = new MessageProperties();
@@ -273,6 +305,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertNull("Unexpected reply-to", properties.getReplyTo());
}
+ @Test
public void testReplyToConversionWhenResultExceeds255()
{
final MessageProperties messageProperties = new MessageProperties();
@@ -290,6 +323,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
}
}
+ @Test
public void testExpirationConversion()
{
long timestamp = System.currentTimeMillis();
@@ -306,6 +340,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected expiration", expiration, properties.getExpiration());
}
+ @Test
public void testTTLConversion()
{
long timestamp = System.currentTimeMillis();
@@ -321,7 +356,8 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected expiration", timestamp + ttl, properties.getExpiration());
}
- public void testMessageIdConversion()
+ @Test
+ public void testMessageIdConversion()
{
UUID messageId = UUID.randomUUID();
final MessageProperties messageProperties = new MessageProperties();
@@ -334,6 +370,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected messageId", "ID:" + messageId, properties.getMessageId().toString());
}
+ @Test
public void testTimestampConversion()
{
final DeliveryProperties deliveryProperties = new DeliveryProperties();
@@ -346,6 +383,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected creation timestamp", timestamp, properties.getTimestamp());
}
+ @Test
public void testArrivalTimeConversion()
{
final long timestamp = System.currentTimeMillis() - 1000;
@@ -356,6 +394,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected creation timestamp", timestamp, properties.getTimestamp());
}
+ @Test
public void testJmsTypeConversion()
{
final String type = "test-type";
@@ -370,9 +409,12 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected subject", type, properties.getType().toString());
Map<String, Object> applicationProperties = FieldTable.convertToMap(properties.getHeaders());
- assertFalse("Unexpected x-jms-type in application properties", applicationProperties.containsKey("x-jms-type"));
+ assertFalse("Unexpected x-jms-type in application properties",
+ applicationProperties.containsKey("x-jms-type"));
+
}
+ @Test
public void testJmsTypeConversionWhenLengthExceeds255()
{
final String type = generateLongString();
@@ -392,6 +434,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
}
}
+ @Test
public void testUserIdConversion()
{
final String userId = "test-userId";
@@ -405,6 +448,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected user-id", userId, properties.getUserId().toString());
}
+ @Test
public void testUserIdConversionExceeds255()
{
final String userId = generateLongString();
@@ -418,6 +462,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertNull("Unexpected user-id", properties.getUserId());
}
+ @Test
public void testUserIdConversionWhenNotUtf8()
{
final byte[] userId = new byte[] {(byte) 0xc3, 0x28};
@@ -431,6 +476,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertTrue("Unexpected user-id", Arrays.equals(userId, properties.getUserId().getBytes()));
}
+ @Test
public void testExchangeConversion()
{
final String testExchange = "testExchange";
@@ -444,6 +490,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected exchange", testExchange, messagePublishInfo.getExchange().toString());
}
+ @Test
public void testRoutingKeyConversion()
{
final String testRoutingKey = "testRoutingKey";
@@ -457,6 +504,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected routing key", testRoutingKey, messagePublishInfo.getRoutingKey().toString());
}
+ @Test
public void testImmediateTrueConversion()
{
final boolean immediate = true;
@@ -471,6 +519,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected immediate flag", immediate, messagePublishInfo.isImmediate());
}
+ @Test
public void testImmediateFalseConversion()
{
final boolean immediate = false;
@@ -485,6 +534,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected immediate flag", immediate, messagePublishInfo.isImmediate());
}
+ @Test
public void testDiscardUnroutableTrueConversion()
{
final boolean discardUnroutable = true;
@@ -495,9 +545,11 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
- assertEquals("Unexpected mandatory flag", !discardUnroutable, messagePublishInfo.isMandatory());
+ final Object expected = !discardUnroutable;
+ assertEquals("Unexpected mandatory flag", expected, messagePublishInfo.isMandatory());
}
+ @Test
public void testDiscardUnroutableFalseConversion()
{
final boolean discardUnroutable = false;
@@ -508,9 +560,11 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
- assertEquals("Unexpected mandatory flag", !discardUnroutable, messagePublishInfo.isMandatory());
+ final Object expected = !discardUnroutable;
+ assertEquals("Unexpected mandatory flag", expected, messagePublishInfo.isMandatory());
}
+ @Test
public void testApplicationIdConversion()
{
String applicationId = "testAppId";
@@ -524,6 +578,7 @@ public class PropertyConverter_0_10_to_0_8Test extends QpidTestCase
assertEquals("Unexpected application id", applicationId, properties.getAppId().toString());
}
+ @Test
public void testApplicationIdConversionWhenLengthExceeds255()
{
String appId = generateLongString();
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_8_to_0_10Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_8_to_0_10Test.java b/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_8_to_0_10Test.java
index 76bc200..3cb8878 100644
--- a/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_8_to_0_10Test.java
+++ b/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/PropertyConverter_0_8_to_0_10Test.java
@@ -21,6 +21,9 @@
package org.apache.qpid.server.protocol.converter.v0_8_v0_10;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -28,6 +31,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import org.junit.Before;
+import org.junit.Test;
+
import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
import org.apache.qpid.server.model.NamedAddressSpace;
import org.apache.qpid.server.protocol.v0_10.MessageTransferMessage;
@@ -42,21 +48,21 @@ import org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperti
import org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody;
import org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo;
import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
+public class PropertyConverter_0_8_to_0_10Test extends UnitTestBase
{
private NamedAddressSpace _namedAddressSpace;
private MessageConverter_0_8_to_0_10 _messageConverter;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
_namedAddressSpace = mock(NamedAddressSpace.class);
_messageConverter = new MessageConverter_0_8_to_0_10();
}
+ @Test
public void testContentTypeConversion()
{
String contentType = "test-content-type";
@@ -71,6 +77,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected content type", contentType, messageProperties.getContentType());
}
+ @Test
public void testContentEncodingConversion()
{
String contentEncoding = "my-test-encoding";
@@ -85,6 +92,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected content encoding", contentEncoding, messageProperties.getContentEncoding());
}
+ @Test
public void testHeaderConversion()
{
Map<String, Object> headers = new HashMap<>();
@@ -102,6 +110,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected applicationProperties", headers, new HashMap<>(applicationProperties));
}
+ @Test
public void testPersistentDeliveryModeConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -112,9 +121,13 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
- assertEquals("Unexpected deliveryMode", MessageDeliveryMode.PERSISTENT, deliveryProperties.getDeliveryMode());
+ assertEquals("Unexpected deliveryMode",
+ MessageDeliveryMode.PERSISTENT,
+ deliveryProperties.getDeliveryMode());
+
}
+ @Test
public void testNonPersistentDeliveryModeConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -125,9 +138,12 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
- assertEquals("Unexpected deliveryMode", MessageDeliveryMode.NON_PERSISTENT, deliveryProperties.getDeliveryMode());
+ assertEquals("Unexpected deliveryMode",
+ MessageDeliveryMode.NON_PERSISTENT,
+ deliveryProperties.getDeliveryMode());
}
+ @Test
public void testPriorityConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -139,9 +155,10 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
- assertEquals("Unexpected priority", priority, deliveryProperties.getPriority().getValue());
+ assertEquals("Unexpected priority", (long) priority, (long) deliveryProperties.getPriority().getValue());
}
+ @Test
public void testCorrelationIdConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -153,9 +170,12 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
- assertEquals("Unexpected correlationId", correlationId, new String(messageProperties.getCorrelationId(), UTF_8));
+ assertEquals("Unexpected correlationId",
+ correlationId,
+ new String(messageProperties.getCorrelationId(), UTF_8));
}
+ @Test
public void testApplicationIdConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -170,6 +190,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected applicationId", applicationId, new String(messageProperties.getAppId(), UTF_8));
}
+ @Test
public void testReplyToConversionWhenBindingURLFormatIsUsed()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -183,9 +204,12 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected reply-to exchange", "amq.direct", messageProperties.getReplyTo().getExchange());
- assertEquals("Unexpected reply-to routing-key", "test_routing_key", messageProperties.getReplyTo().getRoutingKey());
+ assertEquals("Unexpected reply-to routing-key",
+ "test_routing_key",
+ messageProperties.getReplyTo().getRoutingKey());
}
+ @Test
public void testReplyToConversionWhenBindingURLFormatIsUsed2()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -199,9 +223,12 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected reply-to exchange", "amq.direct", messageProperties.getReplyTo().getExchange());
- assertEquals("Unexpected reply-to routing-key", "queue_name", messageProperties.getReplyTo().getRoutingKey());
+ assertEquals("Unexpected reply-to routing-key",
+ "queue_name",
+ messageProperties.getReplyTo().getRoutingKey());
}
+ @Test
public void testReplyToConversionWhenBindingURLFormatIsUsed3()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -214,10 +241,13 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
- assertNull("Unexpected reply-to exchange", messageProperties.getReplyTo().getExchange());
- assertEquals("Unexpected reply-to routing-key", "queue_name", messageProperties.getReplyTo().getRoutingKey());
+ assertNull("Unexpected reply-to exchange", messageProperties.getReplyTo().getExchange());
+ assertEquals("Unexpected reply-to routing-key",
+ "queue_name",
+ messageProperties.getReplyTo().getRoutingKey());
}
+ @Test
public void testReplyToConversionWhenBindingURLFormatIsUsed4()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -231,9 +261,12 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertNull("Unexpected reply-to exchange", messageProperties.getReplyTo().getExchange());
- assertEquals("Unexpected reply-to routing-key", "test_routing_key", messageProperties.getReplyTo().getRoutingKey());
+ assertEquals("Unexpected reply-to routing-key",
+ "test_routing_key",
+ messageProperties.getReplyTo().getRoutingKey());
}
+ @Test
public void testReplyToConversionWhenNonBindingURLFormatIsUsed()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -250,6 +283,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected reply-to routing-key", "test", messageProperties.getReplyTo().getRoutingKey());
}
+ @Test
public void testExpirationConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -264,10 +298,11 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
- assertEquals("Unexpected TTL", ttl, deliveryProperties.getTtl());
+ assertEquals("Unexpected TTL", (long) ttl, deliveryProperties.getTtl());
assertEquals("Unexpected expiration", expiration, deliveryProperties.getExpiration());
}
+ @Test
public void testUuidMessageIdConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -282,6 +317,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected messageId", messageId, messageProperties.getMessageId());
}
+ @Test
public void testUuidMessageIdWithPrefixConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -296,6 +332,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected messageId", messageId, messageProperties.getMessageId());
}
+ @Test
public void testNonUuidMessageIdConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -308,10 +345,11 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected message id",
- UUID.nameUUIDFromBytes(messageId.getBytes(UTF_8)),
- messageProperties.getMessageId());
+ UUID.nameUUIDFromBytes(messageId.getBytes(UTF_8)),
+ messageProperties.getMessageId());
}
+ @Test
public void testTimestampConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -326,6 +364,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected timestamp", timestamp, deliveryProperties.getTimestamp());
}
+ @Test
public void testTypeConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -338,9 +377,12 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
Map<String, Object> applicationProperties = messageProperties.getApplicationHeaders();
- assertEquals("Unexpected x-jms-type in application headers", type, applicationProperties.get("x-jms-type"));
+ assertEquals("Unexpected x-jms-type in application headers",
+ type,
+ applicationProperties.get("x-jms-type"));
}
+ @Test
public void testUserIdConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -355,6 +397,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected user-id", userId, new String(messageProperties.getUserId(), UTF_8));
}
+ @Test
public void testPublishInfoExchangeConversion()
{
final String testExchange = "testExchange";
@@ -368,6 +411,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected exchange", testExchange, deliveryProperties.getExchange());
}
+ @Test
public void testPublishInfoRoutingKeyConversion()
{
final String testRoutingKey = "testRoutingKey";
@@ -381,6 +425,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected routing-key", testRoutingKey, deliveryProperties.getRoutingKey());
}
+ @Test
public void testPublishInfoImmediateTrueConversion()
{
final boolean immediate = true;
@@ -394,6 +439,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected immediate flag", immediate, deliveryProperties.getImmediate());
}
+ @Test
public void testPublishInfoImmediateFalseConversion()
{
final boolean immediate = false;
@@ -407,6 +453,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
assertEquals("Unexpected immediate flag", immediate, deliveryProperties.getImmediate());
}
+ @Test
public void testPublishInfoMandatoryTrueConversion()
{
final boolean mandatory = true;
@@ -417,9 +464,11 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
- assertEquals("Unexpected discard-unroutable flag", !mandatory, deliveryProperties.getDiscardUnroutable());
+ final Object expected = !mandatory;
+ assertEquals("Unexpected discard-unroutable flag", expected, deliveryProperties.getDiscardUnroutable());
}
+ @Test
public void testPublishInfoMandatoryFalseConversion()
{
final boolean mandatory = false;
@@ -430,9 +479,11 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final DeliveryProperties deliveryProperties =
convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
- assertEquals("Unexpected discard-unroutable flag", !mandatory, deliveryProperties.getDiscardUnroutable());
+ final Object expected = !mandatory;
+ assertEquals("Unexpected discard-unroutable flag", expected, deliveryProperties.getDiscardUnroutable());
}
+ @Test
public void testContentLengthConversion()
{
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
@@ -443,7 +494,7 @@ public class PropertyConverter_0_8_to_0_10Test extends QpidTestCase
final MessageProperties messageProperties =
convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
- assertEquals("Unexpected content-length", content.length, messageProperties.getContentLength());
+ assertEquals("Unexpected content-length", (long) content.length, messageProperties.getContentLength());
}
private AMQMessage createTestMessage(final BasicContentHeaderProperties basicContentHeaderProperties)
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java b/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java
index 4fa5734..e1a9632 100644
--- a/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java
+++ b/broker-plugins/amqp-msg-conv-0-8-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_8_v1_0/MessageConverter_0_8_to_1_0Test.java
@@ -23,6 +23,8 @@ package org.apache.qpid.server.protocol.converter.v0_8_v1_0;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getContentType;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -36,6 +38,8 @@ import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Lists;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
@@ -62,9 +66,9 @@ import org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSect
import org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSection;
import org.apache.qpid.server.store.StoredMessage;
import org.apache.qpid.server.typedmessage.TypedBytesContentWriter;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
+public class MessageConverter_0_8_to_1_0Test extends UnitTestBase
{
private final MessageConverter_0_8_to_1_0 _converter = new MessageConverter_0_8_to_1_0();
private final AMQPDescribedTypeRegistry _typeRegistry = AMQPDescribedTypeRegistry.newInstance()
@@ -80,10 +84,9 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
private final ContentHeaderBody _contentHeaderBody = mock(ContentHeaderBody.class);
private final BasicContentHeaderProperties _basicContentHeaderProperties = mock(BasicContentHeaderProperties.class);
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
when(_handle.getMetaData()).thenReturn(_metaData);
when(_metaData.getMessageHeader()).thenReturn(_header);
when(_metaData.getMessagePublishInfo()).thenReturn(new MessagePublishInfo());
@@ -91,76 +94,91 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
when(_contentHeaderBody.getProperties()).thenReturn(_basicContentHeaderProperties);
}
+ @Test
public void testConvertStringMessageBody() throws Exception
{
doTestTextMessage("helloworld", "text/plain");
}
+ @Test
public void testConvertEmptyStringMessageBody() throws Exception
{
doTestTextMessage(null, "text/plain");
}
+ @Test
public void testConvertStringXmlMessageBody() throws Exception
{
doTestTextMessage("<helloworld></helloworld>", "text/xml");
}
+ @Test
public void testConvertEmptyStringXmlMessageBody() throws Exception
{
doTestTextMessage(null, "text/xml");
}
+ @Test
public void testConvertEmptyStringApplicationXmlMessageBody() throws Exception
{
doTestTextMessage(null, "application/xml");
}
+ @Test
public void testConvertStringWithContentTypeText() throws Exception
{
doTestTextMessage("foo","text/foobar");
}
+ @Test
public void testConvertStringWithContentTypeApplicationXml() throws Exception
{
doTestTextMessage("<helloworld></helloworld>","application/xml");
}
+ @Test
public void testConvertStringWithContentTypeApplicationXmlDtd() throws Exception
{
doTestTextMessage("<!DOCTYPE name []>","application/xml-dtd");
}
+ @Test
public void testConvertStringWithContentTypeApplicationFooXml() throws Exception
{
doTestTextMessage("<helloworld></helloworld>","application/foo+xml");
}
+ @Test
public void testConvertStringWithContentTypeApplicationJson() throws Exception
{
doTestTextMessage("[]","application/json");
}
+ @Test
public void testConvertStringWithContentTypeApplicationFooJson() throws Exception
{
doTestTextMessage("[]","application/foo+json");
}
+ @Test
public void testConvertStringWithContentTypeApplicationJavascript() throws Exception
{
doTestTextMessage("var foo","application/javascript");
}
+ @Test
public void testConvertStringWithContentTypeApplicationEcmascript() throws Exception
{
doTestTextMessage("var foo","application/ecmascript");
}
+ @Test
public void testConvertBytesMessageBody() throws Exception
{
doTestBytesMessage("helloworld".getBytes(), "application/octet-stream");
}
+ @Test
public void testConvertBytesMessageBodyNoContentType() throws Exception
{
final byte[] messageContent = "helloworld".getBytes();
@@ -172,6 +190,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
null);
}
+ @Test
public void testConvertBytesMessageBodyUnknownContentType() throws Exception
{
final byte[] messageContent = "helloworld".getBytes();
@@ -184,11 +203,13 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
}
+ @Test
public void testConvertEmptyBytesMessageBody() throws Exception
{
doTestBytesMessage(new byte[0], "application/octet-stream");
}
+ @Test
public void testConvertJmsStreamMessageBody() throws Exception
{
final List<Object> expected = Lists.newArrayList("apple", 43, 31.42D);
@@ -198,6 +219,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestStreamMessage(messageBytes, mimeType, expected, JmsMessageTypeAnnotation.STREAM_MESSAGE.getType());
}
+ @Test
public void testConvertJmsStreamMessageEmptyBody() throws Exception
{
final List<Object> expected = Collections.emptyList();
@@ -205,6 +227,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestStreamMessage(null, "jms/stream-message", expected, JmsMessageTypeAnnotation.STREAM_MESSAGE.getType());
}
+ @Test
public void testConvertAmqpListMessageBody() throws Exception
{
final List<Object> expected = Lists.newArrayList("apple", 43, 31.42D);
@@ -214,6 +237,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestStreamMessage(messageBytes, mimeType, expected, JmsMessageTypeAnnotation.STREAM_MESSAGE.getType());
}
+ @Test
public void testConvertAmqpListMessageBodyWithNonJmsContent() throws Exception
{
final List<Object> expected = Lists.newArrayList("apple", 43, 31.42D, Lists.newArrayList("nonJMSList"));
@@ -223,6 +247,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestStreamMessage(messageBytes, mimeType, expected, null);
}
+ @Test
public void testConvertJmsMapMessageBody() throws Exception
{
final Map<String, Object> expected = Collections.singletonMap("key", "value");
@@ -231,6 +256,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestMapMessage(messageBytes, "jms/map-message", expected, JmsMessageTypeAnnotation.MAP_MESSAGE.getType());
}
+ @Test
public void testConvertJmsMapMessageEmptyBody() throws Exception
{
final Map<String, Object> expected = Collections.emptyMap();
@@ -238,6 +264,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestMapMessage(null, "jms/map-message", expected, JmsMessageTypeAnnotation.MAP_MESSAGE.getType());
}
+ @Test
public void testConvertAmqpMapMessageBody() throws Exception
{
final Map<String, Object> expected = Collections.singletonMap("key", "value");
@@ -246,6 +273,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestMapMessage(messageBytes, "amqp/map", expected, JmsMessageTypeAnnotation.MAP_MESSAGE.getType());
}
+ @Test
public void testConvertAmqpMapMessageBodyWithNonJmsContent() throws Exception
{
final Map<String, Object> expected = Collections.singletonMap("key", Collections.singletonList("nonJmsList"));
@@ -254,6 +282,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestMapMessage(messageBytes, "amqp/map", expected, null);
}
+ @Test
public void testConvertObjectStreamMessageBody() throws Exception
{
final byte[] messageBytes = getObjectStreamMessageBytes(UUID.randomUUID());
@@ -262,6 +291,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestObjectMessage(messageBytes, "application/java-object-stream", expectedBytes);
}
+ @Test
public void testConvertObjectStream2MessageBody() throws Exception
{
final byte[] messageBytes = getObjectStreamMessageBytes(UUID.randomUUID());
@@ -270,6 +300,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestObjectMessage(messageBytes, "application/x-java-serialized-object", expectedBytes);
}
+ @Test
public void testConvertEmptyObjectStreamMessageBody() throws Exception
{
final byte[] messageBytes = null;
@@ -279,16 +310,19 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
doTestObjectMessage(messageBytes, mimeType, expectedBytes);
}
+ @Test
public void testConvertEmptyMessageWithoutContentType() throws Exception
{
doTest(null, null, AmqpValueSection.class, null, null, JmsMessageTypeAnnotation.MESSAGE.getType());
}
+ @Test
public void testConvertEmptyMessageWithUnknownContentType() throws Exception
{
doTest(null, "foo/bar", DataSection.class, new byte[0], Symbol.valueOf("foo/bar"), null);
}
+ @Test
public void testConvertMessageWithoutContentType() throws Exception
{
final byte[] expectedContent = "someContent".getBytes(UTF_8);
@@ -342,7 +376,7 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
{
SectionDecoder sectionDecoder = new SectionDecoderImpl(_typeRegistry.getSectionDecoderRegistry());
final List<EncodingRetainingSection<?>> sections = sectionDecoder.parseAll(content);
- assertEquals("Unexpected number of sections", expectedNumberOfSections, sections.size());
+ assertEquals("Unexpected number of sections", (long) expectedNumberOfSections, (long) sections.size());
return sections;
}
@@ -490,8 +524,8 @@ public class MessageConverter_0_8_to_1_0Test extends QpidTestCase
else
{
assertEquals("Unexpected annotation 'x-opt-jms-msg-type'",
- expectedJmsTypeAnnotation,
- jmsMessageTypeAnnotation);
+ expectedJmsTypeAnnotation,
+ jmsMessageTypeAnnotation);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org