patch and test case for AMQ-514 to make BrokerInfo and the broker name visible to an ActiveMQConnection

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@373548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-01-30 16:59:01 +00:00
parent 92b9d864e5
commit e6747ead95
2 changed files with 29 additions and 0 deletions

View File

@ -1214,6 +1214,23 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
return brokerInfo.getBrokerId().getValue();
}
/**
* 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

View File

@ -60,6 +60,18 @@ public class ActiveMQConnectionFactoryTest extends CombinationTestSupport {
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");
}