CAMEL-8672: RestletComponent should look for "restlet" properties
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d86123a5 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d86123a5 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d86123a5 Branch: refs/heads/camel-2.15.x Commit: d86123a5d72d30a29f2b1418f9fbce5097266cde Parents: f495c3f Author: Anton Koscejev <anton.kosce...@zoomint.com> Authored: Mon Apr 20 08:43:23 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Apr 20 08:51:59 2015 +0200 ---------------------------------------------------------------------- .../component/restlet/RestletComponent.java | 2 +- .../RestRestletComponentConfigurationTest.java | 65 ++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d86123a5/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java index 350d9a1..aef1c24 100644 --- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java +++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java @@ -143,7 +143,7 @@ public class RestletComponent extends HeaderFilterStrategyComponent implements R // configure component options RestConfiguration config = getCamelContext().getRestConfiguration(); - if (config != null && (config.getComponent() == null || config.getComponent().equals("restle"))) { + if (config != null && (config.getComponent() == null || config.getComponent().equals("restlet"))) { // configure additional options on spark configuration if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) { setProperties(this, config.getComponentProperties()); http://git-wip-us.apache.org/repos/asf/camel/blob/d86123a5/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletComponentConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletComponentConfigurationTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletComponentConfigurationTest.java new file mode 100644 index 0000000..08dcf98 --- /dev/null +++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletComponentConfigurationTest.java @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.restlet; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.rest.RestBindingMode; +import org.junit.Test; + +/** + * @version + */ +public class RestRestletComponentConfigurationTest extends RestletTestSupport { + + @Test + public void testRestletPojoInOut() throws Exception { + String body = "{\"id\": 123, \"name\": \"Donald Duck\"}"; + String out = template.requestBody("http://localhost:" + portNum + "/users/lives", body, String.class); + + assertNotNull(out); + assertEquals("{\"iso\":\"EN\",\"country\":\"England\"}", out); + + // verify rest configuration was propagated to restlet component + RestletComponent component = context.getComponent("restlet", RestletComponent.class); + assertEquals(false, component.getControllerDaemon()); + assertEquals((Integer) 3, component.getMaxThreads()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + // configure to use restlet on localhost with the given port + // and enable auto binding mode + restConfiguration() + .component("restlet") + .host("localhost").port(portNum) + .bindingMode(RestBindingMode.auto) + .componentProperty("controllerDaemon", "false") + .componentProperty("maxThreads", "3"); + + // use the rest DSL to define the rest services + rest("/users/") + .post("lives").type(UserPojo.class).outType(CountryPojo.class) + .route() + .bean(new UserService(), "livesWhere"); + } + }; + } + +}