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/10/07 12:26:55 UTC
[1/6] git commit: Update priority scaling to handle values above the
signed byte range. Change methods to use int so facades see original value,
contain any casting to within facade.
Repository: qpid-jms
Updated Branches:
refs/heads/master c311a4218 -> 4723c5a1f
Update priority scaling to handle values above the signed byte range. Change methods to use int so facades see original value, contain any casting to within facade.
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/5e237be5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/5e237be5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/5e237be5
Branch: refs/heads/master
Commit: 5e237be52d91909e489c6bed7296b90345779f2b
Parents: c311a42
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 7 10:16:45 2014 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 7 10:16:45 2014 +0100
----------------------------------------------------------------------
.../org/apache/qpid/jms/message/JmsMessage.java | 2 +-
.../jms/message/facade/JmsMessageFacade.java | 4 +--
.../amqp/message/AmqpJmsMessageFacade.java | 18 ++++++------
.../JmsMessagePropertyIntercepterTest.java | 8 +++---
.../defaults/JmsDefaultMessageFacade.java | 6 ++--
.../amqp/message/AmqpJmsMessageFacadeTest.java | 30 ++++++++++++++++----
6 files changed, 44 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5e237be5/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessage.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessage.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessage.java
index 122c3ab..54ff011 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessage.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessage.java
@@ -235,7 +235,7 @@ public class JmsMessage implements javax.jms.Message {
@Override
public void setJMSPriority(int priority) throws JMSException {
- facade.setPriority((byte) priority);
+ facade.setPriority(priority);
}
@Override
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5e237be5/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
index 3bbea29..01be4d6 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
@@ -296,7 +296,7 @@ public interface JmsMessageFacade {
*
* @return the priority value assigned to this message.
*/
- byte getPriority();
+ int getPriority();
/**
* Sets the message priority for this message using a JMS priority scoped value.
@@ -304,7 +304,7 @@ public interface JmsMessageFacade {
* @param priority
* the new priority value to set on this message.
*/
- void setPriority(byte priority);
+ void setPriority(int priority);
/**
* Returns the set expiration time for this message.
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5e237be5/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
index 07079c1..c05f159 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
@@ -548,16 +548,15 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
}
@Override
- public byte getPriority() {
+ public int getPriority() {
if (message.getHeader() != null) {
UnsignedByte priority = message.getHeader().getPriority();
if (priority != null) {
- byte scaled = priority.byteValue();
- if (scaled < 0) {
- scaled = 0;
- } else if (scaled > 9) {
+ int scaled = priority.intValue();
+ if (scaled > 9) {
scaled = 9;
}
+
return scaled;
}
}
@@ -566,7 +565,7 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
}
@Override
- public void setPriority(byte priority) {
+ public void setPriority(int priority) {
if (priority == DEFAULT_PRIORITY) {
if (message.getHeader() == null) {
return;
@@ -574,13 +573,14 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
message.getHeader().setPriority(null);
}
} else {
+ byte scaled = (byte) priority;
if (priority < 0) {
- priority = 0;
+ scaled = 0;
} else if (priority > 9) {
- priority = 9;
+ scaled = 9;
}
- message.setPriority(priority);
+ message.setPriority(scaled);
}
}
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5e237be5/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java
index d9ed2b3..e9ad243 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java
@@ -250,7 +250,7 @@ public class JmsMessagePropertyIntercepterTest {
@Test
public void testGetJMSPriorityWhenNotSet() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- Mockito.when(message.getPriority()).thenReturn((byte) 4);
+ Mockito.when(message.getPriority()).thenReturn(4);
assertEquals(4, JmsMessagePropertyIntercepter.getProperty(message, JMS_PRIORITY));
Mockito.verify(message).getPriority();
}
@@ -258,7 +258,7 @@ public class JmsMessagePropertyIntercepterTest {
@Test
public void testGetJMSPriorityWhenSet() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- Mockito.when(message.getPriority()).thenReturn((byte) 9);
+ Mockito.when(message.getPriority()).thenReturn(9);
assertEquals(9, JmsMessagePropertyIntercepter.getProperty(message, JMS_PRIORITY));
}
@@ -272,14 +272,14 @@ public class JmsMessagePropertyIntercepterTest {
@Test
public void testJMSPriorityInGetPropertyNamesWhenDefault() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- Mockito.when(message.getPriority()).thenReturn((byte) Message.DEFAULT_PRIORITY);
+ Mockito.when(message.getPriority()).thenReturn(Message.DEFAULT_PRIORITY);
assertTrue(JmsMessagePropertyIntercepter.getPropertyNames(message).contains(JMS_PRIORITY));
}
@Test
public void testJMSPriorityInGetPropertyNamesWhenNotDefault() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- Mockito.when(message.getPriority()).thenReturn((byte) 1);
+ Mockito.when(message.getPriority()).thenReturn(1);
assertTrue(JmsMessagePropertyIntercepter.getPropertyNames(message).contains(JMS_PRIORITY));
}
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5e237be5/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultMessageFacade.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultMessageFacade.java
index 31cca9e..2b03987 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultMessageFacade.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultMessageFacade.java
@@ -54,7 +54,7 @@ public class JmsDefaultMessageFacade implements JmsMessageFacade {
protected Map<String, Object> properties = new HashMap<String, Object>();
- protected byte priority = javax.jms.Message.DEFAULT_PRIORITY;
+ protected int priority = javax.jms.Message.DEFAULT_PRIORITY;
protected String groupId;
protected int groupSequence;
protected String messageId;
@@ -252,12 +252,12 @@ public class JmsDefaultMessageFacade implements JmsMessageFacade {
}
@Override
- public byte getPriority() {
+ public int getPriority() {
return priority;
}
@Override
- public void setPriority(byte priority) {
+ public void setPriority(int priority) {
if (priority < 0) {
this.priority = 0;
} else if (priority > 9) {
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5e237be5/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
index 4e0d2d4..f7ea02c 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
@@ -211,6 +211,8 @@ public class AmqpJmsMessageFacadeTest {
assertEquals("TTL has not been overriden", overrideTtl, message.getTtl());
}
+ // --- priority field ---
+
@Test
public void testGetPriorityIs4ForNewMessage() {
AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
@@ -230,8 +232,6 @@ public class AmqpJmsMessageFacadeTest {
assertEquals("expected priority value not found", 4, amqpMessageFacade.getPriority());
}
- // TODO: start of section marker
-
/**
* When messages have a header section, but lack the priority field,
* the AMQP spec says the priority has default value of 4.
@@ -267,11 +267,12 @@ public class AmqpJmsMessageFacadeTest {
}
/**
- * When messages have a header section, which have a priority value outside the JMS range, ensure it is constrained.
+ * When messages have a header section, which has a priority value just above the
+ * JMS range of 0-9, ensure it is constrained to 9.
*/
@Test
- public void testGetPriorityForReceivedMessageWithPriorityOutsideJmsRange() {
- // value over 9 deliberately
+ public void testGetPriorityForReceivedMessageWithPriorityJustAboveJmsRange() {
+ // value just over 9 deliberately
byte priority = 11;
Message message = Proton.message();
@@ -285,6 +286,25 @@ public class AmqpJmsMessageFacadeTest {
}
/**
+ * When messages have a header section, which has a priority value above the
+ * JMS range of 0-9 and also outside the signed byte range (given AMQP
+ * allowing ubyte priority), ensure it is constrained to 9.
+ */
+ @Test
+ public void testGetPriorityForReceivedMessageWithPriorityAboveSignedByteRange() {
+ String priorityString = String.valueOf(255);
+
+ Message message = Proton.message();
+ Header header = new Header();
+ message.setHeader(header);
+ header.setPriority(UnsignedByte.valueOf(priorityString));
+
+ AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);
+
+ assertEquals("expected priority value not found", 9, amqpMessageFacade.getPriority());
+ }
+
+ /**
* Test that setting the Priority to a non-default value results in the underlying
* message field being populated appropriately, and the value being returned from the Getter.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[5/6] git commit: add some tests for handling of Properties section
creation-time
Posted by ro...@apache.org.
add some tests for handling of Properties section creation-time
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/6d55ce2e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/6d55ce2e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/6d55ce2e
Branch: refs/heads/master
Commit: 6d55ce2e6454a705433eb3f08b869756dd3c3e7b
Parents: a3db689
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 7 10:56:01 2014 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 7 10:56:01 2014 +0100
----------------------------------------------------------------------
.../amqp/message/AmqpJmsMessageFacadeTest.java | 42 ++++++++++++++++++++
1 file changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6d55ce2e/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
index 7bd81e3..3a75d1a 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
@@ -749,6 +749,48 @@ public class AmqpJmsMessageFacadeTest {
assertEquals("Expected creation-time field to be set on new Properties section", new Date(expected), amqpMessageFacade.getAmqpMessage().getProperties().getCreationTime());
}
+ @Test
+ public void testGetTimestampIsZeroForNewMessage() {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ assertEquals("Expected no timestamp", 0, amqpMessageFacade.getTimestamp());
+ }
+
+ @Test
+ public void testSetTimestampOnNewMessage() {
+ Long timestamp = System.currentTimeMillis();
+
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ amqpMessageFacade.setTimestamp(timestamp);
+
+ assertEquals("Expected creation-time field to be set", timestamp.longValue(), amqpMessageFacade.getAmqpMessage().getProperties().getCreationTime().getTime());
+ assertEquals("Expected timestamp", timestamp.longValue(), amqpMessageFacade.getTimestamp());
+ }
+
+ @Test
+ public void testSetTimestampZeroOnNewMessageDoesNotCreatePropertiesSection() {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ amqpMessageFacade.setTimestamp(0);
+
+ assertNull("underlying message should have no properties section", amqpMessageFacade.getAmqpMessage().getProperties());
+ assertEquals("Timestamp should not be set", 0, amqpMessageFacade.getTimestamp());
+ }
+
+ @Test
+ public void testSetTimestampZeroOnMessageWithExistingTimestampClearsCreationTimeField() {
+ Long timestamp = System.currentTimeMillis();
+
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+ amqpMessageFacade.setTimestamp(timestamp);
+
+ amqpMessageFacade.setTimestamp(0);
+
+ assertNull("Expected creation-time to be null", amqpMessageFacade.getAmqpMessage().getProperties().getCreationTime());
+ assertEquals("Expected no timestamp", 0, amqpMessageFacade.getTimestamp());
+ }
+
// --- absolute-expiry-time field ---
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/6] git commit: enable ignored test now that functionality is
implemented
Posted by ro...@apache.org.
enable ignored test now that functionality is implemented
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/de71fe3d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/de71fe3d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/de71fe3d
Branch: refs/heads/master
Commit: de71fe3def15c1ee77466c72fa6d42aaff9b09d1
Parents: 96443b9
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 7 10:27:37 2014 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 7 10:36:26 2014 +0100
----------------------------------------------------------------------
.../org/apache/qpid/jms/integration/SenderIntegrationTest.java | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/de71fe3d/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java
index bff17fa..327c293 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java
@@ -326,8 +326,6 @@ public class SenderIntegrationTest extends QpidJmsTestCase {
* Test that when a message is sent with default priority of 4, the emitted AMQP message has no value in the header
* priority field, since the default for that field is already 4.
*/
- @Ignore
- // TODO: currently failing as we always populate the field
@Test(timeout = 10000)
public void testDefaultPriorityProducesMessagesWithoutPriorityField() throws Exception {
try (TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[3/6] git commit: add some more header priority tests
Posted by ro...@apache.org.
add some more header priority tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/96443b98
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/96443b98
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/96443b98
Branch: refs/heads/master
Commit: 96443b98d9831c33919cb78147458174fe05534e
Parents: 5e237be
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 7 10:27:09 2014 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 7 10:36:26 2014 +0100
----------------------------------------------------------------------
.../amqp/message/AmqpJmsMessageFacadeTest.java | 72 ++++++++++++++++++++
1 file changed, 72 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/96443b98/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
index f7ea02c..5978070 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
@@ -321,6 +321,78 @@ public class AmqpJmsMessageFacadeTest {
assertEquals("expected priority value not found", priority, underlying.getPriority());
}
+ /**
+ * Test that setting the Priority below the JMS range of 0-9 resuls in the underlying
+ * message field being populated with the value 0.
+ */
+ @Test
+ public void testSetPriorityBelowJmsRangeForNewMessage() {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+ amqpMessageFacade.setPriority(-1);
+
+ assertEquals("expected priority value not found", 0, amqpMessageFacade.getPriority());
+
+ Message underlying = amqpMessageFacade.getAmqpMessage();
+ assertEquals("expected priority value not found", 0, underlying.getPriority());
+ }
+
+ /**
+ * Test that setting the Priority above the JMS range of 0-9 resuls in the underlying
+ * message field being populated with the value 9.
+ */
+ @Test
+ public void testSetPriorityAboveJmsRangeForNewMessage() {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+ amqpMessageFacade.setPriority(11);
+
+ assertEquals("expected priority value not found", 9, amqpMessageFacade.getPriority());
+
+ Message underlying = amqpMessageFacade.getAmqpMessage();
+ assertEquals("expected priority value not found", 9, underlying.getPriority());
+ }
+
+ /**
+ * Test that setting the Priority to the default value on a message with no
+ * header section does not result in creating the header section.
+ */
+ @Test
+ public void testSetDefaultPriorityForMessageWithoutHeaderSection() {
+ // Using a received message as new messages to send are set durable by default, which creates the header
+ Message message = Proton.message();
+ AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);
+
+ assertNull("expected no header section to exist", message.getHeader());
+
+ amqpMessageFacade.setPriority(Message.DEFAULT_PRIORITY);
+
+ assertNull("expected no header section to exist", message.getHeader());
+ assertEquals("expected priority to be default", Message.DEFAULT_PRIORITY, amqpMessageFacade.getPriority());
+ }
+
+ /**
+ * Receive message which has a header section with a priority value. Ensure the headers
+ * underlying field value is cleared when the priority is set to the default priority of 4.
+ */
+ @Test
+ public void testSetPriorityToDefaultOnReceivedMessageWithPriorityClearsPriorityField() {
+ byte priority = 11;
+
+ Message message = Proton.message();
+ Header header = new Header();
+ message.setHeader(header);
+ header.setPriority(UnsignedByte.valueOf(priority));
+
+ AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);
+ amqpMessageFacade.setPriority(Message.DEFAULT_PRIORITY);
+
+ //check the expected value is still returned
+ assertEquals("expected priority value not returned", Message.DEFAULT_PRIORITY, amqpMessageFacade.getPriority());
+
+ //check the underlying header field was actually cleared rather than set to Message.DEFAULT_PRIORITY
+ Message underlying = amqpMessageFacade.getAmqpMessage();
+ assertNull("underlying header priority field was not cleared", underlying.getHeader().getPriority());
+ }
+
// ====== AMQP Properties Section =======
// ======================================
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[4/6] git commit: add some tests for handling of Properties section
absolute-expiry-time
Posted by ro...@apache.org.
add some tests for handling of Properties section absolute-expiry-time
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/a3db6896
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/a3db6896
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/a3db6896
Branch: refs/heads/master
Commit: a3db689624f1a0099f111bf53b3e4c29eb3f5d9d
Parents: de71fe3
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 7 10:55:03 2014 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 7 10:55:03 2014 +0100
----------------------------------------------------------------------
.../amqp/message/AmqpJmsMessageFacadeTest.java | 50 +++++++++++++++++++-
1 file changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a3db6896/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
index 5978070..7bd81e3 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
@@ -397,10 +397,11 @@ public class AmqpJmsMessageFacadeTest {
// ======================================
@Test
- public void testGetExpirationIsZeroForNewMessage() {
+ public void testNewMessageHasNoUnderlyingPropertiesSection() {
AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
- assertEquals("Expected no expiration", 0, amqpMessageFacade.getExpiration());
+ Message underlying = amqpMessageFacade.getAmqpMessage();
+ assertNull(underlying.getProperties());
}
// --- message-id and correlation-id ---
@@ -748,6 +749,51 @@ public class AmqpJmsMessageFacadeTest {
assertEquals("Expected creation-time field to be set on new Properties section", new Date(expected), amqpMessageFacade.getAmqpMessage().getProperties().getCreationTime());
}
+ // --- absolute-expiry-time field ---
+
+ @Test
+ public void testGetExpirationIsZeroForNewMessage() {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ assertEquals("Expected no expiration", 0, amqpMessageFacade.getExpiration());
+ }
+
+ @Test
+ public void testSetGetExpirationOnNewMessage() {
+ Long timestamp = System.currentTimeMillis();
+
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ amqpMessageFacade.setExpiration(timestamp);
+
+ assertEquals("Expected absolute-expiry-time to be set", timestamp.longValue(), amqpMessageFacade.getAmqpMessage().getProperties().getAbsoluteExpiryTime().getTime());
+ assertEquals("Expected expiration to be set", timestamp.longValue(), amqpMessageFacade.getExpiration());
+ }
+
+ @Test
+ public void testSetExpirationZeroOnNewMessageDoesNotCreatePropertiesSection() {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ assertNull("Expected properties section not to exist", amqpMessageFacade.getAmqpMessage().getProperties());
+
+ amqpMessageFacade.setExpiration(0);
+
+ assertNull("Expected properties section still not to exist", amqpMessageFacade.getAmqpMessage().getProperties());
+ }
+
+ @Test
+ public void testSetExpirationZeroOnMessageWithExistingExpiryTime() {
+ Long timestamp = System.currentTimeMillis();
+
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+ amqpMessageFacade.setExpiration(timestamp);
+
+ amqpMessageFacade.setExpiration(0);
+
+ assertNull("Expected absolute-expiry-time to be null", amqpMessageFacade.getAmqpMessage().getProperties().getAbsoluteExpiryTime());
+ assertEquals("Expected no expiration", 0, amqpMessageFacade.getExpiration());
+ }
+
// ====== AMQP Message Facade copy() tests =======
// ===============================================
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[6/6] git commit: add some tests for handling of Properties section
group-id and reply-to-group-id
Posted by ro...@apache.org.
add some tests for handling of Properties section group-id and reply-to-group-id
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/4723c5a1
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/4723c5a1
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/4723c5a1
Branch: refs/heads/master
Commit: 4723c5a1f56fd536d44eb5f34bb127cdf2c929db
Parents: 6d55ce2
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 7 11:18:48 2014 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 7 11:18:48 2014 +0100
----------------------------------------------------------------------
.../amqp/message/AmqpJmsMessageFacadeTest.java | 181 +++++++++++++++++++
1 file changed, 181 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/4723c5a1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
index 3a75d1a..fe3ab20 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
@@ -404,6 +404,187 @@ public class AmqpJmsMessageFacadeTest {
assertNull(underlying.getProperties());
}
+ // --- group-id field ---
+
+ @Test
+ public void testGetGroupIdIsNullForNewMessage()
+ {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ assertNull("expected GroupId to be null on new message", amqpMessageFacade.getGroupId());
+ }
+
+ /**
+ * Check that setting GroupId null on a new message does not cause creation of the underlying properties
+ * section. New messages lack the properties section section,
+ * as tested by {@link #testNewMessageHasNoUnderlyingPropertiesSection()}.
+ */
+ @Test
+ public void testSetGroupIdNullOnNewMessageDoesNotCreatePropertiesSection() throws Exception
+ {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ amqpMessageFacade.setGroupId(null);
+
+ assertNull("properties section was created", amqpMessageFacade.getAmqpMessage().getProperties());
+ }
+
+ /**
+ * Check that setting GroupId on the message causes creation of the underlying properties
+ * section with the expected value. New messages lack the properties section section,
+ * as tested by {@link #testNewMessageHasNoUnderlyingPropertiesSection()}.
+ */
+ @Test
+ public void testSetGroupIdOnNewMessage() throws Exception
+ {
+ String groupId = "testValue";
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ amqpMessageFacade.setGroupId(groupId);
+
+ assertNotNull("properties section was not created", amqpMessageFacade.getAmqpMessage().getProperties());
+ assertEquals("value was not set for GroupId as expected", groupId, amqpMessageFacade.getAmqpMessage().getProperties().getGroupId());
+
+ assertEquals("value was not set for GroupId as expected", groupId, amqpMessageFacade.getGroupId());
+ }
+
+ /**
+ * Check that setting UserId null on the message causes any existing value to be cleared
+ */
+ @Test
+ public void testSetGroupIdNullOnMessageWithExistingGroupId() throws Exception
+ {
+ String groupId = "testValue";
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ amqpMessageFacade.setGroupId(groupId);
+ amqpMessageFacade.setGroupId(null);
+
+ assertNull("value was not cleared for GroupId as expected", amqpMessageFacade.getAmqpMessage().getProperties().getGroupId());
+ assertNull("value was not cleared for GroupId as expected", amqpMessageFacade.getGroupId());
+ }
+
+ // --- reply-to-group-id field ---
+
+ /**
+ * Check that setting the ReplyToGroupId works on new messages without a properties
+ * properties section. New messages lack the properties section,
+ * as tested by {@link #testNewMessageHasNoUnderlyingPropertiesSection()}.
+ */
+ @Test
+ public void testGetReplyToGroupIdIsNullForNewMessage()
+ {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ assertNull("expected ReplyToGroupId to be null on new message", amqpMessageFacade.getReplyToGroupId());
+ }
+
+ /**
+ * Check that getting the ReplyToGroupId works on received messages without a properties section
+ */
+ @Test
+ public void testGetReplyToGroupIdWithReceivedMessageWithNoProperties()
+ {
+ Message message = Proton.message();
+ AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);
+
+ String replyToGroupId = amqpMessageFacade.getReplyToGroupId();
+ assertNull("expected ReplyToGroupId to be null on message without properties section", replyToGroupId);
+ }
+
+ /**
+ * Check that setting ReplyToGroupId null on a new message does not cause creation of the
+ * underlying properties section. New messages lack the properties section,
+ * as tested by {@link #testNewMessageHasNoUnderlyingPropertiesSection()}.
+ */
+ @Test
+ public void testSetReplyToGroupIdNullOnNewMessageDoesNotCreatePropertiesSection() throws Exception
+ {
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ amqpMessageFacade.setReplyToGroupId(null);
+
+ assertNull("properties section was created", amqpMessageFacade.getAmqpMessage().getProperties());
+ }
+
+ /**
+ * Check that getting the ReplyToGroupId works on received messages with a
+ * properties section, but no reply-to-group-id
+ */
+ @Test
+ public void testGetReplyToGroupIdWithReceivedMessageWithPropertiesButNoReplyToGroupId()
+ {
+ Message message = Proton.message();
+
+ Properties props = new Properties();
+ props.setContentType(Symbol.valueOf("content-type"));
+ message.setProperties(props);
+
+ AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);
+
+ String replyToGroupId = amqpMessageFacade.getReplyToGroupId();
+ assertNull("expected ReplyToGroupId to be null on message with properties section but no reply-to-group-id", replyToGroupId);
+ }
+
+ /**
+ * Check that getting the ReplyToGroupId returns the expected value from a
+ * received messages with a reply-to-group-id.
+ */
+ @Test
+ public void testGetReplyToGroupIdWithReceivedMessage()
+ {
+ String replyToGroupId = "myReplyGroup";
+
+ Message message = Proton.message();
+
+ Properties props = new Properties();
+ props.setReplyToGroupId(replyToGroupId);
+ message.setProperties(props);
+
+ AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);
+
+ String actual = amqpMessageFacade.getReplyToGroupId();
+ assertNotNull("expected ReplyToGroupId on message was not found", actual);
+ assertEquals("expected ReplyToGroupId on message was not found", replyToGroupId, actual);
+ }
+
+ /**
+ * Test that setting the ReplyToGroupId sets the expected value into the
+ * reply-to-group-id of the underlying proton message.
+ */
+ @Test
+ public void testSetReplyToGroupId()
+ {
+ String replyToGroupId = "myReplyGroup";
+
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ Message underlyingMessage = amqpMessageFacade.getAmqpMessage();
+
+ amqpMessageFacade.setReplyToGroupId(replyToGroupId);
+
+ assertNotNull("expected ReplyToGroupId on message was not found", underlyingMessage.getReplyToGroupId());
+ assertEquals("expected ReplyToGroupId on message was not found", replyToGroupId, underlyingMessage.getReplyToGroupId());
+ }
+
+ /**
+ * Test that setting and getting the ReplyToGroupId yields the expected result
+ */
+ @Test
+ public void testSetGetReplyToGroupId()
+ {
+ String replyToGroupId = "myReplyGroup";
+
+ AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+ assertNull(amqpMessageFacade.getReplyToGroupId());
+
+ amqpMessageFacade.setReplyToGroupId(replyToGroupId);
+
+ assertNotNull("expected ReplyToGroupId on message was not found", amqpMessageFacade.getReplyToGroupId());
+ assertEquals("expected ReplyToGroupId on message was not found", replyToGroupId, amqpMessageFacade.getReplyToGroupId());
+ }
+
// --- message-id and correlation-id ---
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org