jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1823231 - /jmeter/trunk/test/src/org/apache/jmeter/engine/LocalHostTest.java
Date Mon, 05 Feb 2018 20:06:44 GMT
Author: fschumacher
Date: Mon Feb  5 20:06:44 2018
New Revision: 1823231

URL: http://svn.apache.org/viewvc?rev=1823231&view=rev
Log:
Add a test to get more info, why nightly is currently not working

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/engine/LocalHostTest.java

Modified: jmeter/trunk/test/src/org/apache/jmeter/engine/LocalHostTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/engine/LocalHostTest.java?rev=1823231&r1=1823230&r2=1823231&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/engine/LocalHostTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/engine/LocalHostTest.java Mon Feb  5 20:06:44
2018
@@ -19,7 +19,11 @@
 package org.apache.jmeter.engine;
 
 import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.UnknownHostException;
+import java.util.Collections;
 
+import org.junit.Assert;
 import org.junit.Test;
 
 /**
@@ -28,7 +32,29 @@ import org.junit.Test;
 public class LocalHostTest {
 
     @Test
+    public void testInterfaces() throws Exception {
+        InetAddress localHost = getLocalHost();
+        boolean localHostIsBound = Collections.list(NetworkInterface.getNetworkInterfaces()).stream()
+                .flatMap(iface -> Collections.list(iface.getInetAddresses())
+                        .stream())
+                .filter(addr -> addr.equals(localHost))
+                .findFirst()
+                .isPresent();
+        Assert.assertTrue("localHost: " + localHost + " is bound to an interface", localHostIsBound);
+    }
+
+    @Test
     public void testLocalHost() throws Exception {
+        InetAddress localHost = getLocalHost();
+        showAddress(localHost);
+        showAddress(InetAddress.getByName("localhost"));
+        for (InetAddress a : InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()))
{
+            perr("====================");
+            showAddress(a);            
+        }
+    }
+
+    private InetAddress getLocalHost() throws UnknownHostException {
         final String key = "java.rmi.server.hostname";
         String host = System.getProperties().getProperty(key); // $NON-NLS-1$
         perr(key + "=" + host);
@@ -38,12 +64,7 @@ public class LocalHostTest {
         } else {
             localHost = InetAddress.getByName(host);
         }
-        showAddress(localHost);
-        showAddress(InetAddress.getByName("localhost"));
-        for (InetAddress a : InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()))
{
-            perr("====================");
-            showAddress(a);            
-        }
+        return localHost;
     }
 
     private static void showAddress(InetAddress localHost) {



Mime
View raw message