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 2010/02/23 10:00:49 UTC
svn commit: r915247 [3/3] - in /camel/trunk: apache-camel/
apache-camel/src/main/descriptors/
components/camel-gae/src/main/java/org/apache/camel/component/gae/http/
components/camel-gae/src/main/java/org/apache/camel/component/gae/task/
components/cam...
Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java Tue Feb 23 09:00:46 2010
@@ -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.http.handler;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.protocol.HttpContext;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class AuthenticationValidationHandler extends BasicValidationHandler {
+
+ protected String user;
+ protected String password;
+
+ public AuthenticationValidationHandler(String expectedMethod,
+ String expectedQuery, Object expectedContent,
+ String responseContent, String user, String password) {
+ super(expectedMethod, expectedQuery, expectedContent, responseContent);
+
+ this.user = user;
+ this.password = password;
+ }
+
+ public void handle(final HttpRequest request, final HttpResponse response,
+ final HttpContext context) throws HttpException, IOException {
+ if (!getExpectedCredential().equals(context.getAttribute("creds"))) {
+ response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
+ return;
+ }
+
+ super.handle(request, response, context);
+ }
+
+ private String getExpectedCredential() {
+ return user + ":" + password;
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,89 @@
+/**
+ * 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.handler;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.util.IOHelper;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.http.util.EntityUtils;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class BasicValidationHandler implements HttpRequestHandler {
+
+ protected String expectedMethod;
+ protected String expectedQuery;
+ protected Object expectedContent;
+ protected String responseContent;
+
+ public BasicValidationHandler(String expectedMethod, String expectedQuery,
+ Object expectedContent, String responseContent) {
+ this.expectedMethod = expectedMethod;
+ this.expectedQuery = expectedQuery;
+ this.expectedContent = expectedContent;
+ this.responseContent = responseContent;
+ }
+
+ public void handle(final HttpRequest request, final HttpResponse response,
+ final HttpContext context) throws HttpException, IOException {
+
+ if (expectedMethod != null && !expectedMethod.equals(request.getRequestLine().getMethod())) {
+ response.setStatusCode(HttpStatus.SC_METHOD_FAILURE);
+ return;
+ }
+
+ try {
+ String query = new URI(request.getRequestLine().getUri()).getQuery();
+ if (expectedQuery != null && !expectedQuery.equals(query)) {
+ response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
+ return;
+ }
+ } catch (URISyntaxException e) {
+ throw IOHelper.createIOException(e);
+ }
+
+ if (expectedContent != null) {
+ HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
+ String content = EntityUtils.toString(entity);
+
+ if (!expectedContent.equals(content)) {
+ response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
+ return;
+ }
+ }
+
+ response.setStatusCode(HttpStatus.SC_OK);
+ if (responseContent != null) {
+ response.setEntity(new StringEntity(responseContent, HTTP.ASCII));
+ }
+ }
+
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,50 @@
+/**
+ * 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.handler;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.protocol.HttpContext;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class DelayValidationHandler extends BasicValidationHandler {
+
+ protected int delay;
+
+ public DelayValidationHandler(String expectedMethod, String expectedQuery,
+ Object expectedContent, String responseContent, int delay) {
+ super(expectedMethod, expectedQuery, expectedContent, responseContent);
+ this.delay = delay;
+ }
+
+ public void handle(final HttpRequest request, final HttpResponse response,
+ final HttpContext context) throws HttpException, IOException {
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+
+ super.handle(request, response, context);
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,70 @@
+/**
+ * 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.handler;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.http.Header;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.protocol.HttpContext;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HeaderValidationHandler extends BasicValidationHandler {
+
+ protected Map<String, String> expectedHeaders;
+
+ public HeaderValidationHandler(String expectedMethod, String expectedQuery,
+ Object expectedContent, String responseContent,
+ Map<String, String> expectedHeaders) {
+ super(expectedMethod, expectedQuery, expectedContent, responseContent);
+ this.expectedHeaders = expectedHeaders;
+ }
+
+ public void handle(final HttpRequest request, final HttpResponse response,
+ final HttpContext context) throws HttpException, IOException {
+
+ if (expectedHeaders != null) {
+ for (Entry<String, String> entry : expectedHeaders.entrySet()) {
+ boolean haederExist = false;
+ Header[] headers = request.getHeaders(entry.getKey());
+
+ for (Header header : headers) {
+ if (header.getValue().equalsIgnoreCase(entry.getValue())) {
+ haederExist = true;
+ break;
+ }
+ }
+
+ if (!haederExist) {
+ response.setStatusCode(HttpStatus.SC_EXPECTATION_FAILED);
+ return;
+ }
+ }
+ }
+
+ super.handle(request, response, context);
+ }
+
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,59 @@
+/**
+ * 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.handler;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.protocol.HttpContext;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class ProxyAuthenticationValidationHandler extends BasicValidationHandler {
+
+ protected String user;
+ protected String password;
+
+ public ProxyAuthenticationValidationHandler(String expectedMethod,
+ String expectedQuery, Object expectedContent,
+ String responseContent, String user, String password) {
+ super(expectedMethod, expectedQuery, expectedContent, responseContent);
+ this.user = user;
+ this.password = password;
+ }
+
+ public void handle(final HttpRequest request, final HttpResponse response,
+ final HttpContext context) throws HttpException, IOException {
+
+ if (!getExpectedCredential().equals(context.getAttribute("proxy-creds"))) {
+ response.setStatusCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
+ return;
+ }
+
+ super.handle(request, response, context);
+ }
+
+ private String getExpectedCredential() {
+ return user + ":" + password;
+ }
+
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-http/src/test/resources/localhost.ks
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/resources/localhost.ks?rev=915247&view=auto
==============================================================================
Binary file - no diff available.
Propchange: camel/trunk/components/camel-http/src/test/resources/localhost.ks
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: camel/trunk/components/camel-jetty/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/pom.xml?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/pom.xml (original)
+++ camel/trunk/components/camel-jetty/pom.xml Tue Feb 23 09:00:46 2010
@@ -64,6 +64,13 @@
<artifactId>camel-spring</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${httpclient4-version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
<!-- to allow Spring annotations (jmx) to be tested -->
<dependency>
<groupId>org.springframework</groupId>
Modified: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java (original)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java Tue Feb 23 09:00:46 2010
@@ -117,7 +117,7 @@
protected JettyContentExchange createHttpExchange(Exchange exchange) throws Exception {
String url = HttpProducerHelper.createURL(exchange, getEndpoint());
HttpMethods methodToUse = HttpProducerHelper.createMethod(exchange, getEndpoint(), exchange.getIn().getBody() != null);
- String method = methodToUse.createMethod(url).getName();
+ String method = methodToUse.createMethod(url).getMethod();
JettyContentExchange httpExchange = new JettyContentExchange(exchange, getBinding(), client);
httpExchange.setMethod(method);
Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpGetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpGetTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpGetTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpGetTest.java Tue Feb 23 09:00:46 2010
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.jetty;
+import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -24,17 +25,57 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
* @version $Revision$
*/
public class HttpGetTest extends CamelTestSupport {
+
protected String expectedText = "<html";
+ protected LocalTestServer localServer;
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ localServer = new LocalTestServer(null, null);
+ localServer.register("/", new HttpRequestHandler() {
+ public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws IOException {
+ if (!"GET".equals(request.getRequestLine().getMethod())) {
+ response.setStatusCode(HttpStatus.SC_METHOD_FAILURE);
+ return;
+ }
+
+ response.setStatusCode(HttpStatus.SC_OK);
+ response.setEntity(new StringEntity(expectedText, HTTP.ISO_8859_1));
+ }
+ });
+ localServer.start();
+
+ super.setUp();
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (localServer != null) {
+ localServer.stop();
+ }
+ }
@Test
- @Ignore("ignore online tests, will be improved in Camel 2.3")
public void testHttpGet() throws Exception {
MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
mockEndpoint.expectedMessageCount(1);
@@ -66,7 +107,7 @@
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
- from("direct:start").to("http://www.google.com").to("mock:results");
+ from("direct:start").to("http://" + localServer.getServiceHostName() + ":" + localServer.getServicePort()).to("mock:results");
}
};
}
Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java Tue Feb 23 09:00:46 2010
@@ -20,9 +20,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -34,11 +34,16 @@
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.converter.stream.InputStreamCache;
import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.HTTP;
import org.junit.Test;
/**
@@ -46,7 +51,7 @@
*/
public class HttpRouteTest extends CamelTestSupport {
protected static final String POST_MESSAGE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> "
- + "<test>Hello World</test>";
+ + "<test>Hello World</test>";
protected String expectedBody = "<hello>world!</hello>";
@Test
@@ -83,60 +88,65 @@
String data = new String(os.toByteArray());
assertEquals("<b>Hello World</b>", data);
}
-
+
@Test
public void testEchoEndpoint() throws Exception {
String out = template.requestBody("http://localhost:9080/echo", "HelloWorld", String.class);
- assertEquals("Get a wrong output " , "HelloWorld", out);
+ assertEquals("Get a wrong output ", "HelloWorld", out);
}
-
+
@Test
public void testPostParameter() throws Exception {
- NameValuePair[] data = {new NameValuePair("request", "PostParameter"),
- new NameValuePair("others", "bloggs")};
- HttpClient client = new HttpClient();
- PostMethod post = new PostMethod("http://localhost:9080/parameter");
- post.setRequestBody(data);
- client.executeMethod(post);
- InputStream response = post.getResponseBodyAsStream();
+ List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+ nameValuePairs.add(new BasicNameValuePair("request", "PostParameter"));
+ nameValuePairs.add(new BasicNameValuePair("others", "bloggs"));
+ HttpClient client = new DefaultHttpClient();
+ HttpPost post = new HttpPost("http://localhost:9080/parameter");
+ UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nameValuePairs);
+ post.setEntity(entity);
+ HttpResponse httpResponse = client.execute(post);
+ InputStream response = httpResponse.getEntity().getContent();
String out = context.getTypeConverter().convertTo(String.class, response);
- assertEquals("Get a wrong output " , "PostParameter", out);
+ assertEquals("Get a wrong output ", "PostParameter", out);
}
-
+
@Test
public void testPostXMLMessage() throws Exception {
- HttpClient client = new HttpClient();
- PostMethod post = new PostMethod("http://localhost:9080/postxml");
- StringRequestEntity entity = new StringRequestEntity(POST_MESSAGE, "application/xml", "UTF-8");
- post.setRequestEntity(entity);
- client.executeMethod(post);
- InputStream response = post.getResponseBodyAsStream();
+ HttpClient client = new DefaultHttpClient();
+ HttpPost post = new HttpPost("http://localhost:9080/postxml");
+ StringEntity entity = new StringEntity(POST_MESSAGE, "UTF-8");
+ entity.setContentType("application/xml" + HTTP.CHARSET_PARAM + "UTF-8");
+ post.setEntity(entity);
+ HttpResponse httpResponse = client.execute(post);
+ InputStream response = httpResponse.getEntity().getContent();
String out = context.getTypeConverter().convertTo(String.class, response);
- assertEquals("Get a wrong output " , "OK", out);
+ assertEquals("Get a wrong output ", "OK", out);
}
-
+
@Test
public void testPostParameterInURI() throws Exception {
- HttpClient client = new HttpClient();
- PostMethod post = new PostMethod("http://localhost:9080/parameter?request=PostParameter&others=bloggs");
- StringRequestEntity entity = new StringRequestEntity(POST_MESSAGE, "application/xml", "UTF-8");
- post.setRequestEntity(entity);
- client.executeMethod(post);
- InputStream response = post.getResponseBodyAsStream();
+ HttpClient client = new DefaultHttpClient();
+ HttpPost post = new HttpPost("http://localhost:9080/parameter?request=PostParameter&others=bloggs");
+ StringEntity entity = new StringEntity(POST_MESSAGE, "UTF-8");
+ entity.setContentType("application/xml" + HTTP.CHARSET_PARAM + "UTF-8");
+ post.setEntity(entity);
+ HttpResponse httpResponse = client.execute(post);
+ InputStream response = httpResponse.getEntity().getContent();
String out = context.getTypeConverter().convertTo(String.class, response);
- assertEquals("Get a wrong output " , "PostParameter", out);
+ assertEquals("Get a wrong output ", "PostParameter", out);
}
-
+
@Test
public void testPutParameterInURI() throws Exception {
- HttpClient client = new HttpClient();
- PutMethod put = new PutMethod("http://localhost:9080/parameter?request=PutParameter&others=bloggs");
- StringRequestEntity entity = new StringRequestEntity(POST_MESSAGE, "application/xml", "UTF-8");
- put.setRequestEntity(entity);
- client.executeMethod(put);
- InputStream response = put.getResponseBodyAsStream();
+ HttpClient client = new DefaultHttpClient();
+ HttpPut put = new HttpPut("http://localhost:9080/parameter?request=PutParameter&others=bloggs");
+ StringEntity entity = new StringEntity(POST_MESSAGE, "UTF-8");
+ entity.setContentType("application/xml" + HTTP.CHARSET_PARAM + "UTF-8");
+ put.setEntity(entity);
+ HttpResponse httpResponse = client.execute(put);
+ InputStream response = httpResponse.getEntity().getContent();
String out = context.getTypeConverter().convertTo(String.class, response);
- assertEquals("Get a wrong output " , "PutParameter", out);
+ assertEquals("Get a wrong output ", "PutParameter", out);
}
protected void invokeHttpEndpoint() throws IOException {
@@ -155,7 +165,7 @@
Processor proc = new Processor() {
public void process(Exchange exchange) throws Exception {
try {
- HttpMessage message = (HttpMessage)exchange.getIn();
+ HttpMessage message = (HttpMessage) exchange.getIn();
HttpSession session = message.getRequest().getSession();
assertNotNull("we should get session here", session);
} catch (Exception e) {
@@ -165,7 +175,7 @@
exchange.getOut().setBody("<b>Hello World</b>");
}
};
-
+
Processor printProcessor = new Processor() {
public void process(Exchange exchange) throws Exception {
Message out = exchange.getOut();
@@ -174,14 +184,14 @@
log.info("Process body = " + exchange.getIn().getBody(String.class));
InputStreamCache cache = out.getBody(InputStreamCache.class);
cache.reset();
- }
+ }
};
from("jetty:http://localhost:9080/hello?sessionSupport=true").process(proc);
-
+
from("jetty:http://localhost:9080/echo").process(printProcessor).process(printProcessor);
-
+
Processor procParameters = new Processor() {
- public void process(Exchange exchange) throws Exception {
+ public void process(Exchange exchange) throws Exception {
HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
String value = req.getParameter("request");
String requestValue = exchange.getIn().getHeader("request", String.class);
@@ -193,19 +203,19 @@
}
}
};
-
+
from("jetty:http://localhost:9080/parameter").process(procParameters);
-
+
from("jetty:http://localhost:9080/postxml").process(new Processor() {
public void process(Exchange exchange) throws Exception {
- String value = exchange.getIn().getBody(String.class);
+ String value = exchange.getIn().getBody(String.class);
assertEquals("The response message is wrong", value, POST_MESSAGE);
exchange.getOut().setBody("OK");
}
-
+
});
-
+
}
};
}
Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java Tue Feb 23 09:00:46 2010
@@ -20,6 +20,7 @@
import org.apache.camel.component.http.HttpEndpoint;
import org.apache.camel.component.http.HttpProducer;
import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.http.params.CoreConnectionPNames;
import org.junit.Test;
/**
@@ -32,8 +33,8 @@
// assert jetty was configured with our timeout
HttpEndpoint jettyEndpoint = context.getEndpoint("http://localhost:8080/myapp/myservice?httpClient.soTimeout=5555", HttpEndpoint.class);
assertNotNull("Jetty endpoint should not be null ", jettyEndpoint);
- HttpProducer producer = (HttpProducer)jettyEndpoint.createProducer();
- assertEquals("Get the wrong http client parameter", 5555, producer.getHttpClient().getParams().getSoTimeout());
+ HttpProducer producer = (HttpProducer) jettyEndpoint.createProducer();
+ assertEquals("Get the wrong http client parameter", 5555, producer.getHttpClient().getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
// send and receive
Object out = template.requestBody("http://localhost:9080/myapp/myservice", "Hello World");
Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java Tue Feb 23 09:00:46 2010
@@ -22,7 +22,6 @@
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpComponent;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
@@ -50,9 +49,6 @@
// connections to some host and there is nothing that
// closes the http connection here.
- context.getComponent("http", HttpComponent.class).getHttpConnectionManager().getParams()
- .setDefaultMaxConnectionsPerHost(5);
-
String endpointName = "seda:withoutConversion?concurrentConsumers=5";
sendMessagesTo(endpointName, 5);
}
@@ -100,10 +96,10 @@
return new RouteBuilder() {
public void configure() {
from("seda:withConversion?concurrentConsumers=5").to("http://localhost:5430/search")
- .convertBodyTo(String.class).to("mock:results");
+ .convertBodyTo(String.class).to("mock:results");
from("seda:withoutConversion?concurrentConsumers=5").to("http://localhost:5430/search")
- .to("mock:results");
+ .to("mock:results");
from("jetty:http://localhost:5430/search").process(new Processor() {
public void process(Exchange exchange) throws Exception {
Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java Tue Feb 23 09:00:46 2010
@@ -22,13 +22,11 @@
import java.util.Map;
import java.util.Properties;
-import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.Service;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.After;
import org.junit.Before;
@@ -36,16 +34,16 @@
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-public class SpringHttpsRouteTest extends CamelTestSupport {
+public class SpringHttpsRouteTest extends CamelSpringTestSupport {
private static final String NULL_VALUE_MARKER = CamelTestSupport.class.getCanonicalName();
protected String expectedBody = "<hello>world!</hello>";
protected String pwd = "changeit";
protected Properties originalValues = new Properties();
-
+
@Override
@Before
public void setUp() throws Exception {
- super.setUp();
+ super.setUp();
// ensure jsse clients can validate the self signed dummy localhost cert,
// use the server keystore as the trust store for these tests
URL trustStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
@@ -57,9 +55,6 @@
public void tearDown() throws Exception {
restoreSystemProperties();
super.tearDown();
- JettyHttpComponent component = context.getComponent("jetty", JettyHttpComponent.class);
- context.stop();
- component.stop();
}
private void setSystemProp(String key, String value) {
@@ -69,11 +64,11 @@
private void restoreSystemProperties() {
for (Object key : originalValues.keySet()) {
- Object value = (String) originalValues.get(key);
+ Object value = (String) originalValues.get(key);
if (NULL_VALUE_MARKER.equals(value)) {
- System.getProperties().remove(key);
+ System.getProperties().remove(key);
} else {
- System.setProperty((String)key, (String)value);
+ System.setProperty((String) key, (String) value);
}
}
}
@@ -99,10 +94,10 @@
assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
}
-
+
@Test
public void testEndpointWithoutHttps() {
- MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:a", MockEndpoint.class);
+ MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:a", MockEndpoint.class);
try {
template.sendBodyAndHeader("http://localhost:9080/test", expectedBody, "Content-Type", "application/xml");
fail("expect exception on access to https endpoint via http");
@@ -111,28 +106,12 @@
assertTrue("mock endpoint was not called", mockEndpoint.getExchanges().isEmpty());
}
-
-
protected void invokeHttpEndpoint() throws IOException {
template.sendBodyAndHeader("https://localhost:9080/test", expectedBody, "Content-Type", "application/xml");
}
- protected CamelContext createCamelContext() throws Exception {
- setUseRouteBuilder(false);
-
- final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/component/jetty/jetty-https.xml");
- setCamelContextService(new Service() {
- public void start() throws Exception {
- applicationContext.start();
-
- }
-
- public void stop() throws Exception {
- applicationContext.stop();
- }
- });
-
- return SpringCamelContext.springCamelContext(applicationContext);
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/component/jetty/jetty-https.xml");
}
-}
-
+}
\ No newline at end of file
Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTest.java (added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,101 @@
+/**
+ * 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.jettyproducer;
+
+import java.io.IOException;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class JettyHttpProducerAsyncTest extends CamelTestSupport {
+
+ protected LocalTestServer localServer;
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ localServer = new LocalTestServer(null, null);
+ localServer.register("/", new HttpRequestHandler() {
+ public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws IOException {
+ if (!"GET".equals(request.getRequestLine().getMethod())) {
+ response.setStatusCode(HttpStatus.SC_METHOD_FAILURE);
+ return;
+ }
+
+ response.setStatusCode(HttpStatus.SC_OK);
+ response.setEntity(new StringEntity("google", HTTP.ISO_8859_1));
+ }
+ });
+ localServer.start();
+
+ super.setUp();
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (localServer != null) {
+ localServer.stop();
+ }
+ }
+
+ @Test
+ public void testGoogleFrontPageAsync() throws Exception {
+ // these tests does not run well on Windows
+ if (isPlatform("windows")) {
+ return;
+ }
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.message(0).body(String.class).contains("google");
+
+ template.sendBody("direct:start", null);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ // to prevent redirect being thrown as an exception
+ .toAsync("jetty://http://" + localServer.getServiceHostName() + ":" + localServer.getServicePort() + "?throwExceptionOnFailure=false")
+ .to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerTest.java (added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,93 @@
+/**
+ * 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.jettyproducer;
+
+import java.io.IOException;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class JettyHttpProducerTest extends CamelTestSupport {
+
+ protected LocalTestServer localServer;
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ localServer = new LocalTestServer(null, null);
+ localServer.register("/", new HttpRequestHandler() {
+ public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws IOException {
+ if (!"GET".equals(request.getRequestLine().getMethod())) {
+ response.setStatusCode(HttpStatus.SC_METHOD_FAILURE);
+ return;
+ }
+
+ response.setStatusCode(HttpStatus.SC_OK);
+ response.setEntity(new StringEntity("google", HTTP.ISO_8859_1));
+ }
+ });
+ localServer.start();
+
+ super.setUp();
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (localServer != null) {
+ localServer.stop();
+ }
+ }
+
+ @Test
+ public void testGoogleFrontPage() throws Exception {
+ // these tests does not run well on Windows
+ if (isPlatform("windows")) {
+ return;
+ }
+
+ String reply = template.requestBody("direct:start", null, String.class);
+ assertNotNull(reply);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // to prevent redirect being thrown as an exception
+ from("direct:start").to("jetty://http://" + localServer.getServiceHostName() + ":" + localServer.getServicePort() + "?throwExceptionOnFailure=false");
+ }
+ };
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java (original)
+++ camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java Tue Feb 23 09:00:46 2010
@@ -25,12 +25,11 @@
import org.apache.camel.component.http.HttpComponent;
import org.apache.camel.component.http.HttpConsumer;
import org.apache.camel.util.CastUtils;
-import org.apache.camel.util.IntrospectionSupport;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.URISupport;
import org.apache.camel.util.UnsafeUriCharactersEncoder;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.params.HttpParams;
public class ServletComponent extends HttpComponent {
@@ -58,8 +57,7 @@
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
uri = uri.startsWith("servlet:") ? remaining : uri;
- HttpClientParams params = new HttpClientParams();
- IntrospectionSupport.setProperties(params, parameters, "httpClient.");
+ HttpParams clientParams = configureHttpParams(parameters);
// configure regular parameters
configureParameters(parameters);
@@ -69,7 +67,7 @@
CastUtils.cast(parameters));
uri = httpUri.toString();
- ServletEndpoint result = createServletEndpoint(uri, this, httpUri, params, getHttpConnectionManager(), httpClientConfigurer);
+ ServletEndpoint result = createServletEndpoint(uri, this, httpUri, clientParams, getHttpConnectionManager(), httpClientConfigurer);
if (httpBinding != null) {
result.setBinding(httpBinding);
}
@@ -79,8 +77,8 @@
}
protected ServletEndpoint createServletEndpoint(String endpointUri,
- ServletComponent component, URI httpUri, HttpClientParams params,
- HttpConnectionManager httpConnectionManager,
+ ServletComponent component, URI httpUri, HttpParams params,
+ ClientConnectionManager httpConnectionManager,
HttpClientConfigurer clientConfigurer) throws Exception {
return new ServletEndpoint(endpointUri, component, httpUri, params,
httpConnectionManager, clientConfigurer);
Modified: camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java (original)
+++ camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java Tue Feb 23 09:00:46 2010
@@ -25,8 +25,8 @@
import org.apache.camel.component.http.HttpClientConfigurer;
import org.apache.camel.component.http.HttpConsumer;
import org.apache.camel.component.http.HttpEndpoint;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.params.HttpParams;
public class ServletEndpoint extends HttpEndpoint {
private String servletName;
@@ -35,8 +35,8 @@
super();
}
- public ServletEndpoint(String endPointURI, ServletComponent component, URI httpUri, HttpClientParams params
- , HttpConnectionManager httpConnectionManager, HttpClientConfigurer clientConfigurer) throws URISyntaxException {
+ public ServletEndpoint(String endPointURI, ServletComponent component, URI httpUri, HttpParams params
+ , ClientConnectionManager httpConnectionManager, HttpClientConfigurer clientConfigurer) throws URISyntaxException {
super(endPointURI, component, httpUri, params, httpConnectionManager, clientConfigurer);
}
Modified: camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java (original)
+++ camel/trunk/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java Tue Feb 23 09:00:46 2010
@@ -100,14 +100,11 @@
assertEquals("<request> hello world </request>", s);
}
}).transform(constant("Bye World"));
- }
-
-
+ }
}
protected RouteBuilder createRouteBuilder() throws Exception {
return new MyServletRoute();
}
-
}
Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Tue Feb 23 09:00:46 2010
@@ -70,7 +70,8 @@
<hibernate-entitymanager-version>3.2.1.ga</hibernate-entitymanager-version>
<hsqldb-version>1.8.0.7</hsqldb-version>
<httpunit-version>1.6.2</httpunit-version>
- <httpcore-version>4.0</httpcore-version>
+ <httpcore4-version>4.0.1</httpcore4-version>
+ <httpclient4-version>4.0.1</httpclient4-version>
<httpclient-version>3.1</httpclient-version>
<javamail-version>1.4.1</javamail-version>
<javax-mail-version>1.4.1_2</javax-mail-version>
@@ -92,7 +93,7 @@
<pax-tiny-bundle-version>1.2.0</pax-tiny-bundle-version>
<qpid-version>0.5.0</qpid-version>
<quartz-version>1.6.6</quartz-version>
- <restlet-version>1.1.5</restlet-version>
+ <restlet-version>1.1.8</restlet-version>
<saxon-version>9.1.0.8</saxon-version>
<scala-version>2.7.7</scala-version>
<scala-plugin-version>2.9.1</scala-plugin-version>
@@ -942,14 +943,21 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
- <version>${httpcore-version}</version>
+ <version>${httpcore4-version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId>
- <version>${httpcore-version}</version>
+ <version>${httpcore4-version}</version>
</dependency>
+ <!-- optional old http client -->
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+
<!-- optional scripting support -->
<dependency>
<groupId>org.livetribe</groupId>