You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/08/18 06:06:29 UTC
svn commit: r686675 - in /activemq/camel/trunk/tests/camel-itest: ./
src/test/java/org/apache/camel/itest/jetty/
src/test/resources/org/apache/camel/itest/jetty/
Author: ningjiang
Date: Sun Aug 17 21:06:29 2008
New Revision: 686675
URL: http://svn.apache.org/viewvc?rev=686675&view=rev
Log:
CAMEL-832 Added a test to show how to put the jetty requst into the jms queue
Added:
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java (with props)
activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java (with props)
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/
activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml (with props)
Modified:
activemq/camel/trunk/tests/camel-itest/pom.xml
Modified: activemq/camel/trunk/tests/camel-itest/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/pom.xml?rev=686675&r1=686674&r2=686675&view=diff
==============================================================================
--- activemq/camel/trunk/tests/camel-itest/pom.xml (original)
+++ activemq/camel/trunk/tests/camel-itest/pom.xml Sun Aug 17 21:06:29 2008
@@ -45,6 +45,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jetty</artifactId>
+ </dependency>
<!-- testing -->
<dependency>
Added: activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java?rev=686675&view=auto
==============================================================================
--- activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java (added)
+++ activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java Sun Aug 17 21:06:29 2008
@@ -0,0 +1,62 @@
+/**
+ * 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.cxf.CxfConstants;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+
+@ContextConfiguration
+public class JettyJmsTest extends AbstractJUnit38SpringContextTests {
+
+ @Autowired
+ protected CamelContext camelContext;
+
+ @EndpointInject(uri = "mock:resultEndpoint")
+ protected MockEndpoint resultEndpoint;
+
+ public void testMocksAreValid() throws Exception {
+ assertNotNull(camelContext);
+ assertNotNull(resultEndpoint);
+
+ ProducerTemplate<Exchange> template = camelContext.createProducerTemplate();
+ template.sendBodyAndHeader("jetty:http://localhost:9000/test", "Hello form Willem", "Operation", "greetMe");
+
+ // Sleep a while and wait for the message whole processing
+ Thread.sleep(4000);
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ List<Exchange> list = resultEndpoint.getReceivedExchanges();
+ assertEquals("Should get one message", list.size(), 1);
+
+ for (Exchange exchange : list) {
+ Object result = exchange.getIn().getBody();
+ assertEquals("Should get the request", "Hello form Willem", result);
+ assertEquals("Should get the header", "greetMe", exchange.getIn().getHeader("Operation"));
+ }
+
+ }
+
+}
Propchange: activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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/SetExchangeProcessor.java?rev=686675&view=auto
==============================================================================
--- activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java (added)
+++ activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java Sun Aug 17 21:06:29 2008
@@ -0,0 +1,36 @@
+/**
+ * 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;
+
+public class SetExchangeProcessor implements Processor {
+
+ public void process(Exchange exchange) throws Exception {
+ // Override the exchange pattern
+ exchange.setPattern(ExchangePattern.InOnly);
+ // Convert the input stream into a string
+ String result = exchange.getIn().getBody(String.class);
+ // Copy the message header
+ exchange.getOut().setHeaders(exchange.getIn().getHeaders());
+ exchange.getOut().setBody(result);
+
+ }
+
+}
Propchange: activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/SetExchangeProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=686675&view=auto
==============================================================================
--- 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/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml Sun Aug 17 21:06:29 2008
@@ -0,0 +1,53 @@
+<?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="setExchangeProcessor" class="org.apache.camel.itest.jetty.SetExchangeProcessor"/>
+
+ <!-- START SNIPPET: example -->
+ <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="jetty:http://localhost:9000/test"/>
+ <process ref="setExchangeProcessor"/>
+ <to uri="jms:responseQueue"/>
+ </route>
+ <route>
+ <from uri="jms:responseQueue"/>
+ <to uri="mock:resultEndpoint"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+
+</beans>
Propchange: activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: activemq/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml