Author: ningjiang
Date: Wed Apr 22 08:05:12 2009
New Revision: 767403

URL: http://svn.apache.org/viewvc?rev=767403&view=rev
Log:
Added an integration test of Mulitcast according to the mail list

Added:
    
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyFileMulticastTest.java
   (with props)
    
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyFileMulticastTest-context.xml
   (with props)
Modified:
    
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java
    
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java
    
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java

Added: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyFileMulticastTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyFileMulticastTest.java?rev=767403&view=auto
==============================================================================
--- 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyFileMulticastTest.java
 (added)
+++ 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyFileMulticastTest.java
 Wed Apr 22 08:05:12 2009
@@ -0,0 +1,66 @@
+/**
+ * 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.itest.jetty;
+
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.interceptor.Tracer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import 
org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+
+...@contextconfiguration
+public class JettyFileMulticastTest extends AbstractJUnit38SpringContextTests {
+    
+    @Autowired
+    protected CamelContext camelContext;
+
+    @EndpointInject(uri = "mock:resultEndpoint")
+    protected MockEndpoint resultEndpoint;
+   
+    @EndpointInject(uri = "mock:fileEndpoint")
+    protected MockEndpoint fileEndpoint;
+    
+    public void testMulticastEndpoint() throws Exception {
+        assertNotNull(resultEndpoint);
+        assertNotNull(fileEndpoint);
+        
+        resultEndpoint.reset();
+        fileEndpoint.reset();
+        
+        ProducerTemplate template = camelContext.createProducerTemplate();
+        template.sendBodyAndHeader("direct:start", "Hello form Willem", 
"Operation", "greetMe");
+
+        // Sleep a while and wait for the message whole processing
+        Thread.sleep(2000);
+
+        MockEndpoint.assertIsSatisfied(camelContext);
+        List<Exchange> resultExchanges = resultEndpoint.getReceivedExchanges();
+        assertEquals("Should get one message for mock endpoint", 
resultExchanges.size(), 1);
+        
+        String result = resultExchanges.get(0).getIn().getBody(String.class);
+        assertEquals("Should get the request", "<response>Hello form 
Willem</response>", result);
+        assertEquals("Should get the header", "greetMe", 
resultExchanges.get(0).getIn().getHeader("Operation"));        
+        
+    }
+
+}

Propchange: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyFileMulticastTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyFileMulticastTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java?rev=767403&r1=767402&r2=767403&view=diff
==============================================================================
--- 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java
 (original)
+++ 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java
 Wed Apr 22 08:05:12 2009
@@ -54,8 +54,8 @@
     }
 
     private void validMockes() throws Exception {
-        resultEndpoint.reset();
         assertNotNull(resultEndpoint);
+        resultEndpoint.reset();        
 
         ProducerTemplate template = camelContext.createProducerTemplate();
         template.sendBodyAndHeader("jetty:http://localhost:9000/test";, "Hello 
form Willem", "Operation", "greetMe");

Modified: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java?rev=767403&r1=767402&r2=767403&view=diff
==============================================================================
--- 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java
 (original)
+++ 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java
 Wed Apr 22 08:05:12 2009
@@ -40,7 +40,7 @@
             }
 
         });
-        assertEquals("get result ", "<message>out</message>", 
exchange.getOut().getBody(String.class));
+        assertEquals("get result ", 
"<response><hello>Willem</hello></response>", 
exchange.getOut().getBody(String.class));
         Thread.sleep(2000);
 
     }

Modified: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java?rev=767403&r1=767402&r2=767403&view=diff
==============================================================================
--- 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java
 (original)
+++ 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java
 Wed Apr 22 08:05:12 2009
@@ -24,9 +24,9 @@
     public void process(Exchange exchange) throws Exception {
 
         // Convert the input stream into a string
-        String result = exchange.getIn().getBody(String.class);
-
-        exchange.getOut().setBody("<message>out</message>");
+        String request = exchange.getIn().getBody(String.class);
+        
+        exchange.getOut().setBody("<response>" + request + "</response>");
 
     }
 

Added: 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyFileMulticastTest-context.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyFileMulticastTest-context.xml?rev=767403&view=auto
==============================================================================
--- 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyFileMulticastTest-context.xml
 (added)
+++ 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyFileMulticastTest-context.xml
 Wed Apr 22 08:05:12 2009
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+ 
+  <bean id="SetResponseProcessor" 
class="org.apache.camel.itest.jetty.SetResponseProcessor"/>
+
+  <!-- START SNIPPET: example -->
+  <camelContext xmlns="http://camel.apache.org/schema/spring"; trace="true">
+    <route>
+        <from uri="jetty:http://localhost:9000/test"/>        
+        <process ref="SetResponseProcessor"/>        
+    </route>
+    <route>
+        <from uri="direct:start"/>
+        <to uri="jetty:http://localhost:9000/test"/>       
+        <multicast>
+          <to uri="direct:file"/> 
+          <to uri="direct:mock"/>
+        </multicast>
+    </route>
+    <route>
+        <from uri="direct:file"/>
+        <setHeader headerName="CamelFileName">
+           <constant>test.xml</constant>
+        </setHeader>
+        <to uri="file://target?append=false"/>
+        <to uri="mock:fileEndpoint"/>
+    </route>
+    <route>
+       <from uri="direct:mock"/>       
+       <to uri="mock:resultEndpoint"/>
+    </route>
+  </camelContext>
+  <!-- END SNIPPET: example -->
+
+</beans>

Propchange: 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyFileMulticastTest-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyFileMulticastTest-context.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyFileMulticastTest-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to