camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r692853 - in /activemq/camel/trunk/components/camel-mina/src: main/java/org/apache/camel/component/mina/ test/java/org/apache/camel/component/mina/
Date Sun, 07 Sep 2008 13:53:19 GMT
Author: davsclaus
Date: Sun Sep  7 06:53:18 2008
New Revision: 692853

URL: http://svn.apache.org/viewvc?rev=692853&view=rev
Log:
CAMEL-881: codec option fails if not possible to find i registry

Modified:
    activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
    activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java
    activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java
    activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java

Modified: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java?rev=692853&r1=692852&r2=692853&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
(original)
+++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
Sun Sep  7 06:53:18 2008
@@ -65,15 +65,14 @@
     private static final transient Log LOG = LogFactory.getLog(MinaComponent.class);
 
     private static final long DEFAULT_CONNECT_TIMEOUT = 30000;
-    boolean sync = true;
-    boolean textline;
-    String codec;
-    String encoding;
-    long timeout;
-    boolean lazySessionCreation;
-    boolean transferExchange;
-    boolean minaLogger;
-
+    private boolean sync = true;
+    private boolean textline;
+    private String codec;
+    private String encoding;
+    private long timeout;
+    private boolean lazySessionCreation;
+    private boolean transferExchange;
+    private boolean minaLogger;
     // encoder used for datagram
     private CharsetEncoder encoder;
 
@@ -302,6 +301,9 @@
         ProtocolCodecFactory codecFactory = null;
         if (codec != null) {
             codecFactory = getCamelContext().getRegistry().lookup(codec, ProtocolCodecFactory.class);
+            if (codecFactory == null) {
+                throw new IllegalArgumentException("Codec " + codec + " not found in registry.");
+            }
             if (LOG.isDebugEnabled()) {
                 LOG.debug(type + ": Using custom CodecFactory: " + codecFactory);
             }

Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java?rev=692853&r1=692852&r2=692853&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java
(original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaCustomCodecTest.java
Sun Sep  7 06:53:18 2008
@@ -17,6 +17,7 @@
 package org.apache.camel.component.mina;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
@@ -45,6 +46,15 @@
         mock.assertIsSatisfied();
     }
 
+    public void testBadConfiguration() throws Exception {
+        try {
+            template.sendBody("mina:tcp://localhost:11300?sync=true&codec=XXX", "Hello
World");
+            fail("Should have thrown a ResolveEndpointFailedException");
+        } catch (ResolveEndpointFailedException e) {
+            // ok
+        }
+    }
+
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
         jndi.bind("myCodec", new MyCodec());

Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java?rev=692853&r1=692852&r2=692853&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java
(original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java
Sun Sep  7 06:53:18 2008
@@ -52,7 +52,6 @@
 
         template.sendBody(uri, body);
         assertMockEndpointsSatisifed();
-        System.out.println(endpoint.getExchanges().get(0).getIn().getBody());
     }
 
     public void testTCPEncodeUTF8InputIsString() throws Exception {

Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java?rev=692853&r1=692852&r2=692853&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java
(original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpTextlineProtocolTest.java
Sun Sep  7 06:53:18 2008
@@ -22,7 +22,7 @@
 public class MinaTcpTextlineProtocolTest extends MinaVmTest {
     @Override
     protected void setUp() throws Exception {
-        uri = "mina:tcp://localhost:6124?codec=textline";
+        uri = "mina:tcp://localhost:6124?textline=true";
         super.setUp();
     }
 }



Mime
View raw message