camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r925764 - in /camel/trunk/components/camel-jetty/src/test: java/org/apache/camel/component/jetty/ resources/org/apache/camel/component/jetty/
Date Sun, 21 Mar 2010 13:13:05 GMT
Author: davsclaus
Date: Sun Mar 21 13:13:05 2010
New Revision: 925764

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

Added:
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
  (with props)
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
  (with props)
    camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml
  (with props)
    camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection.xml
      - copied, changed from r925747, camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml

Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java?rev=925764&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
(added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
Sun Mar 21 13:13:05 2010
@@ -0,0 +1,65 @@
+/**
+ * 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.component.jetty;
+
+import java.net.ConnectException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.apache.http.conn.HttpHostConnectException;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringJettyNoConnectionRedeliveryTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml");
+    }
+
+    @Test
+    public void testConnectionOk() throws Exception {
+        String reply = template.requestBody("direct:start", "World", String.class);
+        assertEquals("Bye World", reply);
+    }
+
+    @Test
+    public void testConnectionNotOk() throws Exception {
+        // stop Jetty so there should not be a connection
+        JettyHttpComponent jetty = context.getComponent("jetty", JettyHttpComponent.class);
+        jetty.stop();
+
+        Exchange exchange = template.request("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("Moon");
+            }
+        });
+
+        assertTrue(exchange.isFailed());
+
+        HttpHostConnectException cause = assertIsInstanceOf(HttpHostConnectException.class,
exchange.getException());
+        assertIsInstanceOf(ConnectException.class, cause.getCause());
+
+        assertEquals(true, exchange.getIn().getHeader(Exchange.REDELIVERED));
+        assertEquals(4, exchange.getIn().getHeader(Exchange.REDELIVERY_COUNTER));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java?rev=925764&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
(added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
Sun Mar 21 13:13:05 2010
@@ -0,0 +1,58 @@
+/**
+ * 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.component.jetty;
+
+import java.net.ConnectException;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.apache.http.conn.HttpHostConnectException;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringJettyNoConnectionTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/jetty/jetty-noconnection.xml");
+    }
+
+    @Test
+    public void testConnectionOk() throws Exception {
+        String reply = template.requestBody("direct:start", "World", String.class);
+        assertEquals("Bye World", reply);
+    }
+
+    @Test
+    public void testConnectionNotOk() throws Exception {
+        // stop Jetty so there should not be a connection
+        JettyHttpComponent jetty = context.getComponent("jetty", JettyHttpComponent.class);
+        jetty.stop();
+
+        try {
+            template.requestBody("direct:start", "Moon", String.class);
+            fail("Should have thrown an exception");
+        } catch (CamelExecutionException e) {
+            assertIsInstanceOf(HttpHostConnectException.class, e.getCause());
+            assertIsInstanceOf(ConnectException.class, e.getCause().getCause());
+        }
+    }
+}

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml?rev=925764&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml
(added)
+++ camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml
Sun Mar 21 13:13:05 2010
@@ -0,0 +1,44 @@
+<?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
+    ">
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+        <route>
+            <from uri="direct:start"/>
+            <onException>
+                <exception>java.net.ConnectException</exception>
+                <redeliveryPolicy maximumRedeliveries="4" redeliveryDelay="100" maximumRedeliveryDelay="5000"
+                                  backOffMultiplier="2" useExponentialBackOff="true"/>
+            </onException>
+            <to uri="http://localhost:9221/hi"/>
+        </route>
+
+        <route>
+            <from uri="jetty:http://localhost:9221/hi"/>
+            <transform><simple>Bye ${body}</simple></transform>
+        </route>
+        
+    </camelContext>
+
+</beans>

Propchange: camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection.xml
(from r925747, camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection.xml?p2=camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection.xml&p1=camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml&r1=925747&r2=925764&rev=925764&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml
(original)
+++ camel/trunk/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-noconnection.xml
Sun Mar 21 13:13:05 2010
@@ -21,17 +21,18 @@
        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="jetty" class="org.apache.camel.component.jetty.JettyHttpComponent">
-    <property name="sslPassword" value="changeit"/>
-    <property name="sslKeyPassword" value="changeit"/>
-    <property name="keystore" value="src/test/resources/jsse/localhost.ks"/>
-  </bean>  
-    
-  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-    <route>
-      <from uri="jetty:https://localhost:9080/test"/>
-      <to uri="mock:a"/>
-    </route>
-  </camelContext>
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <to uri="http://localhost:9222/hi"/>
+        </route>
+
+        <route>
+            <from uri="jetty:http://localhost:9222/hi"/>
+            <transform><simple>Bye ${body}</simple></transform>
+        </route>
+        
+    </camelContext>
 
 </beans>



Mime
View raw message