Repository: camel Updated Branches: refs/heads/master cee33bce0 -> 9d661ab4b
Fix for CAMEL=7566 Expose the component options for Camel Servlet Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9d661ab4 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9d661ab4 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9d661ab4 Branch: refs/heads/master Commit: 9d661ab4b9097855ea4c9ac9bd1301808bb9a1fe Parents: cee33bc Author: Kevin Earls <ke...@kevinearls.com> Authored: Wed Jul 2 14:50:40 2014 +0200 Committer: Kevin Earls <ke...@kevinearls.com> Committed: Wed Jul 2 14:50:40 2014 +0200 ---------------------------------------------------------------------- .../component/servlet/ServletComponent.java | 4 ++ .../component/servlet/ServletEndpoint.java | 4 ++ ...ponentConfigurationAndDocumentationTest.java | 58 ++++++++++++++++++++ 3 files changed, 66 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9d661ab4/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java index 87699c1..15aec3e 100644 --- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java +++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java @@ -39,6 +39,10 @@ public class ServletComponent extends HttpComponent { private String servletName = "CamelServlet"; private HttpRegistry httpRegistry; + public ServletComponent() { + super(ServletEndpoint.class); + } + @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { HttpClientParams params = new HttpClientParams(); http://git-wip-us.apache.org/repos/asf/camel/blob/9d661ab4/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java index 1dfa120..84af20d 100644 --- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java +++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java @@ -24,11 +24,15 @@ import org.apache.camel.Processor; import org.apache.camel.Producer; import org.apache.camel.component.http.HttpClientConfigurer; import org.apache.camel.component.http.HttpEndpoint; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; import org.apache.commons.httpclient.HttpConnectionManager; import org.apache.commons.httpclient.params.HttpClientParams; +@UriEndpoint(scheme = "servlet", consumerClass = ServletConsumer.class) public class ServletEndpoint extends HttpEndpoint { + @UriParam private String servletName; public ServletEndpoint() { http://git-wip-us.apache.org/repos/asf/camel/blob/9d661ab4/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletComponentConfigurationAndDocumentationTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletComponentConfigurationAndDocumentationTest.java new file mode 100644 index 0000000..ebc2ab5 --- /dev/null +++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletComponentConfigurationAndDocumentationTest.java @@ -0,0 +1,58 @@ +/** + * 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.servlet; + +import org.apache.camel.CamelContext; +import org.apache.camel.ComponentConfiguration; +import org.apache.camel.EndpointConfiguration; +import org.apache.camel.component.http.HttpComponent; +import org.apache.camel.impl.DefaultCamelContext; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class ServletComponentConfigurationAndDocumentationTest extends CamelTestSupport { + + @Override + public boolean isUseRouteBuilder() { + return false; + } + + @Test + public void testComponentConfiguration() throws Exception { + ServletComponent comp = context.getComponent("servlet", ServletComponent.class); + EndpointConfiguration conf = comp.createConfiguration("servlet://foo?servletName=MyServlet&proxyHost=myotherproxy&proxyPort=2345"); + + assertEquals("myotherproxy", conf.getParameter("proxyHost")); + assertEquals("2345", conf.getParameter("proxyPort")); + assertEquals("MyServlet", conf.getParameter("servletName")); + + ComponentConfiguration compConf = comp.createComponentConfiguration(); + String json = compConf.createParameterJsonSchema(); + assertNotNull(json); + + assertTrue(json.contains("\"servletName\": { \"type\": \"java.lang.String\" }")); + assertTrue(json.contains("\"matchOnUriPrefix\": { \"type\": \"boolean\" }")); + } + + @Test + public void testComponentDocumentation() throws Exception { + CamelContext context = new DefaultCamelContext(); + String html = context.getComponentDocumentation("servlet"); + assertNotNull("Should have found some auto-generated HTML if on Java 7", html); + } + +}