Пример #1
0
 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);
   }
 }
Пример #2
0
 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);
   }
 }
Пример #3
0
 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();
   }
 }
Пример #4
0
  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);
  }
Пример #5
0
  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);
  }