camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1165157 - in /camel/trunk/components/camel-servlet/src: main/java/org/apache/camel/component/servlet/ServletEndpoint.java test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
Date Mon, 05 Sep 2011 03:45:18 GMT
Author: ningjiang
Date: Mon Sep  5 03:45:18 2011
New Revision: 1165157

URL: http://svn.apache.org/viewvc?rev=1165157&view=rev
Log:
CAMEL-4412 ServletEndpoint doesn't support to create the producer

Modified:
    camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
    camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java

Modified: camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java?rev=1165157&r1=1165156&r2=1165157&view=diff
==============================================================================
--- camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
(original)
+++ camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
Mon Sep  5 03:45:18 2011
@@ -21,6 +21,7 @@ import java.net.URISyntaxException;
 
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
+import org.apache.camel.Producer;
 import org.apache.camel.component.http.HttpClientConfigurer;
 import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.http.HttpEndpoint;
@@ -49,6 +50,11 @@ public class ServletEndpoint extends Htt
     }
 
     @Override
+    public Producer createProducer() throws Exception {
+        throw new UnsupportedOperationException("You cannot create producer with servlet
endpoint, please consider to use http or http4 endpoint.");
+    }
+
+    @Override
     public Consumer createConsumer(Processor processor) throws Exception {
         return new HttpConsumer(this, processor);
     }

Modified: camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java?rev=1165157&r1=1165156&r2=1165157&view=diff
==============================================================================
--- camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
(original)
+++ camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
Mon Sep  5 03:45:18 2011
@@ -25,6 +25,7 @@ import com.meterware.httpunit.WebRequest
 import com.meterware.httpunit.WebResponse;
 import com.meterware.servletunit.ServletUnitClient;
 import org.apache.camel.Exchange;
+import org.apache.camel.FailedToCreateProducerException;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;
@@ -63,6 +64,26 @@ public class HttpClientRouteTest extends
         assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
         assertEquals("The response body is wrong", "Bye World", response.getText());
     }
+
+    @Test
+    public void testCreateSerlvetEndpointProducer() throws Exception {
+        if (!startCamelContext) {
+            // don't test it with web.xml configure
+            return;
+        }
+        try {
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("direct:start").to("servlet:///testworld");
+                }
+            });
+            fail("Excepts exception here");
+        } catch (Exception ex) {
+            assertTrue("Get a wrong exception." , ex instanceof FailedToCreateProducerException);
+            assertTrue("Get a wrong cause of exception.", ex.getCause() instanceof UnsupportedOperationException);
+        }
+    }
     
     public static class MyServletRoute extends RouteBuilder {
 



Mime
View raw message