activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r519997 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/CompositeProcessor.java main/java/org/apache/camel/builder/DestinationBuilder.java test/java/org/apache/camel/RouteBuilderTest.java
Date Mon, 19 Mar 2007 16:30:23 GMT
Author: jstrachan
Date: Mon Mar 19 09:30:21 2007
New Revision: 519997

URL: http://svn.apache.org/viewvc?view=rev&rev=519997
Log:
added a WireTap test case

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CompositeProcessor.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DestinationBuilder.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CompositeProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CompositeProcessor.java?view=diff&rev=519997&r1=519996&r2=519997
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CompositeProcessor.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CompositeProcessor.java
Mon Mar 19 09:30:21 2007
@@ -53,4 +53,8 @@
         builder.append(" ]");
         return builder.toString();
     }
+
+    public Collection<Processor<E>> getProcessors() {
+        return processors;
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DestinationBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DestinationBuilder.java?view=diff&rev=519997&r1=519996&r2=519997
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DestinationBuilder.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DestinationBuilder.java
Mon Mar 19 09:30:21 2007
@@ -76,6 +76,29 @@
 
 
     /**
+     * Sends the exchange to the given endpoint URI
+     */
+    public ProcessorBuilder<E> to(String... uris) {
+        ProcessorBuilder<E> answer = null;
+        for (String uri : uris) {
+            answer = to(endpoint(uri));
+        }
+        return answer;
+    }
+
+    /**
+     * Sends the exchange to the given endpoint
+     */
+    public ProcessorBuilder<E> to(Endpoint<E>... endpoints) {
+        ProcessorBuilder<E> answer = null;
+        for (Endpoint<E> endpoint : endpoints) {
+            answer = to(endpoint);          
+        }
+        return answer;
+    }
+
+
+    /**
      * Adds the custom processor to this destination
      */
     public ProcessorBuilder<E> process(Processor<E> processor) {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java?view=diff&rev=519997&r1=519996&r2=519997
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java Mon
Mar 19 09:30:21 2007
@@ -22,6 +22,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Collection;
+import java.util.ArrayList;
 
 /**
  * @version $Revision$
@@ -176,6 +178,35 @@
             assertTrue("Processor should be a FilterProcessor but was: " + processor + "
with type: " + processor.getClass().getName(), processor instanceof FilterProcessor);
             FilterProcessor filterProcessor = (FilterProcessor) processor;
             assertEquals("Should be called with my processor", myProcessor, filterProcessor.getProcessor());
+        }
+    }
+
+    public void testWireTap() throws Exception {
+        // START SNIPPET: e6
+        RouteBuilder<Exchange> builder = new RouteBuilder<Exchange>() {
+            public void configure() {
+                from("seda:a").to("seda:tap", "seda:b");
+            }
+        };
+        // END SNIPPET: e6
+
+        Map<Endpoint<Exchange>, Processor<Exchange>> routeMap = builder.getRouteMap();
+        System.out.println("Created map: " + routeMap);
+
+        Set<Map.Entry<Endpoint<Exchange>, Processor<Exchange>>> routes
= routeMap.entrySet();
+        assertEquals("Number routes created", 1, routes.size());
+        for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route :
routes) {
+            Endpoint<Exchange> key = route.getKey();
+            assertEquals("From endpoint", "seda:a", key.getEndpointUri());
+            Processor processor = route.getValue();
+
+            assertTrue("Processor should be a CompositeProcessor but was: " + processor +
" with type: " + processor.getClass().getName(), processor instanceof CompositeProcessor);
+            CompositeProcessor<Exchange> compositeProcessor = (CompositeProcessor<Exchange>)
processor;
+            List<Processor<Exchange>> processors = new ArrayList<Processor<Exchange>>(compositeProcessor.getProcessors());
+            assertEquals("Should have 2 processors", 2, processors.size());
+
+            assertSendTo(processors.get(0), "seda:tap");
+            assertSendTo(processors.get(1), "seda:b");
         }
     }
 



Mime
View raw message