camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r704638 - /activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamSourceContentBasedRouterTest.java
Date Tue, 14 Oct 2008 19:37:46 GMT
Author: gertv
Date: Tue Oct 14 12:37:46 2008
New Revision: 704638

URL: http://svn.apache.org/viewvc?rev=704638&view=rev
Log:
CAMEL-973: Just a test case to show an XPath CBR in Camel

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamSourceContentBasedRouterTest.java

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamSourceContentBasedRouterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamSourceContentBasedRouterTest.java?rev=704638&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamSourceContentBasedRouterTest.java
(added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamSourceContentBasedRouterTest.java
Tue Oct 14 12:37:46 2008
@@ -0,0 +1,75 @@
+/**
+ * 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;
+
+import java.io.StringReader;
+
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.jaxp.StringSource;
+
+/**
+ * Test for handling a StreamSource in a content-based router with XPath predicates
+ *
+ * @version $Revision: 693948 $
+ */
+public class StreamSourceContentBasedRouterTest extends ContextTestSupport {
+    protected MockEndpoint x;
+    protected MockEndpoint y;
+
+    public void testSendStreamSource() throws Exception {
+        x.expectedMessageCount(1);
+        y.expectedMessageCount(1);
+     
+        sendBody("direct:start", new StreamSource(new StringReader("<message>xx</message>")));
+        sendBody("direct:start", new StreamSource(new StringReader("<message>yy</message>")));
+        
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testSendStringSource() throws Exception {
+        x.expectedMessageCount(1);
+        y.expectedMessageCount(1);
+     
+        sendBody("direct:start", new StringSource("<message>xx</message>"));
+        sendBody("direct:start", new StringSource("<message>yy</message>"));
+        
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        x = getMockEndpoint("mock:x");
+        y = getMockEndpoint("mock:y");
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start").convertBodyTo(String.class).choice()
+                  .when().xpath("/message/text() = 'xx'").to("mock:x")
+                  .when().xpath("/message/text() = 'yy'").to("mock:y");
+            }
+        };
+    }
+
+}



Mime
View raw message