You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cs...@apache.org on 2015/01/15 09:48:50 UTC
[14/23] camel git commit: CAMEL-8239 Split jetty8 and jetty9 support
into separate modules
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySimplifiedHandle404Test.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySimplifiedHandle404Test.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySimplifiedHandle404Test.java
deleted file mode 100644
index 8d2eeed..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySimplifiedHandle404Test.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.processor.aggregate.AggregationStrategy;
-import org.junit.Test;
-
-/**
- * Based on end user on forum how to get the 404 error code in his enrich aggregator
- *
- * @version
- */
-public class JettySimplifiedHandle404Test extends BaseJettyTest {
-
- @Test
- public void testSimulate404() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Page not found");
- mock.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 404);
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // disable error handling
- errorHandler(noErrorHandler());
-
- // START SNIPPET: e1
- // We set throwExceptionOnFailure to false to let Camel return any response from the remove HTTP server without thrown
- // HttpOperationFailedException in case of failures.
- // This allows us to handle all responses in the aggregation strategy where we can check the HTTP response code
- // and decide what to do. As this is based on an unit test we assert the code is 404
- from("direct:start").enrich("http://localhost:{{port}}/myserver?throwExceptionOnFailure=false&user=Camel", new AggregationStrategy() {
- public Exchange aggregate(Exchange original, Exchange resource) {
- // get the response code
- Integer code = resource.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
- assertEquals(404, code.intValue());
- return resource;
- }
- }).to("mock:result");
-
- // this is our jetty server where we simulate the 404
- from("jetty://http://localhost:{{port}}/myserver")
- .process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getOut().setBody("Page not found");
- exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
- }
- });
- // END SNIPPET: e1
- }
- };
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySimulateInOnlyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySimulateInOnlyTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySimulateInOnlyTest.java
deleted file mode 100644
index 1d5000d..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySimulateInOnlyTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class JettySimulateInOnlyTest extends BaseJettyTest {
-
- private static String route = "";
-
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @Test
- public void testSimulateInOnlyUsingWireTap() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // START SNIPPET: e1
- from("jetty://http://localhost:{{port}}/myserver")
- // turn the route to in only as we do not want jetty to wait for the response
- // we can do this using the wiretap EIP pattern
- .wireTap("direct:continue")
- // and then construct a canned empty response
- .transform(constant("OK"));
-
- from("direct:continue")
- .delay(1500)
- .process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- route += "B";
- }
- }).
- to("mock:result");
- // END SNIPPET: e1
- }
- });
- context.start();
-
- route = "";
-
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedHeaderReceived("foo", "bar");
-
- String reply = template.requestBody("http://localhost:{{port}}/myserver?foo=bar", null, String.class);
- route += "A";
- assertEquals("OK", reply);
-
- assertMockEndpointsSatisfied();
-
- assertEquals("AB", route);
- }
-
- @Test
- public void testSimulateInOnly() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("jetty://http://localhost:{{port}}/myserver")
- // turn the route to in only as we do not want jetty to wait for the response
- // we can do this by changing the MEP and sending to a seda endpoint to spin off
- // a new thread continue doing the routing
- .setExchangePattern(ExchangePattern.InOnly)
- .to("seda:continue")
- // and then construct a canned empty response
- .transform(constant("OK"));
-
- from("seda:continue")
- .delay(1000)
- .process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- route += "B";
- }
- }).
- to("mock:result");
- }
- });
- context.start();
-
- route = "";
-
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedHeaderReceived("foo", "bar");
-
- String reply = template.requestBody("http://localhost:{{port}}/myserver?foo=bar", null, String.class);
- route += "A";
- assertEquals("OK", reply);
-
- assertMockEndpointsSatisfied();
-
- assertEquals("AB", route);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySteveIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySteveIssueTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySteveIssueTest.java
deleted file mode 100644
index d66eadb..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySteveIssueTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * Unit test based on Steve request for CAMEL-877.
- */
-public class JettySteveIssueTest extends BaseJettyTest {
-
- private String serverUri = "http://localhost:" + getPort() + "/myservice";
-
- @Test
- public void testSendX() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("<html><body>foo</body></html>");
- mock.expectedHeaderReceived("x", "foo");
-
- template.requestBody(serverUri + "?x=foo", null, Object.class);
-
- assertMockEndpointsSatisfied();
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from("jetty:" + serverUri)
- .setBody().simple("<html><body>${in.header.x}</body></html>")
- .to("mock:result");
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyStreamCacheIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyStreamCacheIssueTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyStreamCacheIssueTest.java
deleted file mode 100644
index 719c992..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyStreamCacheIssueTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class JettyStreamCacheIssueTest extends BaseJettyTest {
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- CamelContext context = super.createCamelContext();
- // ensure we overflow and spool to disk
- context.getStreamCachingStrategy().setSpoolThreshold(5000);
- context.setStreamCaching(true);
- return context;
- }
-
- @Test
- public void testStreamCache() throws Exception {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < 10000; i++) {
- sb.append("0123456789");
- }
- String input = sb.toString();
-
- String out = template.requestBody("direct:input", input, String.class);
- assertEquals(input, out);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:input").to("jetty:http://localhost:" + getPort() + "/input");
-
- from("jetty:http://localhost:" + getPort() + "/input").process(new Processor() {
- @Override
- public void process(final Exchange exchange) throws Exception {
- Assert.assertFalse(exchange.hasOut());
- }
- });
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java
deleted file mode 100644
index 31e05cc..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpOperationFailedException;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class JettySuspendResumeTest extends BaseJettyTest {
-
- private String serverUri = "http://localhost:" + getPort() + "/cool";
-
- @Test
- public void testJettySuspendResume() throws Exception {
- context.getShutdownStrategy().setTimeout(50);
-
- String reply = template.requestBody(serverUri, "World", String.class);
- assertEquals("Bye World", reply);
-
- // now suspend jetty
- HttpConsumer consumer = (HttpConsumer) context.getRoute("route1").getConsumer();
- assertNotNull(consumer);
-
- // suspend
- consumer.suspend();
-
- try {
- template.requestBody(serverUri, "Moon", String.class);
- fail("Should throw exception");
- } catch (Exception e) {
- HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
- assertEquals(503, cause.getStatusCode());
- }
-
- // resume
- consumer.resume();
-
- // and send request which should be processed
- reply = template.requestBody(serverUri, "Moon", String.class);
- assertEquals("Bye Moon", reply);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("jetty://" + serverUri).id("route1")
- .transform(body().prepend("Bye "));
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java
deleted file mode 100644
index 3935c71..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpOperationFailedException;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class JettySuspendTest extends BaseJettyTest {
-
- private String serverUri = "http://localhost:" + getPort() + "/cool";
-
- @Test
- public void testJettySuspend() throws Exception {
- context.getShutdownStrategy().setTimeout(50);
-
- String reply = template.requestBody(serverUri, "World", String.class);
- assertEquals("Bye World", reply);
-
- // now suspend jetty
- HttpConsumer consumer = (HttpConsumer) context.getRoute("route1").getConsumer();
- assertNotNull(consumer);
-
- // suspend
- consumer.suspend();
-
- try {
- template.requestBody(serverUri, "Moon", String.class);
- fail("Should throw exception");
- } catch (Exception e) {
- HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
- assertEquals(503, cause.getStatusCode());
- }
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("jetty://" + serverUri).id("route1")
- .transform(body().prepend("Bye "));
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java
deleted file mode 100644
index cacbe95..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class JettySuspendWhileInProgressTest extends BaseJettyTest {
-
- private String serverUri = "http://localhost:" + getPort() + "/cool";
-
- @Test
- public void testJettySuspendWhileInProgress() throws Exception {
- context.getShutdownStrategy().setTimeout(50);
-
- // send a request/reply and have future handle so we can shutdown while in progress
- Future<String> reply = template.asyncRequestBodyAndHeader(serverUri, null, "name", "Camel", String.class);
-
- // shutdown camel while in progress, wait 2 sec so the first req has been received in Camel route
- Executors.newSingleThreadExecutor().execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(2000);
- context.stop();
- } catch (Exception e) {
- // ignore
- }
- }
- });
-
- // wait a bit more before sending next
- Thread.sleep(5000);
-
- // now send a new req/reply
- Future<String> reply2 = template.asyncRequestBodyAndHeader(serverUri, null, "name", "Tiger", String.class);
-
- // the first should wait to have its reply returned
- assertEquals("Bye Camel", reply.get(20, TimeUnit.SECONDS));
-
- // the 2nd should have a 503 returned as we are shutting down
- try {
- reply2.get(20, TimeUnit.SECONDS);
- fail("Should throw exception");
- } catch (Exception e) {
- RuntimeCamelException rce = assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
- HttpOperationFailedException hofe = assertIsInstanceOf(HttpOperationFailedException.class, rce.getCause());
- assertEquals(503, hofe.getStatusCode());
- }
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from("jetty://" + serverUri)
- .log("Got data will wait 10 sec with reply")
- .delay(10000)
- .transform(simple("Bye ${header.name}"));
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyWithXPathChoiceTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyWithXPathChoiceTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyWithXPathChoiceTest.java
deleted file mode 100644
index 836533d..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyWithXPathChoiceTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.apache.camel.component.mock.MockEndpoint.expectsMessageCount;
-
-public class JettyWithXPathChoiceTest extends BaseJettyTest {
- protected MockEndpoint x;
- protected MockEndpoint y;
- protected MockEndpoint z;
-
- @Test
- public void testSendToFirstWhen() throws Exception {
- String body = "<one/>";
- expectsMessageCount(0, y, z);
-
- sendBody(body);
-
- assertMockEndpointsSatisfied();
-
- x.reset();
- y.reset();
- z.reset();
-
- body = "<two/>";
- expectsMessageCount(0, x, z);
-
- sendBody(body);
-
- assertMockEndpointsSatisfied();
- }
-
- private void sendBody(String body) {
- template.sendBody("http://localhost:{{port}}/myworld", body);
- }
-
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
-
- x = getMockEndpoint("mock:x");
- y = getMockEndpoint("mock:y");
- z = getMockEndpoint("mock:z");
- }
-
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("jetty:http://localhost:{{port}}/myworld")
- // use stream caching
- .streamCaching()
- .choice()
- .when().xpath("/one").to("mock:x")
- .when().xpath("/two").to("mock:y")
- .otherwise().to("mock:z")
- .end();
-
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
deleted file mode 100644
index 7c81101..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.io.File;
-
-import javax.activation.DataHandler;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.junit.Test;
-
-public class MultiPartFormTest extends BaseJettyTest {
- private RequestEntity createMultipartRequestEntity() throws Exception {
- File file = new File("src/main/resources/META-INF/NOTICE.txt");
-
- Part[] parts = {new StringPart("comment", "A binary file of some kind"),
- new FilePart(file.getName(), file)};
-
- return new MultipartRequestEntity(parts, new HttpMethodParams());
-
- }
-
- @Test
- public void testSendMultiPartForm() throws Exception {
- HttpClient httpclient = new HttpClient();
-
- PostMethod httppost = new PostMethod("http://localhost:" + getPort() + "/test");
-
- httppost.setRequestEntity(createMultipartRequestEntity());
-
- int status = httpclient.executeMethod(httppost);
-
- assertEquals("Get a wrong response status", 200, status);
- String result = httppost.getResponseBodyAsString();
-
- assertEquals("Get a wrong result", "A binary file of some kind", result);
-
- }
-
- @Test
- public void testSendMultiPartFormFromCamelHttpComponnent() throws Exception {
- String result = template.requestBody("http://localhost:" + getPort() + "/test", createMultipartRequestEntity(), String.class);
- assertEquals("Get a wrong result", "A binary file of some kind", result);
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- // START SNIPPET: e1
- // Set the jetty temp directory which store the file for multi
- // part form
- // camel-jetty will clean up the file after it handled the
- // request.
- // The option works rightly from Camel 2.4.0
- getContext().getProperties().put("CamelJettyTempDir", "target");
-
- from("jetty://http://localhost:{{port}}/test").process(new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- Message in = exchange.getIn();
- assertEquals("Get a wrong attachement size", 1, in.getAttachments().size());
- // The file name is attachment id
- DataHandler data = in.getAttachment("NOTICE.txt");
-
- assertNotNull("Should get the DataHandle NOTICE.txt", data);
- // This assert is wrong, but the correct content-type
- // (application/octet-stream)
- // will not be returned until Jetty makes it available -
- // currently the content-type
- // returned is just the default for FileDataHandler (for
- // the implentation being used)
- // assertEquals("Get a wrong content type",
- // "text/plain", data.getContentType());
- assertEquals("Got the wrong name", "NOTICE.txt", data.getName());
-
- assertTrue("We should get the data from the DataHandle", data.getDataSource()
- .getInputStream().available() > 0);
-
- // The other form date can be get from the message
- // header
- exchange.getOut().setBody(in.getHeader("comment"));
- }
-
- });
- // END SNIPPET: e1
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
deleted file mode 100644
index 846f8df..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.activation.DataHandler;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.JndiRegistry;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
-import org.eclipse.jetty.servlets.MultiPartFilter;
-import org.junit.Test;
-
-public class MultiPartFormWithCustomFilterTest extends BaseJettyTest {
-
- private static class MyMultipartFilter extends MultiPartFilter {
- @Override
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
- // set a marker attribute to show that this filter class was used
- ((HttpServletResponse)response).addHeader("MyMultipartFilter", "true");
-
- super.doFilter(request, response, chain);
- }
- }
-
- @Test
- public void testSendMultiPartForm() throws Exception {
- HttpClient httpclient = new HttpClient();
- File file = new File("src/main/resources/META-INF/NOTICE.txt");
- PostMethod httppost = new PostMethod("http://localhost:" + getPort() + "/test");
- Part[] parts = {
- new StringPart("comment", "A binary file of some kind"),
- new FilePart(file.getName(), file)
- };
-
- MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, httppost.getParams());
- httppost.setRequestEntity(reqEntity);
-
- int status = httpclient.executeMethod(httppost);
-
- assertEquals("Get a wrong response status", 200, status);
-
- String result = httppost.getResponseBodyAsString();
- assertEquals("Get a wrong result", "A binary file of some kind", result);
- assertNotNull("Did not use custom multipart filter", httppost.getResponseHeader("MyMultipartFilter"));
- }
-
- @Test
- public void testSendMultiPartFormOverrideEnableMultpartFilterFalse() throws Exception {
- HttpClient httpclient = new HttpClient();
-
- File file = new File("src/main/resources/META-INF/NOTICE.txt");
-
- PostMethod httppost = new PostMethod("http://localhost:" + getPort() + "/test2");
- Part[] parts = {
- new StringPart("comment", "A binary file of some kind"),
- new FilePart(file.getName(), file)
- };
-
- MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, httppost.getParams());
- httppost.setRequestEntity(reqEntity);
-
- int status = httpclient.executeMethod(httppost);
-
- assertEquals("Get a wrong response status", 200, status);
- assertNotNull("Did not use custom multipart filter", httppost.getResponseHeader("MyMultipartFilter"));
- }
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myMultipartFilter", new MyMultipartFilter());
- return jndi;
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- // START SNIPPET: e1
- // Set the jetty temp directory which store the file for multi part form
- // camel-jetty will clean up the file after it handled the request.
- // The option works rightly from Camel 2.4.0
- getContext().getProperties().put("CamelJettyTempDir", "target");
-
- from("jetty://http://localhost:{{port}}/test?multipartFilterRef=myMultipartFilter").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- Message in = exchange.getIn();
- assertEquals("Get a wrong attachement size", 1, in.getAttachments().size());
- // The file name is attachment id
- DataHandler data = in.getAttachment("NOTICE.txt");
-
- assertNotNull("Should get the DataHandle NOTICE.txt", data);
- // This assert is wrong, but the correct content-type (application/octet-stream)
- // will not be returned until Jetty makes it available - currently the content-type
- // returned is just the default for FileDataHandler (for the implentation being used)
- //assertEquals("Get a wrong content type", "text/plain", data.getContentType());
- assertEquals("Got the wrong name", "NOTICE.txt", data.getName());
-
- assertTrue("We should get the data from the DataHandle", data.getDataSource()
- .getInputStream().available() > 0);
-
- // The other form date can be get from the message header
- exchange.getOut().setBody(in.getHeader("comment"));
- }
- });
- // END SNIPPET: e1
-
- // Test to ensure that setting a multipartFilterRef overrides the enableMultipartFilter=false parameter
- from("jetty://http://localhost:{{port}}/test2?multipartFilterRef=myMultipartFilter&enableMultipartFilter=false").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- Message in = exchange.getIn();
- assertEquals("Get a wrong attachement size", 1, in.getAttachments().size());
- DataHandler data = in.getAttachment("NOTICE.txt");
-
- assertNotNull("Should get the DataHandle NOTICE.txt", data);
- // The other form date can be get from the message header
- exchange.getOut().setBody(in.getHeader("comment"));
- }
- });
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java
deleted file mode 100644
index d1f77db..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.io.InputStream;
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpComponent;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class MultiThreadedHttpGetTest extends BaseJettyTest {
-
- @Test
- public void testHttpGetWithConversion() throws Exception {
-
- // In this scenario response stream is converted to String
- // so the stream has to be read to the end. When this happens
- // the associated connection is released automatically.
-
- String endpointName = "seda:withConversion?concurrentConsumers=5";
- sendMessagesTo(endpointName, 5);
- }
-
- @Test
- public void testHttpGetWithoutConversion() throws Exception {
-
- // This is needed as by default there are 2 parallel
- // connections to some host and there is nothing that
- // closes the http connection here.
- // Need to set the httpConnectionManager
- HttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
- httpConnectionManager.getParams().setDefaultMaxConnectionsPerHost(5);
- context.getComponent("http", HttpComponent.class).setHttpConnectionManager(httpConnectionManager);
-
-
- String endpointName = "seda:withoutConversion?concurrentConsumers=5";
- sendMessagesTo(endpointName, 5);
- }
-
- @Test
- public void testHttpGetWithExplicitStreamClose() throws Exception {
-
- // We close connections explicitely at the very end of the flow
- // (camel doesn't know when the stream is not needed any more)
-
- MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
-
- for (int i = 0; i < 5; i++) {
- mockEndpoint.expectedMessageCount(1);
- template.sendBody("seda:withoutConversion?concurrentConsumers=5", null);
- mockEndpoint.assertIsSatisfied();
- Object response = mockEndpoint.getReceivedExchanges().get(0).getIn().getBody();
- InputStream responseStream = assertIsInstanceOf(InputStream.class, response);
- responseStream.close();
- mockEndpoint.reset();
- }
- }
-
- protected void sendMessagesTo(String endpointName, int count) throws InterruptedException {
- MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
- mockEndpoint.expectedMessageCount(count);
-
- for (int i = 0; i < count; i++) {
- template.sendBody(endpointName, null);
- }
-
- mockEndpoint.assertIsSatisfied();
- List<Exchange> list = mockEndpoint.getReceivedExchanges();
- for (Exchange exchange : list) {
- String body = exchange.getIn().getBody(String.class);
-
- log.debug("Body: " + body);
- assertNotNull("Should have a body!", body);
- assertTrue("body should contain: <html", body.contains("<html"));
- }
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() {
- from("seda:withConversion?concurrentConsumers=5").to("http://localhost:{{port}}/search")
- .convertBodyTo(String.class).to("mock:results");
-
- from("seda:withoutConversion?concurrentConsumers=5").to("http://localhost:{{port}}/search")
- .to("mock:results");
-
- from("jetty:http://localhost:{{port}}/search").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getOut().setBody("<html>Bye World</html>");
- }
- });
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java
deleted file mode 100644
index 917ae35..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.eclipse.jetty.server.handler.ErrorHandler;
-
-public class MyErrorHandler extends ErrorHandler {
-
- protected void writeErrorPageBody(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks)
- throws IOException {
- String uri = request.getRequestURI();
-
- writeErrorPageMessage(request, writer, code, message, uri);
- if (showStacks) {
- writeErrorPageStacks(request, writer);
- }
- writer.write("<hr /><i><small>MyErrorHandler</small></i>");
- for (int i = 0; i < 20; i++) {
- writer.write("<br/> \n");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
deleted file mode 100644
index 8ca31d4..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.Producer;
-import org.apache.camel.component.http.UrlRewrite;
-
-/**
- *
- */
-public class MyUrlRewrite implements UrlRewrite {
-
- @Override
- public String rewrite(String url, String relativeUrl, Producer producer) {
- return url.replaceAll("foo", "bar");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SimpleJettyChunkedFalseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SimpleJettyChunkedFalseTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SimpleJettyChunkedFalseTest.java
deleted file mode 100644
index 56114d2..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SimpleJettyChunkedFalseTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
-
-public class SimpleJettyChunkedFalseTest extends BaseJettyTest {
-
- @Test
- public void testSimple() throws Exception {
- String result = template.requestBody("http://localhost:{{port}}/myapp", "Camel", String.class);
- assertEquals("Hello Camel", result);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from("jetty:http://localhost:{{port}}/myapp?chunked=false")
- .transform(body().prepend("Hello "));
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SimpleJettyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SimpleJettyTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SimpleJettyTest.java
deleted file mode 100644
index aa06352..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SimpleJettyTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
-
-public class SimpleJettyTest extends BaseJettyTest {
-
- @Test
- public void testSimple() throws Exception {
- String result = template.requestBody("http://localhost:{{port}}/myapp", "Camel", String.class);
- assertEquals("Hello Camel", result);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from("jetty:http://localhost:{{port}}/myapp")
- .transform(body().prepend("Hello "));
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
deleted file mode 100644
index fe4154f..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import javax.annotation.Resource;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.test.junit4.TestSupport;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"/org/apache/camel/component/jetty/jetty-https.xml"})
-public class SpringHttpsRouteTest {
- private static final String NULL_VALUE_MARKER = CamelTestSupport.class.getCanonicalName();
- protected String expectedBody = "<hello>world!</hello>";
- protected String pwd = "changeit";
- protected Properties originalValues = new Properties();
- protected transient Log log = LogFactory.getLog(TestSupport.class);
-
- @EndpointInject(uri = "mock:a")
- MockEndpoint mockEndpoint;
-
- @Produce
- private ProducerTemplate template;
-
- private Integer port;
-
- @Before
- public void setUp() throws Exception {
- // ensure jsse clients can validate the self signed dummy localhost cert,
- // use the server keystore as the trust store for these tests
- URL trustStoreUrl = Thread.currentThread().getContextClassLoader().getResource("jsse/localhost.ks");
- setSystemProp("javax.net.ssl.trustStore", trustStoreUrl.getPath());
- }
-
- @After
- public void tearDown() throws Exception {
- restoreSystemProperties();
- }
-
- private void setSystemProp(String key, String value) {
- String originalValue = System.setProperty(key, value);
- originalValues.put(key, originalValue != null ? originalValue : NULL_VALUE_MARKER);
- }
-
- private void restoreSystemProperties() {
- for (Object key : originalValues.keySet()) {
- Object value = originalValues.get(key);
- if (NULL_VALUE_MARKER.equals(value)) {
- System.getProperties().remove(key);
- } else {
- System.setProperty((String) key, (String) value);
- }
- }
- }
-
- @Test
- public void testEndpoint() throws Exception {
- mockEndpoint.reset();
- mockEndpoint.expectedBodiesReceived(expectedBody);
-
- template.sendBodyAndHeader("https://localhost:" + port + "/test", expectedBody, "Content-Type", "application/xml");
-
- mockEndpoint.assertIsSatisfied();
- List<Exchange> list = mockEndpoint.getReceivedExchanges();
- Exchange exchange = list.get(0);
- Assert.assertNotNull("exchange", exchange);
-
- Message in = exchange.getIn();
- assertNotNull("in", in);
-
- Map<String, Object> headers = in.getHeaders();
-
- log.info("Headers: " + headers);
-
- assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
- }
-
- @Test
- public void testEndpointWithoutHttps() {
- mockEndpoint.reset();
- try {
- template.sendBodyAndHeader("http://localhost:" + port + "/test", expectedBody, "Content-Type", "application/xml");
- fail("expect exception on access to https endpoint via http");
- } catch (RuntimeCamelException expected) {
- }
- assertTrue("mock endpoint was not called", mockEndpoint.getExchanges().isEmpty());
- }
-
- public Integer getPort() {
- return port;
- }
-
- @Resource(name = "dynaPort")
- public void setPort(Integer port) {
- this.port = port;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
deleted file mode 100644
index 3b26744..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionRedeliveryTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.net.ConnectException;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * @version
- */
-public class SpringJettyNoConnectionRedeliveryTest extends CamelSpringTestSupport {
-
- @Override
- protected AbstractXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/component/jetty/jetty-noconnection-redelivery.xml");
- }
-
- @Test
- public void testConnectionOk() throws Exception {
- String reply = template.requestBody("direct:start", "World", String.class);
- assertEquals("Bye World", reply);
- }
-
- @Test
- public void testConnectionNotOk() throws Exception {
- // stop Jetty route so there should not be a connection
- context.stopRoute("jetty");
-
- Exchange exchange = template.request("direct:start", new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody("Moon");
- }
- });
-
- assertTrue(exchange.isFailed());
-
- // there should be a connect exception as cause
- ConnectException ce = exchange.getException(ConnectException.class);
- assertNotNull(ce);
-
- assertEquals(true, exchange.getIn().getHeader(Exchange.REDELIVERED));
- assertEquals(4, exchange.getIn().getHeader(Exchange.REDELIVERY_COUNTER));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
deleted file mode 100644
index fd5eae0..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringJettyNoConnectionTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.net.ConnectException;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * @version
- */
-public class SpringJettyNoConnectionTest extends CamelSpringTestSupport {
-
- @Override
- protected AbstractXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/component/jetty/jetty-noconnection.xml");
- }
-
- @Test
- public void testConnectionOk() throws Exception {
- String reply = template.requestBody("direct:start", "World", String.class);
- assertEquals("Bye World", reply);
- }
-
- @Test
- public void testConnectionNotOk() throws Exception {
- // stop Jetty route so there should not be a connection
- context.stopRoute("jetty");
-
- try {
- template.requestBody("direct:start", "Moon", String.class);
- fail("Should have thrown an exception");
- } catch (CamelExecutionException e) {
- assertIsInstanceOf(ConnectException.class, e.getCause());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/TwoCamelContextWithJettyRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/TwoCamelContextWithJettyRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/TwoCamelContextWithJettyRouteTest.java
deleted file mode 100644
index 420ec91..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/TwoCamelContextWithJettyRouteTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty;
-
-import java.net.ConnectException;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.junit.Test;
-
-public class TwoCamelContextWithJettyRouteTest extends BaseJettyTest {
-
- private int port1;
- private int port2;
-
- @Test
- public void testTwoServerPorts() throws Exception {
- // create another camelContext
- CamelContext contextB = new DefaultCamelContext();
- contextB.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("jetty://http://localhost:" + port2 + "/myotherapp").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- String in = exchange.getIn().getBody(String.class);
- exchange.getOut().setBody("Hi " + in);
- }
- });
- }
- });
- contextB.start();
-
- String reply = template.requestBody("direct:a", "World", String.class);
- assertEquals("Bye World", reply);
-
- reply = template.requestBody("direct:b", "Camel", String.class);
- assertEquals("Hi Camel", reply);
-
- contextB.stop();
-
- reply = template.requestBody("direct:a", "Earth", String.class);
- assertEquals("Bye Earth", reply);
-
- try {
- reply = template.requestBody("direct:b", "Moon", String.class);
- // expert the exception here
- fail("Expert the exception here");
- } catch (Exception ex) {
- assertTrue("Should get the ConnectException", ex.getCause() instanceof ConnectException);
- }
-
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- port1 = getPort();
- port2 = getNextPort();
-
- from("direct:a").to("http://localhost:" + port1 + "/myapp");
-
- from("direct:b").to("http://localhost:" + port2 + "/myotherapp");
-
- from("jetty://http://localhost:" + port1 + "/myapp").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- String in = exchange.getIn().getBody(String.class);
- exchange.getOut().setBody("Bye " + in);
- }
- });
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncCBRTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncCBRTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncCBRTest.java
deleted file mode 100644
index e3f41c9..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncCBRTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty.async;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.jetty.BaseJettyTest;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class JettyAsyncCBRTest extends BaseJettyTest {
-
- @Test
- public void testJettyAsync() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-
- String reply = template.requestBody("http://localhost:{{port}}/myservice", "Hello Camel", String.class);
- assertEquals("Bye World", reply);
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- context.addComponent("async", new MyAsyncComponent());
-
- from("jetty:http://localhost:{{port}}/myservice")
- .convertBodyTo(String.class)
- .choice()
- .when(body().contains("Camel"))
- .to("async:bye:world")
- .end()
- .to("mock:result");
- }
- };
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationDisabledTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationDisabledTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationDisabledTest.java
deleted file mode 100644
index acca758..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationDisabledTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty.async;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.jetty.BaseJettyTest;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class JettyAsyncContinuationDisabledTest extends BaseJettyTest {
-
- @Test
- public void testJettyAsyncContinuationDisabled() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-
- String out = template.requestBody("http://localhost:{{port}}/myservice", null, String.class);
- assertEquals("Bye World", out);
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- context.addComponent("async", new MyAsyncComponent());
-
- from("jetty:http://localhost:{{port}}/myservice?useContinuation=false")
- .to("async:bye:world")
- .to("mock:result");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutOkTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutOkTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutOkTest.java
deleted file mode 100644
index 023d79c..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutOkTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty.async;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.jetty.BaseJettyTest;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class JettyAsyncContinuationTimeoutOkTest extends BaseJettyTest {
-
- @Test
- public void testJettyAsyncTimeoutOk() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-
- String reply = template.requestBody("http://localhost:{{port}}/myservice", null, String.class);
- assertEquals("Bye World", reply);
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- context.addComponent("async", new MyAsyncComponent());
-
- from("jetty:http://localhost:{{port}}/myservice?continuationTimeout=3000")
- .to("async:bye:world")
- .to("mock:result");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java
deleted file mode 100644
index 91c7535..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty.async;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
-import org.apache.camel.component.jetty.BaseJettyTest;
-import org.apache.camel.util.StopWatch;
-import org.junit.Test;
-
-/**
- * @version
- */
-public class JettyAsyncContinuationTimeoutTest extends BaseJettyTest {
-
- @Test
- public void testJettyAsyncTimeout() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-
- StopWatch watch = new StopWatch();
- try {
- template.requestBody("http://localhost:{{port}}/myservice", null, String.class);
- fail("Should have thrown an exception");
- } catch (CamelExecutionException e) {
- log.info("Timeout hit and client got reply with failure status code");
-
- long taken = watch.stop();
-
- HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
- assertEquals(503, cause.getStatusCode());
-
- // should be approx 3-4 sec.
- assertTrue("Timeout should occur faster than " + taken, taken < 4500);
- }
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- context.addComponent("async", new MyAsyncComponent());
-
- from("jetty:http://localhost:{{port}}/myservice?continuationTimeout=3000")
- .to("async:bye:world?delay=6000")
- .to("mock:result");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java
deleted file mode 100644
index c85d716..0000000
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty.async;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
-import org.apache.camel.component.jetty.BaseJettyTest;
-import org.apache.camel.util.StopWatch;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @version
- */
-@Ignore("This test takes a long time to run, so run it manually")
-public class JettyAsyncDefaultContinuationTimeoutTest extends BaseJettyTest {
-
- @Test
- public void testJettyAsyncTimeout() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-
- StopWatch watch = new StopWatch();
- try {
- template.requestBody("http://localhost:{{port}}/myservice", null, String.class);
- fail("Should have thrown an exception");
- } catch (CamelExecutionException e) {
- log.info("Timeout hit and client got reply with failure status code");
-
- long taken = watch.stop();
-
- HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
- assertEquals(503, cause.getStatusCode());
-
- // should be approx 30-34 sec.
- assertTrue("Timeout should occur faster than " + taken, taken < 34000);
- }
-
- assertMockEndpointsSatisfied(2, TimeUnit.MINUTES);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- context.addComponent("async", new MyAsyncComponent());
-
- from("jetty:http://localhost:{{port}}/myservice")
- .to("async:bye:world?delay=45s")
- .to("mock:result");
- }
- };
- }
-}