camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r826648 - in /camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet: RestletExceptionResponseTest.java RestletFaultTest.java
Date Mon, 19 Oct 2009 11:56:43 GMT
Author: davsclaus
Date: Mon Oct 19 11:56:43 2009
New Revision: 826648

URL: http://svn.apache.org/viewvc?rev=826648&view=rev
Log:
MR-199: Added more unit tests.

Added:
    camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
  (contents, props changed)
      - copied, changed from r826643, camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java
Modified:
    camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java

Copied: camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
(from r826643, camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java?p2=camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java&p1=camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java&r1=826643&r2=826648&rev=826648&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java
(original)
+++ camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
Mon Oct 19 11:56:43 2009
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 package org.apache.camel.component.restlet;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
@@ -28,7 +29,7 @@
  *
  * @version $Revision$
  */
-public class RestletFaultTest extends CamelTestSupport {
+public class RestletExceptionResponseTest extends CamelTestSupport {
 
     @Override
     protected RouteBuilder createRouteBuilder() {
@@ -38,26 +39,25 @@
             public void configure() throws Exception {
                 from("restlet:http://localhost:9080/users/{username}?restletMethod=POST").process(new
Processor() {
                     public void process(Exchange exchange) throws Exception {
-                        exchange.getOut().setFault(true);
-                        exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, "404");
-                        exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "text/plain");
-                        exchange.getOut().setBody("Application fault");
-                    }        
+                        exchange.setException(new IllegalArgumentException("Damn something
went wrong"));
+                    }
                 });
             }
         };
     }
-    
+
     @Test
-    public void testFaultResponse() throws Exception {
+    public void testExceptionResponse() throws Exception {
         HttpMethod method = new PostMethod("http://localhost:9080/users/homer");
         try {
             HttpClient client = new HttpClient();
-            assertEquals(404, client.executeMethod(method));
-            assertTrue(method.getResponseHeader("Content-Type").getValue()
-                    .startsWith("text/plain"));
+            assertEquals(500, client.executeMethod(method));
+            assertTrue(method.getResponseHeader("Content-Type").getValue().startsWith("text/plain"));
+            String body = method.getResponseBodyAsString();
+            assertTrue(body.contains("IllegalArgumentException"));
+            assertTrue(body.contains("Damn something went wrong"));
         } finally {
             method.releaseConnection();
         }
     }
-}
+}
\ No newline at end of file

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

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

Modified: camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java?rev=826648&r1=826647&r2=826648&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java
(original)
+++ camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletFaultTest.java
Mon Oct 19 11:56:43 2009
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 package org.apache.camel.component.restlet;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;



Mime
View raw message