You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/11/13 12:47:13 UTC

svn commit: r594496 - in /activemq/camel/trunk/components/camel-mina: ./ src/test/data/ src/test/java/org/apache/camel/component/mina/ src/test/resources/

Author: jstrachan
Date: Tue Nov 13 03:47:09 2007
New Revision: 594496

URL: http://svn.apache.org/viewvc?rev=594496&view=rev
Log:
added test case to try reproduce the issue reported here: http://www.nabble.com/Problem-using-the-mina-component-tf4760195s22882.html but unfortuately things seem to work

Added:
    activemq/camel/trunk/components/camel-mina/src/test/data/
    activemq/camel/trunk/components/camel-mina/src/test/data/message1.txt   (with props)
    activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java   (contents, props changed)
      - copied, changed from r594071, activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVmTest.java
    activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java   (with props)
    activemq/camel/trunk/components/camel-mina/src/test/resources/
    activemq/camel/trunk/components/camel-mina/src/test/resources/jndi-example.properties
      - copied, changed from r594071, activemq/camel/trunk/camel-core/src/test/resources/jndi-example.properties
Modified:
    activemq/camel/trunk/components/camel-mina/pom.xml

Modified: activemq/camel/trunk/components/camel-mina/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/pom.xml?rev=594496&r1=594495&r2=594496&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/pom.xml (original)
+++ activemq/camel/trunk/components/camel-mina/pom.xml Tue Nov 13 03:47:09 2007
@@ -53,6 +53,13 @@
       <artifactId>slf4j-simple</artifactId>
     </dependency>
 
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>

Added: activemq/camel/trunk/components/camel-mina/src/test/data/message1.txt
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/data/message1.txt?rev=594496&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/data/message1.txt (added)
+++ activemq/camel/trunk/components/camel-mina/src/test/data/message1.txt Tue Nov 13 03:47:09 2007
@@ -0,0 +1 @@
+Hello World

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

Copied: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java (from r594071, activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVmTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java?p2=activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java&p1=activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVmTest.java&r1=594071&r2=594496&rev=594496&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaVmTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java Tue Nov 13 03:47:09 2007
@@ -16,74 +16,31 @@
  */
 package org.apache.camel.component.mina;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.TestCase;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
 
 /**
  * @version $Revision$
  */
-public class MinaVmTest extends TestCase {
-    protected CamelContext container = new DefaultCamelContext();
-    protected CountDownLatch latch = new CountDownLatch(1);
-    protected Exchange receivedExchange;
-    protected String uri = "mina:vm://localhost:8080";
-    protected Producer<MinaExchange> producer;
+public class MinaFileTcpTest extends ContextTestSupport {
 
     public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:results");
+        endpoint.expectedMessageCount(1);
 
-        // now lets fire in a message
-        Endpoint<MinaExchange> endpoint = container.getEndpoint(uri);
-        MinaExchange exchange = endpoint.createExchange();
-        Message message = exchange.getIn();
-        message.setBody("Hello there!");
-        message.setHeader("cheese", 123);
-
-        producer = endpoint.createProducer();
-        producer.start();
-        producer.process(exchange);
-
-        // now lets sleep for a while
-        boolean received = latch.await(5, TimeUnit.SECONDS);
-        assertTrue("Did not receive the message!", received);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        container.addRoutes(createRouteBuilder());
-        container.start();
-    }
-
-
-    @Override
-    protected void tearDown() throws Exception {
-        if (producer != null) {
-            producer.stop();
-        }
-        container.stop();
+        assertMockEndpointsSatisifed();
     }
 
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from(uri).process(new Processor() {
-                    public void process(Exchange e) {
-                        System.out.println("Received exchange: " + e.getIn());
-                        receivedExchange = e;
-                        latch.countDown();
-                    }
-                });
+                // lets setup a server
+                from("mina:tcp://localhost:9123").to("mock:results");
+
+                from("file:src/test/data?noop=true").
+                        to("mina:tcp://localhost:9123");
             }
         };
     }
-}
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileTcpTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java?rev=594496&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java (added)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java Tue Nov 13 03:47:09 2007
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mina;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision: 563665 $
+ */
+public class MinaFileUdpTest extends ContextTestSupport {
+
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:results");
+        endpoint.expectedMessageCount(1);
+
+        assertMockEndpointsSatisifed();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // lets setup a server
+                from("mina:udp://localhost:9123").to("mock:results");
+
+                from("file:src/test/data?noop=true").
+                        to("mina:udp://localhost:9123");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaFileUdpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: activemq/camel/trunk/components/camel-mina/src/test/resources/jndi-example.properties (from r594071, activemq/camel/trunk/camel-core/src/test/resources/jndi-example.properties)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/resources/jndi-example.properties?p2=activemq/camel/trunk/components/camel-mina/src/test/resources/jndi-example.properties&p1=activemq/camel/trunk/camel-core/src/test/resources/jndi-example.properties&r1=594071&r2=594496&rev=594496&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/resources/jndi-example.properties (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/resources/jndi-example.properties Tue Nov 13 03:47:09 2007
@@ -19,11 +19,4 @@
 
 java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory
 
-# the following properties will be copied into the context
-foo = bar
-
-example.class = org.apache.camel.util.jndi.ExampleBean
-example.name = James
-example.price = 2.34
-
 # END SNIPPET: jndi