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 2012/01/02 17:00:01 UTC

svn commit: r1226449 [2/5] - in /camel/trunk: ./ apache-camel/ apache-camel/src/main/descriptors/ components/ components/camel-mina2/ components/camel-mina2/src/ components/camel-mina2/src/main/ components/camel-mina2/src/main/java/ components/camel-mi...

Added: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineCodecFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineCodecFactory.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineCodecFactory.java (added)
+++ camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineCodecFactory.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,72 @@
+/**
+ * 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.mina2;
+
+import java.nio.charset.Charset;
+
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.textline.LineDelimiter;
+import org.apache.mina.filter.codec.textline.TextLineDecoder;
+import org.apache.mina.filter.codec.textline.TextLineEncoder;
+
+/**
+ * Text line codec that supports setting charset and delimiter.
+ * <p/>
+ * Uses Mina's default TextLineEncoder and TextLineDncoder. 
+ */
+public class Mina2TextLineCodecFactory implements ProtocolCodecFactory {
+
+    private TextLineEncoder encoder;
+    private TextLineDecoder decoder;
+
+    public Mina2TextLineCodecFactory(Charset charset, LineDelimiter delimiter) {
+        if (delimiter.equals(LineDelimiter.AUTO)) {
+            // AUTO not supported by encoder
+            encoder = new TextLineEncoder(charset);
+        } else {
+            encoder = new TextLineEncoder(charset, delimiter);
+        }
+        decoder = new TextLineDecoder(charset, delimiter);
+    }
+
+    public ProtocolEncoder getEncoder(IoSession session) throws Exception {
+        return encoder;
+    }
+
+    public ProtocolDecoder getDecoder(IoSession session) throws Exception {
+        return decoder;
+    }
+
+    public void setEncoderMaxLineLength(int encoderMaxLineLength) {
+        encoder.setMaxLineLength(encoderMaxLineLength);
+    }
+
+    public int getEncoderMaxLineLength() {
+        return encoder.getMaxLineLength();
+    }
+
+    public void setDecoderMaxLineLength(int decoderMaxLineLength) {
+        decoder.setMaxLineLength(decoderMaxLineLength);
+    }
+
+    public int getDecoderMaxLineLength() {
+        return decoder.getMaxLineLength();
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineCodecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineCodecFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineDelimiter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineDelimiter.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineDelimiter.java (added)
+++ camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineDelimiter.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,25 @@
+/**
+ * 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.mina2;
+
+/**
+ * Possible text line delimiters to be used with the textline codec.
+ */
+public enum Mina2TextLineDelimiter {
+
+    DEFAULT, AUTO, UNIX, WINDOWS, MAC
+}

Propchange: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineDelimiter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2TextLineDelimiter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2UdpProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2UdpProtocolCodecFactory.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2UdpProtocolCodecFactory.java (added)
+++ camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2UdpProtocolCodecFactory.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,98 @@
+/**
+ * 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.mina2;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+
+/**
+ * @version 
+ */
+public class Mina2UdpProtocolCodecFactory implements ProtocolCodecFactory {
+
+    private final Charset charset;
+    private final CamelContext context;
+
+    public Mina2UdpProtocolCodecFactory(CamelContext context, Charset charset) {
+        this.context = context;
+        this.charset = charset;
+    }
+
+    public ProtocolEncoder getEncoder(IoSession session) throws Exception {
+        return new ProtocolEncoder() {
+
+            private CharsetEncoder encoder;
+
+            public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
+                if (encoder == null) {
+                    encoder = charset.newEncoder();
+                }
+                IoBuffer buf = toIoBuffer(message, encoder);
+                buf.flip();
+                out.write(buf);
+            }
+
+            public void dispose(IoSession session) throws Exception {
+                // do nothing
+            }
+        };
+    }
+
+    public ProtocolDecoder getDecoder(IoSession session) throws Exception {
+        return new ProtocolDecoder() {
+
+            public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
+                // convert to bytes to write, we can not pass in the byte buffer as it could be sent to
+                // multiple mina sessions so we must convert it to bytes
+                byte[] bytes = context.getTypeConverter().convertTo(byte[].class, in);
+                out.write(bytes);
+            }
+
+            public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception {
+                // do nothing
+            }
+
+            public void dispose(IoSession session) throws Exception {
+                // do nothing
+            }
+        };
+    }
+
+    private IoBuffer toIoBuffer(Object message, CharsetEncoder encoder)
+        throws CharacterCodingException, NoTypeConversionAvailableException {
+        String value = context.getTypeConverter().convertTo(String.class, message);
+        if (value != null) {
+            IoBuffer answer = IoBuffer.allocate(value.length()).setAutoExpand(true);
+            answer.putString(value, encoder);
+            return answer;
+        }
+
+        // failback to use a byte buffer converter
+        return context.getTypeConverter().mandatoryConvertTo(IoBuffer.class, message);
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2UdpProtocolCodecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2UdpProtocolCodecFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/resources/META-INF/LICENSE.txt?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-mina2/src/main/resources/META-INF/LICENSE.txt Mon Jan  2 15:59:58 2012
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Propchange: camel/trunk/components/camel-mina2/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-mina2/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/resources/META-INF/NOTICE.txt?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-mina2/src/main/resources/META-INF/NOTICE.txt Mon Jan  2 15:59:58 2012
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Propchange: camel/trunk/components/camel-mina2/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-mina2/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/resources/META-INF/services/org/apache/camel/TypeConverter?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/resources/META-INF/services/org/apache/camel/TypeConverter (added)
+++ camel/trunk/components/camel-mina2/src/main/resources/META-INF/services/org/apache/camel/TypeConverter Mon Jan  2 15:59:58 2012
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.camel.component.mina2.Mina2Converter
\ No newline at end of file

Added: camel/trunk/components/camel-mina2/src/main/resources/META-INF/services/org/apache/camel/component/mina2
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/resources/META-INF/services/org/apache/camel/component/mina2?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/resources/META-INF/services/org/apache/camel/component/mina2 (added)
+++ camel/trunk/components/camel-mina2/src/main/resources/META-INF/services/org/apache/camel/component/mina2 Mon Jan  2 15:59:58 2012
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.mina2.Mina2Component

Added: camel/trunk/components/camel-mina2/src/test/data/message1.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/data/message1.txt?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/data/message1.txt (added)
+++ camel/trunk/components/camel-mina2/src/test/data/message1.txt Mon Jan  2 15:59:58 2012
@@ -0,0 +1 @@
+Hello World
\ No newline at end of file

Propchange: camel/trunk/components/camel-mina2/src/test/data/message1.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/data/message1.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,84 @@
+/**
+ * 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.mina2;
+
+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.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 BaseMina2Test extends CamelTestSupport {
+
+    private static volatile int port;
+
+    @BeforeClass
+    public static void initPort() throws Exception {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+
+    @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();
+//      return port;
+        return AvailablePortFinder.getNextAvailable();
+    }
+
+    protected int getPort() {
+        return port;
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/MessageIOSessionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/MessageIOSessionTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/MessageIOSessionTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/MessageIOSessionTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,70 @@
+/**
+ * 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.mina2;
+
+import java.net.SocketAddress;
+
+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.junit.Test;
+
+/**
+ * Unit test to check if the message of an exchange send from the MinaConsumer
+ * is a MinaMessage.
+ */
+public class MessageIOSessionTest extends BaseMina2Test {
+
+    @Test
+    public void testIoSession() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        template.sendBody("mina2:tcp://localhost:{{port}}?textline=true", "Hello World");
+        assertMockEndpointsSatisfied();
+
+        Exchange exchange = mock.getExchanges().get(0);
+        Message message = exchange.getIn();
+        assertNotNull(message.getHeader(Mina2Constants.MINA_IOSESSION));
+
+    }
+
+    @Test
+    public void testLocalAndRemoteAddressHeaders() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        template.sendBody("mina2:tcp://localhost:{{port}}?textline=true", "Hello World");
+        assertMockEndpointsSatisfied();
+
+        Message message = mock.getExchanges().get(0).getIn();
+        // Not making assumptions on what these headers contain, because it might differ 
+        // on different machines/OSs.
+        assertNotNull(message.getHeader(Mina2Constants.MINA_LOCAL_ADDRESS, SocketAddress.class));
+        assertNotNull(message.getHeader(Mina2Constants.MINA_REMOTE_ADDRESS, SocketAddress.class));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() throws Exception {
+                from("mina2:tcp://localhost:{{port}}?textline=true").to("log://mytest").to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/MessageIOSessionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/MessageIOSessionTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ClientServerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ClientServerTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ClientServerTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ClientServerTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,63 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class Mina2ClientServerTest extends BaseMina2Test {
+
+    @Test
+    public void testSendToServer() throws InterruptedException {
+        // START SNIPPET: e3
+        String out = (String) template.requestBody("mina2:tcp://localhost:{{port}}?textline=true", "Chad");
+        assertEquals("Hello Chad", out);
+        // END SNIPPET: e3
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() throws Exception {
+                // START SNIPPET: e1
+                // lets setup a server on port {{port}}
+                // and we let the request-reply be processed in the MyServerProcessor
+                from("mina2:tcp://localhost:{{port}}?textline=true").process(new MyServerProcessor());
+                // END SNIPPET: e1
+            }
+        };
+    }
+
+    // START SNIPPET: e2
+    private static class MyServerProcessor implements Processor {
+
+        public void process(Exchange exchange) throws Exception {
+            // get the input from the IN body
+            String name = exchange.getIn().getBody(String.class);
+            // send back a response on the OUT body
+            exchange.getOut().setBody("Hello " + name);
+        }
+    }
+    // END SNIPPET: e2
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ClientServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ClientServerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,52 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * For testing various minor holes that hasn't been covered by other unit tests.
+ *
+ * @version 
+ */
+public class Mina2ComponentTest extends CamelTestSupport {
+
+    @Test
+    public void testUnknownProtocol() {
+        try {
+            template.sendBody("mina2:xxx://localhost:8080", "mina2:xxx://localhost:8080");
+            fail("Should have thrown a ResolveEndpointFailedException");
+        } catch (ResolveEndpointFailedException e) {
+            assertTrue("Should be an IAE exception", e.getCause() instanceof IllegalArgumentException);
+            assertEquals("Unrecognised MINA protocol: xxx for uri: mina2://xxx://localhost:8080", e.getCause().getMessage());
+        }
+    }
+
+    @Test
+    public void testMistypedProtocol() {
+        try {
+            // the protocol is mistyped as a colon is missing after tcp
+            template.sendBody("mina2:tcp//localhost:8080", "mina2:tcp//localhost:8080");
+            fail("Should have thrown a ResolveEndpointFailedException");
+        } catch (ResolveEndpointFailedException e) {
+            assertTrue("Should be an IAE exception", e.getCause() instanceof IllegalArgumentException);
+            assertEquals("Unrecognised MINA protocol: null for uri: mina2://tcp//localhost:8080", e.getCause().getMessage());
+        }
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentWithConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentWithConfigurationTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentWithConfigurationTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentWithConfigurationTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,55 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class Mina2ComponentWithConfigurationTest extends CamelTestSupport {
+
+    @Test
+    public void testMinaComponentWithConfiguration() throws Exception {
+        Mina2Component comp = context.getComponent("mina2", Mina2Component.class);
+
+        Mina2Configuration cfg1 = new Mina2Configuration();
+        cfg1.setHost("abc");
+        cfg1.setPort(4455);
+        cfg1.setProtocol("tcp");
+        Mina2Configuration cfg2 = new Mina2Configuration();
+        cfg2.setHost("abc");
+        cfg2.setPort(4455);
+        cfg2.setProtocol("udp");
+
+
+        Mina2Endpoint e1 = (Mina2Endpoint) comp.createEndpoint(cfg1);
+        Mina2Endpoint e2 = (Mina2Endpoint) comp.createEndpoint(cfg2);
+
+        // should not be same
+        assertNotSame(e1, e2);
+        assertNotSame(e1.getConfiguration(), e2.getConfiguration());
+
+        e2.getConfiguration().setPort(5566);
+
+        assertEquals(false, e1.getConfiguration().isTextline());
+        assertEquals(false, e2.getConfiguration().isTextline());
+        assertEquals(4455, e1.getConfiguration().getPort());
+        assertEquals(5566, e2.getConfiguration().getPort());
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentWithConfigurationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ComponentWithConfigurationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConsumerTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConsumerTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConsumerTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,76 @@
+/**
+ * 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.mina2;
+
+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.junit.Test;
+
+/**
+ * Unit test for wiki documentation
+ */
+public class Mina2ConsumerTest extends BaseMina2Test {
+
+    int port1;
+    int port2;
+
+    @Test
+    public void testSendTextlineText() throws Exception {
+        // START SNIPPET: e2
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+
+        template.sendBody("mina2:tcp://localhost:" + port1 + "?textline=true&sync=false", "Hello World");
+
+        assertMockEndpointsSatisfied();
+        // END SNIPPET: e2
+    }
+
+    @Test
+    public void testSendTextlineSyncText() throws Exception {
+        // START SNIPPET: e4
+        String response = (String) template.requestBody("mina2:tcp://localhost:" + port2 + "?textline=true&sync=true", "World");
+        assertEquals("Bye World", response);
+        // END SNIPPET: e4
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            public void configure() throws Exception {
+                port1 = getPort();
+                port2 = getNextPort();
+
+                // START SNIPPET: e1
+                from("mina2:tcp://localhost:" + port1 + "?textline=true&sync=false").to("mock:result");
+                // END SNIPPET: e1
+
+                // START SNIPPET: e3
+                from("mina2: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);
+                    }
+                });
+                // END SNIPPET: e3
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConverterTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConverterTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConverterTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,93 @@
+/**
+ * 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.mina2;
+
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import junit.framework.TestCase;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.mina.core.buffer.IoBuffer;
+
+/**
+ * @version 
+ */
+public class Mina2ConverterTest extends TestCase {
+
+    public void testToByteArray() {
+        byte[] in = "Hello World".getBytes();
+        IoBuffer bb = IoBuffer.wrap(in);
+
+        byte[] out = Mina2Converter.toByteArray(bb);
+
+        for (int i = 0; i < out.length; i++) {
+            assertEquals(in[i], out[i]);
+        }
+    }
+
+    public void testToString() throws UnsupportedEncodingException {
+        String in = "Hello World \u4f60\u597d";
+        IoBuffer bb = IoBuffer.wrap(in.getBytes("UTF-8"));
+        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
+        exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+
+        String out = Mina2Converter.toString(bb, exchange);
+        assertEquals("Hello World \u4f60\u597d", out);
+    }
+
+    public void testToStringTwoTimes() throws UnsupportedEncodingException {
+        String in = "Hello World \u4f60\u597d";
+        IoBuffer bb = IoBuffer.wrap(in.getBytes("UTF-8"));
+        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
+        exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+
+        String out = Mina2Converter.toString(bb, exchange);
+        assertEquals("Hello World \u4f60\u597d", out);
+
+        // should NOT be possible to convert to string without affecting the ByteBuffer
+        out = Mina2Converter.toString(bb, exchange);
+        assertEquals("", out);
+    }
+
+    public void testToInputStream() throws Exception {
+        byte[] in = "Hello World".getBytes();
+        IoBuffer bb = IoBuffer.wrap(in);
+
+        InputStream is = Mina2Converter.toInputStream(bb);
+        for (byte b : in) {
+            int out = is.read();
+            assertEquals(b, out);
+        }
+    }
+
+    public void testToByteBuffer() {
+        byte[] in = "Hello World".getBytes();
+
+        IoBuffer bb = Mina2Converter.toIoBuffer(in);
+        assertNotNull(bb);
+
+        // convert back to byte[] and see if the bytes are equal
+        bb.flip(); // must flip to change direction to read
+        byte[] out = Mina2Converter.toByteArray(bb);
+
+        for (int i = 0; i < out.length; i++) {
+            assertEquals(in[i], out[i]);
+        }
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConverterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ConverterTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,134 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+import org.junit.Test;
+
+/**
+ * Unit test with custom codec.
+ */
+public class Mina2CustomCodecTest extends BaseMina2Test {
+
+    @Test
+    public void testMyCodec() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Bye World");
+
+        Object out = template.requestBody("mina2:tcp://localhost:{{port}}?sync=true&codec=#myCodec", "Hello World");
+        assertEquals("Bye World", out);
+
+        mock.assertIsSatisfied();
+    }
+
+    @Test
+    public void testTCPEncodeUTF8InputIsString() throws Exception {
+        final String myUri = "mina2:tcp://localhost:" + getNextPort() + "?encoding=UTF-8&sync=false";
+        context.addRoutes(new RouteBuilder() {
+
+            public void configure() {
+                from(myUri).to("mock:result");
+            }
+        });
+
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+
+        // include a UTF-8 char in the text \u0E08 is a Thai elephant
+        String body = "Hello Thai Elephant \u0E08";
+
+        endpoint.expectedMessageCount(1);
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBody(myUri, body);
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testBadConfiguration() throws Exception {
+        try {
+            template.sendBody("mina2:tcp://localhost:{{port}}?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());
+        return jndi;
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            public void configure() throws Exception {
+                from("mina2:tcp://localhost:{{port}}?sync=true&codec=#myCodec").transform(constant("Bye World")).to("mock:result");
+            }
+        };
+    }
+
+    private static class MyCodec implements ProtocolCodecFactory {
+
+        public ProtocolEncoder getEncoder(IoSession session) throws Exception {
+            return new ProtocolEncoder() {
+
+                public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out)
+                    throws Exception {
+                    IoBuffer bb = IoBuffer.allocate(32).setAutoExpand(true);
+                    String s = (String) message;
+                    bb.put(s.getBytes("US-ASCII"));
+                    bb.flip();
+                    out.write(bb);
+                }
+
+                public void dispose(IoSession ioSession) throws Exception {
+                    // do nothing
+                }
+            };
+
+        }
+
+        public ProtocolDecoder getDecoder(IoSession session) throws Exception {
+            return new CumulativeProtocolDecoder() {
+
+                protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
+                    if (in.remaining() > 0) {
+                        byte[] buf = new byte[in.remaining()];
+                        in.get(buf);
+                        out.write(new String(buf, "US-ASCII"));
+                        return true;
+                    } else {
+                        return false;
+                    }
+                }
+            };
+        }
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2DisconnectTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2DisconnectTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2DisconnectTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2DisconnectTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,50 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * Unit test for close session when complete test.
+ */
+public class Mina2DisconnectTest extends BaseMina2Test {
+
+    @Test
+    public void testCloseSessionWhenComplete() throws Exception {
+        Object out = template.requestBody("mina2:tcp://localhost:{{port}}?sync=true&textline=true&disconnect=true", "Chad");
+        assertEquals("Bye Chad", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            public void configure() throws Exception {
+                from("mina2: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);
+                    }
+                });
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2DisconnectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2DisconnectTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,203 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.Processor;
+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.junit.Test;
+
+/**
+ * Unit testing using different encodings with the TCP protocol.
+ *
+ * @version 
+ */
+public class Mina2EncodingTest extends BaseMina2Test {
+
+    @Test
+    public void testTCPEncodeUTF8InputIsBytes() throws Exception {
+        final String uri = "mina2:tcp://localhost:{{port}}?encoding=UTF-8&sync=false";
+        context.addRoutes(new RouteBuilder() {
+
+            public void configure() {
+                from(uri).to("mock:result");
+            }
+        });
+
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+
+        // include a UTF-8 char in the text \u0E08 is a Thai elephant
+        byte[] body = "Hello Thai Elephant \u0E08".getBytes("UTF-8");
+
+        endpoint.expectedMessageCount(1);
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBody(uri, body);
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testTCPEncodeUTF8InputIsString() throws Exception {
+        final String uri = "mina2:tcp://localhost:{{port}}?encoding=UTF-8&sync=false";
+        context.addRoutes(new RouteBuilder() {
+
+            public void configure() {
+                from(uri).to("mock:result");
+            }
+        });
+
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+
+        // include a UTF-8 char in the text \u0E08 is a Thai elephant
+        String body = "Hello Thai Elephant \u0E08";
+
+        endpoint.expectedMessageCount(1);
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBody(uri, body);
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testTCPEncodeUTF8TextLineInputIsString() throws Exception {
+        final String uri = "mina2:tcp://localhost:{{port}}?textline=true&encoding=UTF-8&sync=false";
+        context.addRoutes(new RouteBuilder() {
+
+            public void configure() {
+                from(uri).to("mock:result");
+            }
+        });
+
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+
+        // include a UTF-8 char in the text \u0E08 is a Thai elephant
+        String body = "Hello Thai Elephant \u0E08";
+
+        endpoint.expectedMessageCount(1);
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBody(uri, body);
+        assertMockEndpointsSatisfied();
+    }
+
+    // Note: MINA does not support sending bytes with the textline codec
+    // See TextLineEncoder#encode where the message is converted to String using .toString()
+    @Test
+    public void testUDPEncodeUTF8InputIsBytes() throws Exception {
+        final String uri = "mina2:udp://localhost:{{port}}?encoding=UTF-8&sync=false";
+        context.addRoutes(new RouteBuilder() {
+
+            public void configure() {
+                from(uri).to("mock:result");
+            }
+        });
+
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+
+        // include a UTF-8 char in the text \u0E08 is a Thai elephant
+        byte[] body = "Hello Thai Elephant \u0E08".getBytes();
+
+        endpoint.expectedMessageCount(1);
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBody(uri, body);
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testUDPEncodeUTF8InputIsString() throws Exception {
+        final String uri = "mina2:udp://localhost:{{port}}?encoding=UTF-8&sync=false";
+        context.addRoutes(new RouteBuilder() {
+
+            public void configure() {
+                from(uri).to("mock:result");
+            }
+        });
+
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+
+        // include a UTF-8 char in the text \u0E08 is a Thai elephant
+        String body = "Hello Thai Elephant \u0E08";
+        //String body = "Hello Thai Elephant Yay";
+
+        endpoint.expectedMessageCount(1);
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBody(uri, body);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testUDPEncodeUTF8InputIsStringNoMock() throws Exception {
+        // this unit test covers for testUDPEncodeUTF8InputIsString until the encoding is fixed
+
+        // include a UTF-8 char in the text \u0E08 is a Thai elephant
+        final String hello = "Hello Thai Elephant \u0E08";
+        final String bye = "Hello Thai Elephant \u0E08";
+
+        final String uri = "mina2:udp://localhost:{{port}}?sync=true&encoding=UTF-8";
+        context.addRoutes(new RouteBuilder() {
+
+            public void configure() {
+                from(uri).process(new Processor() {
+
+                    public void process(Exchange exchange) throws Exception {
+                        String s = exchange.getIn().getBody(String.class);
+                        assertEquals(hello, s);
+                        exchange.getOut().setBody(bye);
+                    }
+                });
+            }
+        });
+
+        Endpoint endpoint = context.getEndpoint(uri);
+        Producer producer = endpoint.createProducer();
+        Exchange exchange = producer.createExchange();
+        exchange.getIn().setBody(hello);
+
+        producer.start();
+        producer.process(exchange);
+
+        String s = exchange.getOut().getBody(String.class);
+        assertEquals(bye, s);
+
+        producer.stop();
+    }
+
+    @Test
+    public void testInvalidEncoding() throws Exception {
+        final String uri = "mina2:tcp://localhost:{{port}}?textline=true&encoding=XXX&sync=false";
+
+        try {
+            context.addRoutes(new RouteBuilder() {
+
+                public void configure() {
+                    from(uri).to("mock:result");
+                }
+            });
+            fail("Should have thrown a ResolveEndpointFailedException due invalid encoding parameter");
+        } catch (IllegalArgumentException e) {
+            // We were suppose to get here.
+        }
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeDefaultTimeOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeDefaultTimeOutTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeDefaultTimeOutTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeDefaultTimeOutTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,60 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * To test timeout.
+ *
+ * @version 
+ */
+public class Mina2ExchangeDefaultTimeOutTest extends BaseMina2Test {
+
+    @Test
+    public void testDefaultTimeOut() {
+        try {
+            String result = (String) template.requestBody("mina2: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");
+        }
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            public void configure() {
+                from("mina2: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 3 seconds so we just wait 5 seconds
+                        // (template.requestBody is a MinaProducer behind the doors)
+                        Thread.sleep(1000);
+
+                        e.getOut().setBody("Okay I will be faster in the future");
+                    }
+                });
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeDefaultTimeOutTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeDefaultTimeOutTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeTimeOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeTimeOutTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeTimeOutTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeTimeOutTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,70 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangeTimedOutException;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * To test timeout.
+ *
+ * @version 
+ */
+public class Mina2ExchangeTimeOutTest extends BaseMina2Test {
+
+    @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("mina2:tcp://localhost:{{port}}?textline=true&sync=true&timeout=500");
+        Producer producer = endpoint.createProducer();
+        producer.start();
+        Exchange exchange = producer.createExchange();
+        exchange.getIn().setBody("Hello World");
+        try {
+            producer.process(exchange);
+            fail("Should have thrown an ExchangeTimedOutException wrapped in a RuntimeCamelException");
+        } catch (Exception e) {
+            assertTrue("Should have thrown an ExchangeTimedOutException", e instanceof ExchangeTimedOutException);
+        }
+        producer.stop();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            public void configure() {
+                from("mina2:tcp://localhost:{{port}}?textline=true&sync=true&timeout=30000").process(new Processor() {
+
+                    public void process(Exchange e) throws Exception {
+                        assertEquals("Hello World", e.getIn().getBody(String.class));
+                        // MinaProducer has a default timeout of 3 seconds so we just wait 2 seconds
+                        // (template.requestBody is a MinaProducer behind the doors)
+                        Thread.sleep(2000);
+
+                        e.getOut().setBody("Okay I will be faster in the future");
+                    }
+                });
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeTimeOutTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ExchangeTimeOutTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileTcpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileTcpTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileTcpTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileTcpTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,49 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class Mina2FileTcpTest extends BaseMina2Test {
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:results");
+        endpoint.expectedMessageCount(1);
+        endpoint.message(0).body().startsWith("Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            public void configure() {
+                // lets setup a server
+                from("mina2:tcp://localhost:{{port}}?sync=false&textline=true").to("mock:results");
+
+                from("file:src/test/data?noop=true&fileName=message1.txt").
+                    to("mina2:tcp://localhost:{{port}}?sync=false&textline=true");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileTcpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileTcpTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileUdpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileUdpTest.java?rev=1226449&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileUdpTest.java (added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileUdpTest.java Mon Jan  2 15:59:58 2012
@@ -0,0 +1,49 @@
+/**
+ * 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.mina2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class Mina2FileUdpTest extends BaseMina2Test {
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:results");
+        endpoint.expectedMessageCount(1);
+        endpoint.message(0).body().startsWith("Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            public void configure() {
+                // lets setup a server
+                from("mina2:udp://localhost:{{port}}?sync=false&textline=true").to("mock:results");
+
+                from("file:src/test/data?noop=true").
+                    to("mina2:udp://localhost:{{port}}?sync=false&textline=true");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileUdpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2FileUdpTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date