You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by wt...@apache.org on 2009/01/01 21:21:15 UTC
svn commit: r730599 - in /activemq/camel/trunk/components/camel-restlet/src:
main/java/org/apache/camel/component/restlet/
test/java/org/apache/camel/component/restlet/
test/java/org/apache/camel/component/restlet/route/
test/resources/org/apache/camel...
Author: wtam
Date: Thu Jan 1 12:21:15 2009
New Revision: 730599
URL: http://svn.apache.org/viewvc?rev=730599&view=rev
Log:
[CAMEL-1203] Restlet component update with snippet tags
Modified:
activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConstants.java
activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderAuthTest.java
activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java
activemq/camel/trunk/components/camel-restlet/src/test/resources/org/apache/camel/component/restlet/camel-context.xml
Modified: activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java?rev=730599&r1=730598&r2=730599&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java (original)
+++ activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java Thu Jan 1 12:21:15 2009
@@ -175,7 +175,7 @@
}
}
- private String buildKey(RestletEndpoint endpoint) {
+ private static String buildKey(RestletEndpoint endpoint) {
return endpoint.getHost() + ":" + endpoint.getPort();
}
Modified: activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConstants.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConstants.java?rev=730599&r1=730598&r2=730599&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConstants.java (original)
+++ activemq/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConstants.java Thu Jan 1 12:21:15 2009
@@ -23,8 +23,8 @@
*/
public final class RestletConstants {
- public static final String LOGIN = "camel.restlet.auth.login";
- public static final String PASSWORD = "camel.restlet.auth.password";
+ public static final String LOGIN = "org.apache.camel.restlet.auth.login";
+ public static final String PASSWORD = "org.apache.camel.restlet.auth.password";
private RestletConstants() {
}
Modified: activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderAuthTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderAuthTest.java?rev=730599&r1=730598&r2=730599&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderAuthTest.java (original)
+++ activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderAuthTest.java Thu Jan 1 12:21:15 2009
@@ -17,6 +17,8 @@
package org.apache.camel.component.restlet;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.camel.spring.SpringTestSupport;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -24,15 +26,30 @@
public class RestletRouteBuilderAuthTest extends SpringTestSupport {
public void testBasicAuth() throws IOException {
- String response = (String) template.requestBody("direct:start-auth",
- "<order foo='1'/>");
- assertEquals("received [<order foo='1'/>] as an order id = " + 89531,
+
+ // START SNIPPET: auth_request
+ final String id = "89531";
+
+ Map<String, Object> headers = new HashMap<String, Object>();
+ headers.put(RestletConstants.LOGIN, "admin");
+ headers.put(RestletConstants.PASSWORD, "foo");
+ headers.put("id", id);
+
+ String response = (String) template.requestBodyAndHeaders("direct:start-auth",
+ "<order foo='1'/>", headers);
+ // END SNIPPET: auth_request
+
+ assertEquals("received [<order foo='1'/>] as an order id = " + id,
response);
}
public void testhBasicAuthError() throws IOException {
- String response = (String) template.requestBody("direct:start-bad-auth",
- "<order foo='1'/>");
+ Map<String, Object> headers = new HashMap<String, Object>();
+ headers.put(RestletConstants.LOGIN, "admin");
+ headers.put(RestletConstants.PASSWORD, "bad");
+ headers.put("id", "xyz");
+ String response = (String) template.requestBodyAndHeaders("direct:start-auth",
+ "<order foo='1'/>", headers);
assertTrue(response.contains("requires user authentication"));
}
Modified: activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java?rev=730599&r1=730598&r2=730599&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java (original)
+++ activemq/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java Thu Jan 1 12:21:15 2009
@@ -19,7 +19,6 @@
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.restlet.RestletConstants;
/**
* Route builder for RestletRouteBuilderAuthTest
@@ -27,25 +26,11 @@
* @version $Revision$
*/
public class TestRouteBuilder extends RouteBuilder {
- private static final String ID = "89531";
@Override
public void configure() throws Exception {
- // Note: restletMethod and restletRealmRef are stripped
- // from the query before a request is sent as they are
- // only processed by Camel.
-
- from("direct:start-auth").setHeader("id", constant(ID))
- .setHeader(RestletConstants.LOGIN, constant("admin"))
- .setHeader(RestletConstants.PASSWORD, constant("foo"))
- .to("restlet:http://localhost:8080/securedOrders?restletMethod=post");
-
- from("direct:start-bad-auth").setHeader("id", constant(ID))
- .setHeader(RestletConstants.LOGIN, constant("admizzzn"))
- .setHeader(RestletConstants.PASSWORD, constant("fozzzo"))
- .to("restlet:http://localhost:8080/securedOrders?restletMethod=post");
-
+ // START SNIPPET: consumer_route
from("restlet:http://localhost:8080/securedOrders?restletMethod=post&restletRealmRef=realm").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody(
@@ -54,6 +39,15 @@
+ exchange.getIn().getHeader("id"));
}
});
+ // END SNIPPET: consumer_route
+
+ // START SNIPPET: producer_route
+ // Note: restletMethod and restletRealmRef are stripped
+ // from the query before a request is sent as they are
+ // only processed by Camel.
+ from("direct:start-auth").to("restlet:http://localhost:8080/securedOrders?restletMethod=post");
+ // END SNIPPET: producer_route
+
}
}
Modified: activemq/camel/trunk/components/camel-restlet/src/test/resources/org/apache/camel/component/restlet/camel-context.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-restlet/src/test/resources/org/apache/camel/component/restlet/camel-context.xml?rev=730599&r1=730598&r2=730599&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-restlet/src/test/resources/org/apache/camel/component/restlet/camel-context.xml (original)
+++ activemq/camel/trunk/components/camel-restlet/src/test/resources/org/apache/camel/component/restlet/camel-context.xml Thu Jan 1 12:21:15 2009
@@ -12,7 +12,7 @@
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" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
@@ -28,8 +28,12 @@
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
<package>org.apache.camel.component.restlet.route</package>
</camelContext>
+
+ <!-- START SNIPPET: realm -->
<util:map id="realm">
<entry key="admin" value="foo" />
<entry key="bar" value="foo" />
</util:map>
+ <!-- END SNIPPET: realm -->
+
</beans>
\ No newline at end of file