camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1164343 - in /camel/trunk/components/camel-restlet: pom.xml src/main/java/org/apache/camel/component/restlet/RestletProducer.java src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
Date Fri, 02 Sep 2011 03:47:23 GMT
Author: ningjiang
Date: Fri Sep  2 03:47:22 2011
New Revision: 1164343

URL: http://svn.apache.org/viewvc?rev=1164343&view=rev
Log:
CAMEL-4325 Fixed the issue of wrong exception uri when an HTTP error code is returned

Modified:
    camel/trunk/components/camel-restlet/pom.xml
    camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
    camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java

Modified: camel/trunk/components/camel-restlet/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/pom.xml?rev=1164343&r1=1164342&r2=1164343&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/pom.xml (original)
+++ camel/trunk/components/camel-restlet/pom.xml Fri Sep  2 03:47:22 2011
@@ -72,6 +72,12 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jetty</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpclient</artifactId>
       <version>${httpclient4-version}</version>

Modified: camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java?rev=1164343&r1=1164342&r2=1164343&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
(original)
+++ camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
Fri Sep  2 03:47:22 2011
@@ -168,7 +168,7 @@ public class RestletProducer extends Def
 
     protected RestletOperationException populateRestletProducerException(Exchange exchange,
Response response, int responseCode) {
         RestletOperationException exception;
-        String uri = exchange.getFromEndpoint().getEndpointUri();
+        String uri = response.getRequest().getResourceRef().toString();
         String statusText = response.getStatus().getDescription();
         Map<String, String> headers = parseResponseHeaders(response, exchange);
         String copy;

Modified: camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java?rev=1164343&r1=1164342&r2=1164343&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
(original)
+++ camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
Fri Sep  2 03:47:22 2011
@@ -42,6 +42,7 @@ public class RestletExceptionResponseTes
                         exchange.setException(new IllegalArgumentException("Damn something
went wrong"));
                     }
                 });
+                from("direct:start").to("restlet:http://localhost:" + portNum + "/users/tester?restletMethod=POST");
             }
         };
     }
@@ -58,8 +59,17 @@ public class RestletExceptionResponseTes
 
     @Test
     public void testRestletProducerGetExceptionResponse() throws Exception {
+        sendRequest("restlet:http://localhost:" + portNum + "/users/tester?restletMethod=POST");
+    }
+
+    @Test
+    public void testSendRequestDirectEndpoint() throws Exception {
+        sendRequest("direct:start");
+    }
+
+    protected void sendRequest(String endpointUri) throws Exception {
         Exchange exchange = template.request(
-            "restlet:http://localhost:" + portNum + "/users/tester?restletMethod=POST",
+            endpointUri,
                 new Processor() {
                     @Override
                     public void process(Exchange exchange) throws Exception {
@@ -68,7 +78,9 @@ public class RestletExceptionResponseTes
             });
         RestletOperationException exception = (RestletOperationException) exchange.getException();
         String body = exception.getResponseBody();
+        assertEquals("http://localhost:" + portNum + "/users/tester", exception.getUri());
         assertTrue(body.contains("IllegalArgumentException"));
         assertTrue(body.contains("Damn something went wrong"));
     }
+
 }
\ No newline at end of file



Mime
View raw message