Repository: qpid-jms Updated Branches: refs/heads/master a0f228bad -> a088d9980
Complete path coverage of destination transformation method. Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/4d3ea7a1 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/4d3ea7a1 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/4d3ea7a1 Branch: refs/heads/master Commit: 4d3ea7a1422bf710440f9a291832d05c7f871335 Parents: a0f228b Author: Timothy Bish <[email protected]> Authored: Wed Oct 15 09:43:04 2014 -0400 Committer: Timothy Bish <[email protected]> Committed: Wed Oct 15 09:43:04 2014 -0400 ---------------------------------------------------------------------- .../message/JmsMessageTransformationTest.java | 89 +++++++++++++++++--- 1 file changed, 76 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/4d3ea7a1/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessageTransformationTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessageTransformationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessageTransformationTest.java index 3904439..84c294f 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessageTransformationTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessageTransformationTest.java @@ -19,6 +19,7 @@ package org.apache.qpid.jms.message; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -51,6 +52,12 @@ public class JmsMessageTransformationTest { //---------- Test Destination Transformation -----------------------------// @Test + public void testTransformNullDestinationNoExceptions() throws JMSException { + JmsDestination transformed = JmsMessageTransformation.transformDestination(createMockJmsConnection(), null); + assertNull(transformed); + } + + @Test public void testPlainDestinationThrowsJMSEx() throws JMSException { ForeignDestination destination = new ForeignDestination(DESTINATION_NAME); try { @@ -71,6 +78,43 @@ public class JmsMessageTransformationTest { } @Test + public void testCompositeTopicAndQueueDestinationNoNameThrowsJMSEx() throws JMSException { + ForeignTopicAndQueue destination = new ForeignTopicAndQueue(DESTINATION_NAME); + destination.setReturnQueueName(false); + destination.setReturnTopicName(false); + + try { + JmsMessageTransformation.transformDestination(createMockJmsConnection(), destination); + fail("Should have thrown an JMSException"); + } catch (JMSException ex) { + } + } + + @Test + public void testTransformCompositeDestinationFromForeignTopic() throws JMSException { + ForeignTopicAndQueue destination = new ForeignTopicAndQueue(DESTINATION_NAME); + destination.setReturnQueueName(false); + + JmsDestination transformed = JmsMessageTransformation.transformDestination(createMockJmsConnection(), destination); + assertNotNull(transformed); + assertTrue(transformed.isTopic()); + assertFalse(transformed.isTemporary()); + assertEquals(DESTINATION_NAME, transformed.getName()); + } + + @Test + public void testTransformCompositeDestinationFromForeignQueue() throws JMSException { + ForeignTopicAndQueue destination = new ForeignTopicAndQueue(DESTINATION_NAME); + destination.setReturnTopicName(false); + + JmsDestination transformed = JmsMessageTransformation.transformDestination(createMockJmsConnection(), destination); + assertNotNull(transformed); + assertTrue(transformed.isQueue()); + assertFalse(transformed.isTemporary()); + assertEquals(DESTINATION_NAME, transformed.getName()); + } + + @Test public void testJmsDestinationIsNotTransformed() throws JMSException { JmsDestination destination = new JmsTopic(DESTINATION_NAME); JmsDestination transformed = JmsMessageTransformation.transformDestination(createMockJmsConnection(), destination); @@ -164,53 +208,72 @@ public class JmsMessageTransformationTest { } } - private class ForeignTopicAndQueue extends ForeignDestination implements Queue, Topic { + private class ForeignTemporaryQueue extends ForeignQueue implements TemporaryQueue { - public ForeignTopicAndQueue(String name) { + public ForeignTemporaryQueue(String name) { super(name); } @Override - public String getTopicName() throws JMSException { + public String getQueueName() throws JMSException { return name; } @Override - public String getQueueName() throws JMSException { - return name; + public void delete() throws JMSException { + } } - private class ForeignTemporaryQueue extends ForeignQueue implements TemporaryQueue { + private class ForeignTemporaryTopic extends ForeignTopic implements TemporaryTopic { - public ForeignTemporaryQueue(String name) { + public ForeignTemporaryTopic(String name) { super(name); } @Override - public String getQueueName() throws JMSException { + public String getTopicName() throws JMSException { return name; } @Override public void delete() throws JMSException { - } } - private class ForeignTemporaryTopic extends ForeignTopic implements TemporaryTopic { + private class ForeignTopicAndQueue extends ForeignDestination implements Queue, Topic { - public ForeignTemporaryTopic(String name) { + private boolean returnTopicName = true; + private boolean returnQueueName = true; + + public ForeignTopicAndQueue(String name) { super(name); } @Override public String getTopicName() throws JMSException { - return name; + if (returnTopicName) { + return name; + } + + return null; } @Override - public void delete() throws JMSException { + public String getQueueName() throws JMSException { + if (returnQueueName) { + return name; + } + + return null; + } + + public void setReturnTopicName(boolean returnTopicName) { + this.returnTopicName = returnTopicName; + } + + public void setReturnQueueName(boolean returnQueueName) { + this.returnQueueName = returnQueueName; } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
