Author: asoldano
Date: 2014-02-21 11:03:51 -0500 (Fri, 21 Feb 2014)
New Revision: 18405
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/udp/UDPEndpointAPITestCase.java
Log:
[JBWS-3721] Fixing testcase
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/udp/UDPEndpointAPITestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/udp/UDPEndpointAPITestCase.java 2014-02-21
10:18:45 UTC (rev 18404)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/udp/UDPEndpointAPITestCase.java 2014-02-21
16:03:51 UTC (rev 18405)
@@ -23,7 +23,11 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.InterfaceAddress;
+import java.net.NetworkInterface;
import java.net.URL;
+import java.util.Enumeration;
import javax.xml.namespace.QName;
import javax.xml.ws.Endpoint;
@@ -58,6 +62,10 @@
public void testClientSide() throws Exception
{
+ if (!isProperNetworkSetup()) {
+ System.out.println("Skipping broadcast test: no non-loopback IPv4 interface
available");
+ return;
+ }
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
Object implementor = new HelloWorldImpl();
@@ -78,4 +86,34 @@
}
}
+ private boolean isProperNetworkSetup() throws Exception {
+ Enumeration<NetworkInterface> interfaces =
NetworkInterface.getNetworkInterfaces();
+ int count = 0;
+ while (interfaces.hasMoreElements())
+ {
+ NetworkInterface networkInterface = interfaces.nextElement();
+ if (!networkInterface.isUp() || networkInterface.isLoopback() ||
!isBroadcastAddressAvailable(networkInterface))
+ {
+ continue;
+ }
+ count++;
+ }
+ if (count == 0)
+ {
+ //no non-loopbacks, cannot do broadcasts
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isBroadcastAddressAvailable(NetworkInterface networkInterface) {
+ for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses())
{
+ InetAddress broadcast = interfaceAddress.getBroadcast();
+ if (broadcast != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}