Author: jstrachan
Date: Mon Jan 30 08:59:01 2006
New Revision: 373548

URL: http://svn.apache.org/viewcvs?rev=373548&view=rev
Log:
patch and test case for AMQ-514 to make BrokerInfo and the broker name visible 
to an ActiveMQConnection

Modified:
    
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.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/ActiveMQConnection.java
URL: 
http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java?rev=373548&r1=373547&r2=373548&view=diff
==============================================================================
--- 
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
 (original)
+++ 
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
 Mon Jan 30 08:59:01 2006
@@ -1215,6 +1215,23 @@
     }
 
     /**
+     * Returns the broker name if one is available or null if one is not 
available yet.
+     */
+    public String getBrokerName() {
+        if (brokerInfo == null) {
+            return null;
+        }
+        return brokerInfo.getBrokerName();
+    }
+   
+    /**
+     * Returns the broker information if it is available or null if it is not 
available yet.
+     */
+    public BrokerInfo getBrokerInfo() {
+        return brokerInfo;
+    }
+
+    /**
      * @return Returns the RedeliveryPolicy.
      * @throws JMSException
      */

Modified: 
incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java?rev=373548&r1=373547&r2=373548&view=diff
==============================================================================
--- 
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
 Mon Jan 30 08:59:01 2006
@@ -60,6 +60,18 @@
         assertNull( BrokerRegistry.getInstance().lookup("localhost") );
     }
     
+    public void testGetBrokerName() throws URISyntaxException, JMSException {
+        ActiveMQConnectionFactory cf = new 
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+        ActiveMQConnection connection = (ActiveMQConnection) 
cf.createConnection();
+        connection.start();
+        
+        String brokerName = connection.getBrokerName();
+        System.out.println("Got broker name: " + brokerName);
+        
+        assertNotNull("No broker name available!", brokerName);
+        connection.close();
+    }
+    
     public void testCreateTcpConnectionUsingAllocatedPort() throws Exception {
         
assertCreateConnection("tcp://localhost:0?wireFormat.tcpNoDelayEnabled=true");
     }


Reply via email to