Add tests for the default cases when doing a Get Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/52e02b69 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/52e02b69 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/52e02b69
Branch: refs/heads/master Commit: 52e02b692c71e642adc0a90a4c77f45612f88c5e Parents: bb6959d Author: Timothy Bish <tabish...@gmail.com> Authored: Mon Sep 29 11:22:53 2014 -0400 Committer: Timothy Bish <tabish...@gmail.com> Committed: Mon Sep 29 11:22:53 2014 -0400 ---------------------------------------------------------------------- .../JmsMessagePropertyIntercepterTest.java | 106 +++++++++++++++++++ 1 file changed, 106 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/52e02b69/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 535d203..63252c6 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 @@ -30,11 +30,16 @@ import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_REDELIVERED; import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_REPLYTO; import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_TIMESTAMP; import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_TYPE; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import javax.jms.JMSException; +import org.apache.qpid.jms.message.facade.JmsMessageFacade; import org.junit.Test; +import org.mockito.Mockito; public class JmsMessagePropertyIntercepterTest { @@ -45,6 +50,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_DESTINATION)); } + @Test + public void testGetJMSDestinationWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertNull(JmsMessagePropertyIntercepter.getProperty(message, JMS_DESTINATION)); + Mockito.verify(message).getDestination(); + } + //---------- JMSReplyTo --------------------------------------------------// @Test @@ -52,6 +64,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_REPLYTO)); } + @Test + public void testGetJMSReplyToWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertNull(JmsMessagePropertyIntercepter.getProperty(message, JMS_REPLYTO)); + Mockito.verify(message).getReplyTo(); + } + //---------- JMSType -----------------------------------------------------// @Test @@ -59,6 +78,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_TYPE)); } + @Test + public void testGetJMSTypeWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertNull(JmsMessagePropertyIntercepter.getProperty(message, JMS_TYPE)); + Mockito.verify(message).getType(); + } + //---------- JMSDeliveryMode ---------------------------------------------// @Test @@ -66,6 +92,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_DELIVERY_MODE)); } + @Test + public void testGetJMSDeliveryModeWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertEquals("NON_PERSISTENT", JmsMessagePropertyIntercepter.getProperty(message, JMS_DELIVERY_MODE)); + Mockito.verify(message).isPersistent(); + } + //---------- JMSPriority ---------------------------------------------// @Test @@ -73,6 +106,14 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_PRIORITY)); } + @Test + public void testGetJMSPriorityWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + Mockito.when(message.getPriority()).thenReturn((byte) 4); + assertEquals(4, JmsMessagePropertyIntercepter.getProperty(message, JMS_PRIORITY)); + Mockito.verify(message).getPriority(); + } + //---------- JMSMessageID ---------------------------------------------// @Test @@ -80,6 +121,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_MESSAGEID)); } + @Test + public void testGetJMSMessageIdWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertNull(JmsMessagePropertyIntercepter.getProperty(message, JMS_MESSAGEID)); + Mockito.verify(message).getMessageId(); + } + //---------- JMSTimestamp ---------------------------------------------// @Test @@ -87,6 +135,14 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_TIMESTAMP)); } + @Test + public void testGetJMSTimeStampWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + Mockito.when(message.getTimestamp()).thenReturn(0L); + assertEquals(Long.valueOf(0L), JmsMessagePropertyIntercepter.getProperty(message, JMS_TIMESTAMP)); + Mockito.verify(message).getTimestamp(); + } + //---------- JMSCorrelationID ---------------------------------------------// @Test @@ -94,6 +150,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_CORRELATIONID)); } + @Test + public void testGetJMSCorrelationIdWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertNull(JmsMessagePropertyIntercepter.getProperty(message, JMS_CORRELATIONID)); + Mockito.verify(message).getCorrelationId(); + } + //---------- JMSExpiration ---------------------------------------------// @Test @@ -101,6 +164,14 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_EXPIRATION)); } + @Test + public void testGetJMSExpirationWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + Mockito.when(message.getExpiration()).thenReturn(0L); + assertEquals(Long.valueOf(0L), JmsMessagePropertyIntercepter.getProperty(message, JMS_EXPIRATION)); + Mockito.verify(message).getExpiration(); + } + //---------- JMSRedelivered ---------------------------------------------// @Test @@ -108,6 +179,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_REDELIVERED)); } + @Test + public void testGetJMSRedeliveredWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertFalse((Boolean) JmsMessagePropertyIntercepter.getProperty(message, JMS_REDELIVERED)); + Mockito.verify(message).isRedelivered(); + } + //---------- JMSXGroupID ---------------------------------------------// @Test @@ -115,6 +193,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMSX_GROUPID)); } + @Test + public void testGetJMSXGroupIdWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertNull(JmsMessagePropertyIntercepter.getProperty(message, JMSX_GROUPID)); + Mockito.verify(message).getGroupId(); + } + //---------- JMSXGroupSeq ---------------------------------------------// @Test @@ -122,6 +207,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMSX_GROUPSEQ)); } + @Test + public void testGetJMSXGroupSeqWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertEquals(Integer.valueOf(0), JmsMessagePropertyIntercepter.getProperty(message, JMSX_GROUPSEQ)); + Mockito.verify(message).getGroupSequence(); + } + //---------- JMSXDeliveryCount ---------------------------------------------// @Test @@ -129,6 +221,13 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMSX_DELIVERY_COUNT)); } + @Test + public void testGetJMSXDeliveryCountWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertEquals(Integer.valueOf(1), JmsMessagePropertyIntercepter.getProperty(message, JMSX_DELIVERY_COUNT)); + Mockito.verify(message).getRedeliveryCounter(); + } + //---------- JMSXUserID ---------------------------------------------// @Test @@ -136,4 +235,11 @@ public class JmsMessagePropertyIntercepterTest { assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMSX_USERID)); } + @Test + public void testGetJMSXUserIdWhenNotSet() throws JMSException { + JmsMessageFacade message = Mockito.mock(JmsMessageFacade.class); + assertNull(JmsMessagePropertyIntercepter.getProperty(message, JMSX_USERID)); + Mockito.verify(message).getUserId(); + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org