You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/04/05 17:00:56 UTC

camel git commit: Added Tests to camel-jetty9 for big form POST method

Repository: camel
Updated Branches:
  refs/heads/master 08aea81cc -> ea3a17488


Added Tests to camel-jetty9 for big form POST method


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

Branch: refs/heads/master
Commit: ea3a17488504c390e5b15f62dc9a85bb65098903
Parents: 08aea81
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Apr 5 16:38:51 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Apr 5 16:57:25 2016 +0200

----------------------------------------------------------------------
 components/camel-jetty9/pom.xml                 |   6 +
 .../jetty/HttpBridgeBigFormPostRouteTest.java   | 126 +++++++++++++++++++
 2 files changed, 132 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ea3a1748/components/camel-jetty9/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/pom.xml b/components/camel-jetty9/pom.xml
index e5f5c30..0423731 100644
--- a/components/camel-jetty9/pom.xml
+++ b/components/camel-jetty9/pom.xml
@@ -138,6 +138,12 @@
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.5.2</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/camel/blob/ea3a1748/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeBigFormPostRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeBigFormPostRouteTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeBigFormPostRouteTest.java
new file mode 100644
index 0000000..9d4221d
--- /dev/null
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeBigFormPostRouteTest.java
@@ -0,0 +1,126 @@
+/**
+ * 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.jetty;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.http.Consts;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.junit.Test;
+
+public class HttpBridgeBigFormPostRouteTest extends BaseJettyTest {
+
+    private static final String LARGE_HEADER_VALUE = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. "
+            + "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley "
+            + "of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap "
+            + "into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of "
+            + "Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus "
+            + "PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting "
+            + "industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer "
+            + "took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, "
+            + "but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s "
+            + "with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing "
+            + "software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing "
+            + "and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an "
+            + "unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five "
+            + "centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the "
+            + "1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing "
+            + "software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and "
+            + "typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown "
+            + "printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, "
+            + "but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the "
+            + "release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus "
+            + "PageMaker including versions of Lorem Ipsum." + "Lorem Ipsum is simply dummy text of the printing and typesetting industry. "
+            + "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley "
+            + "of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap "
+            + "into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of "
+            + "Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus "
+            + "PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting "
+            + "industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer "
+            + "took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, "
+            + "but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s "
+            + "with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing "
+            + "software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing "
+            + "and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an "
+            + "unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five "
+            + "centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the "
+            + "1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing "
+            + "software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and "
+            + "typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown "
+            + "printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, "
+            + "but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the "
+            + "release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus "
+            + "PageMaker including versions of Lorem Ipsum.";
+
+    private int port1;
+    private int port2;
+
+    @Test
+    public void testHttpClient() throws Exception {
+        
+        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+        nvps.add(new BasicNameValuePair("param1", LARGE_HEADER_VALUE));
+        nvps.add(new BasicNameValuePair("param2", LARGE_HEADER_VALUE));
+        nvps.add(new BasicNameValuePair("param3", LARGE_HEADER_VALUE));
+
+        HttpEntity entity = new UrlEncodedFormEntity(nvps, Consts.UTF_8);
+        HttpPost httpPost = new HttpPost("http://localhost:" + port2 + "/test/hello");
+        httpPost.setEntity(entity);
+
+        HttpHost proxy = new HttpHost("localhost", 8888, "http");
+        RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
+        httpPost.setConfig(config);
+
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        try {
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            assertEquals(response.getStatusLine().getStatusCode(), 200);
+            response.close();
+        } catch (IOException e) {
+        } finally {
+            httpClient.close();
+        }
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                port1 = getPort();
+                port2 = getNextPort();
+
+                errorHandler(noErrorHandler());
+
+                from("jetty:http://localhost:" + port2 + "/test/hello?matchOnUriPrefix=true")
+                    .removeHeaders("formMetaData")
+                    .to("http://localhost:" + port1 + "?bridgeEndpoint=true");
+            }
+        };
+    }  
+
+}