You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2014/02/03 15:49:44 UTC
svn commit: r1563934 - in /qpid/jms/trunk/src/test/java/org/apache/qpid/jms:
engine/AmqpMessageTest.java engine/TestAmqpMessage.java
impl/MessageImplTest.java impl/SenderImplTest.java impl/TestMessageImpl.java
Author: robbie
Date: Mon Feb 3 14:49:43 2014
New Revision: 1563934
URL: http://svn.apache.org/r1563934
Log:
QPIDJMS-9: tidy up message tests to remove their direct use/knowledge of the test message classes
Modified:
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/TestAmqpMessage.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TestMessageImpl.java
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageTest.java?rev=1563934&r1=1563933&r2=1563934&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageTest.java Mon Feb 3 14:49:43 2014
@@ -73,7 +73,7 @@ public class AmqpMessageTest extends Qpi
{
//Check a Proton Message without any application properties section
Message message1 = Proton.message();
- TestAmqpMessage testAmqpMessage1 = new TestAmqpMessage(message1, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage1 = TestAmqpMessage.createReceivedMessage(message1, _mockDelivery, _mockAmqpConnection);
Set<String> applicationPropertyNames = testAmqpMessage1.getApplicationPropertyNames();
assertNotNull(applicationPropertyNames);
@@ -87,7 +87,7 @@ public class AmqpMessageTest extends Qpi
Message message2 = Proton.message();
message2.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap ));
- TestAmqpMessage testAmqpMessage2 = new TestAmqpMessage(message2, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage2 = TestAmqpMessage.createReceivedMessage(message2, _mockDelivery, _mockAmqpConnection);
Set<String> applicationPropertyNames2 = testAmqpMessage2.getApplicationPropertyNames();
assertEquals(2, applicationPropertyNames2.size());
@@ -104,7 +104,7 @@ public class AmqpMessageTest extends Qpi
Message message = Proton.message();
message.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap ));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
Set<String> applicationPropertyNames = testAmqpMessage.getApplicationPropertyNames();
assertEquals(1, applicationPropertyNames.size());
@@ -125,7 +125,7 @@ public class AmqpMessageTest extends Qpi
Message message = Proton.message();
message.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap ));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertTrue(testAmqpMessage.applicationPropertyExists(TEST_PROP_A));
assertFalse(testAmqpMessage.applicationPropertyExists(TEST_PROP_B));
@@ -140,7 +140,7 @@ public class AmqpMessageTest extends Qpi
Message message = Proton.message();
message.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap ));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertEquals(TEST_VALUE_STRING_A, testAmqpMessage.getApplicationProperty(TEST_PROP_A));
assertNull(testAmqpMessage.getApplicationProperty(TEST_PROP_B));
@@ -150,7 +150,7 @@ public class AmqpMessageTest extends Qpi
public void testSetApplicationProperty()
{
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertNull(testAmqpMessage.getApplicationProperty(TEST_PROP_A));
testAmqpMessage.setApplicationProperty(TEST_PROP_A, TEST_VALUE_STRING_A);
@@ -161,7 +161,7 @@ public class AmqpMessageTest extends Qpi
public void testSetApplicationPropertyUsingNullKeyCausesIAE()
{
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
try
{
@@ -176,25 +176,31 @@ public class AmqpMessageTest extends Qpi
// ====== Header =======
+ /**
+ * To satisfy the JMS requirement that messages are durable by default, the
+ * {@link AmqpMessage} objects created for sending new messages are populated
+ * with a header section with durable set to true.
+ */
@Test
- public void testNewMessageHasNoUnderlyingHeaderSection()
+ public void testNewMessageHasUnderlyingHeaderSectionWithDurableTrue()
{
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
Message underlying = testAmqpMessage.getMessage();
- assertNull(underlying.getHeader());
+ assertNotNull(underlying.getHeader());
+ assertTrue(underlying.getHeader().getDurable());
}
@Test
public void testGetTtlIsNullForNewMessage()
{
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
assertNull(testAmqpMessage.getTtl());
}
@Test
- public void testGetTtlOnRecievedMessageWithTtl()
+ public void testGetTtlOnReceivedMessageWithTtl()
{
Long ttl = 123L;
@@ -203,7 +209,7 @@ public class AmqpMessageTest extends Qpi
header.setTtl(UnsignedInteger.valueOf(ttl));
message.setHeader(header);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertEquals(ttl, testAmqpMessage.getTtl());
}
@@ -213,7 +219,7 @@ public class AmqpMessageTest extends Qpi
{
Long ttl = 123L;
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setTtl(ttl);
@@ -226,7 +232,7 @@ public class AmqpMessageTest extends Qpi
{
Long ttl = 123L;
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setTtl(ttl);
testAmqpMessage.setTtl(null);
@@ -243,7 +249,7 @@ public class AmqpMessageTest extends Qpi
@Test
public void testGetPriorityIs4ForNewMessage()
{
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
assertEquals("expected priority value not found", 4, testAmqpMessage.getPriority());
}
@@ -253,14 +259,14 @@ public class AmqpMessageTest extends Qpi
* the AMQP spec says the priority has default value of 4.
*/
@Test
- public void testGetPriorityIs4ForRecievedMessageWithHeaderButWithoutPriority()
+ public void testGetPriorityIs4ForReceivedMessageWithHeaderButWithoutPriority()
{
Message message = Proton.message();
Header header = new Header();
message.setHeader(header);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertEquals("expected priority value not found", 4, testAmqpMessage.getPriority());
}
@@ -269,7 +275,7 @@ public class AmqpMessageTest extends Qpi
* When messages have a header section, which have a priority value, ensure it is returned.
*/
@Test
- public void testGetPriorityForRecievedMessageWithHeaderWithPriority()
+ public void testGetPriorityForReceivedMessageWithHeaderWithPriority()
{
//value over 10
byte priority = 11;
@@ -279,7 +285,7 @@ public class AmqpMessageTest extends Qpi
message.setHeader(header);
header.setPriority(UnsignedByte.valueOf(priority));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertEquals("expected priority value not found", priority, testAmqpMessage.getPriority());
}
@@ -294,7 +300,7 @@ public class AmqpMessageTest extends Qpi
//value over 10
byte priority = 11;
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setPriority(priority);
Message underlying = testAmqpMessage.getMessage();
@@ -308,7 +314,7 @@ public class AmqpMessageTest extends Qpi
* underlying field value is cleared when the priority is set to the default priority of 4.
*/
@Test
- public void testSetPriorityToDefaultOnRecievedMessageWithPriorityClearsPriorityField()
+ public void testSetPriorityToDefaultOnReceivedMessageWithPriorityClearsPriorityField()
{
byte priority = 11;
@@ -317,7 +323,7 @@ public class AmqpMessageTest extends Qpi
message.setHeader(header);
header.setPriority(UnsignedByte.valueOf(priority));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
testAmqpMessage.setPriority(AmqpMessage.DEFAULT_PRIORITY);
//check the expected value is still returned
@@ -334,7 +340,7 @@ public class AmqpMessageTest extends Qpi
public void testGetToWithReceivedMessageWithNoProperties()
{
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
String toAddress = testAmqpMessage.getTo();
assertNull(toAddress);
@@ -349,7 +355,7 @@ public class AmqpMessageTest extends Qpi
props.setContentType(Symbol.valueOf("content-type"));
message.setProperties(props);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
String toAddress = testAmqpMessage.getTo();
assertNull(toAddress);
@@ -366,7 +372,7 @@ public class AmqpMessageTest extends Qpi
props.setTo(testToAddress);
message.setProperties(props);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
String toAddress = testAmqpMessage.getTo();
assertNotNull(toAddress);
@@ -378,7 +384,7 @@ public class AmqpMessageTest extends Qpi
{
String testToAddress = "myTestAddress";
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
Message underlyingMessage = testAmqpMessage.getMessage();
assertNull(underlyingMessage.getAddress());
@@ -394,7 +400,7 @@ public class AmqpMessageTest extends Qpi
{
String testToAddress = "myTestAddress";
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
assertNull(testAmqpMessage.getTo());
@@ -408,7 +414,7 @@ public class AmqpMessageTest extends Qpi
public void testGetReplyToWithReceivedMessageWithNoProperties()
{
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
String replyToAddress = testAmqpMessage.getReplyTo();
assertNull(replyToAddress);
@@ -423,7 +429,7 @@ public class AmqpMessageTest extends Qpi
props.setContentType(Symbol.valueOf("content-type"));
message.setProperties(props);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
String replyToAddress = testAmqpMessage.getReplyTo();
assertNull(replyToAddress);
@@ -440,7 +446,7 @@ public class AmqpMessageTest extends Qpi
props.setReplyTo(testReplyToAddress);
message.setProperties(props);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
String replyToAddress = testAmqpMessage.getReplyTo();
assertNotNull(replyToAddress);
@@ -452,7 +458,7 @@ public class AmqpMessageTest extends Qpi
{
String testReplyToAddress = "myTestAddress";
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
Message underlyingMessage = testAmqpMessage.getMessage();
assertNull(underlyingMessage.getReplyTo());
@@ -468,7 +474,7 @@ public class AmqpMessageTest extends Qpi
{
String testReplyToAddress = "myTestAddress";
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
assertNull(testAmqpMessage.getReplyTo());
@@ -481,7 +487,7 @@ public class AmqpMessageTest extends Qpi
@Test
public void testNewMessageHasNoUnderlyingPropertiesSection()
{
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
Message underlying = testAmqpMessage.getMessage();
assertNull(underlying.getProperties());
@@ -490,7 +496,7 @@ public class AmqpMessageTest extends Qpi
@Test
public void testGetCreationTimeIsNullForNewMessage()
{
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
assertNull(testAmqpMessage.getCreationTime());
}
@@ -500,7 +506,7 @@ public class AmqpMessageTest extends Qpi
{
Long timestamp = System.currentTimeMillis();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setCreationTime(timestamp);
@@ -513,7 +519,7 @@ public class AmqpMessageTest extends Qpi
{
Long timestamp = System.currentTimeMillis();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setCreationTime(timestamp);
testAmqpMessage.setCreationTime(null);
@@ -525,7 +531,7 @@ public class AmqpMessageTest extends Qpi
@Test
public void testGetAbsoluteExpiryTimeIsNullForNewMessage()
{
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
assertNull(testAmqpMessage.getAbsoluteExpiryTime());
}
@@ -535,7 +541,7 @@ public class AmqpMessageTest extends Qpi
{
Long timestamp = System.currentTimeMillis();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setAbsoluteExpiryTime(timestamp);
@@ -548,7 +554,7 @@ public class AmqpMessageTest extends Qpi
{
Long timestamp = System.currentTimeMillis();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setAbsoluteExpiryTime(timestamp);
testAmqpMessage.setAbsoluteExpiryTime(null);
@@ -561,7 +567,7 @@ public class AmqpMessageTest extends Qpi
@Test
public void testGetMessageIdIsNullOnNewMessage()
{
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
assertNull("Expected messageId to be null on new message", testAmqpMessage.getMessageId());
}
@@ -574,7 +580,7 @@ public class AmqpMessageTest extends Qpi
{
String testMessageId = "myStringMessageId";
- AmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setMessageId(testMessageId);
assertEquals("Expected messageId not returned", testMessageId, testAmqpMessage.getMessageId());
@@ -598,7 +604,7 @@ public class AmqpMessageTest extends Qpi
{
UUID testMessageId = UUID.randomUUID();
- AmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setMessageId(testMessageId);
assertEquals("Expected messageId not returned", testMessageId, testAmqpMessage.getMessageId());
@@ -622,7 +628,7 @@ public class AmqpMessageTest extends Qpi
{
BigInteger testMessageId = BigInteger.valueOf(123456789);
- AmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setMessageId(testMessageId);
assertEquals("Expected messageId not returned", testMessageId, testAmqpMessage.getMessageId());
@@ -646,7 +652,7 @@ public class AmqpMessageTest extends Qpi
public void testSetMessageIdOnNewMessageWithULongOurOfRangeThrowsIAE()
{
//negative value
- AmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
try
{
testAmqpMessage.setMessageId(BigInteger.valueOf(-1));
@@ -682,7 +688,7 @@ public class AmqpMessageTest extends Qpi
{
ByteBuffer testMessageId = createByteBufferForBinaryId();
- AmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
testAmqpMessage.setMessageId(testMessageId);
assertEquals("Expected messageId not returned", testMessageId, testAmqpMessage.getMessageId());
@@ -720,7 +726,7 @@ public class AmqpMessageTest extends Qpi
props.setMessageId(underlyingIdObject);
message.setProperties(props);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertNotNull("Expected a messageId on received message", testAmqpMessage.getMessageId());
@@ -748,7 +754,7 @@ public class AmqpMessageTest extends Qpi
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertFalse(testAmqpMessage.messageAnnotationExists(symbolKeyName));
}
@@ -765,7 +771,7 @@ public class AmqpMessageTest extends Qpi
annotationsMap.put(Symbol.valueOf(symbolKeyName), value);
message.setMessageAnnotations(new MessageAnnotations(annotationsMap));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertTrue(testAmqpMessage.messageAnnotationExists(symbolKeyName));
assertFalse(testAmqpMessage.messageAnnotationExists("otherName"));
@@ -778,7 +784,7 @@ public class AmqpMessageTest extends Qpi
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertNull(testAmqpMessage.getMessageAnnotation(symbolKeyName));
}
@@ -795,7 +801,7 @@ public class AmqpMessageTest extends Qpi
annotationsMap.put(Symbol.valueOf(symbolKeyName), value);
message.setMessageAnnotations(new MessageAnnotations(annotationsMap));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertEquals(value, testAmqpMessage.getMessageAnnotation(symbolKeyName));
assertNull(testAmqpMessage.getMessageAnnotation("otherName"));
@@ -804,7 +810,7 @@ public class AmqpMessageTest extends Qpi
@Test
public void testNewMessageHasNoUnderlyingMessageAnnotationsSection()
{
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
Message underlying = testAmqpMessage.getMessage();
assertNull(underlying.getMessageAnnotations());
@@ -817,7 +823,7 @@ public class AmqpMessageTest extends Qpi
String symbolKeyName2 = "myTestSymbolName2";
String value = "myTestValue";
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
//check setting first annotation creates the annotations section
testAmqpMessage.setMessageAnnotation(symbolKeyName, value);
@@ -849,7 +855,7 @@ public class AmqpMessageTest extends Qpi
annotationsMap.put(Symbol.valueOf(symbolKeyName), value);
message.setMessageAnnotations(new MessageAnnotations(annotationsMap));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertEquals(value, testAmqpMessage.getMessageAnnotation(symbolKeyName));
assertNull(testAmqpMessage.getMessageAnnotation("otherName"));
@@ -863,7 +869,7 @@ public class AmqpMessageTest extends Qpi
{
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
testAmqpMessage.clearMessageAnnotation("keyName");
}
@@ -872,7 +878,7 @@ public class AmqpMessageTest extends Qpi
public void testClearAllMessageAnnotationsUsingNewMessage()
{
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
testAmqpMessage.clearAllMessageAnnotations();
@@ -892,7 +898,7 @@ public class AmqpMessageTest extends Qpi
annotationsMap.put(Symbol.valueOf(symbolKeyName), value);
message.setMessageAnnotations(new MessageAnnotations(annotationsMap));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
testAmqpMessage.clearAllMessageAnnotations();
@@ -904,7 +910,7 @@ public class AmqpMessageTest extends Qpi
public void testGetMessageAnnotationsCountUsingReceivedMessageWithoutMessageAnnotationsSection()
{
Message message = Proton.message();
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertEquals(0, testAmqpMessage.getMessageAnnotationsCount());
}
@@ -923,7 +929,7 @@ public class AmqpMessageTest extends Qpi
annotationsMap.put(Symbol.valueOf(symbolKeyName2), value);
message.setMessageAnnotations(new MessageAnnotations(annotationsMap));
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage(message, _mockDelivery, _mockAmqpConnection);
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createReceivedMessage(message, _mockDelivery, _mockAmqpConnection);
assertEquals(2, testAmqpMessage.getMessageAnnotationsCount());
testAmqpMessage.clearMessageAnnotation(symbolKeyName);
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/TestAmqpMessage.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/TestAmqpMessage.java?rev=1563934&r1=1563933&r2=1563934&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/TestAmqpMessage.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/TestAmqpMessage.java Mon Feb 3 14:49:43 2014
@@ -1,18 +1,29 @@
package org.apache.qpid.jms.engine;
-import org.apache.qpid.proton.Proton;
import org.apache.qpid.proton.engine.Delivery;
import org.apache.qpid.proton.message.Message;
public class TestAmqpMessage extends AmqpMessage
{
- public TestAmqpMessage()
+ //message to be sent
+ private TestAmqpMessage()
{
- this(Proton.message(), null, null);
+ super();
}
- public TestAmqpMessage(Message message, Delivery delivery, AmqpConnection amqpConnection)
+ //message just received
+ private TestAmqpMessage(Message message, Delivery delivery, AmqpConnection amqpConnection)
{
super(message, delivery, amqpConnection);
}
+
+ public static AmqpMessage createNewMessage()
+ {
+ return new TestAmqpMessage();
+ }
+
+ public static AmqpMessage createReceivedMessage(Message message, Delivery delivery, AmqpConnection amqpConnection)
+ {
+ return new TestAmqpMessage(message, delivery, amqpConnection);
+ }
}
\ No newline at end of file
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java?rev=1563934&r1=1563933&r2=1563934&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java Mon Feb 3 14:49:43 2014
@@ -33,6 +33,7 @@ import javax.jms.Queue;
import javax.jms.Topic;
import org.apache.qpid.jms.QpidJmsTestCase;
+import org.apache.qpid.jms.engine.AmqpMessage;
import org.apache.qpid.jms.engine.TestAmqpMessage;
import org.junit.Before;
import org.junit.Test;
@@ -42,8 +43,8 @@ public class MessageImplTest extends Qpi
{
private ConnectionImpl _mockConnectionImpl;
private SessionImpl _mockSessionImpl;
- private TestMessageImpl _testMessage;
- private TestAmqpMessage _testAmqpMessage;
+ private MessageImpl<TestAmqpMessage> _testMessage;
+ private AmqpMessage _testAmqpMessage;
private String _mockQueueName;
private Queue _mockQueue;
private String _mockTopicName;
@@ -60,8 +61,8 @@ public class MessageImplTest extends Qpi
Mockito.when(_mockSessionImpl.getDestinationHelper()).thenReturn(new DestinationHelper());
Mockito.when(_mockSessionImpl.getMessageIdHelper()).thenReturn(new MessageIdHelper());
- _testAmqpMessage = new TestAmqpMessage();
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl);
+ _testAmqpMessage = TestAmqpMessage.createNewMessage();
+ _testMessage = TestMessageImpl.createNewMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl);
_mockQueueName = "mockQueueName";
_mockQueue = Mockito.mock(Queue.class);
@@ -518,12 +519,12 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testSetJMSDestinationNullOnRecievedMessageWithToAndTypeAnnotationClearsTheAnnotation() throws Exception
+ public void testSetJMSDestinationNullOnReceivedMessageWithToAndTypeAnnotationClearsTheAnnotation() throws Exception
{
_testAmqpMessage.setTo(_mockTopicName);
_testAmqpMessage.setMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
DestinationHelper.TOPIC_ATTRIBUTES_STRING);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertNotNull("expected JMSDestination value not present", _testMessage.getJMSDestination());
assertTrue(_testAmqpMessage.messageAnnotationExists(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME));
@@ -543,10 +544,10 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testGetJMSDestinationOnRecievedMessageWithToButWithoutToTypeAnnotation() throws Exception
+ public void testGetJMSDestinationOnReceivedMessageWithToButWithoutToTypeAnnotation() throws Exception
{
_testAmqpMessage.setTo(_mockQueueName);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertNotNull("expected JMSDestination value not present", _testMessage.getJMSDestination());
@@ -555,12 +556,12 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testGetJMSDestinationOnRecievedMessageWithToAndTypeAnnotationForTopic() throws Exception
+ public void testGetJMSDestinationOnReceivedMessageWithToAndTypeAnnotationForTopic() throws Exception
{
_testAmqpMessage.setTo(_mockTopicName);
_testAmqpMessage.setMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
DestinationHelper.TOPIC_ATTRIBUTES_STRING);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertNotNull("expected JMSDestination value not present", _testMessage.getJMSDestination());
@@ -569,12 +570,12 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testGetJMSDestinationOnRecievedMessageWithToAndTypeAnnotationForQueue() throws Exception
+ public void testGetJMSDestinationOnReceivedMessageWithToAndTypeAnnotationForQueue() throws Exception
{
_testAmqpMessage.setTo(_mockQueueName);
_testAmqpMessage.setMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
DestinationHelper.QUEUE_ATTRIBUTES_STRING);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertNotNull("expected JMSDestination value not present", _testMessage.getJMSDestination());
@@ -623,12 +624,12 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testSetJMSReplyToNullOnRecievedMessageWithReplyToAndTypeAnnotationClearsTheAnnotation() throws Exception
+ public void testSetJMSReplyToNullOnReceivedMessageWithReplyToAndTypeAnnotationClearsTheAnnotation() throws Exception
{
_testAmqpMessage.setReplyTo(_mockTopicName);
_testAmqpMessage.setMessageAnnotation(DestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
DestinationHelper.TOPIC_ATTRIBUTES_STRING);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertNotNull("expected JMSReplyTo value not present", _testMessage.getJMSReplyTo());
assertTrue(_testAmqpMessage.messageAnnotationExists(DestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME));
@@ -648,10 +649,10 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testGetJMSReplyToRecievedMessageWithReplyToButWithoutReplyToTypeAnnotation() throws Exception
+ public void testGetJMSReplyToReceivedMessageWithReplyToButWithoutReplyToTypeAnnotation() throws Exception
{
_testAmqpMessage.setReplyTo(_mockQueueName);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertNotNull("expected JMSReplyTo value not present", _testMessage.getJMSReplyTo());
@@ -660,12 +661,12 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testGetJMSReplyToOnRecievedMessageWithReplyToAndTypeAnnotationForTopic() throws Exception
+ public void testGetJMSReplyToOnReceivedMessageWithReplyToAndTypeAnnotationForTopic() throws Exception
{
_testAmqpMessage.setReplyTo(_mockTopicName);
_testAmqpMessage.setMessageAnnotation(DestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
DestinationHelper.TOPIC_ATTRIBUTES_STRING);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertNotNull("expected JMSReplyTo value not present", _testMessage.getJMSReplyTo());
@@ -674,12 +675,12 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testGetJMSReplyToRecievedMessageWithReplyToAndTypeAnnotationForQueue() throws Exception
+ public void testGetJMSReplyToReceivedMessageWithReplyToAndTypeAnnotationForQueue() throws Exception
{
_testAmqpMessage.setReplyTo(_mockQueueName);
_testAmqpMessage.setMessageAnnotation(DestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
DestinationHelper.QUEUE_ATTRIBUTES_STRING);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertNotNull("expected JMSReplyTo value not present", _testMessage.getJMSReplyTo());
@@ -717,21 +718,21 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testGetJMSTimestampOnRecievedMessageWithCreationTime() throws Exception
+ public void testGetJMSTimestampOnReceivedMessageWithCreationTime() throws Exception
{
long timestamp = System.currentTimeMillis();
_testAmqpMessage.setCreationTime(timestamp);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertEquals("expected JMSTimestamp value not present", timestamp, _testMessage.getJMSTimestamp());
}
@Test
- public void testSetJMSTimestampToZeroOnRecievedMessageWithCreationTimeSetsUnderlyingCreationTimeNull() throws Exception
+ public void testSetJMSTimestampToZeroOnReceivedMessageWithCreationTimeSetsUnderlyingCreationTimeNull() throws Exception
{
long timestamp = System.currentTimeMillis();
_testAmqpMessage.setCreationTime(timestamp);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
_testMessage.setJMSTimestamp(0);
@@ -768,7 +769,7 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testGetJMSExpirationOnRecievedMessageWithAbsoluteExpiryTimeAndTtl() throws Exception
+ public void testGetJMSExpirationOnReceivedMessageWithAbsoluteExpiryTimeAndTtl() throws Exception
{
long creationTime = 123456789;
long ttl = 789L;
@@ -776,29 +777,29 @@ public class MessageImplTest extends Qpi
_testAmqpMessage.setTtl(ttl);
_testAmqpMessage.setAbsoluteExpiryTime(expiration);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertEquals("expected JMSExpiration value not present", expiration, _testMessage.getJMSExpiration());
}
@Test
- public void testGetJMSExpirationOnRecievedMessageWithAbsoluteExpiryTimeButNoTtl() throws Exception
+ public void testGetJMSExpirationOnReceivedMessageWithAbsoluteExpiryTimeButNoTtl() throws Exception
{
long expiration = System.currentTimeMillis();
_testAmqpMessage.setAbsoluteExpiryTime(expiration);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertEquals("expected JMSExpiration value not present", expiration, _testMessage.getJMSExpiration());
}
@Test
- public void testGetJMSExpirationOnRecievedMessageWithTtlButNoAbsoluteExpiry() throws Exception
+ public void testGetJMSExpirationOnReceivedMessageWithTtlButNoAbsoluteExpiry() throws Exception
{
long timestamp = System.currentTimeMillis();
long ttl = 999999L;
_testAmqpMessage.setTtl(ttl);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
long jmsExpiration = _testMessage.getJMSExpiration();
@@ -812,11 +813,11 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testSetJMSExpirationToZeroOnRecievedMessageWithAbsoluteExpiryTimeSetsUnderlyingExpiryNull() throws Exception
+ public void testSetJMSExpirationToZeroOnReceivedMessageWithAbsoluteExpiryTimeSetsUnderlyingExpiryNull() throws Exception
{
long timestamp = System.currentTimeMillis();
_testAmqpMessage.setAbsoluteExpiryTime(timestamp);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
_testMessage.setJMSExpiration(0);
@@ -830,12 +831,12 @@ public class MessageImplTest extends Qpi
* returning 0 if an incoming message had only the ttl field set.
*/
@Test
- public void testSetJMSExpirationToZeroOnRecievedMessageWithTtlFieldsResultsInGetJMSExpirationReturningZero() throws Exception
+ public void testSetJMSExpirationToZeroOnReceivedMessageWithTtlFieldsResultsInGetJMSExpirationReturningZero() throws Exception
{
long ttl = 789L;
_testAmqpMessage.setTtl(ttl);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
_testMessage.setJMSExpiration(0);
@@ -848,14 +849,14 @@ public class MessageImplTest extends Qpi
* absolute-expiry-time and ttl fields set.
*/
@Test
- public void testSetJMSExpirationToZeroOnRecievedMessageWithAbsoluteExpiryAndTtlFieldsResultsInGetJMSExpirationReturningZero() throws Exception
+ public void testSetJMSExpirationToZeroOnReceivedMessageWithAbsoluteExpiryAndTtlFieldsResultsInGetJMSExpirationReturningZero() throws Exception
{
long ttl = 789L;
long timestamp = System.currentTimeMillis();
_testAmqpMessage.setTtl(ttl);
_testAmqpMessage.setAbsoluteExpiryTime(timestamp);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
_testMessage.setJMSExpiration(0);
@@ -889,13 +890,13 @@ public class MessageImplTest extends Qpi
* @throws Exception
*/
@Test
- public void testGetJMSPriorityOnRecievedMessageWithNonJmsPriorityIsCappedAt9() throws Exception
+ public void testGetJMSPriorityOnReceivedMessageWithNonJmsPriorityIsCappedAt9() throws Exception
{
short priority = 200;
_testAmqpMessage.setPriority(priority);
//create a received message
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertEquals("expected JMSPriority value to be capped at 9", 9, _testMessage.getJMSPriority());
}
@@ -993,9 +994,9 @@ public class MessageImplTest extends Qpi
* expected JMSMessageID value being returned, i.e. the base string plus the JMS "ID:" prefix.
*/
@Test
- public void testGetJMSMessageIdOnRecievedMessageWithString() throws Exception
+ public void testGetJMSMessageIdOnReceivedMessageWithString() throws Exception
{
- getJMSMessageIdOnRecievedMessageWithStringTestImpl(false);
+ getJMSMessageIdOnReceivedMessageWithStringTestImpl(false);
}
/**
@@ -1003,12 +1004,12 @@ public class MessageImplTest extends Qpi
* expected JMSMessageID value being returned, i.e. the base string plus the JMS "ID:" prefix.
*/
@Test
- public void testGetJMSMessageIdOnRecievedMessageWithStringAlreadyContainingPrefix() throws Exception
+ public void testGetJMSMessageIdOnReceivedMessageWithStringAlreadyContainingPrefix() throws Exception
{
- getJMSMessageIdOnRecievedMessageWithStringTestImpl(true);
+ getJMSMessageIdOnReceivedMessageWithStringTestImpl(true);
}
- private void getJMSMessageIdOnRecievedMessageWithStringTestImpl(boolean prefixAlreadyExists) throws JMSException
+ private void getJMSMessageIdOnReceivedMessageWithStringTestImpl(boolean prefixAlreadyExists) throws JMSException
{
String baseId = "something";
if(prefixAlreadyExists)
@@ -1019,7 +1020,7 @@ public class MessageImplTest extends Qpi
String expectedJmsMessageId = "ID:" + baseId;
_testAmqpMessage.setMessageId(baseId);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
assertEquals("expected JMSMessageID value not present", expectedJmsMessageId, _testMessage.getJMSMessageID());
}
@@ -1126,10 +1127,10 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testJMS_AMQP_TTL_PropertyBehaviourOnRecievedMessageWithUnderlyingTtlFieldSet() throws Exception
+ public void testJMS_AMQP_TTL_PropertyBehaviourOnReceivedMessageWithUnderlyingTtlFieldSet() throws Exception
{
_testAmqpMessage.setTtl(5L);
- _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
//check the propertyExists method
assertFalse(_testMessage.propertyExists(JMS_AMQP_TTL));
@@ -1210,7 +1211,7 @@ public class MessageImplTest extends Qpi
// ====== utility methods =======
- private void assertGetPropertyThrowsMessageFormatException(TestMessageImpl testMessage,
+ private void assertGetPropertyThrowsMessageFormatException(MessageImpl<?> testMessage,
String propertyName,
Class<?> clazz) throws JMSException
{
@@ -1226,7 +1227,7 @@ public class MessageImplTest extends Qpi
}
}
- private Object getMessagePropertyUsingTypeMethod(TestMessageImpl testMessage, String propertyName, Class<?> clazz) throws JMSException
+ private Object getMessagePropertyUsingTypeMethod(MessageImpl<?> testMessage, String propertyName, Class<?> clazz) throws JMSException
{
if(clazz == Boolean.class)
{
@@ -1266,7 +1267,7 @@ public class MessageImplTest extends Qpi
}
}
- private void assertGetPropertyEquals(TestMessageImpl testMessage,
+ private void assertGetPropertyEquals(MessageImpl<?> testMessage,
String propertyName,
Object expectedValue,
Class<?> clazz) throws JMSException
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java?rev=1563934&r1=1563933&r2=1563934&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java Mon Feb 3 14:49:43 2014
@@ -74,9 +74,9 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, null);
+ //explicitly flip the DeliveryMode to NON_PERSISTENT, later verifying it gets changed back to PERSISTENT
testMessage.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
assertEquals(DeliveryMode.NON_PERSISTENT, testMessage.getJMSDeliveryMode());
@@ -96,8 +96,7 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, null);
assertNull(testMessage.getJMSDestination());
@@ -117,8 +116,7 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, null);
assertEquals(0, testMessage.getJMSTimestamp());
long timestamp = System.currentTimeMillis();
@@ -140,8 +138,7 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, null);
assertEquals(Message.DEFAULT_PRIORITY, testMessage.getJMSPriority());
@@ -163,8 +160,7 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, null);
assertEquals(0, testMessage.getJMSTimestamp());
long timestamp = System.currentTimeMillis();
@@ -200,8 +196,7 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, null);
assertEquals(0, testMessage.getJMSTimestamp());
long timestamp = System.currentTimeMillis();
@@ -224,14 +219,14 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
+ AmqpMessage testAmqpMessage = TestAmqpMessage.createNewMessage();
Long oldTtl = 456L;
testAmqpMessage.setTtl(oldTtl);
long expiration = System.currentTimeMillis();
testAmqpMessage.setAbsoluteExpiryTime(expiration);
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, _mockConnection, null);
+ MessageImpl<?> testMessage = TestMessageImpl.createReceivedMessage(testAmqpMessage, _mockSession, _mockConnection, null);
//verify JMSExpiration is non-zero
assertEquals(expiration, testMessage.getJMSExpiration());
@@ -256,10 +251,8 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
-
Long ttlPropValue = 789L;
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, _mockConnection);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, _mockConnection);
testMessage.setLongProperty(JMS_AMQP_TTL, ttlPropValue);
//send the message without any TTL
@@ -284,11 +277,9 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
-
long timestamp = System.currentTimeMillis();
Long ttlPropValue = 789L;
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, _mockConnection);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, _mockConnection);
testMessage.setLongProperty(JMS_AMQP_TTL, ttlPropValue);
//send the message with a different TTL
@@ -315,11 +306,9 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
- TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
-
long timestamp = System.currentTimeMillis();
Long ttlPropValue = 0L;
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, _mockConnection);
+ MessageImpl<?> testMessage = TestMessageImpl.createNewMessage(_mockSession, _mockConnection);
testMessage.setLongProperty(JMS_AMQP_TTL, ttlPropValue);
//send the message with a different TTL
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TestMessageImpl.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TestMessageImpl.java?rev=1563934&r1=1563933&r2=1563934&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TestMessageImpl.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TestMessageImpl.java Mon Feb 3 14:49:43 2014
@@ -2,20 +2,21 @@ package org.apache.qpid.jms.impl;
import javax.jms.Destination;
+import org.apache.qpid.jms.engine.AmqpMessage;
import org.apache.qpid.jms.engine.TestAmqpMessage;
public class TestMessageImpl extends MessageImpl<TestAmqpMessage>
{
//message to be sent
- public TestMessageImpl(TestAmqpMessage amqpMessage, SessionImpl sessionImpl, ConnectionImpl connectionImpl)
+ private TestMessageImpl(TestAmqpMessage amqpMessage, SessionImpl sessionImpl, ConnectionImpl connectionImpl)
{
super(amqpMessage, sessionImpl, connectionImpl);
}
- //message just recieved
- public TestMessageImpl(TestAmqpMessage amqpMessage, SessionImpl sessionImpl, ConnectionImpl connectionImpl, Destination consumerDestination)
+ //message just received
+ private TestMessageImpl(TestAmqpMessage amqpMessage, SessionImpl sessionImpl, ConnectionImpl connectionImpl, Destination consumerDestination)
{
- super(amqpMessage, sessionImpl, connectionImpl, null);
+ super(amqpMessage, sessionImpl, connectionImpl, consumerDestination);
}
@Override
@@ -24,4 +25,32 @@ public class TestMessageImpl extends Mes
//NO-OP
return amqpMessage;
}
+
+
+ public static MessageImpl<TestAmqpMessage> createNewMessage(SessionImpl sessionImpl, ConnectionImpl connectionImpl)
+ {
+ TestAmqpMessage testAmqpMessage = (TestAmqpMessage) TestAmqpMessage.createNewMessage();
+
+ return new TestMessageImpl(testAmqpMessage, sessionImpl, connectionImpl);
+ }
+
+ public static MessageImpl<TestAmqpMessage> createNewMessage(AmqpMessage amqpMessage, SessionImpl sessionImpl, ConnectionImpl connectionImpl)
+ {
+ if(!(amqpMessage instanceof TestAmqpMessage))
+ {
+ throw new IllegalArgumentException("AmqpMessage must be an instance of " + TestAmqpMessage.class.getName());
+ }
+
+ return new TestMessageImpl((TestAmqpMessage) amqpMessage, sessionImpl, connectionImpl);
+ }
+
+ public static MessageImpl<TestAmqpMessage> createReceivedMessage(AmqpMessage amqpMessage, SessionImpl sessionImpl, ConnectionImpl connectionImpl, Destination consumerDestination)
+ {
+ if(!(amqpMessage instanceof TestAmqpMessage))
+ {
+ throw new IllegalArgumentException("AmqpMessage must be an instance of " + TestAmqpMessage.class.getName());
+ }
+
+ return new TestMessageImpl((TestAmqpMessage) amqpMessage, sessionImpl, connectionImpl, consumerDestination);
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org