You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/06/25 11:45:18 UTC

git commit: Fix for CAMEL-7533 Expose the component options for Camel HTTP

Repository: camel
Updated Branches:
  refs/heads/master 0f25b1679 -> 8100a976b


Fix for CAMEL-7533 Expose the component options for Camel HTTP


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8100a976
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8100a976
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8100a976

Branch: refs/heads/master
Commit: 8100a976bad2753c1e2b94ad9b8c676db448706b
Parents: 0f25b16
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Wed Jun 25 11:38:05 2014 +0200
Committer: Kevin Earls <ke...@kevinearls.com>
Committed: Wed Jun 25 11:38:05 2014 +0200

----------------------------------------------------------------------
 .../camel/component/http/HttpEndpoint.java      | 14 +++++
 ...ponentConfigurationAndDocumentationTest.java | 56 ++++++++++++++++++++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8100a976/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
index 29cfd17..4fcef55 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
@@ -27,6 +27,8 @@ import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultPollingEndpoint;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpConnectionManager;
@@ -40,6 +42,7 @@ import org.slf4j.LoggerFactory;
  *
  * @version 
  */
+@UriEndpoint(scheme = "http", consumerClass = HttpConsumer.class)
 public class HttpEndpoint extends DefaultPollingEndpoint implements HeaderFilterStrategyAware {
 
     private static final Logger LOG = LoggerFactory.getLogger(HttpEndpoint.class);
@@ -51,17 +54,28 @@ public class HttpEndpoint extends DefaultPollingEndpoint implements HeaderFilter
     private HttpClientConfigurer httpClientConfigurer;
     private HttpConnectionManager httpConnectionManager;
     private boolean throwExceptionOnFailure = true;
+    @UriParam
     private boolean bridgeEndpoint;
+    @UriParam
     private boolean matchOnUriPrefix;
+    @UriParam
     private boolean chunked = true;
+    @UriParam
     private boolean disableStreamCache;
+    @UriParam
     private String proxyHost;
+    @UriParam
     private int proxyPort;
+    @UriParam
     private String authMethodPriority;
+    @UriParam
     private boolean transferException;
+    @UriParam
     private boolean traceEnabled;
+    @UriParam
     private String httpMethodRestrict;
     private UrlRewrite urlRewrite;
+    @UriParam
     private Integer responseBufferSize;
 
     public HttpEndpoint() {

http://git-wip-us.apache.org/repos/asf/camel/blob/8100a976/components/camel-http/src/test/java/org/apache/camel/component/http/HttpComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpComponentConfigurationAndDocumentationTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..5ec5e70
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpComponentConfigurationAndDocumentationTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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.http;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HttpComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testComponentConfiguration() throws Exception {
+        HttpComponent comp = context.getComponent("http", HttpComponent.class);
+        EndpointConfiguration conf = comp.createConfiguration("http://www.google.com?proxyHost=myotherproxy&proxyPort=2345");
+
+        assertEquals("myotherproxy", conf.getParameter("proxyHost"));
+        assertEquals("2345", conf.getParameter("proxyPort"));
+
+        ComponentConfiguration compConf = comp.createComponentConfiguration();
+        String json = compConf.createParameterJsonSchema();
+        assertNotNull(json);
+
+        assertTrue(json.contains("\"httpMethodRestrict\": { \"type\": \"java.lang.String\" }"));
+        assertTrue(json.contains("\"matchOnUriPrefix\": { \"type\": \"boolean\" }"));
+    }
+
+    @Test
+    public void testComponentDocumentation() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        String html = context.getComponentDocumentation("http");
+        assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+    }
+
+}