camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r955480 - /camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/
Date Thu, 17 Jun 2010 04:44:15 GMT
Author: davsclaus
Date: Thu Jun 17 04:44:14 2010
New Revision: 955480

URL: http://svn.apache.org/viewvc?rev=955480&view=rev
Log:
CAMEL-2723: Added more tests.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncInOnlyEndpointTest.java
      - copied, changed from r955294, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncSedaInOnlyEndpointTest.java
  (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTwoEndpointTest.java
      - copied, changed from r955294, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java
Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithDelayerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithHandleFaultTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithJMXTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithStreamCachingTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithTracingTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncProducerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncComponent.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncEndpoint.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncProducer.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java
Thu Jun 17 04:44:14 2010
@@ -57,7 +57,7 @@ public class AsyncEndpointTest extends C
                                 beforeThreadName = Thread.currentThread().getName();
                             }
                         })
-                        .to("async:foo")
+                        .to("async:Bye Camel")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 afterThreadName = Thread.currentThread().getName();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithDelayerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithDelayerTest.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithDelayerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithDelayerTest.java
Thu Jun 17 04:44:14 2010
@@ -58,7 +58,7 @@ public class AsyncEndpointWithDelayerTes
                                 beforeThreadName = Thread.currentThread().getName();
                             }
                         })
-                        .to("async:foo")
+                        .to("async:Bye Camel")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 afterThreadName = Thread.currentThread().getName();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithHandleFaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithHandleFaultTest.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithHandleFaultTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithHandleFaultTest.java
Thu Jun 17 04:44:14 2010
@@ -65,7 +65,7 @@ public class AsyncEndpointWithHandleFaul
                                 beforeThreadName = Thread.currentThread().getName();
                             }
                         })
-                        .to("async:foo")
+                        .to("async:Bye Camel")
                         .to("log:after")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithJMXTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithJMXTest.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithJMXTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithJMXTest.java
Thu Jun 17 04:44:14 2010
@@ -62,7 +62,7 @@ public class AsyncEndpointWithJMXTest ex
                                 beforeThreadName = Thread.currentThread().getName();
                             }
                         })
-                        .to("async:foo")
+                        .to("async:Bye Camel")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 afterThreadName = Thread.currentThread().getName();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithStreamCachingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithStreamCachingTest.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithStreamCachingTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithStreamCachingTest.java
Thu Jun 17 04:44:14 2010
@@ -58,7 +58,7 @@ public class AsyncEndpointWithStreamCach
                                 beforeThreadName = Thread.currentThread().getName();
                             }
                         })
-                        .to("async:foo")
+                        .to("async:Bye Camel")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 afterThreadName = Thread.currentThread().getName();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithTracingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithTracingTest.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithTracingTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithTracingTest.java
Thu Jun 17 04:44:14 2010
@@ -58,7 +58,7 @@ public class AsyncEndpointWithTracingTes
                                 beforeThreadName = Thread.currentThread().getName();
                             }
                         })
-                        .to("async:foo")
+                        .to("async:Bye Camel")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 afterThreadName = Thread.currentThread().getName();

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncInOnlyEndpointTest.java
(from r955294, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncInOnlyEndpointTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncInOnlyEndpointTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java&r1=955294&r2=955480&rev=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncInOnlyEndpointTest.java
Thu Jun 17 04:44:14 2010
@@ -24,7 +24,7 @@ import org.apache.camel.builder.RouteBui
 /**
  * @version $Revision$
  */
-public class AsyncEndpointTest extends ContextTestSupport {
+public class AsyncInOnlyEndpointTest extends ContextTestSupport {
 
     private static String beforeThreadName;
     private static String afterThreadName;
@@ -34,8 +34,7 @@ public class AsyncEndpointTest extends C
         getMockEndpoint("mock:after").expectedBodiesReceived("Bye Camel");
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");
 
-        String reply = template.requestBody("direct:start", "Hello Camel", String.class);
-        assertEquals("Bye Camel", reply);
+        template.sendBody("direct:start", "Hello Camel");
 
         assertMockEndpointsSatisfied();
 
@@ -57,7 +56,7 @@ public class AsyncEndpointTest extends C
                                 beforeThreadName = Thread.currentThread().getName();
                             }
                         })
-                        .to("async:foo")
+                        .to("async:Bye Camel")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 afterThreadName = Thread.currentThread().getName();
@@ -70,4 +69,4 @@ public class AsyncEndpointTest extends C
         };
     }
 
-}
+}
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncProducerTest.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncProducerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncProducerTest.java
Thu Jun 17 04:44:14 2010
@@ -49,7 +49,7 @@ public class AsyncProducerTest extends C
             @Override
             public void configure() throws Exception {
                 context.addComponent("async", new MyAsyncComponent());
-                Producer myAsyncProducer = context.getEndpoint("async:foo").createProducer();
+                Producer myAsyncProducer = context.getEndpoint("async:Bye Camel").createProducer();
 
                 from("direct:start")
                     .to("mock:before")

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncSedaInOnlyEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncSedaInOnlyEndpointTest.java?rev=955480&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncSedaInOnlyEndpointTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncSedaInOnlyEndpointTest.java
Thu Jun 17 04:44:14 2010
@@ -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.processor.async;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class AsyncSedaInOnlyEndpointTest extends ContextTestSupport {
+
+    private static String beforeThreadName;
+    private static String afterThreadName;
+
+    public void testAsyncEndpoint() throws Exception {
+        getMockEndpoint("mock:before").expectedBodiesReceived("Hello Camel");
+        getMockEndpoint("mock:after").expectedBodiesReceived("Bye Camel");
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");
+
+        template.sendBody("seda:start", "Hello Camel");
+
+        assertMockEndpointsSatisfied();
+
+        assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                context.addComponent("async", new MyAsyncComponent());
+
+                from("seda:start")
+                        .to("mock:before")
+                        .to("log:before")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                beforeThreadName = Thread.currentThread().getName();
+                            }
+                        })
+                        .to("async:Bye Camel")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                afterThreadName = Thread.currentThread().getName();
+                            }
+                        })
+                        .to("log:after")
+                        .to("mock:after")
+                        .to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncSedaInOnlyEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncSedaInOnlyEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTwoEndpointTest.java
(from r955294, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTwoEndpointTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTwoEndpointTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java&r1=955294&r2=955480&rev=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTwoEndpointTest.java
Thu Jun 17 04:44:14 2010
@@ -24,13 +24,15 @@ import org.apache.camel.builder.RouteBui
 /**
  * @version $Revision$
  */
-public class AsyncEndpointTest extends ContextTestSupport {
+public class AsyncTwoEndpointTest extends ContextTestSupport {
 
     private static String beforeThreadName;
+    private static String middleThreadName;
     private static String afterThreadName;
 
     public void testAsyncEndpoint() throws Exception {
         getMockEndpoint("mock:before").expectedBodiesReceived("Hello Camel");
+        getMockEndpoint("mock:middle").expectedBodiesReceived("Hi Camel");
         getMockEndpoint("mock:after").expectedBodiesReceived("Bye Camel");
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");
 
@@ -39,6 +41,8 @@ public class AsyncEndpointTest extends C
 
         assertMockEndpointsSatisfied();
 
+        assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(middleThreadName));
+        assertFalse("Should use different threads", middleThreadName.equalsIgnoreCase(afterThreadName));
         assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
     }
 
@@ -57,7 +61,15 @@ public class AsyncEndpointTest extends C
                                 beforeThreadName = Thread.currentThread().getName();
                             }
                         })
-                        .to("async:foo")
+                        .to("async:Hi Camel")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                middleThreadName = Thread.currentThread().getName();
+                            }
+                        })
+                        .to("log:middle")
+                        .to("mock:middle")
+                        .to("async:Bye Camel")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 afterThreadName = Thread.currentThread().getName();
@@ -70,4 +82,4 @@ public class AsyncEndpointTest extends C
         };
     }
 
-}
+}
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncComponent.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncComponent.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncComponent.java
Thu Jun 17 04:44:14 2010
@@ -28,6 +28,10 @@ public class MyAsyncComponent extends De
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
-        return new MyAsyncEndpoint(uri, this);
+        MyAsyncEndpoint answer = new MyAsyncEndpoint(uri, this);
+        answer.setReply(remaining);
+        setProperties(answer, parameters);
+        return answer;
     }
+
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncEndpoint.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncEndpoint.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncEndpoint.java
Thu Jun 17 04:44:14 2010
@@ -27,6 +27,8 @@ import org.apache.camel.impl.DefaultEndp
  */
 public class MyAsyncEndpoint extends DefaultEndpoint {
 
+    private String reply;
+
     public MyAsyncEndpoint(String endpointUri, Component component) {
         super(endpointUri, component);
     }
@@ -42,4 +44,12 @@ public class MyAsyncEndpoint extends Def
     public boolean isSingleton() {
         return false;
     }
+
+    public String getReply() {
+        return reply;
+    }
+
+    public void setReply(String reply) {
+        this.reply = reply;
+    }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncProducer.java?rev=955480&r1=955479&r2=955480&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncProducer.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncProducer.java
Thu Jun 17 04:44:14 2010
@@ -22,7 +22,6 @@ import java.util.concurrent.Executors;
 
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.AsyncProcessor;
-import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Producer;
@@ -54,7 +53,8 @@ public class MyAsyncProducer implements 
                 LOG.info("Simulating a task which takes 2 sec to reply");
 
                 Thread.sleep(2000);
-                exchange.getOut().setBody("Bye Camel");
+                String reply = endpoint.getReply();
+                exchange.getOut().setBody(reply);
 
                 LOG.info("Callback done(false)");
                 callback.done(false);



Mime
View raw message