camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r581855 - in /activemq/camel/trunk/components/camel-spring/src/test: java/org/apache/camel/spring/processor/ resources/org/apache/camel/spring/processor/
Date Thu, 04 Oct 2007 11:31:19 GMT
Author: jstrachan
Date: Thu Oct  4 04:31:18 2007
New Revision: 581855

URL: http://svn.apache.org/viewvc?rev=581855&view=rev
Log:
added a simple example to show how to use <process> from inside a spring XML

Added:
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProcessor.java
  (with props)
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTransformTest.java
      - copied, changed from r580858, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/transform.xml
      - copied, changed from r580858, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProcessor.java?rev=581855&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProcessor.java
(added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProcessor.java
Thu Oct  4 04:31:18 2007
@@ -0,0 +1,34 @@
+/**
+ *
+ * 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.spring.processor;
+
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+
+/**
+ * A simple processor which transforms the input
+ *
+ * @version $Revision: 1.1 $
+*/
+public class MyProcessor implements Processor {
+    public void process(Exchange exchange) {
+        Message in = exchange.getIn();
+        in.setBody(in.getBody(String.class) + " World!");
+    }
+}

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTransformTest.java
(from r580858, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTransformTest.java?p2=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTransformTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java&r1=580858&r2=581855&rev=581855&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTransformTest.java
Thu Oct  4 04:31:18 2007
@@ -14,22 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.processor;
+package org.apache.camel.spring.processor;
 
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
+import org.apache.camel.CamelContext;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * @version $Revision: 1.1 $
  */
-public class TransformTest extends ContextTestSupport {
-    protected MockEndpoint resultEndpoint;
+public class SpringTransformTest extends ContextTestSupport {
 
-    public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception
{
+    public void testSendAMessageWhichIsTransformed() throws Exception {
+        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
         resultEndpoint.expectedBodiesReceived("Hello World!");
 
         sendBody("direct:start", "Hello");
@@ -37,25 +36,7 @@
         resultEndpoint.assertIsSatisfied();
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        resultEndpoint = getMockEndpoint("mock:result");
-    }
-
-    protected RouteBuilder createRouteBuilder() {
-        return new RouteBuilder() {
-            public void configure() {
-                // START SNIPPET: example
-                from("direct:start").process(new Processor() {
-                    public void process(Exchange exchange) {
-                        Message in = exchange.getIn();
-                        in.setBody(in.getBody(String.class) + " World!");
-                    }
-                }).to("mock:result");
-                // END SNIPPET: example
-            }
-        };
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/transform.xml");
     }
-}
+}
\ No newline at end of file

Copied: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/transform.xml
(from r580858, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/transform.xml?p2=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/transform.xml&p1=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml&r1=580858&r2=581855&rev=581855&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/transform.xml
Thu Oct  4 04:31:18 2007
@@ -26,12 +26,12 @@
   <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
     <route>
       <from uri="direct:start"/>
-      <filter>
-        <xpath>$foo = 'bar'</xpath>
-        <to uri="mock:result"/>
-      </filter>
+      <process ref="myProcessor"/>
+      <to uri="mock:result"/>
     </route>
   </camelContext>
+
+  <bean id="myProcessor" class="org.apache.camel.spring.processor.MyProcessor"/>
   <!-- END SNIPPET: example -->
 
 </beans>



Mime
View raw message