activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r453380 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/vm/VMTransportFactory.java test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
Date Thu, 05 Oct 2006 21:05:52 GMT
Author: chirino
Date: Thu Oct  5 14:05:52 2006
New Revision: 453380

URL: http://svn.apache.org/viewvc?view=rev&rev=453380
Log:
http://issues.apache.org/activemq/browse/AMQ-958

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java?view=diff&rev=453380&r1=453379&r2=453380
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
Thu Oct  5 14:05:52 2006
@@ -56,6 +56,7 @@
         URI brokerURI;
         String host;
         Map options;
+        boolean create=true;
         CompositeData data=URISupport.parseComposite(location);
         if(data.getComponents().length==1&&"broker".equals(data.getComponents()[0].getScheme())){
             brokerURI=data.getComponents()[0];
@@ -79,6 +80,9 @@
                     Map brokerOptions=IntrospectionSupport.extractProperties(options,"broker.");
                     brokerURI=new URI("broker://()/"+host+"?"+URISupport.createQueryString(brokerOptions));
                 }
+                if( "false".equals(options.get("create")) ) {
+                	create=false;
+                }
             }catch(URISyntaxException e1){
                 throw IOExceptionSupport.create(e1);
             }
@@ -97,6 +101,9 @@
             synchronized( BrokerRegistry.getInstance().getRegistryMutext() ) {
                 broker=BrokerRegistry.getInstance().lookup(host);
                 if(broker==null){
+                	if( !create ) {
+                		throw new IOException("Broker named '"+host+"' does not exist.");
+                	}
                     try{
                         if(brokerFactoryHandler!=null){
                             broker=brokerFactoryHandler.createBroker(brokerURI);

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java?view=diff&rev=453380&r1=453379&r2=453380
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
Thu Oct  5 14:05:52 2006
@@ -97,7 +97,16 @@
     public void testCreateTcpConnectionUsingKnownPort() throws Exception {
         assertCreateConnection("tcp://localhost:61610?wireFormat.tcpNoDelayEnabled=true");
     }
-    
+
+    public void testConnectionFailsToConnectToVMBrokerThatIsNotRunning() throws Exception
{    	
+		ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?create=false");
+    	try {
+    		factory.createConnection();
+			fail("Expected connection failure.");
+		} catch (JMSException e) {
+		}
+    }
+
     protected void assertCreateConnection(String uri) throws Exception {
         // Start up a broker with a tcp connector.
         BrokerService broker = new BrokerService();



Mime
View raw message