Author: janstey
Date: Mon Nov 17 09:47:50 2008
New Revision: 718295

URL: http://svn.apache.org/viewvc?rev=718295&view=rev
Log:
Merged revisions 718279 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r718279 | janstey | 2008-11-17 13:56:38 -0330 (Mon, 17 Nov 2008) | 1 line
  
  CAMEL-1091 - Fix compilation issue on Java 1.5
........

Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    
activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/InterfacesTest.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/InterfacesTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/InterfacesTest.java?rev=718295&r1=718294&r2=718295&view=diff
==============================================================================
--- 
activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/InterfacesTest.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/InterfacesTest.java
 Mon Nov 17 09:47:50 2008
@@ -15,25 +15,27 @@
     
     private String remoteInterfaceAddress;
 
-    public InterfacesTest() throws SocketException {
-        // retirieve an address of some remote network interface
+    public InterfacesTest() throws IOException {
+        // Retrieve an address of some remote network interface
         Enumeration<NetworkInterface> interfaces =  
NetworkInterface.getNetworkInterfaces();
         
         while(interfaces.hasMoreElements()) {
             NetworkInterface interfaze = interfaces.nextElement();
-            if (!interfaze.isUp() || interfaze.isLoopback()) {
-                continue;
-            }
             Enumeration<InetAddress> addresses =  interfaze.getInetAddresses();
-            if(addresses.hasMoreElements()) {
-                remoteInterfaceAddress = 
addresses.nextElement().getHostAddress();
+            if(addresses.hasMoreElements()) {                
+                InetAddress nextAddress = addresses.nextElement();
+                if (nextAddress.isLoopbackAddress() || 
nextAddress.isReachable(2000)) {
+                    break;
+                }
+                remoteInterfaceAddress = nextAddress.getHostAddress();
             }
         };
         
     }
     
     public void testLocalInterfaceHandled() throws IOException, 
InterruptedException {
-        getMockEndpoint("mock:endpoint").expectedMessageCount(3);
+        int expectedMessages = (remoteInterfaceAddress != null) ? 3 : 2;
+        
getMockEndpoint("mock:endpoint").expectedMessageCount(expectedMessages);
         
         URL localUrl = new URL("http://localhost:4567/testRoute";);
         String localResponse = IOUtils.toString(localUrl.openStream());
@@ -44,9 +46,11 @@
         localResponse = IOUtils.toString(localUrl.openStream());
         assertEquals("local-differentPort", localResponse);
         
-        URL url = new URL("http://"; + remoteInterfaceAddress + 
":4567/testRoute");
-        String remoteResponse = IOUtils.toString(url.openStream());
-        assertEquals("remote", remoteResponse);
+        if (remoteInterfaceAddress != null) {
+            URL url = new URL("http://"; + remoteInterfaceAddress + 
":4567/testRoute");
+            String remoteResponse = IOUtils.toString(url.openStream());
+            assertEquals("remote", remoteResponse);
+        }
         
         assertMockEndpointsSatisfied();
     }
@@ -65,9 +69,11 @@
                     .setBody().constant("local-differentPort")
                     .to("mock:endpoint");
                 
-                from("jetty:http://"; + remoteInterfaceAddress + 
":4567/testRoute")
-                    .setBody().constant("remote")
-                    .to("mock:endpoint");
+                if (remoteInterfaceAddress != null) {
+                    from("jetty:http://"; + remoteInterfaceAddress + 
":4567/testRoute")
+                        .setBody().constant("remote")
+                        .to("mock:endpoint");
+                }
             }
         };
     }


Reply via email to