Author: ningjiang Date: Thu Feb 12 08:16:11 2009 New Revision: 743649 URL: http://svn.apache.org/viewvc?rev=743649&view=rev Log: Merged revisions 742898 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk
........ r742898 | ningjiang | 2009-02-10 17:07:49 +0800 (Tue, 10 Feb 2009) | 1 line CAMEL-1327 applied the patch with thanks to Roberto, also added some unit tests in camel-jetty ........ Added: camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java - copied unchanged from r742898, camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java - copied unchanged from r742898, camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java camel/branches/camel-1.x/components/camel-http/src/test/java/org/apache/camel/component/http/GZIPHelperTest.java - copied unchanged from r742898, camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/GZIPHelperTest.java Modified: camel/branches/camel-1.x/ (props changed) camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ConvertPayloadToInputStreamTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteUsingUrlPostTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java Propchange: camel/branches/camel-1.x/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Feb 12 08:16:11 2009 @@ -1 +1 @@ -/camel/trunk:739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742854,742856 +/camel/trunk:739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742854,742856,742898 Propchange: camel/branches/camel-1.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java (original) +++ camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java Thu Feb 12 08:16:11 2009 @@ -16,15 +16,20 @@ */ package org.apache.camel.component.http; +import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.io.PrintWriter; +import java.util.zip.GZIPOutputStream; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.camel.Message; +import org.apache.camel.component.http.helper.GZIPHelper; import org.apache.camel.spi.HeaderFilterStrategy; /** @@ -59,13 +64,22 @@ doWriteExceptionResponse(exchange.getException(), response); } } else { - Message out = exchange.getOut(); + // just copy the protocol relates header + copyProtocolHeaders(exchange.getIn(), exchange.getOut()); + Message out = exchange.getOut(); if (out != null) { doWriteResponse(out, response); } } } + private void copyProtocolHeaders(Message request, Message response) { + if (request.getHeader(GZIPHelper.CONTENT_ENCODING) != null) { + String contentEncoding = request.getHeader(GZIPHelper.CONTENT_ENCODING, String.class); + response.setHeader(GZIPHelper.CONTENT_ENCODING, contentEncoding); + } + } + public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException { response.setStatus(500); // 500 for internal server error response.setContentType("text/plain"); @@ -88,8 +102,8 @@ response.setStatus(code); } // set the content type in the response. - if (message.getHeader("Content-Type") != null) { - String contentType = message.getHeader("Content-Type", String.class); + if (message.getHeader("Content-Type") != null) { + String contentType = message.getHeader("Content-Type", String.class); response.setContentType(contentType); } @@ -106,18 +120,22 @@ if (message.getBody() != null) { // try to stream the body since that would be the most efficient InputStream is = message.getBody(InputStream.class); - int length = 0; if (is != null) { - ServletOutputStream os = null; + ServletOutputStream os = response.getOutputStream(); try { - os = response.getOutputStream(); + ByteArrayOutputStream initialArray = new ByteArrayOutputStream(); int c; while ((c = is.read()) >= 0) { - os.write(c); - length++; + initialArray.write(c); } + byte[] processedArray = processReponseContent(message, initialArray.toByteArray(), response); + os.write(processedArray); // set content length before we flush - response.setContentLength(length); + // Here the processedArray length is used instead of the + // length of the characters in written to the initialArray + // because if the method processReponseContent compresses + // the data, the processedArray may contain a different length + response.setContentLength(processedArray.length); os.flush(); } finally { os.close(); @@ -135,6 +153,11 @@ } } + + protected byte[] processReponseContent(Message message, byte[] array, HttpServletResponse response) throws IOException { + String gzipEncoding = message.getHeader(GZIPHelper.CONTENT_ENCODING, String.class); + return GZIPHelper.compressArrayIfGZIPRequested(gzipEncoding, array, response); + } public Object parseBody(HttpMessage httpMessage) throws IOException { // lets assume the body is a reader Modified: camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java (original) +++ camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java Thu Feb 12 08:16:11 2009 @@ -18,11 +18,13 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; import org.apache.camel.Converter; +import org.apache.camel.component.http.helper.GZIPHelper; /** * Some converter methods making it easy to convert the body of a message to servlet types or to switch between @@ -51,6 +53,15 @@ } @Converter + public InputStream toInputStream(HttpMessage message) throws Exception { + HttpServletRequest request = toServletRequest(message); + if (request != null) { + return GZIPHelper.getInputStream(request); + } + return null; + } + + @Converter public BufferedReader toReader(HttpMessage message) throws IOException { HttpServletRequest request = toServletRequest(message); if (request != null) { Modified: camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java (original) +++ camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java Thu Feb 12 08:16:11 2009 @@ -16,6 +16,7 @@ */ package org.apache.camel.component.http; +import org.apache.camel.component.http.helper.GZIPHelper; import org.apache.camel.impl.DefaultHeaderFilterStrategy; /** @@ -30,6 +31,7 @@ protected void initialize() { getOutFilter().add("content-length"); getOutFilter().add("content-type"); + getOutFilter().add(GZIPHelper.CONTENT_ENCODING); getOutFilter().add(HttpMethods.HTTP_METHOD); getOutFilter().add(HttpProducer.QUERY); getOutFilter().add(HttpProducer.HTTP_RESPONSE_CODE.toLowerCase()); Modified: camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java (original) +++ camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java Thu Feb 12 08:16:11 2009 @@ -28,6 +28,7 @@ import org.apache.camel.NoTypeConversionAvailableException; import org.apache.camel.Producer; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.http.helper.GZIPHelper; import org.apache.camel.component.http.helper.LoadingByteArrayOutputStream; import org.apache.camel.impl.DefaultProducer; import org.apache.camel.spi.HeaderFilterStrategy; @@ -154,7 +155,7 @@ InputStream is = null; try { bos = new LoadingByteArrayOutputStream(); - is = method.getResponseBodyAsStream(); + is = GZIPHelper.getInputStream(method); // in case of no response stream if (is == null) { return null; Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ConvertPayloadToInputStreamTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ConvertPayloadToInputStreamTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ConvertPayloadToInputStreamTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ConvertPayloadToInputStreamTest.java Thu Feb 12 08:16:11 2009 @@ -40,7 +40,7 @@ MockEndpoint mockEndpoint = getMockEndpoint("mock:result"); mockEndpoint.expectedMessageCount(1); - template.sendBodyAndHeader("http://localhost:8080/test", expectedBody, "Content-Type", "application/xml"); + template.sendBodyAndHeader("http://localhost:9080/test", expectedBody, "Content-Type", "application/xml"); mockEndpoint.assertIsSatisfied(); List<Exchange> list = mockEndpoint.getReceivedExchanges(); @@ -59,7 +59,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("jetty:http://localhost:8080/test"). + from("jetty:http://localhost:9080/test"). convertBodyTo(InputStream.class). to("mock:result"); } Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java Thu Feb 12 08:16:11 2009 @@ -39,14 +39,14 @@ JettyHttpComponent componentJetty = (JettyHttpComponent) context.getComponent("jetty"); componentJetty.setSslSocketConnector(sslSocketConnector); - from("jetty:https://localhost:8080/test").to("mock:a"); + from("jetty:https://localhost:9080/test").to("mock:a"); Processor proc = new Processor() { public void process(Exchange exchange) throws Exception { exchange.getOut(true).setBody("<b>Hello World</b>"); } }; - from("jetty:https://localhost:8080/hello").process(proc); + from("jetty:https://localhost:9080/hello").process(proc); } }; } Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java Thu Feb 12 08:16:11 2009 @@ -63,7 +63,7 @@ public void testHelloEndpoint() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); - InputStream is = new URL("http://localhost:8080/hello").openStream(); + InputStream is = new URL("http://localhost:9080/hello").openStream(); int c; while ((c = is.read()) >= 0) { os.write(c); @@ -75,14 +75,14 @@ } protected void invokeHttpEndpoint() throws IOException { - template.sendBodyAndHeader("http://localhost:8080/test", expectedBody, "Content-Type", "application/xml"); + template.sendBodyAndHeader("http://localhost:9080/test", expectedBody, "Content-Type", "application/xml"); } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("jetty:http://localhost:8080/test").to("mock:a"); + from("jetty:http://localhost:9080/test").to("mock:a"); Processor proc = new Processor() { public void process(Exchange exchange) throws Exception { @@ -96,7 +96,7 @@ exchange.getOut(true).setBody("<b>Hello World</b>"); } }; - from("jetty:http://localhost:8080/hello?sessionSupport=true").process(proc); + from("jetty:http://localhost:9080/hello?sessionSupport=true").process(proc); } }; } Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteUsingUrlPostTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteUsingUrlPostTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteUsingUrlPostTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteUsingUrlPostTest.java Thu Feb 12 08:16:11 2009 @@ -31,7 +31,7 @@ public class HttpRouteUsingUrlPostTest extends HttpRouteTest { protected void invokeHttpEndpoint() throws IOException { - URL url = new URL("http://localhost:8080/test"); + URL url = new URL("http://localhost:9080/test"); URLConnection urlConnection = url.openConnection(); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java Thu Feb 12 08:16:11 2009 @@ -96,7 +96,7 @@ public void testEndpointWithoutHttps() { MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:a", MockEndpoint.class); try { - template.sendBodyAndHeader("jetty:http://localhost:8080/test", expectedBody, "Content-Type", "application/xml"); + template.sendBodyAndHeader("jetty:http://localhost:9080/test", expectedBody, "Content-Type", "application/xml"); fail("expect exception on access to https endpoint via http"); } catch (RuntimeCamelException expected) { } @@ -106,7 +106,7 @@ public void testHelloEndpoint() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); - InputStream is = new URL("https://localhost:8080/hello").openStream(); + InputStream is = new URL("https://localhost:9080/hello").openStream(); int c; while ((c = is.read()) >= 0) { os.write(c); @@ -119,7 +119,7 @@ public void testHelloEndpointWithoutHttps() throws Exception { try { - new URL("http://localhost:8080/hello").openStream(); + new URL("http://localhost:9080/hello").openStream(); fail("expected SocketException on use ot http"); } catch (SocketException expected) { } @@ -128,7 +128,7 @@ } protected void invokeHttpEndpoint() throws IOException { - template.sendBodyAndHeader("jetty:https://localhost:8080/test", expectedBody, "Content-Type", "application/xml"); + template.sendBodyAndHeader("jetty:https://localhost:9080/test", expectedBody, "Content-Type", "application/xml"); } @Override @@ -142,14 +142,14 @@ URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks"); componentJetty.setKeystore(keyStoreUrl.getPath()); - from("jetty:https://localhost:8080/test").to("mock:a"); + from("jetty:https://localhost:9080/test").to("mock:a"); Processor proc = new Processor() { public void process(Exchange exchange) throws Exception { exchange.getOut(true).setBody("<b>Hello World</b>"); } }; - from("jetty:https://localhost:8080/hello").process(proc); + from("jetty:https://localhost:9080/hello").process(proc); } }; } Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java Thu Feb 12 08:16:11 2009 @@ -21,6 +21,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.http.helper.GZIPHelper; /** * Unit test for content-type @@ -28,7 +29,7 @@ public class JettyContentTypeTest extends ContextTestSupport { public void testSameContentType() throws Exception { - Endpoint endpoint = context.getEndpoint("http://localhost:8080/myapp/myservice"); + Endpoint endpoint = context.getEndpoint("http://localhost:9080/myapp/myservice"); Exchange exchange = endpoint.createExchange(); exchange.getIn().setBody("<order>123</order>"); exchange.getIn().setHeader("user", "Claus"); @@ -39,9 +40,24 @@ assertEquals("<order>OK</order>", body); assertOutMessageHeader(exchange, "content-type", "text/xml"); } + + public void testContentTypeWithGZip() throws Exception { + Endpoint endpoint = context.getEndpoint("http://localhost:9080/myapp/myservice"); + Exchange exchange = endpoint.createExchange(); + exchange.getIn().setBody("<order>123</order>"); + exchange.getIn().setHeader("user", "Claus"); + exchange.getIn().setHeader("content-type", "text/xml"); + GZIPHelper.setGZIPMessageHeader(exchange.getIn()); + template.send(endpoint, exchange); + + String body = exchange.getOut().getBody(String.class); + assertEquals("<order>OK</order>", body); + assertOutMessageHeader(exchange, "content-type", "text/xml"); + assertOutMessageHeader(exchange, GZIPHelper.CONTENT_ENCODING, GZIPHelper.GZIP); + } public void testMixedContentType() throws Exception { - Endpoint endpoint = context.getEndpoint("http://localhost:8080/myapp/myservice"); + Endpoint endpoint = context.getEndpoint("http://localhost:9080/myapp/myservice"); Exchange exchange = endpoint.createExchange(); exchange.getIn().setBody("<order>123</order>"); exchange.getIn().setHeader("Content-Type", "text/xml"); @@ -56,7 +72,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { - from("jetty:http://localhost:8080/myapp/myservice").process(new MyBookService()); + from("jetty:http://localhost:9080/myapp/myservice").process(new MyBookService()); } }; } @@ -64,7 +80,7 @@ public class MyBookService implements Processor { public void process(Exchange exchange) throws Exception { if (exchange.getIn().getHeader("user") != null) { - exchange.getOut().setBody("<order>OK</order>"); + exchange.getOut().setBody("<order>OK</order>"); } else { exchange.getOut().setBody("FAIL"); exchange.getOut().setHeader("Content-Type", "text/plain"); Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java Thu Feb 12 08:16:11 2009 @@ -32,12 +32,12 @@ public class JettyHttpBindingRefTest extends ContextTestSupport { public void testDefaultHttpBinding() throws Exception { - Object out = template.requestBody("http://localhost:8080/myapp/myservice", "Hello World"); + Object out = template.requestBody("http://localhost:9080/myapp/myservice", "Hello World"); assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, out)); } public void testCustomHttpBinding() throws Exception { - Object out = template.requestBody("http://localhost:8081/myapp/myotherservice", "Hello World"); + Object out = template.requestBody("http://localhost:9081/myapp/myotherservice", "Hello World"); assertEquals("Something went wrong but we dont care", context.getTypeConverter().convertTo(String.class, out)); } @@ -56,9 +56,9 @@ public void configure() throws Exception { errorHandler(noErrorHandler()); - from("jetty:http://localhost:8080/myapp/myservice?httpBindingRef=default").transform().constant("Bye World"); + from("jetty:http://localhost:9080/myapp/myservice?httpBindingRef=default").transform().constant("Bye World"); - from("jetty:http://localhost:8081/myapp/myotherservice?httpBindingRef=myownbinder").process(new Processor() { + from("jetty:http://localhost:9081/myapp/myotherservice?httpBindingRef=myownbinder").process(new Processor() { public void process(Exchange exchange) throws Exception { throw new IllegalStateException("Not implemented"); } Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java Thu Feb 12 08:16:11 2009 @@ -34,7 +34,7 @@ assertEquals("Get the wrong http client parameter", 5555, producer.getHttpClient().getParams().getSoTimeout()); // send and receive - Object out = template.requestBody("http://localhost:8080/myapp/myservice", "Hello World"); + Object out = template.requestBody("http://localhost:9080/myapp/myservice", "Hello World"); assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, out)); } @@ -43,7 +43,7 @@ return new RouteBuilder() { @Override public void configure() throws Exception { - from("jetty:http://localhost:8080/myapp/myservice?httpClient.soTimeout=5555").transform().constant("Bye World"); + from("jetty:http://localhost:9080/myapp/myservice?httpClient.soTimeout=5555").transform().constant("Bye World"); } }; } Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java Thu Feb 12 08:16:11 2009 @@ -23,6 +23,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.http.helper.GZIPHelper; /** * Unit test for exposing a http server that returns images @@ -30,19 +31,29 @@ public class JettyImageFileTest extends ContextTestSupport { public void testImageContentType() throws Exception { - Endpoint endpoint = context.getEndpoint("http://localhost:8080/myapp/myservice"); + Endpoint endpoint = context.getEndpoint("http://localhost:9080/myapp/myservice"); Exchange exchange = endpoint.createExchange(); template.send(endpoint, exchange); assertNotNull(exchange.getOut().getBody()); assertOutMessageHeader(exchange, "Content-Type", "image/jpeg"); } + + public void testImageWithGZip() throws Exception { + Endpoint endpoint = context.getEndpoint("http://localhost:9080/myapp/myservice"); + Exchange exchange = endpoint.createExchange(); + GZIPHelper.setGZIPMessageHeader(exchange.getIn()); + template.send(endpoint, exchange); + + assertNotNull(exchange.getOut().getBody()); + assertOutMessageHeader(exchange, "Content-Type", "image/jpeg"); + } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { - from("jetty:http://localhost:8080/myapp/myservice").process(new MyImageService()); + from("jetty:http://localhost:9080/myapp/myservice").process(new MyImageService()); } }; } Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java Thu Feb 12 08:16:11 2009 @@ -30,7 +30,7 @@ public void testResponseBodyWhenError() throws Exception { try { - template.sendBody("http://localhost:8080/myapp/myservice", "bookid=123"); + template.sendBody("http://localhost:9080/myapp/myservice", "bookid=123"); fail("Should have thrown an exception"); } catch (RuntimeCamelException e) { HttpOperationFailedException cause = (HttpOperationFailedException) e.getCause(); @@ -48,7 +48,7 @@ return new RouteBuilder() { public void configure() throws Exception { errorHandler(noErrorHandler()); - from("jetty:http://localhost:8080/myapp/myservice").process(new MyBookService()); + from("jetty:http://localhost:9080/myapp/myservice").process(new MyBookService()); } }; } Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java?rev=743649&r1=743648&r2=743649&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java (original) +++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java Thu Feb 12 08:16:11 2009 @@ -29,7 +29,7 @@ public class JettyRouteTest extends ContextTestSupport { public void testSendToJetty() throws Exception { - Object response = template.requestBody("http://localhost:8080/myapp/myservice", "bookid=123"); + Object response = template.requestBody("http://localhost:9080/myapp/myservice", "bookid=123"); // convert the response to a String String body = context.getTypeConverter().convertTo(String.class, response); assertEquals("<html><body>Book 123 is Camel in Action</body></html>", body); @@ -40,7 +40,7 @@ return new RouteBuilder() { public void configure() throws Exception { // START SNIPPET: e1 - from("jetty:http://localhost:8080/myapp/myservice").process(new MyBookService()); + from("jetty:http://localhost:9080/myapp/myservice").process(new MyBookService()); // END SNIPPET: e1 } };