[mercedesme] Fix unstable ConfigurationTest (#13650)
* Make sure IPv4 is used with default callback URL * Use a more reasonable timeout Fixes #13531 Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
54ccf847da
commit
a4f6159f09
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
package org.openhab.binding.mercedesme.internal.server;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
|
@ -70,7 +71,9 @@ public class Utils {
|
|||
for (Enumeration<InetAddress> addresses = iface.getInetAddresses(); addresses
|
||||
.hasMoreElements();) {
|
||||
InetAddress address = addresses.nextElement();
|
||||
return address.getHostAddress();
|
||||
if (address instanceof Inet4Address) {
|
||||
return address.getHostAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,10 +62,11 @@ class ConfigurationTest {
|
|||
@Test
|
||||
public void testCallbackUrl() throws SocketException {
|
||||
String ip = Utils.getCallbackIP();
|
||||
String message = "IP " + ip + " not reachable";
|
||||
try {
|
||||
assertTrue(InetAddress.getByName(ip).isReachable(10));
|
||||
assertTrue(InetAddress.getByName(ip).isReachable(10000), message);
|
||||
} catch (IOException e) {
|
||||
assertTrue(false, "IP " + ip + " not reachable");
|
||||
fail(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue