Author: cmueller
Date: Sun Feb 26 12:07:52 2012
New Revision: 1293815

URL: http://svn.apache.org/viewvc?rev=1293815&view=rev
Log:
use AvailablePortFinder to prevent the unit tests to fail with address already 
in use

Modified:
    
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java
    
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
    
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
    
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java

Modified: 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java?rev=1293815&r1=1293814&r2=1293815&view=diff
==============================================================================
--- 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java
 (original)
+++ 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpRoute.java
 Sun Feb 26 12:07:52 2012
@@ -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,6 +49,8 @@ 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));
 
@@ -54,7 +58,7 @@ public class JmsToHttpRoute extends Spri
             // must setup policy for each route due CAMEL-1475 bug
             .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/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java?rev=1293815&r1=1293814&r2=1293815&view=diff
==============================================================================
--- 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
 (original)
+++ 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
 Sun Feb 26 12:07:52 2012
@@ -36,7 +36,7 @@ public class JmsToHttpWithOnExceptionAnd
     private String noAccess = "<?xml version=\"1.0\"?><reply><status>Access 
denied</status></reply>";
 
     public void configure() throws Exception {
-        int port = AvailablePortFinder.getNextAvailable();
+        port = AvailablePortFinder.getNextAvailable(8000);
         
         // if its a 404 then regard it as handled
         onException(HttpOperationFailedException.class).onWhen(new Predicate() 
{

Modified: 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java?rev=1293815&r1=1293814&r2=1293815&view=diff
==============================================================================
--- 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
 (original)
+++ 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
 Sun Feb 26 12:07:52 2012
@@ -36,7 +36,7 @@ public class JmsToHttpWithOnExceptionRou
     private String noAccess = "<?xml version=\"1.0\"?><reply><status>Access 
denied</status></reply>";
 
     public void configure() throws Exception {
-        int port = AvailablePortFinder.getNextAvailable();
+        port = AvailablePortFinder.getNextAvailable(8000);
 
         // configure a global transacted error handler
         errorHandler(transactionErrorHandler(required));

Modified: 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java?rev=1293815&r1=1293814&r2=1293815&view=diff
==============================================================================
--- 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java
 (original)
+++ 
camel/branches/camel-2.8.x/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithRollbackRoute.java
 Sun Feb 26 12:07:52 2012
@@ -32,7 +32,7 @@ import org.apache.camel.test.AvailablePo
 public class JmsToHttpWithRollbackRoute extends JmsToHttpRoute {
 
     public void configure() throws Exception {
-        int port = AvailablePortFinder.getNextAvailable();
+        port = AvailablePortFinder.getNextAvailable(8000);
 
         // configure a global transacted error handler
         errorHandler(transactionErrorHandler(required));


Reply via email to