svn commit: r935809 - in /camel/trunk/components/camel-mina/src: main/java/org/apache/camel/component/mina/ test/java/org/apache/camel/component/mina/

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r935809 - in /camel/trunk/components/camel-mina/src: main/java/org/apache/camel/component/mina/ test/java/org/apache/camel/component/mina/

davsclaus-2
Author: davsclaus
Date: Tue Apr 20 05:43:10 2010
New Revision: 935809

URL: http://svn.apache.org/viewvc?rev=935809&view=rev
Log:
CAMEL-2658: GenericFile is not serializable. Fixed MainProducer to convert to String body when textline is enabled.

Modified:
    camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.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/MinaVMFileTcpTest.java

Modified: camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java?rev=935809&r1=935808&r2=935809&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java (original)
+++ camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java Tue Apr 20 05:43:10 2010
@@ -84,6 +84,11 @@ public class MinaProducer extends Defaul
             return; // exit early since nothing to write
         }
 
+        // if textline enabled then covert to a String which must be used for textline
+        if (endpoint.getConfiguration().isTextline()) {
+            body = endpoint.getCamelContext().getTypeConverter().convertTo(String.class, exchange, body);
+        }
+
         // if sync is true then we should also wait for a response (synchronous mode)
         if (sync) {
             // only initialize latch if we should get a response
@@ -107,7 +112,9 @@ public class MinaProducer extends Defaul
 
         if (sync) {
             // wait for response, consider timeout
-            LOG.debug("Waiting for response");
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Waiting for response using timeout " + timeout + " millis.");
+            }
             boolean done = latch.await(timeout, TimeUnit.MILLISECONDS);
             if (!done) {
                 throw new ExchangeTimedOutException(exchange, timeout);
@@ -116,7 +123,7 @@ public class MinaProducer extends Defaul
             // did we get a response
             ResponseHandler handler = (ResponseHandler) session.getHandler();
             if (handler.getCause() != null) {
-                throw new CamelExchangeException("Response Handler had an exception", exchange, handler.getCause());
+                throw new CamelExchangeException("Error occurred in ResponseHandler", exchange, handler.getCause());
             } else if (!handler.isMessageReceived()) {
                 // no message received
                 throw new CamelExchangeException("No response received from remote server: " + endpoint.getEndpointUri(), exchange);

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=935809&r1=935808&r2=935809&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 Tue Apr 20 05:43:10 2010
@@ -28,6 +28,7 @@ public class MinaFileTcpTest extends Con
     public void testMinaRoute() throws Exception {
         MockEndpoint endpoint = getMockEndpoint("mock:results");
         endpoint.expectedMessageCount(1);
+        endpoint.message(0).body().startsWith("Hello World");
 
         assertMockEndpointsSatisfied();
     }
@@ -36,10 +37,11 @@ public class MinaFileTcpTest extends Con
         return new RouteBuilder() {
             public void configure() {
                 // lets setup a server
-                from("mina:tcp://localhost:9123?sync=false").to("mock:results");
+                from("mina:tcp://localhost:9123?sync=false&textline=true")
+                    .to("mock:results");
 
                 from("file:src/test/data?noop=true").
-                        to("mina:tcp://localhost:9123?sync=false&lazySessionCreation=true");
+                    to("mina:tcp://localhost:9123?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=935809&r1=935808&r2=935809&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 Tue Apr 20 05:43:10 2010
@@ -28,6 +28,7 @@ public class MinaFileUdpTest extends Con
     public void testMinaRoute() throws Exception {
         MockEndpoint endpoint = getMockEndpoint("mock:results");
         endpoint.expectedMessageCount(1);
+        endpoint.message(0).body().startsWith("Hello World");
 
         assertMockEndpointsSatisfied();
     }
@@ -36,10 +37,10 @@ public class MinaFileUdpTest extends Con
         return new RouteBuilder() {
             public void configure() {
                 // lets setup a server
-                from("mina:udp://localhost:9123?sync=false").to("mock:results");
+                from("mina:udp://localhost:9123?sync=false&textline=true").to("mock:results");
 
                 from("file:src/test/data?noop=true").
-                        to("mina:udp://localhost:9123?sync=false");
+                        to("mina:udp://localhost:9123?sync=false&textline=true");
             }
         };
     }

Modified: camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVMFileTcpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVMFileTcpTest.java?rev=935809&r1=935808&r2=935809&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVMFileTcpTest.java (original)
+++ camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVMFileTcpTest.java Tue Apr 20 05:43:10 2010
@@ -28,6 +28,7 @@ public class MinaVMFileTcpTest extends C
     public void testMinaRoute() throws Exception {
         MockEndpoint endpoint = getMockEndpoint("mock:results");
         endpoint.expectedMessageCount(1);
+        endpoint.message(0).body().startsWith("Hello World");
 
         assertMockEndpointsSatisfied();
     }
@@ -36,10 +37,10 @@ public class MinaVMFileTcpTest extends C
         return new RouteBuilder() {
             public void configure() {
                 // lets setup a server
-                from("mina:vm://localhost:9123").to("mock:results");
+                from("mina:vm://localhost:9123?sync=false&textline=true").to("mock:results");
 
                 from("file:src/test/data?noop=true").
-                        to("mina:vm://localhost:9123?lazySessionCreation=true");
+                        to("mina:vm://localhost:9123?sync=false&textline=true");
             }
         };
     }