camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r761607 - in /camel/trunk/components/camel-restlet/src: main/java/org/apache/camel/component/restlet/RestletProducer.java test/java/org/apache/camel/component/restlet/RestletResponseTest.java
Date Fri, 03 Apr 2009 10:52:52 GMT
Author: ningjiang
Date: Fri Apr  3 10:52:52 2009
New Revision: 761607

URL: http://svn.apache.org/viewvc?rev=761607&view=rev
Log:
CAMEL-1516 set the context to the Restlet client in RestletProducer

Modified:
    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/RestletResponseTest.java

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=761607&r1=761606&r2=761607&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 Apr  3 10:52:52 2009
@@ -21,6 +21,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.restlet.Client;
+import org.restlet.Context;
 import org.restlet.data.Request;
 import org.restlet.data.Response;
 
@@ -36,6 +37,7 @@
     public RestletProducer(RestletEndpoint endpoint) throws Exception {
         super(endpoint);
         client = new Client(endpoint.getProtocol());
+        client.setContext(new Context());
     }
 
     @Override

Modified: camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java?rev=761607&r1=761606&r2=761607&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java
(original)
+++ camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java
Fri Apr  3 10:52:52 2009
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.restlet;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -38,6 +41,9 @@
             public void configure() throws Exception {
                 from("restlet:http://localhost:9080/users/{username}?restletMethod=POST").process(new
Processor() {
                     public void process(Exchange exchange) throws Exception {
+                        String userName = exchange.getIn().getHeader("username", String.class);
                       
+                        assertNotNull("userName should not be null", userName);
+                        exchange.getOut().setBody("{" + userName + "}");
                         exchange.getOut().setHeader(RestletConstants.RESTLET_RESPONSE_CODE,
"417");
                         exchange.getOut().setHeader(RestletConstants.RESTLET_MEDIA_TYPE,
"application/JSON");
                     }        
@@ -56,6 +62,12 @@
         } finally {
             method.releaseConnection();
         }
-
+    }
+    
+    public void testRestletProducer() throws Exception {
+        Map<String, Object> headers = new HashMap<String, Object>();        
+        headers.put("username", "homer");
+        String response = (String)template.requestBodyAndHeaders("restlet:http://localhost:9080/users/{username}?restletMethod=POST",
"<request>message</request>", headers);
+        assertEquals("The response is wrong ", response, "{homer}");
     }
 }



Mime
View raw message