public void testConnectToServerAcceptingAllHosts() throws Exception {
   Map<NetworkInterface, InetAddress> map =
       NetworkAddressTestBase.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 testConnectToServerWithSameHost() throws Exception {
   Map<NetworkInterface, InetAddress> map =
       NetworkAddressTestBase.getAddressForEachNetworkInterface();
   if (map.size() > 0) {
     Set<Entry<NetworkInterface, InetAddress>> set = map.entrySet();
     Iterator<Entry<NetworkInterface, InetAddress>> iterator = set.iterator();
     InetAddress address = iterator.next().getValue();
     String host = address.getHostAddress();
     testConnection(host, host, true);
   }
 }
 static {
   try {
     Map<NetworkInterface, InetAddress> map =
         NetworkAddressTestBase.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().getHostAddress() + "\n");
     }
     System.out.println(s);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public void testConnectToServerAcceptingOnlyAnotherHost() throws Exception {
    Map<NetworkInterface, InetAddress> map =
        NetworkAddressTestBase.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 =
        NetworkAddressTestBase.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);
  }