camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject git commit: Avoid using hard-coded ports which could break tests on the CI-Server and better benefit from the IOHelper#close() utility.
Date Sat, 16 Nov 2013 23:12:06 GMT
Updated Branches:
  refs/heads/master abbb613e1 -> 4daa73f1e


Avoid using hard-coded ports which could break tests on the CI-Server and better benefit from
the IOHelper#close() utility.

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4daa73f1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4daa73f1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4daa73f1

Branch: refs/heads/master
Commit: 4daa73f1efecd972be56ce42128ea2ced8771e56
Parents: abbb613
Author: Babak Vahdat <bvahdat@apache.org>
Authored: Sun Nov 17 00:11:53 2013 +0100
Committer: Babak Vahdat <bvahdat@apache.org>
Committed: Sun Nov 17 00:11:53 2013 +0100

----------------------------------------------------------------------
 .../org/apache/camel/component/mina/BaseMinaTest.java  |  3 ++-
 .../mina/MinaTcpLineDelimiterUsingPlainSocketTest.java |  9 ++-------
 .../mina/MinaTcpWithInOutUsingPlainSocketTest.java     |  9 ++-------
 .../apache/camel/component/mina/ReverserServer.java    |  2 +-
 .../camel/component/mina/SpringMinaEndpointTest.java   |  3 ++-
 .../component/mina/SpringMinaEndpointTest-context.xml  |  4 +++-
 .../org/apache/camel/component/mina2/Mina2Helper.java  |  2 +-
 .../camel/component/mina2/Mina2PayloadHelper.java      |  2 +-
 .../camel/component/mina2/Mina2ReverserServer.java     |  2 +-
 .../component/mina2/Mina2SpringMinaEndpointTest.java   |  3 ++-
 .../mina2/Mina2SslContextParametersUdpTest.java        |  3 ++-
 .../Mina2TcpLineDelimiterUsingPlainSocketTest.java     | 13 ++++---------
 .../mina2/Mina2TcpWithInOutUsingPlainSocketTest.java   | 13 ++++---------
 .../camel/component/mina2/Mina2UdpConcurrentTest.java  |  3 ++-
 .../camel/component/mina2/Mina2UdpNoCamelTest.java     | 10 ++++++----
 .../org/apache/camel/component/mina2/Mina2UdpTest.java |  3 ++-
 .../mina2/Mina2UdpWithInOutUsingPlainSocketTest.java   |  3 ++-
 .../component/mina2/SpringMinaEndpointTest-context.xml |  4 +++-
 18 files changed, 42 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java
index 23aff9e..d07757d 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/BaseMinaTest.java
@@ -25,6 +25,7 @@ import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
@@ -49,7 +50,7 @@ public class BaseMinaTest extends CamelTestSupport {
         try {
             fos.write(String.valueOf(port).getBytes());
         } finally {
-            fos.close();
+            IOHelper.close(fos);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
index 158f9a4..2f452bc 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
@@ -25,6 +25,7 @@ import java.net.Socket;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 
 /**
@@ -96,13 +97,7 @@ public class MinaTcpLineDelimiterUsingPlainSocketTest extends BaseMinaTest
{
                 return null;
             }
         } finally {
-            if (is != null) {
-                is.close();
-            }
-            if (os != null) {
-                os.close();
-            }
-            soc.close();
+            IOHelper.close(is, os, soc);
         }
 
         // convert the buffer to chars

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
index 8009e77..c41d78c 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
@@ -25,6 +25,7 @@ import java.net.Socket;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 
 /**
@@ -96,13 +97,7 @@ public class MinaTcpWithInOutUsingPlainSocketTest extends BaseMinaTest
{
                 return null;
             }
         } finally {
-            if (is != null) {
-                is.close();
-            }
-            if (os != null) {
-                os.close();
-            }
-            soc.close();
+            IOHelper.close(is, os, soc);
         }
 
         // convert the buffer to chars

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina/src/test/java/org/apache/camel/component/mina/ReverserServer.java
----------------------------------------------------------------------
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/ReverserServer.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/ReverserServer.java
index 604a6f6..c89b331 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/ReverserServer.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/ReverserServer.java
@@ -30,7 +30,7 @@ import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
  * clients.
  */
 public class ReverserServer {
-    protected int port = 6321;
+    protected final int port;
     private IoAcceptor acceptor;
 
     public ReverserServer(int port) {

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina/src/test/java/org/apache/camel/component/mina/SpringMinaEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/SpringMinaEndpointTest.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/SpringMinaEndpointTest.java
index 7483b5c..9bef58d 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/SpringMinaEndpointTest.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/SpringMinaEndpointTest.java
@@ -36,7 +36,8 @@ public class SpringMinaEndpointTest extends CamelSpringTestSupport {
         assertMockEndpointsSatisfied();
         
         MinaEndpoint endpoint = applicationContext.getBean("myMinaEndpoint", MinaEndpoint.class);
-        assertEquals("mina:tcp:localhost:1234", endpoint.getEndpointUri());
+        Integer port = applicationContext.getBean("port", Integer.class);
+        assertEquals("mina:tcp:localhost:" + port, endpoint.getEndpointUri());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
b/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
index f8695b2..e7b0e3a 100644
--- a/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
+++ b/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
@@ -21,6 +21,8 @@
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
+    <bean id="port" class="org.apache.camel.test.AvailablePortFinder" factory-method="getNextAvailable"
/>
+
     <!-- START SNIPPET: e1 -->
     <!-- Creating mina endpoints is a bit complex so we reuse MinaComponnet
          as a factory bean to create our endpoint, this is the easiest to do -->
@@ -43,7 +45,7 @@
     <bean id="myMinaConfig" class="org.apache.camel.component.mina.MinaConfiguration">
         <property name="protocol" value="tcp"/>
         <property name="host" value="localhost"/>
-        <property name="port" value="1234"/>
+        <property name="port" ref="port"/>
         <property name="sync" value="false"/>
     </bean>
     <!-- END SNIPPET: e1 -->

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
index 1ee225c..4505a59 100644
--- a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
+++ b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
@@ -24,7 +24,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Helper class used internally by camel-mina using Apache MINA.
+ * Helper class used internally by camel-mina2 using Apache MINA.
  */
 public final class Mina2Helper {
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2PayloadHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2PayloadHelper.java
b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2PayloadHelper.java
index f7f743d..296cd00 100644
--- a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2PayloadHelper.java
+++ b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2PayloadHelper.java
@@ -20,7 +20,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultExchangeHolder;
 
 /**
- * Helper to get and set the correct payload when transferring data using camel-mina.
+ * Helper to get and set the correct payload when transferring data using camel-mina2.
  * Always use this helper instead of direct access on the exchange object.
  * <p/>
  * This helper ensures that we can also transfer exchange objects over the wire using the

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ReverserServer.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ReverserServer.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ReverserServer.java
index a87c0af..f787d14 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ReverserServer.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ReverserServer.java
@@ -30,7 +30,7 @@ import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
  */
 public class Mina2ReverserServer {
 
-    protected int port = 6321;
+    protected final int port;
     private IoAcceptor acceptor;
 
     public Mina2ReverserServer(int port) {

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SpringMinaEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SpringMinaEndpointTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SpringMinaEndpointTest.java
index f748bef..5fbd402 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SpringMinaEndpointTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SpringMinaEndpointTest.java
@@ -37,7 +37,8 @@ public class Mina2SpringMinaEndpointTest extends CamelSpringTestSupport
{
         assertMockEndpointsSatisfied();
         // checking the endpoint uri
         Mina2Endpoint endpoint = applicationContext.getBean("myMinaEndpoint", Mina2Endpoint.class);
-        assertEquals("mina2:tcp:localhost:1234", endpoint.getEndpointUri());
+        Integer port = applicationContext.getBean("port", Integer.class);
+        assertEquals("mina2:tcp:localhost:" + port, endpoint.getEndpointUri());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersUdpTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersUdpTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersUdpTest.java
index f1fab7c..1873b14 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersUdpTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersUdpTest.java
@@ -22,6 +22,7 @@ import java.net.InetAddress;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 
 /**
@@ -57,7 +58,7 @@ public class Mina2SslContextParametersUdpTest extends BaseMina2Test {
             }
             Thread.sleep(2000);
         } finally {
-            socket.close();
+            IOHelper.close(socket);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpLineDelimiterUsingPlainSocketTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpLineDelimiterUsingPlainSocketTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpLineDelimiterUsingPlainSocketTest.java
index 78d242a..29a95a4 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpLineDelimiterUsingPlainSocketTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpLineDelimiterUsingPlainSocketTest.java
@@ -25,10 +25,11 @@ import java.net.Socket;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 
 /**
- * To test camel-mina component using a TCP client that communicates using TCP socket communication.
+ * To test camel-mina2 component using a TCP client that communicates using TCP socket communication.
  *
  * @version 
  */
@@ -86,7 +87,7 @@ public class Mina2TcpLineDelimiterUsingPlainSocketTest extends BaseMina2Test
{
         InputStream is = null;
         try {
             os = soc.getOutputStream();
-            // must append MAC newline at the end to flag end of textline to Camel-Mina
+            // must append MAC newline at the end to flag end of textline to camel-mina2
             os.write((input + "\r").getBytes());
 
             is = soc.getInputStream();
@@ -96,13 +97,7 @@ public class Mina2TcpLineDelimiterUsingPlainSocketTest extends BaseMina2Test
{
                 return null;
             }
         } finally {
-            if (is != null) {
-                is.close();
-            }
-            if (os != null) {
-                os.close();
-            }
-            soc.close();
+            IOHelper.close(is, os, soc);
         }
 
         // convert the buffer to chars

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
index beaff30..f47aa62 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
@@ -25,10 +25,11 @@ import java.net.Socket;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 
 /**
- * To test camel-mina component using a TCP client that communicates using TCP socket communication.
+ * To test camel-mina2 component using a TCP client that communicates using TCP socket communication.
  *
  * @version 
  */
@@ -86,7 +87,7 @@ public class Mina2TcpWithInOutUsingPlainSocketTest extends BaseMina2Test
{
         InputStream is = null;
         try {
             os = soc.getOutputStream();
-            // must append newline at the end to flag end of textline to Camel-Mina
+            // must append newline at the end to flag end of textline to camel-mina2
             os.write((input + LS).getBytes());
 
             is = soc.getInputStream();
@@ -96,13 +97,7 @@ public class Mina2TcpWithInOutUsingPlainSocketTest extends BaseMina2Test
{
                 return null;
             }
         } finally {
-            if (is != null) {
-                is.close();
-            }
-            if (os != null) {
-                os.close();
-            }
-            soc.close();
+            IOHelper.close(is, os, soc);
         }
 
         // convert the buffer to chars

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpConcurrentTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpConcurrentTest.java
index c1bdf63..24d2f2d 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpConcurrentTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpConcurrentTest.java
@@ -22,6 +22,7 @@ import java.net.InetAddress;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 
 /**
@@ -58,7 +59,7 @@ public class Mina2UdpConcurrentTest extends BaseMina2Test {
             }
             Thread.sleep(2000);
         } finally {
-            socket.close();
+            IOHelper.close(socket);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java
index 5fdf0c6..68d5aa1 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java
@@ -25,6 +25,7 @@ import java.net.SocketException;
 import java.net.UnknownHostException;
 import java.nio.charset.Charset;
 
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.mina.core.service.IoHandlerAdapter;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
@@ -49,11 +50,12 @@ public class Mina2UdpNoCamelTest {
     LineDelimiter delimiter = LineDelimiter.DEFAULT;
     Mina2TextLineCodecFactory codecFactory = new Mina2TextLineCodecFactory(charset, delimiter);
     UDPServer server;
+    private int port = AvailablePortFinder.getNextAvailable();
 
     // Create the UDPServer before the test is run
     @Before
     public void setupUDPAcceptor() throws IOException {
-        server = new UDPServer("127.0.0.1", 1234);
+        server = new UDPServer("127.0.0.1", port);
         server.listen();
     }
 
@@ -65,7 +67,7 @@ public class Mina2UdpNoCamelTest {
     @Test
     public void testMinaUDPWithNoCamel() throws InterruptedException {
         UDPClient client = new UDPClient();
-        client.connect("127.0.0.1", 1234);
+        client.connect("127.0.0.1", port);
         for (int i = 0; i < 222; i++) {
             client.sendNoMina("Hello Mina " + i + System.getProperty("line.separator"));
         }
@@ -120,14 +122,14 @@ public class Mina2UdpNoCamelTest {
 
         /**
          * Three optional arguments can be provided (defaults in brackets):
-         * path, host (localhost) and port (1234).
+         * path, host (localhost) and port.
          *
          * @param args The command line args.
          */
         private final NioDatagramConnector connector;
         private DatagramSocket socket;
         private InetAddress address;
-        private int localPort = 1234;
+        private int localPort;
         private String localHost = "127.0.0.1";
 
         private UDPClient() {

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpTest.java
index 519fb35..378dd49 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpTest.java
@@ -22,6 +22,7 @@ import java.net.InetAddress;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 
 /**
@@ -58,7 +59,7 @@ public class Mina2UdpTest extends BaseMina2Test {
             }
             Thread.sleep(2000);
         } finally {
-            socket.close();
+            IOHelper.close(socket);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpWithInOutUsingPlainSocketTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpWithInOutUsingPlainSocketTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpWithInOutUsingPlainSocketTest.java
index a515a74..c807fe4 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpWithInOutUsingPlainSocketTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpWithInOutUsingPlainSocketTest.java
@@ -23,6 +23,7 @@ import java.net.InetAddress;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.IOHelper;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -58,7 +59,7 @@ public class Mina2UdpWithInOutUsingPlainSocketTest extends BaseMina2Test
{
         LOG.debug("+++ Receiveing data +++");
         socket.receive(receive);
 
-        socket.close();
+        IOHelper.close(socket);
 
         return new String(receive.getData(), 0, receive.getLength());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/4daa73f1/components/camel-mina2/src/test/resources/org/apache/camel/component/mina2/SpringMinaEndpointTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/resources/org/apache/camel/component/mina2/SpringMinaEndpointTest-context.xml
b/components/camel-mina2/src/test/resources/org/apache/camel/component/mina2/SpringMinaEndpointTest-context.xml
index a812be6..022152e 100644
--- a/components/camel-mina2/src/test/resources/org/apache/camel/component/mina2/SpringMinaEndpointTest-context.xml
+++ b/components/camel-mina2/src/test/resources/org/apache/camel/component/mina2/SpringMinaEndpointTest-context.xml
@@ -21,6 +21,8 @@
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
+    <bean id="port" class="org.apache.camel.test.AvailablePortFinder" factory-method="getNextAvailable"
/>
+
     <!-- START SNIPPET: e1 -->
     <!-- Creating mina endpoints is a bit complex so we reuse MinaComponnet
          as a factory bean to create our endpoint, this is the easiest to do -->
@@ -43,7 +45,7 @@
     <bean id="myMinaConfig" class="org.apache.camel.component.mina2.Mina2Configuration">
         <property name="protocol" value="tcp"/>
         <property name="host" value="localhost"/>
-        <property name="port" value="1234"/>
+        <property name="port" ref="port"/>
         <property name="sync" value="false"/>
     </bean>
     <!-- END SNIPPET: e1 -->


Mime
View raw message