if (!ServerManagement.isRemote())
{
return;
}
JBossConnection connection = null;
try
{
String address = InetAddress.getLocalHost().getHostAddress();
System.setProperty("jboss.messaging.callback.bind.address", address);
int freePort = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName());
System.setProperty("jboss.messaging.callback.bind.port", Integer.toString(freePort));
String pollPeriod = "654";
System.setProperty("jboss.messaging.callback.pollPeriod", pollPeriod);
System.setProperty("jboss.messaging.callback.reportPollingStatistics", "true");
connection = (JBossConnection)cf.createConnection();
connection.start();
ClientConnectionDelegate delegate = (ClientConnectionDelegate)connection.getDelegate();
JMSRemotingConnection remotingConnection = delegate.getRemotingConnection();
Client client = remotingConnection.getRemotingClient();
Field field = JMSRemotingConnection.class.getDeclaredField("serverLocator");
field.setAccessible(true);
InvokerLocator locator = (InvokerLocator)field.get(remotingConnection);
String transport = locator.getProtocol();
if ("socket".equals(transport)
|| "sslsocket".equals(transport)
|| "bisocket".equals(transport)
|| "sslbisocket".equals(transport))
{
field = Client.class.getDeclaredField("callbackConnectors");
field.setAccessible(true);
Map callbackConnectors = (Map)field.get(client);
InvokerCallbackHandler callbackHandler = remotingConnection.getCallbackManager();
HashSet map = (HashSet) callbackConnectors.get(callbackHandler);
Connector connector = (Connector)map.iterator().next();
locator = new InvokerLocator(connector.getInvokerLocator());
assertEquals(address, locator.getHost());
assertEquals(freePort, locator.getPort());
}
else if ("http".equals(transport))
{
field = Client.class.getDeclaredField("callbackPollers");
field.setAccessible(true);
Map callbackPollers = (Map)field.get(client);
assertEquals(1, callbackPollers.size());
CallbackPoller callbackPoller =
(CallbackPoller)callbackPollers.values().iterator().next();
field = CallbackPoller.class.getDeclaredField("pollPeriod");
field.setAccessible(true);
assertEquals(pollPeriod, ((Long)field.get(callbackPoller)).toString());
field = CallbackPoller.class.getDeclaredField("reportStatistics");
field.setAccessible(true);
assertEquals(true, ((Boolean) field.get(callbackPoller)).booleanValue());
}
else
{
fail("Unrecognized transport: " + transport);
}
}
finally
{
if (connection != null)
{
connection.close();
}
System.clearProperty("jboss.messaging.callback.bind.address");
System.clearProperty("jboss.messaging.callback.bind.port");