Repository: camel Updated Branches: refs/heads/camel-2.17.x 914850846 -> 1e756e227
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/1e756e22 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1e756e22 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1e756e22 Branch: refs/heads/camel-2.17.x Commit: 1e756e227199aa654d692941eac86d44c5ccac22 Parents: 9148508 Author: Andrea Cosentino <anco...@gmail.com> Authored: Tue Apr 5 16:38:51 2016 +0200 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Tue Apr 5 17:03:44 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/1e756e22/components/camel-jetty9/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-jetty9/pom.xml b/components/camel-jetty9/pom.xml index 3870dc6..9a5e517 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>${httpclient4-version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> http://git-wip-us.apache.org/repos/asf/camel/blob/1e756e22/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"); + } + }; + } + +}