Author: davsclaus
Date: Mon Aug 15 09:50:19 2011
New Revision: 1157751
URL: http://svn.apache.org/viewvc?rev=1157751&view=rev
Log:
Using dynamic ports in tests.
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionAndNoTransactionErrorHandlerConfiguredTest.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionTest.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java
URL:
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java?rev=1157751&r1=1157750&r2=1157751&view=diff
==============================================================================
---
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java
(original)
+++
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java
Mon Aug 15 09:50:19 2011
@@ -24,6 +24,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.spring.SpringRouteBuilder;
import org.apache.camel.spring.spi.SpringTransactionPolicy;
+import org.apache.camel.test.AvailablePortFinder;
/**
* Route that listen on a JMS queue and send a request/reply over http
@@ -35,7 +36,8 @@ import org.apache.camel.spring.spi.Sprin
* @version
*/
public class JmsToHttpRoute extends SpringRouteBuilder {
- protected static int counter;
+ protected static int counter;
+ protected int port;
@Resource(name = "PROPAGATION_REQUIRED")
protected SpringTransactionPolicy required;
@@ -47,14 +49,16 @@ public class JmsToHttpRoute extends Spri
protected String ok = "<?xml
version=\"1.0\"?><reply><status>ok</status></reply>";
public void configure() throws Exception {
+ port = AvailablePortFinder.getNextAvailable(8000);
+
// configure a global transacted error handler
errorHandler(transactionErrorHandler(required));
from(data)
- // must setup policy for each route due CAMEL-1475 bug
+ // use transaction policy for this route
.policy(required)
// send a request to http and get the response
- .to("http://localhost:9091/sender")
+ .to("http://localhost:" + port + "/sender")
// convert the response to String so we can work with it and avoid
streams only be readable once
// as the http component will return data as a stream
.convertBodyTo(String.class)
@@ -77,7 +81,7 @@ public class JmsToHttpRoute extends Spri
// this is our http route that will fail the first 2 attempts
// before it sends an ok response
- from("jetty:http://localhost:9091/sender").process(new Processor() {
+ from("jetty:http://localhost:" + port + "/sender").process(new
Processor() {
public void process(Exchange exchange) throws Exception {
if (counter++ < 2) {
exchange.getOut().setBody(nok);
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionAndNoTransactionErrorHandlerConfiguredTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionAndNoTransactionErrorHandlerConfiguredTest.java?rev=1157751&r1=1157750&r2=1157751&view=diff
==============================================================================
---
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionAndNoTransactionErrorHandlerConfiguredTest.java
(original)
+++
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionAndNoTransactionErrorHandlerConfiguredTest.java
Mon Aug 15 09:50:19 2011
@@ -68,7 +68,7 @@ public class JmsToHttpTXWithOnExceptionA
@Test
public void testRollback() throws Exception {
- // will rollback forver so we run 3 times or more
+ // will rollback forever so we run 3 times or more
rollback.expectedMinimumMessageCount(3);
// use requestBody to force a InOut message exchange pattern ( =
request/reply)
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionTest.java?rev=1157751&r1=1157750&r2=1157751&view=diff
==============================================================================
---
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionTest.java
(original)
+++
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpTXWithOnExceptionTest.java
Mon Aug 15 09:50:19 2011
@@ -69,7 +69,7 @@ public class JmsToHttpTXWithOnExceptionT
@Test
public void testRollback() throws Exception {
- // will rollback forver so we run 3 times or more
+ // will rollback forever so we run 3 times or more
rollback.expectedMinimumMessageCount(3);
// use requestBody to force a InOut message exchange pattern ( =
request/reply)
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
URL:
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java?rev=1157751&r1=1157750&r2=1157751&view=diff
==============================================================================
---
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
(original)
+++
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
Mon Aug 15 09:50:19 2011
@@ -20,6 +20,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.test.AvailablePortFinder;
/**
* Route that listen on a JMS queue and send a request/reply over http
@@ -35,6 +36,8 @@ public class JmsToHttpWithOnExceptionAnd
private String noAccess = "<?xml version=\"1.0\"?><reply><status>Access
denied</status></reply>";
public void configure() throws Exception {
+ port = AvailablePortFinder.getNextAvailable(8000);
+
// if its a 404 then regard it as handled
onException(HttpOperationFailedException.class).onWhen(new Predicate()
{
public boolean matches(Exchange exchange) {
@@ -47,7 +50,7 @@ public class JmsToHttpWithOnExceptionAnd
// must setup policy to indicate transacted route
.policy(required)
// send a request to http and get the response
- .to("http://localhost:8080/sender")
+ .to("http://localhost:" + port + "/sender")
// convert the response to String so we can work with it and avoid
streams only be readable once
// as the http component will return data as a stream
.convertBodyTo(String.class)
@@ -65,7 +68,7 @@ public class JmsToHttpWithOnExceptionAnd
.end();
// this is our http router
- from("jetty:http://localhost:8080/sender").process(new Processor() {
+ from("jetty:http://localhost:" + port + "/sender").process(new
Processor() {
public void process(Exchange exchange) throws Exception {
// first hit is always a error code 500 to force the caller to
retry
if (counter++ < 1) {
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
URL:
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java?rev=1157751&r1=1157750&r2=1157751&view=diff
==============================================================================
---
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
(original)
+++
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
Mon Aug 15 09:50:19 2011
@@ -20,6 +20,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.test.AvailablePortFinder;
/**
* Route that listen on a JMS queue and send a request/reply over http
@@ -35,6 +36,8 @@ public class JmsToHttpWithOnExceptionRou
private String noAccess = "<?xml version=\"1.0\"?><reply><status>Access
denied</status></reply>";
public void configure() throws Exception {
+ port = AvailablePortFinder.getNextAvailable(8000);
+
// configure a global transacted error handler
errorHandler(transactionErrorHandler(required));
@@ -50,7 +53,7 @@ public class JmsToHttpWithOnExceptionRou
// must setup policy to indicate transacted route
.policy(required)
// send a request to http and get the response
- .to("http://localhost:8080/sender")
+ .to("http://localhost:" + port + "/sender")
// convert the response to String so we can work with it and avoid
streams only be readable once
// as the http component will return data as a stream
.convertBodyTo(String.class)
@@ -68,7 +71,7 @@ public class JmsToHttpWithOnExceptionRou
.end();
// this is our http router
- from("jetty:http://localhost:8080/sender").process(new Processor() {
+ from("jetty:http://localhost:" + port + "/sender").process(new
Processor() {
public void process(Exchange exchange) throws Exception {
// first hit is always a error code 500 to force the caller to
retry
if (counter++ < 1) {
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java
URL:
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java?rev=1157751&r1=1157750&r2=1157751&view=diff
==============================================================================
---
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java
(original)
+++
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java
Mon Aug 15 09:50:19 2011
@@ -18,6 +18,7 @@ package org.apache.camel.itest.tx;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
+import org.apache.camel.test.AvailablePortFinder;
/**
* Route that listen on a JMS queue and send a request/reply over http
@@ -31,6 +32,8 @@ import org.apache.camel.Processor;
public class JmsToHttpWithRollbackRoute extends JmsToHttpRoute {
public void configure() throws Exception {
+ port = AvailablePortFinder.getNextAvailable(8000);
+
// configure a global transacted error handler
errorHandler(transactionErrorHandler(required));
@@ -38,7 +41,7 @@ public class JmsToHttpWithRollbackRoute
// must setup policy for each route due CAMEL-1475 bug
.policy(required)
// send a request to http and get the response
- .to("http://localhost:8080/sender")
+ .to("http://localhost:" + port + "/sender")
// convert the response to String so we can work with it and avoid
streams only be readable once
// as the http component will return data as a stream
.convertBodyTo(String.class)
@@ -57,7 +60,7 @@ public class JmsToHttpWithRollbackRoute
// this is our http route that will fail the first 2 attempts
// before it sends an ok response
- from("jetty:http://localhost:8080/sender").process(new Processor() {
+ from("jetty:http://localhost:" + port + "/sender").process(new
Processor() {
public void process(Exchange exchange) throws Exception {
if (counter++ < 2) {
exchange.getOut().setBody(nok);