Author: alessio.soldano(a)jboss.com
Date: 2013-05-08 11:51:40 -0400 (Wed, 08 May 2013)
New Revision: 17538
Modified:
stack/cxf/trunk/modules/addons/transports/udp/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/udp/UDPTransportTest.java
Log:
[JBWS-3595] Improve testcase to avoid verifying broadcast when ipv6 only interfaces are
available
Modified:
stack/cxf/trunk/modules/addons/transports/udp/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/udp/UDPTransportTest.java
===================================================================
---
stack/cxf/trunk/modules/addons/transports/udp/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/udp/UDPTransportTest.java 2013-05-07
17:39:36 UTC (rev 17537)
+++
stack/cxf/trunk/modules/addons/transports/udp/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/udp/UDPTransportTest.java 2013-05-08
15:51:40 UTC (rev 17538)
@@ -21,6 +21,8 @@
*/
package org.jboss.wsf.stack.cxf.addons.transports.udp;
+import java.net.InetAddress;
+import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
@@ -86,7 +88,7 @@
while (interfaces.hasMoreElements())
{
NetworkInterface networkInterface = interfaces.nextElement();
- if (!networkInterface.isUp() || networkInterface.isLoopback())
+ if (!networkInterface.isUp() || networkInterface.isLoopback() ||
!isBroadcastAddressAvailable(networkInterface))
{
continue;
}
@@ -95,7 +97,7 @@
if (count == 0)
{
//no non-loopbacks, cannot do broadcasts
- System.out.println("Skipping broadcast test");
+ System.out.println("Skipping broadcast test: no non-loopback IPv4 interface
available");
return;
}
@@ -121,4 +123,14 @@
((java.io.Closeable) g).close();
}
+
+ private boolean isBroadcastAddressAvailable(NetworkInterface networkInterface) {
+ for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses())
{
+ InetAddress broadcast = interfaceAddress.getBroadcast();
+ if (broadcast != null) {
+ return true;
+ }
+ }
+ return false;
+ }
}
Show replies by date