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 2009/02/10 09:30:25 UTC

svn commit: r742887 - in /camel/trunk/tests/camel-itest/src/test: java/org/apache/camel/itest/http/ resources/org/apache/camel/itest/http/

Author: davsclaus
Date: Tue Feb 10 08:30:24 2009
New Revision: 742887

URL: http://svn.apache.org/viewvc?rev=742887&view=rev
Log:
Sample how to set max connection per host with the http component

Added:
    camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/
    camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest.java   (with props)
    camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/
    camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest-context.xml   (with props)

Added: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest.java?rev=742887&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest.java (added)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest.java Tue Feb 10 08:30:24 2009
@@ -0,0 +1,31 @@
+package org.apache.camel.itest.http;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+
+@ContextConfiguration
+public class HttpMaxConnectionPerHostTest extends AbstractJUnit38SpringContextTests {
+
+    @Autowired
+    protected CamelContext camelContext;
+
+    @EndpointInject(uri = "direct:start")
+    protected ProducerTemplate producer;
+
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint mock;
+
+    public void testMocksIsValid() throws Exception {
+        mock.expectedMessageCount(1);
+
+        producer.sendBody(null);
+
+        mock.assertIsSatisfied();
+    }
+
+}

Propchange: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest-context.xml?rev=742887&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest-context.xml (added)
+++ camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest-context.xml Tue Feb 10 08:30:24 2009
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: e1 -->
+    <bean id="http" class="org.apache.camel.component.http.HttpComponent">
+        <property name="camelContext" ref="camel"/>
+        <property name="httpConnectionManager" ref="myHttpConnectionManager"/>
+    </bean>
+
+    <bean id="myHttpConnectionManager" class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager">
+        <property name="maxConnectionsPerHost" value="5"/>
+    </bean>
+    <!-- END SNIPPET: e1 -->
+
+    <!-- START SNIPPET: e2 -->
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" trace="true">
+        <route>
+            <from uri="direct:start"/>
+            <to uri="http://www.google.com"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+    <!-- END SNIPPET: e2 -->
+
+</beans>

Propchange: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest-context.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/http/HttpMaxConnectionPerHostTest-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml