You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2014/10/10 00:57:34 UTC
git commit: Fix issue when setting delivery mode from string,
add more tests to cover.
Repository: qpid-jms
Updated Branches:
refs/heads/master 80807b34d -> e85c74b46
Fix issue when setting delivery mode from string, add more tests to
cover.
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/e85c74b4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/e85c74b4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/e85c74b4
Branch: refs/heads/master
Commit: e85c74b4698efcdbc55cf8e6952e1e9e34ca6f72
Parents: 80807b3
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Oct 9 18:57:26 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Oct 9 18:57:26 2014 -0400
----------------------------------------------------------------------
.../message/JmsMessagePropertyIntercepter.java | 46 +--
.../JmsMessagePropertyIntercepterTest.java | 363 +++++++++++++++++--
2 files changed, 365 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e85c74b4/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
index 3a4b940..63b6d24 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
@@ -112,26 +112,6 @@ public class JmsMessagePropertyIntercepter {
STANDARD_HEADERS.add(JMS_EXPIRATION);
STANDARD_HEADERS.add(JMS_PRIORITY);
- PROPERTY_INTERCEPTERS.put(JMSX_DELIVERY_COUNT, new PropertyIntercepter() {
- @Override
- public void setProperty(JmsMessageFacade message, Object value) throws JMSException {
- Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
- if (rc == null) {
- throw new JMSException("Property JMSXDeliveryCount cannot be set from a " + value.getClass().getName() + ".");
- }
- message.setDeliveryCount(rc.intValue());
- }
-
- @Override
- public Object getProperty(JmsMessageFacade message) throws JMSException {
- return Integer.valueOf(message.getDeliveryCount());
- }
-
- @Override
- public boolean propertyExists(JmsMessageFacade message) {
- return true;
- }
- });
PROPERTY_INTERCEPTERS.put(JMS_DESTINATION, new PropertyIntercepter() {
@Override
public void setProperty(JmsMessageFacade message, Object value) throws JMSException {
@@ -216,10 +196,12 @@ public class JmsMessagePropertyIntercepter {
rc = DeliveryMode.PERSISTENT;
} else if (((String) value).equalsIgnoreCase("NON_PERSISTENT")) {
rc = DeliveryMode.NON_PERSISTENT;
- } else {
- throw nfe;
}
}
+
+ if (rc == null) {
+ throw nfe;
+ }
}
if (rc == null) {
Boolean bool = (Boolean) TypeConversionSupport.convert(value, Boolean.class);
@@ -361,6 +343,26 @@ public class JmsMessagePropertyIntercepter {
return message.isRedelivered();
}
});
+ PROPERTY_INTERCEPTERS.put(JMSX_DELIVERY_COUNT, new PropertyIntercepter() {
+ @Override
+ public void setProperty(JmsMessageFacade message, Object value) throws JMSException {
+ Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
+ if (rc == null) {
+ throw new JMSException("Property JMSXDeliveryCount cannot be set from a " + value.getClass().getName() + ".");
+ }
+ message.setDeliveryCount(rc.intValue());
+ }
+
+ @Override
+ public Object getProperty(JmsMessageFacade message) throws JMSException {
+ return Integer.valueOf(message.getDeliveryCount());
+ }
+
+ @Override
+ public boolean propertyExists(JmsMessageFacade message) {
+ return true;
+ }
+ });
PROPERTY_INTERCEPTERS.put(JMSX_GROUPID, new PropertyIntercepter() {
@Override
public Object getProperty(JmsMessageFacade message) throws JMSException {
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e85c74b4/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 ee1b7b1..9d088aa 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
@@ -133,6 +133,31 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMS_DESTINATION));
}
+ @Test
+ public void testJMSDestinationPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ JmsDestination queue = new JmsQueue("TestDestination");
+ Mockito.when(message.getDestination()).thenReturn(queue);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_DESTINATION));
+ }
+
+ @Test
+ public void testJMSDestinationPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getDestination()).thenReturn(null);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMS_DESTINATION));
+ }
+
+ @Test
+ public void testSetJMSDestinationConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_DESTINATION, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSReplyTo --------------------------------------------------//
@Test
@@ -190,6 +215,31 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMS_REPLYTO));
}
+ @Test
+ public void testJMSReplyToPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ JmsDestination queue = new JmsQueue("TestDestination");
+ Mockito.when(message.getReplyTo()).thenReturn(queue);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_REPLYTO));
+ }
+
+ @Test
+ public void testJMSReplyToPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getReplyTo()).thenReturn(null);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMS_REPLYTO));
+ }
+
+ @Test
+ public void testSetJMSReplyToConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_REPLYTO, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSType -----------------------------------------------------//
@Test
@@ -244,6 +294,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMS_TYPE));
}
+ @Test
+ public void testJMSTypePropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getType()).thenReturn("SomeType");
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_TYPE));
+ }
+
+ @Test
+ public void testJMSTypePropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getType()).thenReturn(null);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMS_TYPE));
+ }
+
+ @Test
+ public void testSetJMSTypeConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_TYPE, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSDeliveryMode ---------------------------------------------//
@Test
@@ -316,6 +390,35 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, true).contains(JMS_DELIVERY_MODE));
}
+ @Test
+ public void testJMSDeliveryModePropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.isPersistent()).thenReturn(true);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_DELIVERY_MODE));
+ }
+
+ @Test
+ public void testJMSDeliveryModePropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.isPersistent()).thenReturn(false);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_DELIVERY_MODE));
+ }
+
+ @Test
+ public void testSetJMSDeliveryModeConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_DELIVERY_MODE, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_DELIVERY_MODE, "SOMETHING");
+ fail("Should have thrown an exception for this call");
+ } catch (NumberFormatException e) {
+ }
+ }
+
//---------- JMSPriority ---------------------------------------------//
@Test
@@ -366,6 +469,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, true).contains(JMS_PRIORITY));
}
+ @Test
+ public void testJMSPriorityPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getPriority()).thenReturn(1);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_PRIORITY));
+ }
+
+ @Test
+ public void testJMSPriorityPropertExistsWhenSetToDefault() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getPriority()).thenReturn(4);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_PRIORITY));
+ }
+
+ @Test
+ public void testSetJMSPriorityConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_PRIORITY, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSMessageID ---------------------------------------------//
@Test
@@ -420,6 +547,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMS_MESSAGEID));
}
+ @Test
+ public void testJMSMessageIDPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getMessageId()).thenReturn("MESSAGE_ID");
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_MESSAGEID));
+ }
+
+ @Test
+ public void testJMSMessageIDPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getMessageId()).thenReturn(null);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMS_MESSAGEID));
+ }
+
+ @Test
+ public void testSetJMSMessageIDConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_MESSAGEID, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSTimestamp ---------------------------------------------//
@Test
@@ -475,6 +626,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMS_TIMESTAMP));
}
+ @Test
+ public void testJMSTimestampPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getTimestamp()).thenReturn(900L);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_TIMESTAMP));
+ }
+
+ @Test
+ public void testJMSTimestampPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getTimestamp()).thenReturn(0L);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMS_TIMESTAMP));
+ }
+
+ @Test
+ public void testSetJMSTimestampConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_TIMESTAMP, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSCorrelationID ---------------------------------------------//
@Test
@@ -529,6 +704,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMS_CORRELATIONID));
}
+ @Test
+ public void testJMSCorrelationIDPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getCorrelationId()).thenReturn("MESSAGE_ID");
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_CORRELATIONID));
+ }
+
+ @Test
+ public void testJMSCorrelationIDPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getCorrelationId()).thenReturn(null);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMS_CORRELATIONID));
+ }
+
+ @Test
+ public void testSetJMSCorrelationIDConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_CORRELATIONID, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSExpiration ---------------------------------------------//
@Test
@@ -584,6 +783,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMS_EXPIRATION));
}
+ @Test
+ public void testJMSExpirationPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getExpiration()).thenReturn(900L);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_EXPIRATION));
+ }
+
+ @Test
+ public void testJMSExpirationPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getExpiration()).thenReturn(0L);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMS_EXPIRATION));
+ }
+
+ @Test
+ public void testSetJMSExpirationConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_EXPIRATION, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSRedelivered ---------------------------------------------//
@Test
@@ -648,6 +871,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMS_REDELIVERED));
}
+ @Test
+ public void testJMSRedeliveredPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.isRedelivered()).thenReturn(true);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMS_REDELIVERED));
+ }
+
+ @Test
+ public void testJMSRedeliveredPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.isRedelivered()).thenReturn(false);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMS_REDELIVERED));
+ }
+
+ @Test
+ public void testSetJMSRedeliveredConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMS_REDELIVERED, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSXGroupID ---------------------------------------------//
@Test
@@ -691,6 +938,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMSX_GROUPID));
}
+ @Test
+ public void testJMSXGroupIDPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getGroupId()).thenReturn("GROUP_ID");
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_GROUPID));
+ }
+
+ @Test
+ public void testJMSXGroupIDPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getGroupId()).thenReturn(null);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_GROUPID));
+ }
+
+ @Test
+ public void testSetJMSXGroupIDConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMSX_GROUPID, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSXGroupSeq ---------------------------------------------//
@Test
@@ -734,6 +1005,30 @@ public class JmsMessagePropertyIntercepterTest {
assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMSX_GROUPSEQ));
}
+ @Test
+ public void testJMSXGroupSeqPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getGroupSequence()).thenReturn(5);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_GROUPSEQ));
+ }
+
+ @Test
+ public void testJMSXGroupSeqPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getGroupSequence()).thenReturn(0);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_GROUPSEQ));
+ }
+
+ @Test
+ public void testSetJMSXGroupSeqConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMSX_GROUPSEQ, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSXDeliveryCount ---------------------------------------------//
@Test
@@ -777,6 +1072,30 @@ public class JmsMessagePropertyIntercepterTest {
assertTrue(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMSX_DELIVERY_COUNT));
}
+ @Test
+ public void testJMSXDeliveryCountPropertExistsWhenSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getDeliveryCount()).thenReturn(5);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_DELIVERY_COUNT));
+ }
+
+ @Test
+ public void testJMSXDeliveryCountPropertExistsWhenNotSet() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ Mockito.when(message.getDeliveryCount()).thenReturn(0);
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_DELIVERY_COUNT));
+ }
+
+ @Test
+ public void testSetJMSXDeliverCountConversionChecks() throws JMSException {
+ JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMSX_DELIVERY_COUNT, new byte[1]);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
+ }
+
//---------- JMSXUserID ---------------------------------------------//
@Test
@@ -810,48 +1129,48 @@ public class JmsMessagePropertyIntercepterTest {
}
@Test
- public void testJMSXUserIdPropertExistsWhenSet() throws JMSException {
+ public void testSetJMSXUserId() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- Mockito.when(message.getUserId()).thenReturn("Administrator");
- assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_USERID));
+ JmsMessagePropertyIntercepter.setProperty(message, JMSX_USERID, "Administrator");
+ Mockito.verify(message).setUserId("Administrator");
}
@Test
- public void testJMSXUserIdPropertExistsWhenNotSet() throws JMSException {
+ public void testJMSXUserIdCountInGetPropertyNamesWhenSet() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- Mockito.when(message.getUserId()).thenReturn(null);
- assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_USERID));
+ Mockito.when(message.getUserId()).thenReturn("Administrator");
+ assertTrue(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMSX_USERID));
+ assertTrue(JMSX_USERID + " is not a header and should be included",
+ JmsMessagePropertyIntercepter.getPropertyNames(message, true).contains(JMSX_USERID));
}
@Test
- public void testSetJMSXUserId() throws JMSException {
+ public void testJMSXUserIdNotInGetPropertyNamesWhenNotSet() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- JmsMessagePropertyIntercepter.setProperty(message, JMSX_USERID, "Administrator");
- Mockito.verify(message).setUserId("Administrator");
+ assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMSX_USERID));
}
@Test
- public void testSetJMSXUserIdConversionChecks() throws JMSException {
+ public void testJMSXUserIdPropertExistsWhenSet() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- try {
- JmsMessagePropertyIntercepter.setProperty(message, JMSX_USERID, true);
- fail("Cannot set user ID from int value.");
- } catch (JMSException e) {
- }
+ Mockito.when(message.getUserId()).thenReturn("Administrator");
+ assertTrue(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_USERID));
}
@Test
- public void testJMSXUserIdCountInGetPropertyNamesWhenSet() throws JMSException {
+ public void testJMSXUserIdPropertExistsWhenNotSet() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- Mockito.when(message.getUserId()).thenReturn("Administrator");
- assertTrue(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMSX_USERID));
- assertTrue(JMSX_USERID + " is not a header and should be included",
- JmsMessagePropertyIntercepter.getPropertyNames(message, true).contains(JMSX_USERID));
+ Mockito.when(message.getUserId()).thenReturn(null);
+ assertFalse(JmsMessagePropertyIntercepter.propertyExists(message, JMSX_USERID));
}
@Test
- public void testJMSXUserIdNotInGetPropertyNamesWhenNotSet() throws JMSException {
+ public void testSetJMSXUserIdConversionChecks() throws JMSException {
JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class);
- assertFalse(JmsMessagePropertyIntercepter.getPropertyNames(message, false).contains(JMSX_USERID));
+ try {
+ JmsMessagePropertyIntercepter.setProperty(message, JMSX_USERID, true);
+ fail("Should have thrown an exception for this call");
+ } catch (JMSException e) {
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org