You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2018/02/05 20:06:44 UTC
svn commit: r1823231 -
/jmeter/trunk/test/src/org/apache/jmeter/engine/LocalHostTest.java
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) {