You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2011/12/30 09:14:56 UTC
svn commit: r1225768 - in
/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async:
HttpAsyncCallbackTest.java HttpAsyncTest.java HttpAsyncTestSupport.java
HttpJmsAsyncTimeoutTest.java
Author: ningjiang
Date: Fri Dec 30 08:14:56 2011
New Revision: 1225768
URL: http://svn.apache.org/viewvc?rev=1225768&view=rev
Log:
CAMEL-4837 use dynamic port numbers with HttpAsync itest
Added:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTestSupport.java (with props)
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java?rev=1225768&r1=1225767&r2=1225768&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java (original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java Fri Dec 30 08:14:56 2011
@@ -23,13 +23,12 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.support.SynchronizationAdapter;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
* @version
*/
-public class HttpAsyncCallbackTest extends CamelTestSupport {
+public class HttpAsyncCallbackTest extends HttpAsyncTestSupport {
@Test
public void testAsyncAndSyncAtSameTimeWithHttp() throws Exception {
@@ -42,9 +41,10 @@ public class HttpAsyncCallbackTest exten
// Send 3 async request/reply message to the http endpoint
// where we let the callback handle gathering the responses
- template.asyncCallbackRequestBody("http://localhost:9080/myservice", "Claus", callback);
- template.asyncCallbackRequestBody("http://localhost:9080/myservice", "Hadrian", callback);
- template.asyncCallbackRequestBody("http://localhost:9080/myservice", "Willem", callback);
+ String url = "http://localhost:" + getPort() + "/myservice";
+ template.asyncCallbackRequestBody(url, "Claus", callback);
+ template.asyncCallbackRequestBody(url, "Hadrian", callback);
+ template.asyncCallbackRequestBody(url, "Willem", callback);
// give on completion time to complete properly before we do assertions on its size
// TODO: improve MockEndpoint.assertIsSatisfied(long) to make this sleep unnecessary
@@ -90,7 +90,7 @@ public class HttpAsyncCallbackTest exten
// START SNIPPET: e1
// The mocks are here for unit test
// Simulate a slow http service (delaying 1 sec) we want to invoke async
- from("jetty:http://0.0.0.0:9080/myservice")
+ from("jetty:http://0.0.0.0:" + getPort() + "/myservice")
.delay(300)
.transform(body().prepend("Hello "))
.to("mock:result");
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java?rev=1225768&r1=1225767&r2=1225768&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java (original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java Fri Dec 30 08:14:56 2011
@@ -20,13 +20,12 @@ import java.util.concurrent.Future;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
* @version
*/
-public class HttpAsyncTest extends CamelTestSupport {
+public class HttpAsyncTest extends HttpAsyncTestSupport {
@SuppressWarnings("unchecked")
@Test
@@ -38,7 +37,7 @@ public class HttpAsyncTest extends Camel
mock.expectedBodiesReceived("Claus", "Bye World");
// Send a async request/reply message to the http endpoint
- Future future = template.asyncRequestBody("http://0.0.0.0:9080/myservice", "Hello World");
+ Future future = template.asyncRequestBody("http://0.0.0.0:" + getPort() + "/myservice", "Hello World");
// We got the future so in the meantime we can do other stuff, as this is Camel
// so lets invoke another request/reply route but this time is synchronous
@@ -73,7 +72,7 @@ public class HttpAsyncTest extends Camel
from("direct:name").transform(constant("Claus")).to("mock:result");
// Simulate a slow http service (delaying 1 sec) we want to invoke async
- from("jetty:http://0.0.0.0:9080/myservice")
+ from("jetty:http://0.0.0.0:" + getPort() + "/myservice")
.delay(1000)
.transform(constant("Bye World"))
.to("mock:result");
Added: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTestSupport.java?rev=1225768&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTestSupport.java (added)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTestSupport.java Fri Dec 30 08:14:56 2011
@@ -0,0 +1,36 @@
+/**
+ * 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.itest.async;
+
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.BeforeClass;
+
+public class HttpAsyncTestSupport extends CamelTestSupport {
+
+ protected static int port;
+
+ @BeforeClass
+ public static void initPort() throws Exception {
+ port = AvailablePortFinder.getNextAvailable(23000);
+ }
+
+ protected int getPort() {
+ return port;
+ }
+
+}
Propchange: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTestSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTestSupport.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java?rev=1225768&r1=1225767&r2=1225768&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java (original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java Fri Dec 30 08:14:56 2011
@@ -22,19 +22,18 @@ import org.apache.activemq.camel.compone
import org.apache.camel.CamelExecutionException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.http.HttpOperationFailedException;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.util.jndi.JndiContext;
import org.junit.Test;
/**
*
*/
-public class HttpJmsAsyncTimeoutTest extends CamelTestSupport {
+public class HttpJmsAsyncTimeoutTest extends HttpAsyncTestSupport {
@Test
public void testHttpJmsAsync() throws Exception {
try {
- template.requestBody("http://0.0.0.0:9080/myservice", "Hello World", String.class);
+ template.requestBody("http://0.0.0.0:" + getPort() + "/myservice", "Hello World", String.class);
fail("Should have thrown exception");
} catch (CamelExecutionException e) {
HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
@@ -61,7 +60,7 @@ public class HttpJmsAsyncTimeoutTest ext
// a lot of timeouts in the play :)
// jetty will timeout after 2 seconds
- from("jetty:http://0.0.0.0:9080/myservice?continuationTimeout=2000")
+ from("jetty:http://0.0.0.0:" + getPort() + "/myservice?continuationTimeout=2000")
// jms request/reply will timeout after 5 seconds
.to("jms:queue:foo?requestTimeout=5000");