throw JMS IllegalStateException when trying to create connection without giving any remoteURI
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/48e0708b Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/48e0708b Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/48e0708b Branch: refs/heads/master Commit: 48e0708b71e83189d53207d81cac57e38f8f9a50 Parents: 2afe8f7 Author: Robert Gemmell <[email protected]> Authored: Tue Jan 27 13:13:43 2015 +0000 Committer: Robert Gemmell <[email protected]> Committed: Tue Jan 27 14:42:04 2015 +0000 ---------------------------------------------------------------------- .../java/org/apache/qpid/jms/JmsConnectionFactory.java | 5 +++++ .../org/apache/qpid/jms/JmsConnectionFactoryTest.java | 13 +++++++++++++ 2 files changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/48e0708b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java index 55e8360..f2b2337 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java @@ -23,6 +23,7 @@ import java.util.Map; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.ExceptionListener; +import javax.jms.IllegalStateException; import javax.jms.JMSException; import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; @@ -247,6 +248,10 @@ public class JmsConnectionFactory extends JNDIStorable implements ConnectionFact } protected Provider createProvider(URI remoteURI) throws Exception { + if(remoteURI == null) { + throw new IllegalStateException("No remoteURI has been provided"); + } + Provider result = null; try { http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/48e0708b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java index 46cf305..a99eaae 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java @@ -28,6 +28,8 @@ import static org.junit.Assert.fail; import java.util.HashMap; import java.util.Map; +import javax.jms.IllegalStateException; + import org.apache.qpid.jms.test.QpidJmsTestCase; import org.junit.Test; @@ -37,6 +39,17 @@ public class JmsConnectionFactoryTest extends QpidJmsTestCase { private static String QUEUE_PREFIX_PROP = "queuePrefix"; @Test + public void testCreateConnectionWithoutUriThrowsJMSISE() throws Exception { + JmsConnectionFactory cf = new JmsConnectionFactory(); + try { + cf.createConnection(); + fail("Should have thrown exception"); + } catch (IllegalStateException jmsise){ + // expected + } + } + + @Test public void testSetProperties() throws Exception { String clientID = getTestName(); String queuePrefix = "q:"; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
