You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/06/12 14:29:39 UTC

svn commit: r1134920 [1/2] - /camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/

Author: davsclaus
Date: Sun Jun 12 12:29:37 2011
New Revision: 1134920

URL: http://svn.apache.org/viewvc?rev=1134920&view=rev
Log:
CAMEL-3586: Using dynamic port numbers for unit tests.

Added:
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java
Modified:
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MessageIOSessionTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaClientServerTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConsumerTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaDisconnectTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFiltersTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOnlyRouteTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutCloseSessionWhenCompleteTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTextLineDelimiterTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutWithForcedNoResponseTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaLoggerOptionTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaMaxLineLengthTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoDefaultCodecTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoResponseFromServerTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownMockTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaSendToProcessorTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineDelimiterTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaUdpTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaUdpUsingTemplateTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaUdpWithInOutUsingPlainSocketTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVMCustomCodecTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVMFileTcpTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVMTextlineProtocolTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVMTransferExchangeOptionTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVmTest.java
    camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/ReverserServer.java

Added: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java?rev=1134920&view=auto
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java (added)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java Sun Jun 12 12:29:37 2011
@@ -0,0 +1,97 @@
+/**
+ * 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.mina;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Properties;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ *
+ */
+public class BaseMinaTest extends CamelTestSupport {
+    private static volatile int port;
+
+    @BeforeClass
+    public static void initPort() throws Exception {
+        File file = new File("./target/minaport.txt");
+        file = file.getAbsoluteFile();
+
+        if (!file.exists()) {
+            // start from somewhere in the 255xx range
+            port = AvailablePortFinder.getNextAvailable(25500);
+        } else {
+            // read port number from file
+            String s = IOConverter.toString(file, null);
+            port = Integer.parseInt(s);
+            // use next port
+            port++;
+        }
+
+    }
+
+    @AfterClass
+    public static void savePort() throws Exception {
+        File file = new File("./target/minaport.txt");
+        file = file.getAbsoluteFile();
+
+        // save to file, do not append
+        FileOutputStream fos = new FileOutputStream(file, false);
+        try {
+            fos.write(String.valueOf(port).getBytes());
+        } finally {
+            fos.close();
+        }
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        context.addComponent("properties", new PropertiesComponent("ref:prop"));
+        return context;
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+
+        Properties prop = new Properties();
+        prop.setProperty("port", "" + getPort());
+        jndi.bind("prop", prop);
+
+        return jndi;
+    }
+
+    protected int getNextPort() {
+        port = AvailablePortFinder.getNextAvailable(port + 1);
+        return port;
+    }
+
+    protected int getPort() {
+        return port;
+    }
+
+}

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MessageIOSessionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MessageIOSessionTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MessageIOSessionTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MessageIOSessionTest.java Sun Jun 12 12:29:37 2011
@@ -22,20 +22,19 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * Unit test to check if the message of an exchange send from the MinaConsumer
  * is a MinaMessage.
  */
-public class MessageIOSessionTest extends CamelTestSupport {
+public class MessageIOSessionTest extends BaseMinaTest {
 
     @Test
     public void testIoSession() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
-        template.sendBody("mina:tcp://localhost:9200?textline=true&sync=false", "Hello World");
+        template.sendBody("mina:tcp://localhost:{{port}}?textline=true&sync=false", "Hello World");
         assertMockEndpointsSatisfied();
 
         Exchange exchange = mock.getExchanges().get(0);
@@ -48,7 +47,7 @@ public class MessageIOSessionTest extend
     public void testLocalAndRemoteAddressHeaders() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
-        template.sendBody("mina:tcp://localhost:9200?textline=true&sync=false", "Hello World");
+        template.sendBody("mina:tcp://localhost:{{port}}?textline=true&sync=false", "Hello World");
         assertMockEndpointsSatisfied();
         
         Message message = mock.getExchanges().get(0).getIn();
@@ -63,7 +62,7 @@ public class MessageIOSessionTest extend
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("mina:tcp://localhost:9200?textline=true&sync=false")
+                from("mina:tcp://localhost:{{port}}?textline=true&sync=false")
                     .to("log://mytest")
                     .to("mock:result");
             }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaClientServerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaClientServerTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaClientServerTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaClientServerTest.java Sun Jun 12 12:29:37 2011
@@ -19,18 +19,17 @@ package org.apache.camel.component.mina;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * @version 
  */
-public class MinaClientServerTest extends CamelTestSupport {
+public class MinaClientServerTest extends BaseMinaTest {
 
     @Test
     public void testSendToServer() {
         // START SNIPPET: e3
-        String out = (String) template.requestBody("mina:tcp://localhost:5555?sync=true&textline=true", "Claus");
+        String out = (String) template.requestBody("mina:tcp://localhost:{{port}}?sync=true&textline=true", "Claus");
         assertEquals("Hello Claus", out);
         // END SNIPPET: e3
     }
@@ -41,10 +40,10 @@ public class MinaClientServerTest extend
             @Override
             public void configure() throws Exception {
                 // START SNIPPET: e1
-                // lets setup a server on port 5555
+                // lets setup a server on port {{port}}
                 // we set the sync option so we will send a reply
                 // and we let the request-reply be processed in the MyServerProcessor
-                from("mina:tcp://localhost:5555?sync=true&textline=true").process(new MyServerProcessor());
+                from("mina:tcp://localhost:{{port}}?sync=true&textline=true").process(new MyServerProcessor());
                 // END SNIPPET: e1
             }
         };

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConsumerTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConsumerTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConsumerTest.java Sun Jun 12 12:29:37 2011
@@ -21,13 +21,15 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * Unit test for wiki documentation
  */
-public class MinaConsumerTest extends CamelTestSupport {
+public class MinaConsumerTest extends BaseMinaTest {
+
+    int port1;
+    int port2;
 
     @Test
     public void testSendTextlineText() throws Exception {
@@ -35,7 +37,7 @@ public class MinaConsumerTest extends Ca
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
 
-        template.sendBody("mina:tcp://localhost:6200?textline=true&sync=false", "Hello World");
+        template.sendBody("mina:tcp://localhost:" + port1 + "?textline=true&sync=false", "Hello World");
 
         assertMockEndpointsSatisfied();
         // END SNIPPET: e2
@@ -44,7 +46,7 @@ public class MinaConsumerTest extends Ca
     @Test
     public void testSendTextlineSyncText() throws Exception {
         // START SNIPPET: e4
-        String response = (String)template.requestBody("mina:tcp://localhost:9201?textline=true&sync=true", "World");
+        String response = (String)template.requestBody("mina:tcp://localhost:" + port2 + "?textline=true&sync=true", "World");
         assertEquals("Bye World", response);
         // END SNIPPET: e4
     }
@@ -52,12 +54,15 @@ public class MinaConsumerTest extends Ca
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
+                port1 = getPort();
+                port2 = getNextPort();
+
                 // START SNIPPET: e1
-                from("mina:tcp://localhost:6200?textline=true&sync=false").to("mock:result");
+                from("mina:tcp://localhost:" + port1 + "?textline=true&sync=false").to("mock:result");
                 // END SNIPPET: e1
 
                 // START SNIPPET: e3
-                from("mina:tcp://localhost:9201?textline=true&sync=true").process(new Processor() {
+                from("mina:tcp://localhost:" + port2 + "?textline=true&sync=true").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         String body = exchange.getIn().getBody(String.class);
                         exchange.getOut().setBody("Bye " + body);

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java Sun Jun 12 12:29:37 2011
@@ -20,7 +20,6 @@ import org.apache.camel.ResolveEndpointF
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
@@ -34,11 +33,7 @@ import org.junit.Test;
 /**
  * Unit test with custom codec.
  */
-public class MinaCustomCodecTest extends CamelTestSupport {
-
-    protected String uri = "mina:tcp://localhost:9130?sync=true&codec=#myCodec";
-   
-    protected String badUri = "mina:tcp://localhost:9130?sync=true&codec=#XXX";
+public class MinaCustomCodecTest extends BaseMinaTest {
 
     @Test
     public void testMyCodec() throws Exception {
@@ -46,7 +41,7 @@ public class MinaCustomCodecTest extends
         mock.expectedMessageCount(1);
         mock.expectedBodiesReceived("Bye World");
 
-        Object out = template.requestBody(uri, "Hello World");
+        Object out = template.requestBody("mina:tcp://localhost:{{port}}?sync=true&codec=#myCodec", "Hello World");
         assertEquals("Bye World", out);
 
         mock.assertIsSatisfied();
@@ -54,7 +49,7 @@ public class MinaCustomCodecTest extends
     
     @Test
     public void testTCPEncodeUTF8InputIsString() throws Exception {
-        final String myUri = "mina:tcp://localhost:9085?encoding=UTF-8&sync=false";
+        final String myUri = "mina:tcp://localhost:" + getNextPort() + "?encoding=UTF-8&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from(myUri).to("mock:result");
@@ -76,7 +71,7 @@ public class MinaCustomCodecTest extends
     @Test
     public void testBadConfiguration() throws Exception {
         try {
-            template.sendBody(badUri, "Hello World");
+            template.sendBody("mina:tcp://localhost:{{port}}?sync=true&codec=#XXX", "Hello World");
             fail("Should have thrown a ResolveEndpointFailedException");
         } catch (ResolveEndpointFailedException e) {
             // ok
@@ -92,7 +87,7 @@ public class MinaCustomCodecTest extends
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from(uri).transform(constant("Bye World")).to("mock:result");                
+                from("mina:tcp://localhost:{{port}}?sync=true&codec=#myCodec").transform(constant("Bye World")).to("mock:result");
             }
         };
     }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaDisconnectTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaDisconnectTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaDisconnectTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaDisconnectTest.java Sun Jun 12 12:29:37 2011
@@ -19,19 +19,16 @@ package org.apache.camel.component.mina;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * Unit test for close session when complete test.
  */
-public class MinaDisconnectTest extends CamelTestSupport {
-
-    private String uri = "mina:tcp://localhost:8080?sync=true&textline=true&disconnect=true";
+public class MinaDisconnectTest extends BaseMinaTest {
 
     @Test
     public void testCloseSessionWhenComplete() throws Exception {
-        Object out = template.requestBody(uri, "Claus");
+        Object out = template.requestBody("mina:tcp://localhost:{{port}}?sync=true&textline=true&disconnect=true", "Claus");
         assertEquals("Bye Claus", out);
     }
 
@@ -39,7 +36,7 @@ public class MinaDisconnectTest extends 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from(uri).process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?sync=true&textline=true&disconnect=true").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         String body = exchange.getIn().getBody(String.class);
                         exchange.getOut().setBody("Bye " + body);

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java Sun Jun 12 12:29:37 2011
@@ -24,7 +24,6 @@ import org.apache.camel.Producer;
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
@@ -32,11 +31,11 @@ import org.junit.Test;
  *
  * @version 
  */
-public class MinaEncodingTest extends CamelTestSupport {
+public class MinaEncodingTest extends BaseMinaTest {
 
     @Test
     public void testTCPEncodeUTF8InputIsBytes() throws Exception {
-        final String uri = "mina:tcp://localhost:9083?encoding=UTF-8&sync=false";
+        final String uri = "mina:tcp://localhost:{{port}}?encoding=UTF-8&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from(uri).to("mock:result");
@@ -57,7 +56,7 @@ public class MinaEncodingTest extends Ca
 
     @Test
     public void testTCPEncodeUTF8InputIsString() throws Exception {
-        final String uri = "mina:tcp://localhost:9084?encoding=UTF-8&sync=false";
+        final String uri = "mina:tcp://localhost:{{port}}?encoding=UTF-8&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from(uri).to("mock:result");
@@ -78,7 +77,7 @@ public class MinaEncodingTest extends Ca
 
     @Test
     public void testTCPEncodeUTF8TextLineInputIsString() throws Exception {
-        final String uri = "mina:tcp://localhost:9085?textline=true&encoding=UTF-8&sync=false";
+        final String uri = "mina:tcp://localhost:{{port}}?textline=true&encoding=UTF-8&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from(uri).to("mock:result");
@@ -102,7 +101,7 @@ public class MinaEncodingTest extends Ca
 
     @Test
     public void testUDPEncodeUTF8InputIsBytes() throws Exception {
-        final String uri = "mina:udp://localhost:9080?encoding=UTF-8&sync=false";
+        final String uri = "mina:udp://localhost:{{port}}?encoding=UTF-8&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from(uri).to("mock:result");
@@ -123,7 +122,7 @@ public class MinaEncodingTest extends Ca
 
     @Test
     public void testUDPEncodeUTF8InputIsString() throws Exception {
-        final String uri = "mina:udp://localhost:9080?encoding=UTF-8&sync=false";
+        final String uri = "mina:udp://localhost:{{port}}?encoding=UTF-8&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from(uri).to("mock:result");
@@ -151,7 +150,7 @@ public class MinaEncodingTest extends Ca
         final String hello = "Hello Thai Elephant \u0E08";
         final String bye = "Hello Thai Elephant \u0E08";
 
-        final String uri = "mina:udp://localhost:9080?sync=true&encoding=UTF-8";
+        final String uri = "mina:udp://localhost:{{port}}?sync=true&encoding=UTF-8";
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from(uri).process(new Processor() {
@@ -179,7 +178,7 @@ public class MinaEncodingTest extends Ca
 
     @Test
     public void testInvalidEncoding() throws Exception {
-        final String uri = "mina:tcp://localhost:9080?textline=true&encoding=XXX&sync=false";
+        final String uri = "mina:tcp://localhost:{{port}}?textline=true&encoding=XXX&sync=false";
 
         try {
             context.addRoutes(new RouteBuilder() {

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java Sun Jun 12 12:29:37 2011
@@ -20,7 +20,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
@@ -28,15 +27,12 @@ import org.junit.Test;
  *
  * @version 
  */
-public class MinaExchangeDefaultTimeOutTest extends CamelTestSupport {
-
-    private static final int PORT = 6338;
-    protected String uri = "mina:tcp://localhost:" + PORT + "?textline=true&sync=true";
+public class MinaExchangeDefaultTimeOutTest extends BaseMinaTest {
 
     @Test
     public void testDefaultTimeOut() {
         try {
-            String result = (String)template.requestBody(uri, "Hello World");
+            String result = (String)template.requestBody("mina:tcp://localhost:{{port}}?textline=true&sync=true", "Hello World");
             assertEquals("Okay I will be faster in the future", result);
         } catch (RuntimeCamelException e) {
             fail("Should not get a RuntimeCamelException");
@@ -46,7 +42,7 @@ public class MinaExchangeDefaultTimeOutT
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from(uri).process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?textline=true&sync=true").process(new Processor() {
                     public void process(Exchange e) throws Exception {
                         assertEquals("Hello World", e.getIn().getBody(String.class));
                         // MinaProducer has a default timeout of 30 seconds so we just wait 5 seconds

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java Sun Jun 12 12:29:37 2011
@@ -22,7 +22,6 @@ import org.apache.camel.ExchangeTimedOut
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
@@ -30,16 +29,13 @@ import org.junit.Test;
  *
  * @version 
  */
-public class MinaExchangeTimeOutTest extends CamelTestSupport {
-
-    private static final int PORT = 6336;
-    protected String uri = "mina:tcp://localhost:" + PORT + "?textline=true&sync=true";
+public class MinaExchangeTimeOutTest extends BaseMinaTest {
 
     @Test
     public void testUsingTimeoutParameter() throws Exception {
 
         // use a timeout value of 2 seconds (timeout is in millis) so we should actually get a response in this test
-        Endpoint endpoint = context.getEndpoint("mina:tcp://localhost:" + PORT + "?textline=true&sync=true&timeout=2000");
+        Endpoint endpoint = context.getEndpoint("mina:tcp://localhost:{{port}}?textline=true&sync=true&timeout=2000");
         Producer producer = endpoint.createProducer();
         producer.start();
         Exchange exchange = producer.createExchange();
@@ -56,7 +52,7 @@ public class MinaExchangeTimeOutTest ext
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from(uri).process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?textline=true&sync=true").process(new Processor() {
                     public void process(Exchange e) throws Exception {
                         assertEquals("Hello World", e.getIn().getBody(String.class));
                         // MinaProducer has a default timeout of 30 seconds so we just wait 5 seconds

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java Sun Jun 12 12:29:37 2011
@@ -18,13 +18,12 @@ package org.apache.camel.component.mina;
 
 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 MinaFileTcpTest extends CamelTestSupport {
+public class MinaFileTcpTest extends BaseMinaTest {
 
     @Test
     public void testMinaRoute() throws Exception {
@@ -39,11 +38,11 @@ public class MinaFileTcpTest extends Cam
         return new RouteBuilder() {
             public void configure() {
                 // lets setup a server
-                from("mina:tcp://localhost:9123?sync=false&textline=true")
+                from("mina:tcp://localhost:{{port}}?sync=false&textline=true")
                     .to("mock:results");
 
                 from("file:src/test/data?noop=true&fileName=message1.txt").
-                    to("mina:tcp://localhost:9123?sync=false&textline=true");
+                    to("mina:tcp://localhost:{{port}}?sync=false&textline=true");
             }
         };
     }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java Sun Jun 12 12:29:37 2011
@@ -18,13 +18,12 @@ package org.apache.camel.component.mina;
 
 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 MinaFileUdpTest extends CamelTestSupport {
+public class MinaFileUdpTest extends BaseMinaTest {
 
     @Test
     public void testMinaRoute() throws Exception {
@@ -39,10 +38,10 @@ public class MinaFileUdpTest extends Cam
         return new RouteBuilder() {
             public void configure() {
                 // lets setup a server
-                from("mina:udp://localhost:9123?sync=false&textline=true").to("mock:results");
+                from("mina:udp://localhost:{{port}}?sync=false&textline=true").to("mock:results");
 
                 from("file:src/test/data?noop=true").
-                        to("mina:udp://localhost:9123?sync=false&textline=true");
+                        to("mina:udp://localhost:{{port}}?sync=false&textline=true");
             }
         };
     }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFiltersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFiltersTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFiltersTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFiltersTest.java Sun Jun 12 12:29:37 2011
@@ -26,7 +26,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.apache.mina.common.IoFilter;
 import org.apache.mina.common.IoFilterAdapter;
@@ -36,16 +35,16 @@ import org.junit.Test;
 /**
  * For unit testing the <tt>filters</tt> option.
  */
-public class MinaFiltersTest extends CamelTestSupport {
+public class MinaFiltersTest extends BaseMinaTest {
 
     @Test
     public void testFilterListRef() throws Exception {
-        testFilter("mina:tcp://localhost:6321?textline=true&minaLogger=true&sync=false&filters=#myFilters");
+        testFilter("mina:tcp://localhost:{{port}}?textline=true&minaLogger=true&sync=false&filters=#myFilters");
     }
 
     @Test
     public void testFilterElementRef() throws Exception {
-        testFilter("mina:tcp://localhost:6322?textline=true&minaLogger=true&sync=false&filters=#myFilter");
+        testFilter("mina:tcp://localhost:{{port}}?textline=true&minaLogger=true&sync=false&filters=#myFilter");
     }
 
     @Override
@@ -53,10 +52,9 @@ public class MinaFiltersTest extends Cam
         TestFilter.called = 0;
         super.tearDown();
     }
-    
+
     private void testFilter(final String uri) throws Exception {
         context.addRoutes(new RouteBuilder() {
-
             public void configure() throws Exception {
                 from(uri).to("mock:result");
             }
@@ -97,19 +95,21 @@ public class MinaFiltersTest extends Cam
         answer.bind("myFilter", myFilter);
         return answer;
     }
-}
 
-class TestFilter extends IoFilterAdapter {
+    public static final class TestFilter extends IoFilterAdapter {
 
-    public static volatile int called;
+        public static volatile int called;
 
-    @Override
-    public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception {
-        incCalled();
-        nextFilter.sessionCreated(session);
+        @Override
+        public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception {
+            incCalled();
+            nextFilter.sessionCreated(session);
+        }
+
+        public static synchronized void incCalled() {
+            called++;
+        }
     }
 
-    public static synchronized void incCalled() {
-        called++;
-    }
 }
+

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOnlyRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOnlyRouteTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOnlyRouteTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOnlyRouteTest.java Sun Jun 12 12:29:37 2011
@@ -20,14 +20,13 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * Unit test to verify that MINA can be used with an InOnly MEP but still use sync to send and receive data
  * from a remote server.
  */
-public class MinaInOnlyRouteTest extends CamelTestSupport {
+public class MinaInOnlyRouteTest extends BaseMinaTest {
 
     @Test
     public void testInOnlyUsingMina() throws Exception {
@@ -42,7 +41,7 @@ public class MinaInOnlyRouteTest extends
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("mina:tcp://localhost:8080?sync=true").process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?sync=true").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         String body = exchange.getIn().getBody(String.class);
                         exchange.getOut().setBody("Bye " + body);
@@ -51,7 +50,7 @@ public class MinaInOnlyRouteTest extends
 
                 from("timer://start?period=10000&delay=2000")
                         .setBody(constant("Claus"))                
-                        .to("mina:tcp://localhost:8080?sync=true&lazySessionCreation=true")
+                        .to("mina:tcp://localhost:{{port}}?sync=true&lazySessionCreation=true")
                         .to("mock:result");
             }
         };

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutCloseSessionWhenCompleteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutCloseSessionWhenCompleteTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutCloseSessionWhenCompleteTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutCloseSessionWhenCompleteTest.java Sun Jun 12 12:29:37 2011
@@ -19,17 +19,16 @@ package org.apache.camel.component.mina;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * Unit test for close session when complete test.
  */
-public class MinaInOutCloseSessionWhenCompleteTest extends CamelTestSupport {
+public class MinaInOutCloseSessionWhenCompleteTest extends BaseMinaTest {
 
     @Test
     public void testCloseSessionWhenComplete() throws Exception {
-        Object out = template.requestBody("mina:tcp://localhost:8080?sync=true&textline=true", "Claus");
+        Object out = template.requestBody("mina:tcp://localhost:{{port}}?sync=true&textline=true", "Claus");
         assertEquals("Bye Claus", out);
     }
 
@@ -37,7 +36,7 @@ public class MinaInOutCloseSessionWhenCo
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("mina:tcp://localhost:8080?sync=true&textline=true").process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?sync=true&textline=true").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         String body = exchange.getIn().getBody(String.class);
                         exchange.getOut().setBody("Bye " + body);

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTest.java Sun Jun 12 12:29:37 2011
@@ -20,14 +20,13 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * Unit test to verify that MINA can be used with an InOut MEP but still use sync to send and receive data
  * from a remote server.
  */
-public class MinaInOutRouteTest extends CamelTestSupport {
+public class MinaInOutRouteTest extends BaseMinaTest {
 
     @Test
     public void testInOutUsingMina() throws Exception {
@@ -47,7 +46,7 @@ public class MinaInOutRouteTest extends 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("mina:tcp://localhost:8080?sync=true").process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?sync=true").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         String body = exchange.getIn().getBody(String.class);
                         exchange.getOut().setBody("Bye " + body);
@@ -55,7 +54,7 @@ public class MinaInOutRouteTest extends 
                 });
 
                 from("direct:in")
-                        .to("mina:tcp://localhost:8080?sync=true&lazySessionCreation=true")
+                        .to("mina:tcp://localhost:{{port}}?sync=true&lazySessionCreation=true")
                         .to("mock:result");
             }
         };

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTextLineDelimiterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTextLineDelimiterTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTextLineDelimiterTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutRouteTextLineDelimiterTest.java Sun Jun 12 12:29:37 2011
@@ -20,16 +20,13 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * Unit test to verify that MINA can be used with an InOut MEP but still use sync to send and receive data
  * from a remote server and using MAC textline delimiter.
  */
-public class MinaInOutRouteTextLineDelimiterTest extends CamelTestSupport {
-
-    private String uri = "mina:tcp://localhost:8080?sync=true&textline=true&textlineDelimiter=MAC";
+public class MinaInOutRouteTextLineDelimiterTest extends BaseMinaTest {
 
     @Test
     public void testInOutUsingMina() throws Exception {
@@ -38,7 +35,7 @@ public class MinaInOutRouteTextLineDelim
         // we should preserve headers
         mock.setResultWaitTime(5000);
 
-        Object out = template.requestBody(uri, "Claus");
+        Object out = template.requestBody("mina:tcp://localhost:{{port}}?sync=true&textline=true&textlineDelimiter=MAC", "Claus");
 
         assertMockEndpointsSatisfied();
         assertEquals("Bye Claus", out);
@@ -48,7 +45,7 @@ public class MinaInOutRouteTextLineDelim
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from(uri).process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?sync=true&textline=true&textlineDelimiter=MAC").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         String body = exchange.getIn().getBody(String.class);
                         exchange.getOut().setBody("Bye " + body);

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutWithForcedNoResponseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutWithForcedNoResponseTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutWithForcedNoResponseTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaInOutWithForcedNoResponseTest.java Sun Jun 12 12:29:37 2011
@@ -19,24 +19,26 @@ package org.apache.camel.component.mina;
 import org.apache.camel.ExchangeTimedOutException;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * Unit test with InOut however we want sometimes to not send a response.
  */
-public class MinaInOutWithForcedNoResponseTest extends CamelTestSupport {
+public class MinaInOutWithForcedNoResponseTest extends BaseMinaTest {
+
+    int port1;
+    int port2;
 
     @Test
     public void testResponse() throws Exception {
-        Object out = template.requestBody("mina:tcp://localhost:4444?sync=true", "Copenhagen");
+        Object out = template.requestBody("mina:tcp://localhost:" + port1 + "?sync=true", "Copenhagen");
         assertEquals("Hello Claus", out);
     }
 
     @Test
     public void testNoResponse() throws Exception {
         try {
-            template.requestBody("mina:tcp://localhost:4444?sync=true", "London");
+            template.requestBody("mina:tcp://localhost:" + port1 + "?sync=true", "London");
             fail("Should throw an exception");
         } catch (RuntimeCamelException e) {
             assertTrue(e.getCause().getMessage().startsWith("No response"));
@@ -46,7 +48,7 @@ public class MinaInOutWithForcedNoRespon
     @Test
     public void testNoResponseDisconnectOnNoReplyFalse() throws Exception {
         try {
-            template.requestBody("mina:tcp://localhost:4445?sync=true&timeout=3000", "London");
+            template.requestBody("mina:tcp://localhost:" + port2 + "?sync=true&timeout=3000", "London");
             fail("Should throw an exception");
         } catch (RuntimeCamelException e) {
             assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
@@ -57,12 +59,15 @@ public class MinaInOutWithForcedNoRespon
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("mina:tcp://localhost:4444?sync=true")
+                port1 = getPort();
+                port2 = getNextPort();
+
+                from("mina:tcp://localhost:" + port1 + "?sync=true")
                     .choice()
                         .when(body().isEqualTo("Copenhagen")).transform(constant("Hello Claus"))
                         .otherwise().transform(constant(null));
 
-                from("mina:tcp://localhost:4445?sync=true&disconnectOnNoReply=false&noReplyLogLevel=OFF")
+                from("mina:tcp://localhost:" + port2 + "?sync=true&disconnectOnNoReply=false&noReplyLogLevel=OFF")
                     .choice()
                         .when(body().isEqualTo("Copenhagen")).transform(constant("Hello Claus"))
                         .otherwise().transform(constant(null));

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaLoggerOptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaLoggerOptionTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaLoggerOptionTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaLoggerOptionTest.java Sun Jun 12 12:29:37 2011
@@ -23,18 +23,17 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.mina.common.IoSession;
 import org.junit.Test;
 
 /**
  * For unit testing the <tt>logger</tt> option.
  */
-public class MinaLoggerOptionTest extends CamelTestSupport {
+public class MinaLoggerOptionTest extends BaseMinaTest {
 
     @Test
     public void testLoggerOptionTrue() throws Exception {
-        final String uri = "mina:tcp://localhost:6321?textline=true&minaLogger=true&sync=false";
+        final String uri = "mina:tcp://localhost:{{port}}?textline=true&minaLogger=true&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() throws Exception {
                 from(uri).to("mock:result");
@@ -65,7 +64,7 @@ public class MinaLoggerOptionTest extend
 
     @Test
     public void testLoggerOptionFalse() throws Exception {
-        final String uri = "mina:tcp://localhost:6321?textline=true&minaLogger=false&sync=false";
+        final String uri = "mina:tcp://localhost:{{port}}?textline=true&minaLogger=false&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() throws Exception {
                 from(uri).to("mock:result");
@@ -96,7 +95,7 @@ public class MinaLoggerOptionTest extend
 
     @Test
     public void testNoLoggerOption() throws Exception {
-        final String uri = "mina:tcp://localhost:6321?textline=true&sync=false";
+        final String uri = "mina:tcp://localhost:{{port}}?textline=true&sync=false";
         context.addRoutes(new RouteBuilder() {
             public void configure() throws Exception {
                 from(uri).to("mock:result");

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaMaxLineLengthTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaMaxLineLengthTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaMaxLineLengthTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaMaxLineLengthTest.java Sun Jun 12 12:29:37 2011
@@ -19,13 +19,12 @@ package org.apache.camel.component.mina;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * @version 
  */
-public class MinaMaxLineLengthTest extends CamelTestSupport {
+public class MinaMaxLineLengthTest extends BaseMinaTest {
 
     @Test
     public void testSendToServer() {
@@ -35,7 +34,7 @@ public class MinaMaxLineLengthTest exten
         }
 
         // START SNIPPET: e3
-        String out = (String) template.requestBody("mina:tcp://localhost:5555?sync=true&textline=true&encoderMaxLineLength=5000&decoderMaxLineLength=5000", request);
+        String out = (String) template.requestBody("mina:tcp://localhost:{{port}}?sync=true&textline=true&encoderMaxLineLength=5000&decoderMaxLineLength=5000", request);
         assertEquals(request, out);
         // END SNIPPET: e3
     }
@@ -46,10 +45,11 @@ public class MinaMaxLineLengthTest exten
             @Override
             public void configure() throws Exception {
                 // START SNIPPET: e1
-                // lets setup a server on port 5555
+                // lets setup a server on port {{port}}
                 // we set the sync option so we will send a reply
                 // and we let the request-reply be processed in the MyServerProcessor
-                from("mina:tcp://localhost:5555?sync=true&textline=true&encoderMaxLineLength=5000&decoderMaxLineLength=5000").process(new MyServerProcessor());
+                from("mina:tcp://localhost:{{port}}?sync=true&textline=true&encoderMaxLineLength=5000&decoderMaxLineLength=5000")
+                        .process(new MyServerProcessor());
                 // END SNIPPET: e1
             }
         };

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoDefaultCodecTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoDefaultCodecTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoDefaultCodecTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoDefaultCodecTest.java Sun Jun 12 12:29:37 2011
@@ -19,21 +19,26 @@ package org.apache.camel.component.mina;
 import java.util.List;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.mina.common.IoFilterChain.Entry;
 import org.junit.Test;
 
 /**
  * For unit testing the <tt>noDefaultCodec</tt> option.
  */
-public class MinaNoDefaultCodecTest extends CamelTestSupport {
+public class MinaNoDefaultCodecTest extends BaseMinaTest {
+
+    int port1;
+    int port2;
 
     @Test
     public void testFilter() throws Exception {
-        final String uri1 = "mina:tcp://localhost:6321?allowDefaultCodec=false";
-        final String uri2 = "mina:tcp://localhost:6322";
-        context.addRoutes(new RouteBuilder() {
+        port1 = getPort();
+        port2 = getNextPort();
 
+        final String uri1 = "mina:tcp://localhost:" + port1 + "?allowDefaultCodec=false";
+        final String uri2 = "mina:tcp://localhost:" + port2;
+
+        context.addRoutes(new RouteBuilder() {
             public void configure() throws Exception {
                 from(uri1).to("mock:result");
                 from(uri2).to("mock:result");

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoResponseFromServerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoResponseFromServerTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoResponseFromServerTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaNoResponseFromServerTest.java Sun Jun 12 12:29:37 2011
@@ -21,7 +21,6 @@ import org.apache.camel.RuntimeCamelExce
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
@@ -34,9 +33,7 @@ import org.junit.Test;
 /**
  * Unit test to test what happens if remote server closes session but doesn't reply
  */
-public class MinaNoResponseFromServerTest extends CamelTestSupport {
-
-    private String uri = "mina:tcp://localhost:11300?sync=true&codec=#myCodec";
+public class MinaNoResponseFromServerTest extends BaseMinaTest {
 
     @Test
     public void testNoResponse() throws Exception {
@@ -44,7 +41,7 @@ public class MinaNoResponseFromServerTes
         mock.expectedMessageCount(0);
 
         try {
-            template.requestBody(uri, "Hello World");
+            template.requestBody("mina:tcp://localhost:{{port}}?sync=true&codec=#myCodec", "Hello World");
             fail("Should throw a CamelExchangeException");
         } catch (RuntimeCamelException e) {
             assertIsInstanceOf(CamelExchangeException.class, e.getCause());
@@ -63,7 +60,8 @@ public class MinaNoResponseFromServerTes
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from(uri).transform(constant("Bye World")).to("mock:result");
+                from("mina:tcp://localhost:{{port}}?sync=true&codec=#myCodec")
+                        .transform(constant("Bye World")).to("mock:result");
             }
         };
     }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java Sun Jun 12 12:29:37 2011
@@ -26,13 +26,12 @@ import java.util.concurrent.Future;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * @version 
  */
-public class MinaProducerAnotherConcurrentTest extends CamelTestSupport {
+public class MinaProducerAnotherConcurrentTest extends BaseMinaTest {
 
     @Test
     public void testSimple() throws Exception {
@@ -79,9 +78,9 @@ public class MinaProducerAnotherConcurre
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("direct:start").to("mina:tcp://localhost:9080?sync=true");
+                from("direct:start").to("mina:tcp://localhost:{{port}}?sync=true");
 
-                from("mina:tcp://localhost:9080?sync=true").process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?sync=true").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         String body = exchange.getIn().getBody(String.class);
                         exchange.getOut().setBody("Bye " + body);

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java Sun Jun 12 12:29:37 2011
@@ -28,13 +28,12 @@ import java.util.concurrent.Future;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * @version 
  */
-public class MinaProducerConcurrentTest extends CamelTestSupport {
+public class MinaProducerConcurrentTest extends BaseMinaTest {
 
     @Test
     public void testNoConcurrentProducers() throws Exception {
@@ -55,7 +54,7 @@ public class MinaProducerConcurrentTest 
             final int index = i;
             Future out = executor.submit(new Callable<Object>() {
                 public Object call() throws Exception {
-                    return template.requestBody("mina:tcp://localhost:9090?sync=true", index, String.class);
+                    return template.requestBody("mina:tcp://localhost:{{port}}?sync=true", index, String.class);
                 }
             });
             responses.put(index, out);
@@ -79,7 +78,7 @@ public class MinaProducerConcurrentTest 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("mina:tcp://localhost:9090?sync=true").process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?sync=true").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         String body = exchange.getIn().getBody(String.class);
                         exchange.getOut().setBody("Bye " + body);

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownMockTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownMockTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownMockTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownMockTest.java Sun Jun 12 12:29:37 2011
@@ -23,7 +23,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.mina.transport.socket.nio.SocketConnector;
 import org.junit.Test;
 
@@ -34,9 +33,7 @@ import static org.easymock.classextensio
 /**
  * Unit testing for using a MinaProducer that it can shutdown properly (CAMEL-395)
  */
-public class MinaProducerShutdownMockTest extends CamelTestSupport {
-
-    private static final String URI = "mina:tcp://localhost:6321?textline=true&sync=false";
+public class MinaProducerShutdownMockTest extends BaseMinaTest {
 
     @Test
     public void testProducerShutdownTestingWithMock() throws Exception {
@@ -49,7 +46,7 @@ public class MinaProducerShutdownMockTes
         replay(mockConnector);
 
         // normal camel code to get a producer
-        Endpoint endpoint = context.getEndpoint(URI);
+        Endpoint endpoint = context.getEndpoint("mina:tcp://localhost:{{port}}?textline=true&sync=false");
         Exchange exchange = endpoint.createExchange();
         Producer producer = endpoint.createProducer();
         producer.start();
@@ -74,7 +71,7 @@ public class MinaProducerShutdownMockTes
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from(URI).to("mock:result");
+                from("mina:tcp://localhost:{{port}}?textline=true&sync=false").to("mock:result");
             }
         };
     }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownTest.java Sun Jun 12 12:29:37 2011
@@ -22,12 +22,14 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.Ignore;
 
 /**
  * Unit testing for using a MinaProducer that it can shutdown properly (CAMEL-395)
  * <p>
  * Run this test from maven: mvn exec:java and see the output if there is a error.
  */
+@Ignore
 public class MinaProducerShutdownTest {
 
     private static final String URI = "mina:tcp://localhost:6321?textline=true&sync=false";

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaSendToProcessorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaSendToProcessorTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaSendToProcessorTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaSendToProcessorTest.java Sun Jun 12 12:29:37 2011
@@ -18,17 +18,16 @@ package org.apache.camel.component.mina;
 
 import org.apache.camel.FailedToCreateProducerException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class MinaSendToProcessorTest extends CamelTestSupport {
+public class MinaSendToProcessorTest extends BaseMinaTest {
 
     @Test
     public void testConnectionOnStartupTest() throws Exception {
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("mina:tcp://localhost:6123?sync=false&lazySessionCreation=false");
+                from("direct:start").to("mina:tcp://localhost:{{port}}?sync=false&lazySessionCreation=false");
             }
         });
 
@@ -37,8 +36,6 @@ public class MinaSendToProcessorTest ext
             fail("Should have thrown an exception");
         } catch (FailedToCreateProducerException e) {
             // expected
-            assertEquals("Failed to create Producer for endpoint: Endpoint[mina://tcp://localhost:6123?lazySessionCreation=false&sync=false]."
-                         + " Reason: org.apache.mina.common.RuntimeIOException: Failed to get the session.", e.getMessage());
         }
     }
 
@@ -47,7 +44,7 @@ public class MinaSendToProcessorTest ext
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("mina:tcp://localhost:6123?sync=false");
+                from("direct:start").to("mina:tcp://localhost:{{port}}?sync=false");
             }
         });
 

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java Sun Jun 12 12:29:37 2011
@@ -25,7 +25,6 @@ import java.net.Socket;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
@@ -33,12 +32,7 @@ import org.junit.Test;
  *
  * @version 
  */
-public class MinaTcpLineDelimiterUsingPlainSocketTest extends CamelTestSupport {
-
-    private static final int PORT = 6334;
-    // use parameter sync=true to force InOut pattern of the MinaExchange
-    // use MAC textline delimiter
-    protected String uri = "mina:tcp://localhost:" + PORT + "?textline=true&textlineDelimiter=MAC&sync=true";
+public class MinaTcpLineDelimiterUsingPlainSocketTest extends BaseMinaTest {
 
     @Test
     public void testSendAndReceiveOnce() throws Exception {
@@ -85,7 +79,7 @@ public class MinaTcpLineDelimiterUsingPl
         byte buf[] = new byte[128];
 
         Socket soc = new Socket();
-        soc.connect(new InetSocketAddress("localhost", PORT));
+        soc.connect(new InetSocketAddress("localhost", getPort()));
 
         // Send message using plain Socket to test if this works
         OutputStream os = null;
@@ -132,7 +126,7 @@ public class MinaTcpLineDelimiterUsingPl
                 // use no delay for fast unit testing
                 errorHandler(defaultErrorHandler().maximumRedeliveries(2));
 
-                from(uri).process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?textline=true&textlineDelimiter=MAC&sync=true").process(new Processor() {
                     public void process(Exchange e) {
                         String in = e.getIn().getBody(String.class);
                         if ("force-null-out-body".equals(in)) {

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTest.java Sun Jun 12 12:29:37 2011
@@ -16,14 +16,32 @@
  */
 package org.apache.camel.component.mina;
 
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
 /**
  * @version 
  */
-public class MinaTcpTest extends MinaVmTest {
+public class MinaTcpTest extends BaseMinaTest {
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+        Object body = "Hello there!";
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBodyAndHeader("mina:tcp://localhost:{{port}}?sync=false&minaLogger=true", body, "cheese", 123);
+
+        assertMockEndpointsSatisfied();
+    }
 
-    @Override
-    public void setUp() throws Exception {
-        uri = "mina:tcp://localhost:6123?sync=false";
-        super.setUp();
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("mina:tcp://localhost:{{port}}?sync=false&minaLogger=true")
+                        .to("log:before?showAll=true").to("mock:result").to("log:after?showAll=true");
+            }
+        };
     }
 }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineDelimiterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineDelimiterTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineDelimiterTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineDelimiterTest.java Sun Jun 12 12:29:37 2011
@@ -16,14 +16,33 @@
  */
 package org.apache.camel.component.mina;
 
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
 /**
  * @version 
  */
-public class MinaTcpTextlineDelimiterTest extends MinaVmTest {
+public class MinaTcpTextlineDelimiterTest extends BaseMinaTest {
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+        Object body = "Hello there!";
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBodyAndHeader("mina:tcp://localhost:{{port}}?sync=false&textline=true&textlineDelimiter=UNIX", body, "cheese", 123);
 
-    @Override
-    public void setUp() throws Exception {
-        uri = "mina:tcp://localhost:6124?sync=false&textline=true&textlineDelimiter=UNIX";
-        super.setUp();
+        assertMockEndpointsSatisfied();
     }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("mina:tcp://localhost:{{port}}?sync=false&textline=true&textlineDelimiter=UNIX")
+                        .to("log:before?showAll=true").to("mock:result").to("log:after?showAll=true");
+            }
+        };
+    }
+
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java Sun Jun 12 12:29:37 2011
@@ -16,14 +16,33 @@
  */
 package org.apache.camel.component.mina;
 
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
 /**
  * @version 
  */
-public class MinaTcpTextlineProtocolTest extends MinaVmTest {
+public class MinaTcpTextlineProtocolTest extends BaseMinaTest {
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+        Object body = "Hello there!";
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBodyAndHeader("mina:tcp://localhost:{{port}}?textline=true&sync=false", body, "cheese", 123);
 
-    @Override
-    public void setUp() throws Exception {
-        uri = "mina:tcp://localhost:6124?textline=true&sync=false";
-        super.setUp();
+        assertMockEndpointsSatisfied();
     }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("mina:tcp://localhost:{{port}}?textline=true&sync=false")
+                        .to("log:before?showAll=true").to("mock:result").to("log:after?showAll=true");
+            }
+        };
+    }
+
 }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutTest.java Sun Jun 12 12:29:37 2011
@@ -19,9 +19,6 @@ package org.apache.camel.component.mina;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
-import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
@@ -29,31 +26,40 @@ import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.Test;
 
 /**
  * @version 
  */
-public class MinaTcpWithInOutTest extends TestCase {
+public class MinaTcpWithInOutTest extends BaseMinaTest {
 
     private String uri;
     private Exchange receivedExchange;
     private CountDownLatch latch;
-    private CamelContext container;
 
+    @Test
     public void testMinaRouteWithInOut() throws Exception {
-        container = new DefaultCamelContext();
         latch = new CountDownLatch(1);
-        uri = "mina:tcp://localhost:6321?textline=true";
+        uri = "mina:tcp://localhost:{{port}}?textline=true";
 
-        ReverserServer server = new ReverserServer();
+        ReverserServer server = new ReverserServer(getPort());
         server.start();
 
-        container.addRoutes(createRouteBuilder());
-        container.start();
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:x").to(uri).process(new Processor() {
+                    public void process(Exchange e) {
+                        receivedExchange = e;
+                        latch.countDown();
+                    }
+                });
+            }
+        });
+        context.start();
 
         // now lets fire in a message
-        Endpoint endpoint = container.getEndpoint("direct:x");
+        Endpoint endpoint = context.getEndpoint("direct:x");
         Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
         Message message = exchange.getIn();
         message.setBody("Hello!");
@@ -70,24 +76,34 @@ public class MinaTcpWithInOutTest extend
         assertEquals("!olleH", receivedExchange.getIn().getBody());
 
         producer.stop();
-        container.stop();
+        context.stop();
         server.stop();
     }
 
+    @Test
     public void testMinaRouteWithInOutLazy() throws Exception {
-        container = new DefaultCamelContext();
         latch = new CountDownLatch(1);
-        uri = "mina:tcp://localhost:6321?textline=true&lazySessionCreation=true";
-
-        container.addRoutes(createRouteBuilder());
-        container.start();
+        uri = "mina:tcp://localhost:{{port}}?textline=true&lazySessionCreation=true";
 
         // The server is activated after Camel to check if the lazyness is working
-        ReverserServer server = new ReverserServer();
+        ReverserServer server = new ReverserServer(getPort());
         server.start();
 
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:x").to(uri).process(new Processor() {
+                    public void process(Exchange e) {
+                        receivedExchange = e;
+                        latch.countDown();
+                    }
+                });
+            }
+        });
+        context.start();
+
         // now lets fire in a message
-        Endpoint endpoint = container.getEndpoint("direct:x");
+        Endpoint endpoint = context.getEndpoint("direct:x");
         Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
         Message message = exchange.getIn();
         message.setBody("Hello!");
@@ -104,21 +120,13 @@ public class MinaTcpWithInOutTest extend
         assertEquals("!olleH", receivedExchange.getIn().getBody());
 
         producer.stop();
-        container.stop();
+        context.stop();
         server.stop();
     }
 
-    protected RouteBuilder createRouteBuilder() {
-        return new RouteBuilder() {
-            public void configure() {
-                from("direct:x").to(uri).process(new Processor() {
-                    public void process(Exchange e) {
-                        receivedExchange = e;
-                        latch.countDown();
-                    }
-                });
-            }
-        };
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
     }
 
 }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java Sun Jun 12 12:29:37 2011
@@ -25,7 +25,6 @@ import java.net.Socket;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
@@ -33,11 +32,7 @@ import org.junit.Test;
  *
  * @version 
  */
-public class MinaTcpWithInOutUsingPlainSocketTest extends CamelTestSupport {
-
-    private static final int PORT = 6333;
-    // use parameter sync=true to force InOut pattern of the MinaExchange
-    protected String uri = "mina:tcp://localhost:" + PORT + "?textline=true&sync=true";
+public class MinaTcpWithInOutUsingPlainSocketTest extends BaseMinaTest {
 
     @Test
     public void testSendAndReceiveOnce() throws Exception {
@@ -84,7 +79,7 @@ public class MinaTcpWithInOutUsingPlainS
         byte buf[] = new byte[128];
 
         Socket soc = new Socket();
-        soc.connect(new InetSocketAddress("localhost", PORT));
+        soc.connect(new InetSocketAddress("localhost", getPort()));
 
         // Send message using plain Socket to test if this works
         OutputStream os = null;
@@ -128,7 +123,7 @@ public class MinaTcpWithInOutUsingPlainS
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from(uri).process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?textline=true&sync=true").process(new Processor() {
                     public void process(Exchange e) {
                         String in = e.getIn().getBody(String.class);
                         if ("force-null-out-body".equals(in)) {

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java?rev=1134920&r1=1134919&r2=1134920&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java Sun Jun 12 12:29:37 2011
@@ -16,27 +16,20 @@
  */
 package org.apache.camel.component.mina;
 
-import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  * To unit test CAMEL-364.
  */
-public class MinaTcpWithIoOutProcessorExceptionTest extends CamelTestSupport {
-    private static final int PORT = 6334;
-    protected CamelContext container = new DefaultCamelContext();
-    // use parameter sync=true to force InOut pattern of the MinaExchange
-    protected String uri = "mina:tcp://localhost:" + PORT + "?textline=true&sync=true";
+public class MinaTcpWithIoOutProcessorExceptionTest extends BaseMinaTest {
 
     @Test
     public void testExceptionThrownInProcessor() {
         String body = "Hello World";
-        Object result = template.requestBody(uri, body);
+        Object result = template.requestBody("mina:tcp://localhost:{{port}}?textline=true&sync=true", body);
         // The exception should be passed to the client
         assertNotNull("the result should not be null", result);
         assertEquals("result is IllegalArgumentException", result, "java.lang.IllegalArgumentException: Forced exception");
@@ -48,7 +41,7 @@ public class MinaTcpWithIoOutProcessorEx
                 // use no delay for fast unit testing
                 errorHandler(defaultErrorHandler().maximumRedeliveries(2));
 
-                from(uri).process(new Processor() {
+                from("mina:tcp://localhost:{{port}}?textline=true&sync=true").process(new Processor() {
                     public void process(Exchange e) {
                         assertEquals("Hello World", e.getIn().getBody(String.class));
                         // simulate a problem processing the input to see if we can handle it properly