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 [2/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/HttpBodyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.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.http;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.camel.component.http.handler.HeaderValidationHandler;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpBodyTest extends BaseHttpTest {
+
+    // default content encoding of the local test server
+    private String charset = "ISO-8859-1";
+
+    @Test
+    public void httpPostWithStringBody() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                // without this property, camel use the os default encoding
+                // to create the byte array for the StringRequestEntity
+                exchange.setProperty(Exchange.CHARSET_NAME, charset);
+                exchange.getIn().setBody(getBody());
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpPostWithByteArrayBody() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody(getBody().getBytes(charset));
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpPostWithInputStreamBody() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody(new ByteArrayInputStream(getBody().getBytes(charset)));
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpPostWithImage() throws Exception {
+        Map<String, String> expectedHeaders = new HashMap<String, String>();
+        expectedHeaders.put("Content-Type", "image/jpeg");
+        localServer.register("/", new HeaderValidationHandler("POST", null, null, getExpectedContent(), expectedHeaders));
+
+        Exchange exchange = template.send("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody(new File("src/test/data/logo.jpeg"));
+                exchange.getIn().setHeader("Content-Type", "image/jpeg");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        server.register("/", new BasicValidationHandler("POST", null, getBody(), getExpectedContent()));
+    }
+
+    protected String getBody() {
+        return "hl=de&q=camel+rocks";
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,57 @@
+/**
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpBridgeEndpointTest extends BaseHttpTest {
+
+    @Test
+    public void notBridgeEndpoint() throws Exception {
+        Exchange exchange = template.request("http://host/?bridgeEndpoint=false", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_URI, "http://" + getHostName() + ":" + getPort() + "/");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void bridgeEndpoint() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/?bridgeEndpoint=true", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_URI, "http://host:8080/");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        server.register("/", new BasicValidationHandler("GET", null, null, getExpectedContent()));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,62 @@
+/**
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.HeaderValidationHandler;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpCamelHeadersTest extends BaseHttpTest {
+
+    @Test
+    public void httpHeadersShouldPresent() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader("TestHeader", "test");
+                exchange.getIn().setHeader("Accept-Language", "pl");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Override
+    protected void assertHeaders(Map<String, Object> headers) {
+        super.assertHeaders(headers);
+
+        assertEquals("test", headers.get("TestHeader"));
+        assertEquals("pl", headers.get("Accept-Language"));
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        Map<String, String> expectedHeaders = new HashMap<String, String>();
+        expectedHeaders.put("TestHeader", "test");
+        expectedHeaders.put("Accept-Language", "pl");
+
+        server.register("/", new HeaderValidationHandler("GET", null, null, getExpectedContent(), expectedHeaders));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.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;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpCharsetTest extends BaseHttpTest {
+
+    // default content encoding of the local test server
+    private String charset = "ISO-8859-1";
+
+    @Test
+    public void sendCharsetInExchangeProperty() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.setProperty(Exchange.CHARSET_NAME, charset);
+                exchange.getIn().setBody(getBody());
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void sendByteArrayCharsetInExchangeProperty() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.setProperty(Exchange.CHARSET_NAME, charset);
+                exchange.getIn().setBody(getBody().getBytes(charset));
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void sendInputStreamCharsetInExchangeProperty() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.setProperty(Exchange.CHARSET_NAME, charset);
+                exchange.getIn().setBody(new ByteArrayInputStream(getBody().getBytes(charset)));
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        server.register("/", new BasicValidationHandler("POST", null, getBody(), getExpectedContent()));
+    }
+
+    protected String getBody() {
+        char lattinSmallLetterAWithDiaeresis = 0x00E4;
+        char lattinSmallLetterOWithDiaeresis = 0x00F6;
+        char lattinSmallLetterUWithDiaeresis = 0x00FC;
+        char lattinSmallLetterSharpS = 0x00DF;
+
+        return "hl=de&q=camel+"
+                + lattinSmallLetterAWithDiaeresis
+                + lattinSmallLetterOWithDiaeresis
+                + lattinSmallLetterUWithDiaeresis
+                + lattinSmallLetterSharpS;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,166 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.HeaderValidationHandler;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.HttpStatus;
+import org.apache.http.entity.HttpEntityWrapper;
+import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
+import org.junit.Test;
+
+/**
+ * 
+ * @version $Revision$
+ */
+public class HttpCompressionTest extends BaseHttpTest {
+
+    @Test
+    public void compressedHttpPost() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain");
+                exchange.getIn().setHeader(Exchange.CONTENT_ENCODING, "gzip");
+                exchange.getIn().setBody(getBody());
+            }
+        });
+
+        assertNotNull(exchange);
+
+        Message out = exchange.getOut();
+        assertNotNull(out);
+
+        Map<String, Object> headers = out.getHeaders();
+        assertEquals(HttpStatus.SC_OK, headers.get(Exchange.HTTP_RESPONSE_CODE));
+        assertEquals("gzip", headers.get("Content-Encoding"));
+
+        assertBody(out.getBody(String.class));
+    }
+
+    @Override
+    protected BasicHttpProcessor getBasicHttpProcessor() {
+        BasicHttpProcessor httpproc = new BasicHttpProcessor();
+        httpproc.addInterceptor(new RequestDecompressingInterceptor());
+
+        httpproc.addInterceptor(new ResponseCompressingInterceptor());
+
+        return httpproc;
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        Map<String, String> expectedHeaders = new HashMap<String, String>();
+        expectedHeaders.put("Content-Type", "text/plain");
+        expectedHeaders.put("Content-Encoding", "gzip");
+
+        server.register("/", new HeaderValidationHandler("POST", null, getBody(), getExpectedContent(), expectedHeaders));
+    }
+
+    protected String getBody() {
+        return "hl=en&q=camel";
+    }
+
+    static class RequestDecompressingInterceptor implements HttpRequestInterceptor {
+
+        public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
+            Header contentEncoding = request.getFirstHeader("Content-Encoding");
+
+            if (contentEncoding != null
+                    && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
+                HttpEntity entity = ((HttpEntityEnclosingRequest) request)
+                        .getEntity();
+                ((HttpEntityEnclosingRequest) request)
+                        .setEntity(new GzipDecompressingEntity(entity));
+            }
+        }
+
+        static class GzipDecompressingEntity extends HttpEntityWrapper {
+
+            public GzipDecompressingEntity(final HttpEntity entity) {
+                super(entity);
+            }
+
+            @Override
+            public InputStream getContent() throws IOException,
+                    IllegalStateException {
+                InputStream wrappedin = wrappedEntity.getContent();
+                return new GZIPInputStream(wrappedin);
+            }
+
+            @Override
+            public long getContentLength() {
+                return -1;
+            }
+        }
+    }
+
+    static class ResponseCompressingInterceptor implements HttpResponseInterceptor {
+
+        public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
+            response.setHeader("Content-Encoding", "gzip");
+            HttpEntity entity = response.getEntity();
+            response.setEntity(new GzipCompressingEntity(entity));
+        }
+
+        static class GzipCompressingEntity extends HttpEntityWrapper {
+
+            public GzipCompressingEntity(final HttpEntity entity) {
+                super(entity);
+            }
+
+            @Override
+            public Header getContentEncoding() {
+                return new BasicHeader("Content-Encoding", "gzip");
+            }
+
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                GZIPOutputStream gzip = new GZIPOutputStream(outstream);
+                gzip.write(EntityUtils.toByteArray(wrappedEntity));
+                gzip.close();
+            }
+
+            @Override
+            public long getContentLength() {
+                return -1;
+            }
+        }
+    }
+    
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java (original)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java Tue Feb 23 09:00:46 2010
@@ -28,10 +28,13 @@
 
 /**
  * Unit test of invalid configuration
+ *
+ * @version $Revision$
  */
 public class HttpInvalidConfigurationTest extends CamelTestSupport {
 
     @Before
+    @Override
     public void setUp() throws Exception {
         try {
             super.setUp();
@@ -47,6 +50,7 @@
         // dummy
     }
 
+    @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
@@ -54,5 +58,4 @@
             }
         };
     }
-
-}
+}
\ No newline at end of file

Modified: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java (original)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java Tue Feb 23 09:00:46 2010
@@ -28,10 +28,13 @@
 
 /**
  * Unit test of invalid configuration
+ *
+ * @version $Revision$
  */
 public class HttpInvalidHttpClientConfigurationTest extends CamelTestSupport {
 
     @Before
+    @Override
     public void setUp() throws Exception {
         try {
             super.setUp();
@@ -47,6 +50,7 @@
         // dummy
     }
 
+    @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
@@ -54,5 +58,4 @@
             }
         };
     }
-
 }
\ No newline at end of file

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,138 @@
+/**
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpMethodsTest extends BaseHttpTest {
+
+    @Test
+    public void httpGet() throws Exception {
+        localServer.register("/", new BasicValidationHandler("GET", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpPost() throws Exception {
+        localServer.register("/", new BasicValidationHandler("POST", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpPostWithBody() throws Exception {
+        localServer.register("/", new BasicValidationHandler("POST", null, "rocks camel?", getExpectedContent()));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("rocks camel?");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpPut() throws Exception {
+        localServer.register("/", new BasicValidationHandler("PUT", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_METHOD, "PUT");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpTrace() throws Exception {
+        localServer.register("/", new BasicValidationHandler("TRACE", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_METHOD, "TRACE");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpOptions() throws Exception {
+        localServer.register("/", new BasicValidationHandler("OPTIONS", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_METHOD, "OPTIONS");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpDelete() throws Exception {
+        localServer.register("/", new BasicValidationHandler("DELETE", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_METHOD, "DELETE");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpHead() throws Exception {
+        localServer.register("/", new BasicValidationHandler("HEAD", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_METHOD, "HEAD");
+            }
+        });
+
+        assertNotNull(exchange);
+
+        Message out = exchange.getOut();
+        assertNotNull(out);
+        assertHeaders(out.getHeaders());
+        assertNull(out.getBody(String.class));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,56 @@
+/**
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpPathTest extends BaseHttpTest {
+
+    @Test
+    public void httpPath() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/search", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpPathHeader() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_PATH, "search");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        server.register("/search", new BasicValidationHandler("GET", null, null, getExpectedContent()));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.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;
+
+import java.net.SocketTimeoutException;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.http.handler.DelayValidationHandler;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpPollingConsumerTest extends BaseHttpTest {
+
+    @Test
+    public void testReceive() throws Exception {
+        String body = consumer.receiveBody("http://" + getHostName() + ":" + getPort() + "/", String.class);
+        assertEquals(getExpectedContent(), body);
+    }
+
+    @Test
+    public void testReceiveTimeout() throws Exception {
+        String body = consumer.receiveBody("http://" + getHostName() + ":" + getPort() + "/", 5000, String.class);
+        assertEquals(getExpectedContent(), body);
+    }
+
+    @Test
+    public void testReceiveTimeoutTriggered() throws Exception {
+        try {
+            consumer.receiveBody("http://" + getHostName() + ":" + getPort() + "/", 250, String.class);
+            fail("Should have thrown an exception");
+        } catch (RuntimeCamelException e) {
+            assertIsInstanceOf(SocketTimeoutException.class, e.getCause());
+        }
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        server.register("/", new DelayValidationHandler("GET", null, null, getExpectedContent(), 1000));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java (original)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java Tue Feb 23 09:00:46 2010
@@ -16,11 +16,8 @@
  */
 package org.apache.camel.component.http;
 
-import java.io.IOException;
-
 import org.apache.camel.Exchange;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.commons.httpclient.HttpMethod;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
 import org.junit.Test;
 
 import static org.apache.camel.component.http.HttpMethods.GET;
@@ -28,156 +25,127 @@
 
 /**
  * Unit test to verify the algorithm for selecting either GET or POST.
+ *
+ * @version $Revision$
  */
-public class HttpProducerSelectMethodTest extends CamelTestSupport {
+public class HttpProducerSelectMethodTest extends BaseHttpTest {
 
     @Test
-    public void testNoDataDefaultIsGet() throws Exception {
+    public void noDataDefaultIsGet() throws Exception {
+        localServer.register("/", new BasicValidationHandler("GET", null, null, getExpectedContent()));
+
         HttpComponent component = new HttpComponent();
         component.setCamelContext(context);
-        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://www.google.com");
-        MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET", null);
-
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://" + getHostName() + ":" + getPort());
+        HttpProducer producer = new HttpProducer(endpoiont);
         Exchange exchange = producer.createExchange();
         exchange.getIn().setBody(null);
-        try {
-            producer.process(exchange);
-            fail("Should have thrown HttpOperationFailedException");
-        } catch (HttpOperationFailedException e) {
-            assertEquals(500, e.getStatusCode());
-        }
+        producer.start();
+        producer.process(exchange);
         producer.stop();
+
+        assertExchange(exchange);
     }
 
     @Test
-    public void testDataDefaultIsPost() throws Exception {
+    public void dataDefaultIsPost() throws Exception {
+        localServer.register("/", new BasicValidationHandler("POST", null, null, getExpectedContent()));
+
         HttpComponent component = new HttpComponent();
         component.setCamelContext(context);
-        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://www.google.com");
-        MyHttpProducer producer = new MyHttpProducer(endpoiont, "POST", null);
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://" + getHostName() + ":" + getPort());
+        HttpProducer producer = new HttpProducer(endpoiont);
 
         Exchange exchange = producer.createExchange();
         exchange.getIn().setBody("This is some data to post");
-        try {
-            producer.process(exchange);
-            fail("Should have thrown HttpOperationFailedException");
-        } catch (HttpOperationFailedException e) {
-            assertEquals(500, e.getStatusCode());
-        }
+        producer.start();
+        producer.process(exchange);
         producer.stop();
+
+        assertExchange(exchange);
     }
 
     @Test
-    public void testWithMethodPostInHeader() throws Exception {
+    public void withMethodPostInHeader() throws Exception {
+        localServer.register("/", new BasicValidationHandler("POST", null, null, getExpectedContent()));
+
         HttpComponent component = new HttpComponent();
         component.setCamelContext(context);
-        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://www.google.com");
-        MyHttpProducer producer = new MyHttpProducer(endpoiont, "POST", null);
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://" + getHostName() + ":" + getPort());
+        HttpProducer producer = new HttpProducer(endpoiont);
 
         Exchange exchange = producer.createExchange();
         exchange.getIn().setBody("");
         exchange.getIn().setHeader(Exchange.HTTP_METHOD, POST);
-        try {
-            producer.process(exchange);
-            fail("Should have thrown HttpOperationFailedException");
-        } catch (HttpOperationFailedException e) {
-            assertEquals(500, e.getStatusCode());
-        }
+        producer.start();
+        producer.process(exchange);
         producer.stop();
     }
 
     @Test
-    public void testWithMethodGetInHeader() throws Exception {
+    public void withMethodGetInHeader() throws Exception {
+        localServer.register("/", new BasicValidationHandler("GET", null, null, getExpectedContent()));
+
         HttpComponent component = new HttpComponent();
         component.setCamelContext(context);
-        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://www.google.com");
-        MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET", null);
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://" + getHostName() + ":" + getPort());
+        HttpProducer producer = new HttpProducer(endpoiont);
 
         Exchange exchange = producer.createExchange();
         exchange.getIn().setBody("");
         exchange.getIn().setHeader(Exchange.HTTP_METHOD, GET);
-        try {
-            producer.process(exchange);
-            fail("Should have thrown HttpOperationFailedException");
-        } catch (HttpOperationFailedException e) {
-            assertEquals(500, e.getStatusCode());
-        }
+        producer.start();
+        producer.process(exchange);
         producer.stop();
     }
 
     @Test
-    public void testWithEndpointQuery() throws Exception {
+    public void withEndpointQuery() throws Exception {
+        localServer.register("/", new BasicValidationHandler("GET", "q=Camel", null, getExpectedContent()));
+
         HttpComponent component = new HttpComponent();
         component.setCamelContext(context);
-        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://www.google.com?q=Camel");
-        MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET", "q=Camel");
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://" + getHostName() + ":" + getPort() + "?q=Camel");
+        HttpProducer producer = new HttpProducer(endpoiont);
 
         Exchange exchange = producer.createExchange();
         exchange.getIn().setBody("");
-        try {
-            producer.process(exchange);
-            fail("Should have thrown HttpOperationFailedException");
-        } catch (HttpOperationFailedException e) {
-            assertEquals(500, e.getStatusCode());
-        }
+        producer.start();
+        producer.process(exchange);
         producer.stop();
     }
 
     @Test
-    public void testWithQueryInHeader() throws Exception {
+    public void withQueryInHeader() throws Exception {
+        localServer.register("/", new BasicValidationHandler("GET", "q=Camel", null, getExpectedContent()));
+
         HttpComponent component = new HttpComponent();
         component.setCamelContext(context);
-        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://www.google.com");
-        MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET", "q=Camel");
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://" + getHostName() + ":" + getPort());
+        HttpProducer producer = new HttpProducer(endpoiont);
 
         Exchange exchange = producer.createExchange();
         exchange.getIn().setBody("");
         exchange.getIn().setHeader(Exchange.HTTP_QUERY, "q=Camel");
-        try {
-            producer.process(exchange);
-            fail("Should have thrown HttpOperationFailedException");
-        } catch (HttpOperationFailedException e) {
-            assertEquals(500, e.getStatusCode());
-        }
+        producer.start();
+        producer.process(exchange);
         producer.stop();
     }
 
     @Test
-    public void testWithQueryInHeaderOverrideEndpoint() throws Exception {
+    public void withQueryInHeaderOverrideEndpoint() throws Exception {
+        localServer.register("/", new BasicValidationHandler("GET", "q=Camel", null, getExpectedContent()));
+
         HttpComponent component = new HttpComponent();
         component.setCamelContext(context);
-        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://www.google.com?q=Donkey");
-        MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET", "q=Camel");
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http://" + getHostName() + ":" + getPort() + "?q=Donkey");
+        HttpProducer producer = new HttpProducer(endpoiont);
 
         Exchange exchange = producer.createExchange();
         exchange.getIn().setBody("");
         exchange.getIn().setHeader(Exchange.HTTP_QUERY, "q=Camel");
-        try {
-            producer.process(exchange);
-            fail("Should have thrown HttpOperationFailedException");
-        } catch (HttpOperationFailedException e) {
-            assertEquals(500, e.getStatusCode());
-        }
+        producer.start();
+        producer.process(exchange);
         producer.stop();
     }
-
-    private static class MyHttpProducer extends HttpProducer {
-        private String name;
-        private String queryString;
-
-        public MyHttpProducer(HttpEndpoint endpoint, String name, String queryString) {
-            super(endpoint);
-            this.name = name;
-            this.queryString = queryString;
-        }
-
-        @Override
-        protected int executeMethod(HttpMethod method) throws IOException {
-            // do the assertion what to expected either GET or POST
-            assertEquals(name, method.getName());
-            assertEquals(queryString, method.getQueryString());
-            // return 500 to not extract response as we dont have any
-            return 500;
-        }
-    }
-}
+}
\ No newline at end of file

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,207 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.HeaderValidationHandler;
+import org.apache.camel.component.http.handler.ProxyAuthenticationValidationHandler;
+import org.apache.commons.codec.BinaryDecoder;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.http.Header;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.HttpStatus;
+import org.apache.http.ProtocolException;
+import org.apache.http.auth.AUTH;
+import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.ResponseContent;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpProxyServerTest extends BaseHttpTest {
+
+    private LocalTestServer proxy;
+    private String user = "camel";
+    private String password = "password";
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+
+        BasicHttpProcessor httpproc = new BasicHttpProcessor();
+        httpproc.addInterceptor(new RequestProxyBasicAuth());
+        httpproc.addInterceptor(new ResponseContent());
+        httpproc.addInterceptor(new ResponseProxyBasicUnauthorized());
+
+        proxy = new LocalTestServer(httpproc, null);
+        proxy.start();
+    }
+
+    @Override
+    @After
+    public void tearDown() throws Exception {
+        if (proxy != null) {
+            proxy.stop();
+        }
+
+        super.tearDown();
+    }
+
+    @Test
+    public void httpGetWithProxyAndWithoutUser() throws Exception {
+        Map<String, String> expectedHeaders = new HashMap<String, String>();
+        expectedHeaders.put("Host", getHostName() + ":" + getPort());
+        expectedHeaders.put("Proxy-Connection", "Keep-Alive");
+        proxy.register("*", new HeaderValidationHandler("GET", null, null, getExpectedContent(), expectedHeaders));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "?proxyHost=" + getProxyHost() + "&proxyPort=" + getProxyPort(), new Processor() {
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpGetWithProxyInCamelContextAndWithoutUser() throws Exception {
+        context.getProperties().put("http.proxyHost", getProxyHost());
+        context.getProperties().put("http.proxyPort", String.valueOf(getProxyPort()));
+
+        Map<String, String> expectedHeaders = new HashMap<String, String>();
+        expectedHeaders.put("Host", getHostName() + ":" + getPort());
+        expectedHeaders.put("Proxy-Connection", "Keep-Alive");
+
+        try {
+            proxy.register("*", new HeaderValidationHandler("GET", null, null, getExpectedContent(), expectedHeaders));
+
+            Exchange exchange = template.request("http://" + getHostName() + ":" + getPort(), new Processor() {
+                public void process(Exchange exchange) throws Exception {
+                }
+            });
+
+            assertExchange(exchange);
+        } finally {
+            context.getProperties().remove("http.proxyHost");
+            context.getProperties().remove("http.proxyPort");
+        }
+    }
+
+    @Test
+    public void httpGetWithDuplicateProxyConfigurationAndWithoutUser() throws Exception {
+        context.getProperties().put("http.proxyHost", "XXX");
+        context.getProperties().put("http.proxyPort", "11111");
+
+        Map<String, String> expectedHeaders = new HashMap<String, String>();
+        expectedHeaders.put("Host", getHostName() + ":" + getPort());
+        expectedHeaders.put("Proxy-Connection", "Keep-Alive");
+
+        try {
+            proxy.register("*", new HeaderValidationHandler("GET", null, null, getExpectedContent(), expectedHeaders));
+
+            Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "?proxyHost="
+                    + getProxyHost() + "&proxyPort=" + getProxyPort(), new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                        }
+                    });
+
+            assertExchange(exchange);
+        } finally {
+            context.getProperties().remove("http.proxyHost");
+            context.getProperties().remove("http.proxyPort");
+        }
+    }
+
+    @Test
+    public void httpGetWithProxyAndWithUser() throws Exception {
+        proxy.register("*", new ProxyAuthenticationValidationHandler("GET", null, null, getExpectedContent(), user, password));
+
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "?proxyHost="
+                + getProxyHost() + "&proxyPort=" + getProxyPort() + "&proxyUsername=camel&proxyPassword=password", new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                    }
+                });
+
+        assertExchange(exchange);
+    }
+
+    private String getProxyHost() {
+        return proxy.getServiceHostName();
+    }
+
+    private int getProxyPort() {
+        return proxy.getServicePort();
+    }
+
+    class RequestProxyBasicAuth implements HttpRequestInterceptor {
+        public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
+            String auth = null;
+
+            Header h = request.getFirstHeader(AUTH.PROXY_AUTH_RESP);
+            if (h != null) {
+                String s = h.getValue();
+                if (s != null) {
+                    auth = s.trim();
+                }
+            }
+
+            if (auth != null) {
+                int i = auth.indexOf(' ');
+                if (i == -1) {
+                    throw new ProtocolException("Invalid Authorization header: " + auth);
+                }
+                String authscheme = auth.substring(0, i);
+                if (authscheme.equalsIgnoreCase("basic")) {
+                    String s = auth.substring(i + 1).trim();
+                    byte[] credsRaw = s.getBytes(HTTP.ASCII);
+                    BinaryDecoder codec = new Base64();
+                    try {
+                        String creds = new String(codec.decode(credsRaw), HTTP.ASCII);
+                        context.setAttribute("proxy-creds", creds);
+                    } catch (DecoderException ex) {
+                        throw new ProtocolException("Malformed BASIC credentials");
+                    }
+                }
+            }
+        }
+    }
+
+    class ResponseProxyBasicUnauthorized implements HttpResponseInterceptor {
+        public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
+            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
+                response.addHeader(AUTH.PROXY_AUTH, "Basic realm=\"test realm\"");
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,57 @@
+/**
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpQueryTest extends BaseHttpTest {
+
+    @Test
+    public void httpQuery() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/?hl=en&q=camel", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpQueryHeader() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_QUERY, "hl=en&q=camel");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        server.register("/", new BasicValidationHandler("GET", "hl=en&q=camel", null, getExpectedContent()));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java (original)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java Tue Feb 23 09:00:46 2010
@@ -19,32 +19,34 @@
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.commons.httpclient.HttpClient;
+import org.apache.http.client.HttpClient;
 import org.junit.Test;
 
 /**
  * Unit test for resolving reference parameters.
+ *
+ * @version $Revision: $
  */
 public class HttpReferenceParameterTest extends CamelTestSupport {
 
-    private static final String TEST_URI_1 = "http://localhost:8080?httpBindingRef=#customBinding&httpClientConfigurerRef=#customConfigurer"; 
-    private static final String TEST_URI_2 = "http://localhost:8081?httpBindingRef=customBinding&httpClientConfigurerRef=customConfigurer"; 
-    
+    private static final String TEST_URI_1 = "http://localhost:8080?httpBindingRef=#customBinding&httpClientConfigurerRef=#customConfigurer";
+    private static final String TEST_URI_2 = "http://localhost:8081?httpBindingRef=customBinding&httpClientConfigurerRef=customConfigurer";
+
     private HttpEndpoint endpoint1;
     private HttpEndpoint endpoint2;
-    
+
     private TestHttpBinding testBinding;
     private TestClientConfigurer testConfigurer;
-    
+
     @Override
     public void setUp() throws Exception {
         this.testBinding = new TestHttpBinding();
         this.testConfigurer = new TestClientConfigurer();
         super.setUp();
-        this.endpoint1 = (HttpEndpoint)context.getEndpoint(TEST_URI_1);
-        this.endpoint2 = (HttpEndpoint)context.getEndpoint(TEST_URI_2);
+        this.endpoint1 = (HttpEndpoint) context.getEndpoint(TEST_URI_1);
+        this.endpoint2 = (HttpEndpoint) context.getEndpoint(TEST_URI_2);
     }
-    
+
     @Test
     public void testHttpBindingRef() {
         assertSame(testBinding, endpoint1.getBinding());
@@ -64,7 +66,7 @@
         registry.bind("customConfigurer", testConfigurer);
         return registry;
     }
-    
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -77,12 +79,10 @@
 
     private static class TestHttpBinding extends DefaultHttpBinding {
     }
-    
+
     private static class TestClientConfigurer implements HttpClientConfigurer {
 
         public void configureHttpClient(HttpClient client) {
         }
-
     }
-    
-}
+}
\ No newline at end of file

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.http.handler.DelayValidationHandler;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpSOTimeoutTest extends BaseHttpTest {
+
+    @Test
+    public void httpGet() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "?httpClient.soTimeout=5000", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Test
+    public void httpGetShouldThrowASocketTimeoutException() throws Exception {
+        try {
+            template.request("http://" + getHostName() + ":" + getPort() + "?httpClient.soTimeout=1000", new Processor() {
+                public void process(Exchange exchange) throws Exception {
+                }
+            });
+            fail("Should throw a RuntimeCamelException");
+        } catch (RuntimeCamelException e) {
+            // expected
+        }
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        server.register("/", new DelayValidationHandler("GET", null, null, getExpectedContent(), 2000));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,130 @@
+/**
+ * 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;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * Abstract base class for unit testing using a http server.
+ * The setUp method starts the server before the camel context is started and
+ * the tearDown method stops the server after the camel context is stopped.
+ *
+ * @version $Revision$
+ */
+public abstract class HttpServerTestSupport extends CamelTestSupport {
+
+    protected LocalTestServer localServer;
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        localServer = new LocalTestServer(
+                getBasicHttpProcessor(),
+                getConnectionReuseStrategy(),
+                getHttpParams(),
+                getSSLContext());
+        registerHandler(localServer);
+        localServer.start();
+
+        super.setUp();
+    }
+
+    @After
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+
+        if (localServer != null) {
+            localServer.stop();
+        }
+    }
+
+    /**
+     * Returns the org.apache.http.protocol.BasicHttpProcessor which should be
+     * used by the server.
+     *
+     * @return basicHttpProcessor
+     */
+    protected BasicHttpProcessor getBasicHttpProcessor() {
+        return null;
+    }
+
+    /**
+     * Returns the org.apache.http.ConnectionReuseStrategy which should be used
+     * by the server.
+     *
+     * @return connectionReuseStrategy
+     */
+    protected ConnectionReuseStrategy getConnectionReuseStrategy() {
+        return null;
+    }
+
+    /**
+     * Returns the org.apache.http.params.HttpParams which should be used by
+     * the server.
+     *
+     * @return httpParams
+     */
+    protected HttpParams getHttpParams() {
+        return null;
+    }
+
+    /**
+     * Returns the javax.net.ssl.SSLContext which should be used by the server.
+     *
+     * @return sslContext
+     * @throws Exception
+     */
+    protected SSLContext getSSLContext() throws Exception {
+        return null;
+    }
+
+    /**
+     * Register the org.apache.http.protocol.HttpRequestHandler which handles
+     * the request and set the proper response (headers and content).
+     *
+     * @param server
+     */
+    protected void registerHandler(LocalTestServer server) {
+    }
+
+    /**
+     * Obtains the host name of the local test server.
+     *
+     * @return hostName
+     */
+    protected String getHostName() {
+        return localServer.getServiceHostName();
+    }
+
+    /**
+     * Obtains the port of the local test server.
+     *
+     * @return port
+     */
+    protected int getPort() {
+        return localServer.getServicePort();
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,73 @@
+/**
+ * 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;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.HttpStatus;
+import org.apache.http.localserver.LocalTestServer;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpThrowExceptionOnFailureTest extends BaseHttpTest {
+
+    @Test
+    public void httpGetWhichReturnsHttp501() throws Exception {
+        Exchange exchange = template.request("http://" + getHostName() + ":" + getPort() + "/XXX?throwExceptionOnFailure=false", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        assertNotNull(exchange);
+
+        Message out = exchange.getOut();
+        assertNotNull(out);
+
+        Map<String, Object> headers = out.getHeaders();
+        assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, headers.get(Exchange.HTTP_RESPONSE_CODE));
+        assertEquals("0", headers.get("Content-Length"));
+    }
+
+    @Test
+    public void httpGetWhichReturnsHttp501ShouldThrowAnException() throws Exception {
+        try {
+            template.request("http://" + getHostName() + ":" + getPort() + "/XXX?throwExceptionOnFailure=true", new Processor() {
+                public void process(Exchange exchange) throws Exception {
+                }
+            });
+            fail("RuntimeCamelException expected");
+        } catch (RuntimeCamelException e) {
+            // expected
+            HttpOperationFailedException ex = (HttpOperationFailedException) e.getCause();
+            assertEquals(501, ex.getStatusCode());
+        }
+
+    }
+
+    @Override
+    protected void registerHandler(LocalTestServer server) {
+        server.register("/", new BasicValidationHandler("GET", null, null, getExpectedContent()));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,42 @@
+/**
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpWithHttpUriHeaderTest extends BaseHttpTest {
+
+    @Test
+    public void notBridgeEndpointWithDefault() throws Exception {
+        localServer.register("/", new BasicValidationHandler("GET", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http://host/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_URI, "http://" + getHostName() + ":" + getPort() + "/");
+            }
+        });
+
+        assertExchange(exchange);
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.AuthenticationValidationHandler;
+import org.apache.http.localserver.RequestBasicAuth;
+import org.apache.http.localserver.ResponseBasicUnauthorized;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.ResponseContent;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpsAuthenticationTest extends BaseHttpsTest {
+
+    private String user = "camel";
+    private String password = "password";
+
+    @Test
+    public void httpsGetWithAuthentication() throws Exception {
+        localServer.register("/", new AuthenticationValidationHandler("GET", null, null, getExpectedContent(), user, password));
+
+        Exchange exchange = template.request("https://" + getHostName() + ":" + getPort() + "/?username=camel&password=password", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+    @Override
+    protected BasicHttpProcessor getBasicHttpProcessor() {
+        BasicHttpProcessor httpproc = new BasicHttpProcessor();
+        httpproc.addInterceptor(new RequestBasicAuth());
+
+        httpproc.addInterceptor(new ResponseContent());
+        httpproc.addInterceptor(new ResponseBasicUnauthorized());
+
+        return httpproc;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsGetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsGetTest.java?rev=915247&r1=915246&r2=915247&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsGetTest.java (original)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsGetTest.java Tue Feb 23 09:00:46 2010
@@ -16,25 +16,26 @@
  */
 package org.apache.camel.component.http;
 
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Before;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.junit.Test;
 
-public class HttpsGetTest extends HttpGetTest {
+/**
+ *
+ * @version $Revision$
+ */
+public class HttpsGetTest extends BaseHttpsTest {
 
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        expectedText = "https://mail.google.com/mail/";
-        super.setUp();
-    }
+    @Test
+    public void httpsGet() throws Exception {
+        localServer.register("/mail/", new BasicValidationHandler("GET", null, null, getExpectedContent()));
 
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() {
-                from("direct:start")
-                    .to("https://mail.google.com/mail/").to("mock:results");
+        Exchange exchange = template.request("https://" + getHostName() + ":" + getPort() + "/mail/", new Processor() {
+            public void process(Exchange exchange) throws Exception {
             }
-        };
+        });
+
+        assertExchange(exchange);
     }
-}
+}
\ No newline at end of file

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsServerTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsServerTestSupport.java?rev=915247&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsServerTestSupport.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsServerTestSupport.java Tue Feb 23 09:00:46 2010
@@ -0,0 +1,77 @@
+/**
+ * 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;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.security.KeyStore;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ *
+ * @version $Revision$
+ */
+public abstract class HttpsServerTestSupport extends HttpServerTestSupport {
+
+    protected static final String KEYSTORE_PATH = "./src/test/resources/localhost.ks";
+    protected static final File KEYSTORE = new File(KEYSTORE_PATH);
+    protected static final String SECURE_SOCKET_PROTOCOL = "SSL";
+    protected static final String PASSWORD = "changeit";
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
+        System.setProperty("javax.net.ssl.trustStore", KEYSTORE_PATH);
+
+        super.setUp();
+    }
+
+    @After
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+
+        System.getProperties().remove("javax.net.ssl.trustStorePassword");
+        System.getProperties().remove("javax.net.ssl.trustStore");
+    }
+
+    @Override
+    protected SSLContext getSSLContext() throws Exception {
+        KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
+        keyStore.load(new FileInputStream(KEYSTORE), PASSWORD.toCharArray());
+
+        KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+        keyManagerFactory.init(keyStore, PASSWORD.toCharArray());
+
+        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+        trustStore.load(new FileInputStream(KEYSTORE), PASSWORD.toCharArray());
+
+        TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+        trustManagerFactory.init(trustStore);
+
+        SSLContext sslcontext = SSLContext.getInstance(SECURE_SOCKET_PROTOCOL);
+        sslcontext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
+
+        return sslcontext;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsServerTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsServerTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date