activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r530760 - in /activemq/camel/trunk/camel-core/src/test/java/org/apache/camel: ContextTestSupport.java processor/TransformTest.java
Date Fri, 20 Apr 2007 12:17:06 GMT
Author: jstrachan
Date: Fri Apr 20 05:17:05 2007
New Revision: 530760

URL: http://svn.apache.org/viewvc?view=rev&rev=530760
Log:
added a test case demonstrating message transformation

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java
  (with props)
Modified:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java?view=diff&rev=530760&r1=530759&r2=530760
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
Fri Apr 20 05:17:05 2007
@@ -58,4 +58,20 @@
     protected Endpoint<Exchange> resolveMandatoryEndpoint(String uri) {
         return resolveMandatoryEndpoint(context, uri);
     }
+
+    /**
+     * Sends a message to the given endpoint URI with the body value
+     *
+     * @param endpointUri the URI of the endpoint to send to
+     * @param body the body for the message
+     */
+    protected void send(String endpointUri, final Object body) {
+        client.send(endpointUri, new Processor<Exchange>() {
+            public void process(Exchange exchange) {
+                Message in = exchange.getIn();
+                in.setBody(body);
+                in.setHeader("testCase", getName());
+            }
+        });
+    }
 }

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java?view=auto&rev=530760
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java
(added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java
Fri Apr 20 05:17:05 2007
@@ -0,0 +1,63 @@
+/**
+ *
+ * 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 org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.Message;
+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 void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception
{
+        resultEndpoint.expectedBodiesReceived("Hello World!");
+
+        send("direct:start", "Hello");
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint("mock:result");
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder<Exchange>() {
+            public void configure() {
+                // START SNIPPET: example
+                from("direct:start").process(new Processor<Exchange>() {
+                    public void process(Exchange exchange) {
+                        Message in = exchange.getIn();
+                        in.setBody(in.getBody(String.class) + " World!");
+                    }
+                }).to("mock:result");
+                // END SNIPPET: example
+            }
+        };
+    }
+}

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



Mime
View raw message