Return-Path: Delivered-To: apmail-camel-commits-archive@www.apache.org Received: (qmail 89212 invoked from network); 20 Apr 2009 06:09:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Apr 2009 06:09:51 -0000 Received: (qmail 91122 invoked by uid 500); 20 Apr 2009 06:09:50 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 91094 invoked by uid 500); 20 Apr 2009 06:09:50 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 91085 invoked by uid 99); 20 Apr 2009 06:09:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2009 06:09:50 +0000 X-ASF-Spam-Status: No, hits=-1998.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2009 06:09:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A7CD323889CF; Mon, 20 Apr 2009 06:09:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r766584 - in /camel/trunk/components: camel-http/src/test/java/org/apache/camel/component/http/ camel-jetty/src/test/java/org/apache/camel/component/jetty/ Date: Mon, 20 Apr 2009 06:09:26 -0000 To: commits@camel.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090420060926.A7CD323889CF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davsclaus Date: Mon Apr 20 06:09:25 2009 New Revision: 766584 URL: http://svn.apache.org/viewvc?rev=766584&view=rev Log: Moved some of the http tests to jetty to avoid online lookup as it failis sporatic on some of the TC servers. Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpPollingGetTest.java (with props) camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java (with props) Removed: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingGetTest.java camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/MultiThreadedHttpGetTest.java Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpPollingGetTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpPollingGetTest.java?rev=766584&view=auto ============================================================================== --- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpPollingGetTest.java (added) +++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpPollingGetTest.java Mon Apr 20 06:09:25 2009 @@ -0,0 +1,75 @@ +/** + * 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.util.List; +import java.util.Map; + +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.ContextTestSupport; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; + +/** + * @version $Revision$ + */ +public class HttpPollingGetTest extends ContextTestSupport { + + protected String expectedText = " list = mockEndpoint.getReceivedExchanges(); + Exchange exchange = list.get(0); + assertNotNull("exchange", exchange); + + Message in = exchange.getIn(); + assertNotNull("in", in); + + Map headers = in.getHeaders(); + + log.debug("Headers: " + headers); + assertTrue("Should be more than one header but was: " + headers, headers.size() > 0); + + String body = in.getBody(String.class); + + log.debug("Body: " + body); + assertNotNull("Should have a body!", body); + assertTrue("body should contain: " + expectedText, body.contains(expectedText)); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + public void configure() { + from("http://localhost:5431/myservice?delay=5000").to("mock:results"); + + from("jetty:http://localhost:5431/myservice").process(new Processor() { + public void process(Exchange exchange) throws Exception { + exchange.getOut().setBody("Bye World"); + } + }); + } + }; + } + +} Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpPollingGetTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpPollingGetTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: 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=766584&view=auto ============================================================================== --- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java (added) +++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java Mon Apr 20 06:09:25 2009 @@ -0,0 +1,113 @@ +/** + * 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.InputStream; +import java.util.List; + +import org.apache.camel.ContextTestSupport; +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; + +/** + * @version $Revision$ + */ +public class MultiThreadedHttpGetTest extends ContextTestSupport { + + public void testHttpGetWithConversion() throws Exception { + + // In this scenario response stream is converted to String + // so the stream has to be read to the end. When this happens + // the associated connection is released automatically. + + String endpointName = "seda:withConversion"; + sendMessagesTo(endpointName, 5); + } + + public void testHttpGetWithoutConversion() throws Exception { + + // This is needed as by default there are 2 parallel + // 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"; + sendMessagesTo(endpointName, 5); + } + + public void testHttpGetWithExplicitStreamClose() throws Exception { + + // We close connections explicitely at the very end of the flow + // (camel doesn't know when the stream is not needed any more) + + MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class); + + for (int i = 0; i < 5; i++) { + mockEndpoint.expectedMessageCount(1); + template.sendBody("seda:withoutConversion", null); + mockEndpoint.assertIsSatisfied(); + Object response = mockEndpoint.getReceivedExchanges().get(0).getIn().getBody(); + InputStream responseStream = assertIsInstanceOf(InputStream.class, response); + responseStream.close(); + mockEndpoint.reset(); + } + } + + protected void sendMessagesTo(String endpointName, int count) throws InterruptedException { + MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class); + mockEndpoint.expectedMessageCount(count); + + for (int i = 0; i < count; i++) { + template.sendBody(endpointName, null); + } + + mockEndpoint.assertIsSatisfied(); + List list = mockEndpoint.getReceivedExchanges(); + for (Exchange exchange : list) { + String body = exchange.getIn().getBody(String.class); + + log.debug("Body: " + body); + assertNotNull("Should have a body!", body); + assertTrue("body should contain: Bye World"); + } + }); + } + }; + } + +} Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date