camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r897802 - in /camel/trunk/tests/camel-itest/src/test: java/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest.java resources/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest-context.xml
Date Mon, 11 Jan 2010 09:01:38 GMT
Author: davsclaus
Date: Mon Jan 11 09:01:37 2010
New Revision: 897802

URL: http://svn.apache.org/viewvc?rev=897802&view=rev
Log:
Added unit test based on user forum issue

Added:
    camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest.java
      - copied, changed from r897754, camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java
    camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest-context.xml
      - copied, changed from r897754, camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml

Copied: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest.java
(from r897754, 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/JettyMulticastJmsFileTest.java?p2=camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest.java&p1=camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsTest.java&r1=897754&r2=897802&rev=897802&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/JettyMulticastJmsFileTest.java
Mon Jan 11 09:01:37 2010
@@ -16,52 +16,42 @@
  */
 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.ConsumerTemplate;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.mock.MockEndpoint;
-
+import org.apache.camel.test.junit4.TestSupport;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 @ContextConfiguration
-public class JettyJmsTest extends AbstractJUnit4SpringContextTests {
+public class JettyMulticastJmsFileTest extends AbstractJUnit4SpringContextTests {
 
     @Autowired
     protected CamelContext camelContext;
 
-    @EndpointInject(uri = "mock:resultEndpoint")
-    protected MockEndpoint resultEndpoint;
-
     @Test
-    public void testMocksAreValid() throws Exception {
-        assertNotNull(resultEndpoint);
-        resultEndpoint.reset();
+    public void testJettyMulticastJmsFile() throws Exception {
+        TestSupport.deleteDirectory("target/jetty");
 
         ProducerTemplate 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);
+        String out = template.requestBody("jetty:http://localhost:9000/test", "Hello World",
String.class);
+        assertEquals("Bye World", out);
+
         template.stop();
 
-        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"));
-        }
+        ConsumerTemplate consumer = camelContext.createConsumerTemplate();
+        String in = consumer.receiveBody("jms:queue:foo", 5000, String.class);
+        assertEquals("Hello World", in);
+
+        String in2 = consumer.receiveBody("file://target/jetty?noop=true&readLock=none",
5000, String.class);
+        assertEquals("Hello World", in2);
+
+        consumer.stop();
     }
 
-}
+}
\ No newline at end of file

Copied: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest-context.xml
(from r897754, camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest-context.xml?p2=camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest-context.xml&p1=camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml&r1=897754&r2=897802&rev=897802&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyJmsTest-context.xml
(original)
+++ camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/jetty/JettyMulticastJmsFileTest-context.xml
Mon Jan 11 09:01:37 2010
@@ -23,32 +23,27 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
- <import resource="classpath:activemq.xml" />
+    <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="vm://localhost?broker.persistent=false" />
-  		</bean>
-  	</property>
-  </bean>
+    <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
+        <property name="connectionFactory">
+            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
+                <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
+            </bean>
+        </property>
+    </bean>
 
-  <bean id="setExchangePatternProcessor" class="org.apache.camel.itest.jetty.SetExchangePatternProcessor"/>
-
-  <!-- START SNIPPET: example -->
-  <camelContext xmlns="http://camel.apache.org/schema/spring" trace="true">
-    <route>
-        <from uri="jetty:http://localhost:9000/test"/>
-        <to uri="log:MyCategory?level=INFO"/>
-        <process ref="setExchangePatternProcessor"/>
-        <to uri="jms:responseQueue"/>
-    </route>
-    <route>
-        <from uri="jms:responseQueue"/>
-        <to uri="mock:resultEndpoint"/>
-    </route>
-  </camelContext>
-  <!-- END SNIPPET: example -->
+    <camelContext xmlns="http://camel.apache.org/schema/spring" trace="true">
+        <route>
+            <from uri="jetty:http://localhost:9000/test"/>
+            <multicast>
+                <to uri="jms:queue:foo" pattern="InOnly"/>
+                <to uri="file://target/jetty" pattern="InOnly"/>
+            </multicast>
+            <transform>
+                <constant>Bye World</constant>
+            </transform>
+        </route>
+    </camelContext>
 
 </beans>



Mime
View raw message