[jboss-cvs] JBoss Messaging SVN: r5727 - in trunk: src/main/org/jboss/messaging/integration/transports/mina and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 26 11:49:17 EST 2009
Author: jmesnil
Date: 2009-01-26 11:49:17 -0500 (Mon, 26 Jan 2009)
New Revision: 5727
Added:
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/MinaNetworkAddressTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/NettyNetworkAddressTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/NetworkAddressTestBase.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/config/impl/TransportConfigurationTest.java
Modified:
trunk/src/main/org/jboss/messaging/core/config/TransportConfiguration.java
trunk/src/main/org/jboss/messaging/integration/transports/mina/MinaAcceptor.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java
Log:
JBMESSAGING-1297: Should be able to bind to multiple interfaces
* for both Netty and MINA, the transport configuration now allows to bind to a single address, a list of (comma-separated) address or to all (using 0.0.0.0)
Modified: trunk/src/main/org/jboss/messaging/core/config/TransportConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/TransportConfiguration.java 2009-01-26 15:49:45 UTC (rev 5726)
+++ trunk/src/main/org/jboss/messaging/core/config/TransportConfiguration.java 2009-01-26 16:49:17 UTC (rev 5727)
@@ -41,6 +41,21 @@
private final Map<String, Object> params;
+ public static String[] splitHosts(final String commaSeparatedHosts)
+ {
+ if (commaSeparatedHosts == null)
+ {
+ return new String[0];
+ }
+ String[] hosts = commaSeparatedHosts.split(",");
+
+ for (int i = 0; i < hosts.length; i++)
+ {
+ hosts[i] = hosts[i].trim();
+ }
+ return hosts;
+ }
+
public TransportConfiguration(final String className, final Map<String, Object> params, final String name)
{
this.factoryClassName = className;
@@ -127,5 +142,4 @@
return false;
}
}
-
}
Modified: trunk/src/main/org/jboss/messaging/integration/transports/mina/MinaAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/mina/MinaAcceptor.java 2009-01-26 15:49:45 UTC (rev 5726)
+++ trunk/src/main/org/jboss/messaging/integration/transports/mina/MinaAcceptor.java 2009-01-26 16:49:17 UTC (rev 5727)
@@ -23,6 +23,9 @@
package org.jboss.messaging.integration.transports.mina;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import org.apache.mina.core.buffer.IoBuffer;
@@ -34,6 +37,7 @@
import org.apache.mina.core.session.IoSession;
import org.apache.mina.transport.socket.SocketAcceptor;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
+import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.spi.Acceptor;
@@ -149,7 +153,6 @@
FilterChainSupport.addCodecFilter(filterChain, handler);
// Bind
- acceptor.setDefaultLocalAddress(new InetSocketAddress(host, port));
acceptor.getSessionConfig().setTcpNoDelay(tcpNoDelay);
if (tcpReceiveBufferSize != -1)
{
@@ -165,7 +168,13 @@
acceptor.setCloseOnDeactivation(false);
acceptor.setHandler(new MinaHandler());
- acceptor.bind();
+ String[] hosts = TransportConfiguration.splitHosts(host);
+ List<SocketAddress> addresses = new ArrayList<SocketAddress>();
+ for (String h : hosts)
+ {
+ addresses.add(new InetSocketAddress(h, port));
+ }
+ acceptor.bind(addresses);
acceptorListener = new MinaSessionListener();
acceptor.addListener(acceptorListener);
}
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java 2009-01-26 15:49:45 UTC (rev 5726)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java 2009-01-26 16:49:17 UTC (rev 5727)
@@ -24,7 +24,10 @@
import static org.jboss.netty.channel.Channels.pipeline;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
+import java.util.Enumeration;
import java.util.Map;
import java.util.Timer;
import java.util.concurrent.ExecutorService;
@@ -33,6 +36,7 @@
import javax.net.ssl.SSLContext;
+import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.impl.ssl.SSLSupport;
import org.jboss.messaging.core.remoting.spi.Acceptor;
@@ -53,6 +57,7 @@
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
+import org.jboss.netty.group.DefaultChannelGroup;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import org.jboss.netty.handler.ssl.SslHandler;
@@ -75,7 +80,7 @@
private ChannelFactory channelFactory;
- private Channel serverChannel;
+ private DefaultChannelGroup serverChannelGroup;
private ServerBootstrap bootstrap;
@@ -256,7 +261,6 @@
});
// Bind
- bootstrap.setOption("localAddress", new InetSocketAddress(host, port));
bootstrap.setOption("child.tcpNoDelay", tcpNoDelay);
if (tcpReceiveBufferSize != -1)
{
@@ -270,7 +274,14 @@
bootstrap.setOption("child.reuseAddress", true);
bootstrap.setOption("child.keepAlive", true);
- serverChannel = bootstrap.bind();
+ serverChannelGroup = new DefaultChannelGroup("jbm");
+
+ String[] hosts = TransportConfiguration.splitHosts(host);
+ for (String h : hosts)
+ {
+ Channel serverChannel = bootstrap.bind(new InetSocketAddress(h, port));
+ serverChannelGroup.add(serverChannel);
+ }
}
public synchronized void stop()
@@ -286,7 +297,7 @@
httpKeepAliveTimer.cancel();
}
- serverChannel.close().awaitUninterruptibly();
+ serverChannelGroup.close().awaitUninterruptibly();
bossExecutor.shutdown();
workerExecutor.shutdown();
for (;;)
Added: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/MinaNetworkAddressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/MinaNetworkAddressTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/MinaNetworkAddressTest.java 2009-01-26 16:49:17 UTC (rev 5727)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.remoting;
+
+import org.jboss.messaging.integration.transports.mina.MinaAcceptorFactory;
+import org.jboss.messaging.integration.transports.mina.MinaConnectorFactory;
+import org.jboss.messaging.integration.transports.mina.TransportConstants;
+
+/**
+ * A NettyNetworkAddressTest
+ *
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ */
+public class MinaNetworkAddressTest extends NetworkAddressTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected String getAcceptorFactoryClassName()
+ {
+ return MinaAcceptorFactory.class.getName();
+ }
+
+ @Override
+ protected String getConnectorFactoryClassName()
+ {
+ return MinaConnectorFactory.class.getName();
+ }
+
+ @Override
+ protected String getHostPropertyKey()
+ {
+ return TransportConstants.HOST_PROP_NAME;
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/NettyNetworkAddressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/NettyNetworkAddressTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/NettyNetworkAddressTest.java 2009-01-26 16:49:17 UTC (rev 5727)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.messaging.tests.integration.remoting;
+
+import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
+import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+import org.jboss.messaging.integration.transports.netty.TransportConstants;
+
+/**
+ * A NettyNetworkAddressTest
+ *
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ */
+public class NettyNetworkAddressTest extends NetworkAddressTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected String getAcceptorFactoryClassName()
+ {
+ return NettyAcceptorFactory.class.getName();
+ }
+
+ @Override
+ protected String getConnectorFactoryClassName()
+ {
+ return NettyConnectorFactory.class.getName();
+ }
+
+ @Override
+ protected String getHostPropertyKey()
+ {
+ return TransportConstants.HOST_PROP_NAME;
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/NetworkAddressTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/NetworkAddressTestBase.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/NetworkAddressTestBase.java 2009-01-26 16:49:17 UTC (rev 5727)
@@ -0,0 +1,241 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.remoting;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
+import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+import org.jboss.messaging.integration.transports.netty.TransportConstants;
+import org.jboss.messaging.tests.util.ServiceTestBase;
+
+/**
+ * A NetworkAddressTest
+ *
+ * @author jmesnil
+ *
+ * Created 26 janv. 2009 15:06:58
+ *
+ *
+ */
+public abstract class NetworkAddressTestBase extends ServiceTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ static
+ {
+ try
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ StringBuilder s = new StringBuilder("using network settings:\n");
+ Set<Entry<NetworkInterface, InetAddress>> set = map.entrySet();
+ for (Entry<NetworkInterface, InetAddress> entry : set)
+ {
+ s.append(entry.getKey().getDisplayName() + ": " + entry.getValue().getHostName() + "\n");
+ }
+ System.out.println(s);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+ public static Map<NetworkInterface, InetAddress> getAddressForEachNetworkInterface() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = new HashMap<NetworkInterface, InetAddress>();
+ Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
+ while (ifaces.hasMoreElements())
+ {
+ NetworkInterface iface = (NetworkInterface)ifaces.nextElement();
+ Enumeration<InetAddress> enumeration = iface.getInetAddresses();
+ while (enumeration.hasMoreElements())
+ {
+ InetAddress inetAddress = (InetAddress)enumeration.nextElement();
+ map.put(iface, inetAddress);
+ break;
+ }
+ }
+
+ return map;
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testConnectToServerWithSameHost() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ Set<Entry<NetworkInterface, InetAddress>> set = map.entrySet();
+ for (Entry<NetworkInterface, InetAddress> entry : set)
+ {
+ String host = entry.getValue().getHostName();
+ testConnection(host, host, true);
+ }
+ }
+
+ public void testConnectToServerAcceptingAllHosts() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ Set<Entry<NetworkInterface, InetAddress>> set = map.entrySet();
+ for (Entry<NetworkInterface, InetAddress> entry : set)
+ {
+ String host = entry.getValue().getHostName();
+ testConnection("0.0.0.0", host, true);
+ }
+ }
+
+ public void testConnectToServerAcceptingOnlyAnotherHost() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ assertTrue("There must be at least 2 network interfaces: test will not be executed", map.size() > 1);
+
+ Set<Entry<NetworkInterface, InetAddress>> set = map.entrySet();
+ Iterator<Entry<NetworkInterface, InetAddress>> iterator = set.iterator();
+ Entry<NetworkInterface, InetAddress> acceptorEntry = iterator.next();
+ Entry<NetworkInterface, InetAddress> connectorEntry = iterator.next();
+
+ testConnection(acceptorEntry.getValue().getHostName(), connectorEntry.getValue().getHostName(), false);
+ }
+
+ public void testConnectorToServerAcceptingAListOfHosts() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ assertTrue("There must be at least 2 network interfaces: test will not be executed", map.size() > 1);
+
+ Set<Entry<NetworkInterface, InetAddress>> set = map.entrySet();
+ Iterator<Entry<NetworkInterface, InetAddress>> iterator = set.iterator();
+ Entry<NetworkInterface, InetAddress> entry1 = iterator.next();
+ Entry<NetworkInterface, InetAddress> entry2 = iterator.next();
+
+ String listOfHosts = entry1.getValue().getHostName() + ", " + entry2.getValue().getHostName();
+
+ testConnection(listOfHosts, entry1.getValue().getHostName(), true);
+ testConnection(listOfHosts, entry2.getValue().getHostName(), true);
+ }
+
+ public void testConnectorToServerAcceptingAListOfHosts_2() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ if (map.size() <= 2)
+ {
+ System.out.println("There must be at least 3 network interfaces: test will not be executed");
+ return;
+ }
+
+ Set<Entry<NetworkInterface, InetAddress>> set = map.entrySet();
+ Iterator<Entry<NetworkInterface, InetAddress>> iterator = set.iterator();
+ Entry<NetworkInterface, InetAddress> entry1 = iterator.next();
+ Entry<NetworkInterface, InetAddress> entry2 = iterator.next();
+ Entry<NetworkInterface, InetAddress> entry3 = iterator.next();
+
+ String listOfHosts = entry1.getValue().getHostName() + ", " + entry2.getValue().getHostName();
+
+ testConnection(listOfHosts, entry1.getValue().getHostName(), true);
+ testConnection(listOfHosts, entry2.getValue().getHostName(), true);
+ testConnection(listOfHosts, entry3.getValue().getHostName(), false);
+ }
+
+ public void testConnection(String acceptorHost, String connectorHost, boolean mustConnect) throws Exception
+ {
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put(getHostPropertyKey(), acceptorHost);
+ TransportConfiguration acceptorConfig = new TransportConfiguration(getAcceptorFactoryClassName(), params);
+ Set<TransportConfiguration> transportConfigs = new HashSet<TransportConfiguration>();
+ transportConfigs.add(acceptorConfig);
+
+ Configuration config = createDefaultConfig(true);
+ config.setAcceptorConfigurations(transportConfigs);
+ MessagingService messagingService = createService(false, config);
+ messagingService.start();
+
+ params = new HashMap<String, Object>();
+ params.put(getHostPropertyKey(), connectorHost);
+ TransportConfiguration connectorConfig = new TransportConfiguration(getConnectorFactoryClassName(), params);
+
+ try
+ {
+ ClientSessionFactory sf = new ClientSessionFactoryImpl(connectorConfig);
+
+ if (mustConnect)
+ {
+ ClientSession session = sf.createSession(false, true, true);
+ session.close();
+ }
+ else
+ {
+ try
+ {
+ sf.createSession(false, true, true);
+ fail("session creation must fail because connector must not be able to connect to the server bound to another network interface");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+ finally
+ {
+ if (messagingService != null)
+ {
+ messagingService.stop();
+ }
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected abstract String getAcceptorFactoryClassName();
+
+ protected abstract String getConnectorFactoryClassName();
+
+ protected abstract String getHostPropertyKey();
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/config/impl/TransportConfigurationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/config/impl/TransportConfigurationTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/config/impl/TransportConfigurationTest.java 2009-01-26 16:49:17 UTC (rev 5727)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.messaging.tests.unit.core.config.impl;
+
+import org.jboss.messaging.core.config.TransportConfiguration;
+
+import junit.framework.TestCase;
+
+/**
+ * A TransportConfigurationTest
+ *
+ * @author jmesnil
+ *
+ * Created 20 janv. 2009 14:46:35
+ *
+ *
+ */
+public class TransportConfigurationTest extends TestCase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testSplitNullAddress() throws Exception
+ {
+ String[] addresses = TransportConfiguration.splitHosts(null);
+
+ assertNotNull(addresses);
+ assertEquals(0, addresses.length);
+ }
+
+ public void testSplitSingleAddress() throws Exception
+ {
+ String[] addresses = TransportConfiguration.splitHosts("localhost");
+
+ assertNotNull(addresses);
+ assertEquals(1, addresses.length);
+ assertEquals("localhost", addresses[0]);
+ }
+
+ public void testSplitManyAddresses() throws Exception
+ {
+ String[] addresses = TransportConfiguration.splitHosts("localhost, 127.0.0.1, 192.168.0.10");
+
+ assertNotNull(addresses);
+ assertEquals(3, addresses.length);
+ assertEquals("localhost", addresses[0]);
+ assertEquals("127.0.0.1", addresses[1]);
+ assertEquals("192.168.0.10", addresses[2]);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
More information about the jboss-cvs-commits
mailing list