Author: ningjiang
Date: Mon Nov 17 23:41:42 2008
New Revision: 718517
URL: http://svn.apache.org/viewvc?rev=718517&view=rev
Log:
Merged revisions 718312,718326,718329,718513-718514 via svnmerge from
https://svn.apache.org/repos/asf/activemq/camel/trunk
........
r718312 | romkal | 2008-11-18 02:19:54 +0800 (Tue, 18 Nov 2008) | 1 line
CAMEL-1091 - Fix test that can recognize localhost as remote interface
........
r718326 | romkal | 2008-11-18 03:03:28 +0800 (Tue, 18 Nov 2008) | 1 line
CAMEL-1091 : added tests for IPv6
........
r718329 | romkal | 2008-11-18 03:16:03 +0800 (Tue, 18 Nov 2008) | 1 line
CAMEL-1091 : typo in IPv6 test
........
r718513 | ningjiang | 2008-11-18 15:10:51 +0800 (Tue, 18 Nov 2008) | 1 line
CAMEL-1091 removed the IPV6 test
........
r718514 | ningjiang | 2008-11-18 15:15:17 +0800 (Tue, 18 Nov 2008) | 1 line
CAMEL-1091 Added the Apache header
........
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/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 17 23:41:42 2008
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718514
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=718517&r1=718516&r2=718517&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 23:41:42 2008
@@ -1,9 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.jetty;
import java.io.IOException;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
-import java.net.SocketException;
import java.net.URL;
import java.util.Enumeration;
@@ -14,23 +30,27 @@
public class InterfacesTest extends ContextTestSupport {
private String remoteInterfaceAddress;
-
+
+
public InterfacesTest() throws IOException {
// Retrieve an address of some remote network interface
Enumeration<NetworkInterface> interfaces =
NetworkInterface.getNetworkInterfaces();
- while(interfaces.hasMoreElements()) {
+ while (remoteInterfaceAddress == null && interfaces.hasMoreElements())
{
NetworkInterface interfaze = interfaces.nextElement();
Enumeration<InetAddress> addresses = interfaze.getInetAddresses();
- if(addresses.hasMoreElements()) {
+ if (addresses.hasMoreElements()) {
InetAddress nextAddress = addresses.nextElement();
- if (nextAddress.isLoopbackAddress() ||
nextAddress.isReachable(2000)) {
- break;
+ if (nextAddress.isLoopbackAddress() ||
!nextAddress.isReachable(2000)) {
+ continue;
+ }
+ if (nextAddress instanceof Inet6Address) {
+ continue;
+ } else {
+ remoteInterfaceAddress = nextAddress.getHostAddress();
}
- remoteInterfaceAddress = nextAddress.getHostAddress();
}
- };
-
+ }
}
public void testLocalInterfaceHandled() throws IOException,
InterruptedException {
@@ -53,6 +73,24 @@
}
assertMockEndpointsSatisfied();
+ }
+
+
+ public void testAllInterfaces() throws Exception {
+ int expectedMessages = (remoteInterfaceAddress != null) ? 2 : 1;
+
getMockEndpoint("mock:endpoint").expectedMessageCount(expectedMessages);
+
+ URL localUrl = new URL("http://localhost:4569/allInterfaces");
+ String localResponse = IOUtils.toString(localUrl.openStream());
+ assertEquals("allInterfaces", localResponse);
+
+ if (remoteInterfaceAddress != null) {
+ URL url = new URL("http://" + remoteInterfaceAddress +
":4569/allInterfaces");
+ String remoteResponse = IOUtils.toString(url.openStream());
+ assertEquals("allInterfaces", remoteResponse);
+ }
+
+ assertMockEndpointsSatisfied();
}
@Override
@@ -74,6 +112,11 @@
.setBody().constant("remote")
.to("mock:endpoint");
}
+
+ from("jetty:http://0.0.0.0:4569/allInterfaces")
+ .setBody().constant("allInterfaces")
+ .to("mock:endpoint");
+
}
};
}