Author: ningjiang
Date: Fri Sep 12 03:06:01 2008
New Revision: 694670

URL: http://svn.apache.org/viewvc?rev=694670&view=rev
Log:
CAMEL-892 Added an integration test to show how to let jetty and jms component 
work with InOut message

Added:
    
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java
   (with props)
    
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangePatternProcessor.java
      - copied, changed from r693883, 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java
    
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java
   (with props)
    
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTwowayTest-context.xml
   (with props)
Removed:
    
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java
Modified:
    
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml

Added: 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java?rev=694670&view=auto
==============================================================================
--- 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java
 (added)
+++ 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTwowayTest.java
 Fri Sep 12 03:06:01 2008
@@ -0,0 +1,47 @@
+/**
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import 
org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+
[EMAIL PROTECTED]
+public class JettyJmsTwowayTest extends AbstractJUnit38SpringContextTests {
+
+    @Autowired
+    protected CamelContext camelContext;
+
+    public void testSendingRequest() throws Exception {
+        assertNotNull("the camelContext should not be null", camelContext);
+        ProducerTemplate<Exchange> template = 
camelContext.createProducerTemplate();
+        Exchange exchange = template.send("jetty:http://localhost:9000/test";, 
new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("<hello>Willem</hello>");
+                exchange.getIn().setHeader("Operation", "greetMe");
+            }
+
+        });
+        assertEquals("get result ", "<message>out</message>", 
exchange.getOut().getBody(String.class));
+        Thread.sleep(2000);
+
+    }
+}

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

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

Copied: 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangePatternProcessor.java
 (from r693883, 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangePatternProcessor.java?p2=activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangePatternProcessor.java&p1=activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java&r1=693883&r2=694670&rev=694670&view=diff
==============================================================================
--- 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java
 (original)
+++ 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangePatternProcessor.java
 Fri Sep 12 03:06:01 2008
@@ -21,7 +21,7 @@
 import org.apache.camel.Processor;
 import org.apache.camel.converter.stream.StreamCache;
 
-public class SetExchangeProcessor implements Processor {
+public class SetExchangePatternProcessor implements Processor {
 
     public void process(Exchange exchange) throws Exception {
         // Override the exchange pattern

Added: 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java?rev=694670&view=auto
==============================================================================
--- 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java
 (added)
+++ 
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetResponseProcessor.java
 Fri Sep 12 03:06:01 2008
@@ -0,0 +1,35 @@
+/**
+ * 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 org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.camel.converter.stream.StreamCache;
+
+public class SetResponseProcessor implements Processor {
+
+    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>");
+
+    }
+
+}

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

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

Modified: 
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml?rev=694670&r1=694669&r2=694670&view=diff
==============================================================================
--- 
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml
 (original)
+++ 
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml
 Fri Sep 12 03:06:01 2008
@@ -34,14 +34,14 @@
        </property>
   </bean>
 
-  <bean id="setExchangeProcessor" 
class="org.apache.camel.itest.jetty.SetExchangeProcessor"/>
+  <bean id="setExchangePatternProcessor" 
class="org.apache.camel.itest.jetty.SetExchangePatternProcessor"/>
 
   <!-- START SNIPPET: example -->
   <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"; 
trace="true">
     <route>
         <from uri="jetty:http://localhost:9000/test"/>
         <to uri="log:MyCategory?level=INFO"/>
-        <process ref="setExchangeProcessor"/>
+        <process ref="setExchangePatternProcessor"/>
         <to uri="jms:responseQueue"/>
     </route>
     <route>

Added: 
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTwowayTest-context.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTwowayTest-context.xml?rev=694670&view=auto
==============================================================================
--- 
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTwowayTest-context.xml
 (added)
+++ 
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTwowayTest-context.xml
 Fri Sep 12 03:06:01 2008
@@ -0,0 +1,52 @@
+<?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://activemq.apache.org/camel/schema/spring 
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+
+ <import resource="classpath:activemq.xml" />
+
+  <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
+       <property name="connectionFactory">
+               <bean class="org.apache.activemq.ActiveMQConnectionFactory">
+                       <property name="brokerURL"
+                               value="tcp://localhost:61616" />
+               </bean>
+       </property>
+  </bean>
+
+  <bean id="setResponseProcessor" 
class="org.apache.camel.itest.jetty.SetResponseProcessor"/>
+
+  <!-- START SNIPPET: example -->
+  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"; 
trace="true">
+    <route>
+        <from uri="jetty:http://localhost:9000/test"/>
+        <to uri="jms:responseQueue"/>
+    </route>
+    <route>
+        <from uri="jms:responseQueue"/>
+        <process ref="setResponseProcessor"/>
+    </route>
+  </camelContext>
+  <!-- END SNIPPET: example -->
+
+</beans>

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

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

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


Reply via email to