[jboss-cvs] JBoss Messaging SVN: r5734 - branches/network_interfaces/tests/src/org/jboss/messaging/tests/integration/remoting.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 27 05:10:19 EST 2009
Author: jmesnil
Date: 2009-01-27 05:10:19 -0500 (Tue, 27 Jan 2009)
New Revision: 5734
Modified:
branches/network_interfaces/tests/src/org/jboss/messaging/tests/integration/remoting/NetworkAddressTestBase.java
Log:
rewrote network interfaces tests
Modified: branches/network_interfaces/tests/src/org/jboss/messaging/tests/integration/remoting/NetworkAddressTestBase.java
===================================================================
--- branches/network_interfaces/tests/src/org/jboss/messaging/tests/integration/remoting/NetworkAddressTestBase.java 2009-01-27 10:05:49 UTC (rev 5733)
+++ branches/network_interfaces/tests/src/org/jboss/messaging/tests/integration/remoting/NetworkAddressTestBase.java 2009-01-27 10:10:19 UTC (rev 5734)
@@ -85,10 +85,12 @@
while (ifaces.hasMoreElements())
{
NetworkInterface iface = (NetworkInterface)ifaces.nextElement();
+ System.out.println(iface.getDisplayName());
Enumeration<InetAddress> enumeration = iface.getInetAddresses();
while (enumeration.hasMoreElements())
{
InetAddress inetAddress = (InetAddress)enumeration.nextElement();
+ System.out.println("\t" + inetAddress.getHostAddress());
map.put(iface, inetAddress);
break;
}
@@ -101,139 +103,135 @@
// 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().getHostAddress();
-// 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().getHostAddress();
-// testConnection("0.0.0.0", host, true);
-// }
-// }
-//
-// public void testConnectToServerAcceptingOnlyAnotherHost() throws Exception
-// {
-// Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
-// if (map.size() <= 2)
-// {
-// System.err.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> acceptorEntry = iterator.next();
-// Entry<NetworkInterface, InetAddress> connectorEntry = iterator.next();
-//
-// testConnection(acceptorEntry.getValue().getHostName(), connectorEntry.getValue().getHostAddress(), false);
-// }
-//
-// public void testConnectorToServerAcceptingAListOfHosts() throws Exception
-// {
-// Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
-// if (map.size() <= 2)
-// {
-// System.err.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();
-//
-// String listOfHosts = entry1.getValue().getHostName() + ", " + entry2.getValue().getHostAddress();
-//
-// testConnection(listOfHosts, entry1.getValue().getHostAddress(), true);
-// testConnection(listOfHosts, entry2.getValue().getHostAddress(), true);
-// }
-//
-// public void testConnectorToServerAcceptingAListOfHosts_2() throws Exception
-// {
-// Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
-// if (map.size() <= 2)
-// {
-// System.err.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().getHostAddress(), true);
-// testConnection(listOfHosts, entry2.getValue().getHostAddress(), true);
-// testConnection(listOfHosts, entry3.getValue().getHostAddress(), false);
-// }
-//
-// public void testConnection(String acceptorHost, String connectorHost, boolean mustConnect) throws Exception
-// {
-// System.out.println("acceptor=" + acceptorHost + ", connector=" + connectorHost + ", mustConnect=" + mustConnect);
-// 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();
-// }
-// }
-// }
-
- public void testFoo()
- {
+ 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().getHostAddress();
+ 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().getHostAddress();
+ testConnection("::0", host, true);
+ }
+ }
+
+ public void testConnectToServerAcceptingOnlyAnotherHost() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ if (map.size() <= 1)
+ {
+ System.err.println("There must be at least 1 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> acceptorEntry = iterator.next();
+ Entry<NetworkInterface, InetAddress> connectorEntry = iterator.next();
+
+ testConnection(acceptorEntry.getValue().getHostName(), connectorEntry.getValue().getHostAddress(), false);
+ }
+
+ public void testConnectorToServerAcceptingAListOfHosts() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ if (map.size() <= 1)
+ {
+ System.err.println("There must be at least 2 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();
+
+ String listOfHosts = entry1.getValue().getHostAddress() + ", " + entry2.getValue().getHostAddress();
+
+ testConnection(listOfHosts, entry1.getValue().getHostAddress(), true);
+ testConnection(listOfHosts, entry2.getValue().getHostAddress(), true);
+ }
+
+ public void testConnectorToServerAcceptingAListOfHosts_2() throws Exception
+ {
+ Map<NetworkInterface, InetAddress> map = getAddressForEachNetworkInterface();
+ if (map.size() <= 2)
+ {
+ System.err.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().getHostAddress() + ", " + entry2.getValue().getHostAddress();
+
+ testConnection(listOfHosts, entry1.getValue().getHostAddress(), true);
+ testConnection(listOfHosts, entry2.getValue().getHostAddress(), true);
+ testConnection(listOfHosts, entry3.getValue().getHostAddress(), false);
+ }
+
+ public void testConnection(String acceptorHost, String connectorHost, boolean mustConnect) throws Exception
+ {
+ System.out.println("acceptor=" + acceptorHost + ", connector=" + connectorHost + ", mustConnect=" + mustConnect);
+ 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 -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list