public void testMultihomeNoPortsWithDefaultPort() throws Throwable
{
log.info("entering " + getName());
// Create ServerConfiguration
ServerConfiguration config = new ServerConfiguration("socket");
Map locatorConfig = new HashMap();
// Add non-multihome invokerLocatorParameters - show they don't interfere.
String serverBindAddress = "localhost";
String serverBindPort = "4446";
String clientConnectAddress = InetAddress.getLocalHost().getHostAddress();
String clientConnectPort = "4447";
locatorConfig.put("serverBindAddress", serverBindAddress);
locatorConfig.put("serverBindPort", serverBindPort);
locatorConfig.put("clientConnectAddress", clientConnectAddress);
locatorConfig.put("clientConnectPort", clientConnectPort);
// Add multihome invokerLocatorParameters.
ArrayList homes = new ArrayList();
Enumeration e1 = NetworkInterface.getNetworkInterfaces();
loop: while (e1.hasMoreElements())
{
NetworkInterface ni = (NetworkInterface) e1.nextElement();
Enumeration e2 = ni.getInetAddresses();
while (e2.hasMoreElements())
{
InetAddress ia = (InetAddress) e2.nextElement();
String host = ia.getHostAddress();
boolean isIPv6 = host.indexOf('[') >= 0 || host.indexOf(':') >= 0;
if (isIPv6) host = '[' + host + ']';
Home h = new Home(host, -1);
homes.add(h);
if (homes.size() >= MAX_HOMES)
break loop;
}
}
Home h = (Home) homes.get(0);
StringBuffer sb = new StringBuffer(h.host);
for (int i = 1; i < homes.size(); i++)
{
h = (Home) homes.get(i);
sb.append('!').append(h.host);
}
locatorConfig.put(InvokerLocator.CONNECT_HOMES_KEY, sb.toString());
locatorConfig.put(InvokerLocator.HOMES_KEY, sb.toString());
locatorConfig.put(InvokerLocator.DEFAULT_CONNECT_PORT, "3333");
locatorConfig.put(InvokerLocator.DEFAULT_PORT, "4444");
config.setInvokerLocatorParameters(locatorConfig);
log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters());
log.info("serverParameters: " + config.getServerParameters());
log.info("invocationHandlers: " + config.getInvocationHandlers());
// Create Connector.
connector = new Connector();
connector.setServerConfiguration(config);
connector.create();