http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncFilterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncFilterTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncFilterTest.java deleted file mode 100644 index 07614f7..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncFilterTest.java +++ /dev/null @@ -1,54 +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 JettyAsyncFilterTest 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) - .filter(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/JettyAsyncTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTest.java deleted file mode 100644 index e082076..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTest.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 JettyAsyncTest extends BaseJettyTest { - - @Test - public void testJettyAsync() 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") - .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/JettyAsyncThrottleTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncThrottleTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncThrottleTest.java deleted file mode 100644 index 890e3dd..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncThrottleTest.java +++ /dev/null @@ -1,76 +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.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * CAMEL-4795, there should be no exceptions in the logs (before the fix there was a NPE) - * - * @version - */ -public class JettyAsyncThrottleTest extends BaseJettyTest { - - @Test - public void testJettyAsync() throws Exception { - getMockEndpoint("mock:result").expectedMessageCount(5); - - template.asyncRequestBody("jetty:http://localhost:{{port}}/myservice", null); - template.asyncRequestBody("jetty:http://localhost:{{port}}/myservice", null); - template.asyncRequestBody("jetty:http://localhost:{{port}}/myservice", null); - template.asyncRequestBody("jetty:http://localhost:{{port}}/myservice", null); - template.asyncRequestBody("jetty:http://localhost:{{port}}/myservice", null); - - assertMockEndpointsSatisfied(); - - for (int i = 0; i < 5; i++) { - Exchange exchange = getMockEndpoint("mock:result").getReceivedExchanges().get(i); - log.info("Reply " + exchange); - } - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - int port2 = getNextPort(); - int port3 = getNextPort(); - - from("jetty:http://localhost:{{port}}/myservice") - .removeHeaders("*") - .throttle(2).asyncDelayed() - .loadBalance().failover() - .to("jetty:http://localhost:" + port2 + "/foo") - .to("jetty:http://localhost:" + port3 + "/bar") - .end() - .to("mock:result"); - - from("jetty:http://localhost:" + port2 + "/foo") - .transform().constant("foo") - .to("mock:foo"); - - from("jetty:http://localhost:" + port3 + "/bar") - .transform().constant("bar") - .to("mock:bar"); - } - }; - } -} \ 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/JettyAsyncTransformTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTransformTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTransformTest.java deleted file mode 100644 index 7755f36..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTransformTest.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 JettyAsyncTransformTest extends BaseJettyTest { - - @Test - public void testJettyAsync() 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") - .to("log:foo") - .convertBodyTo(String.class) - .transform(constant("Hello World")) - .to("async:hi:world") - .transform(constant("Bye World")) - .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/JettyAsyncTryCatchFinallyTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTryCatchFinallyTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTryCatchFinallyTest.java deleted file mode 100644 index 8993de4..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncTryCatchFinallyTest.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.async; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * @version - */ -public class JettyAsyncTryCatchFinallyTest extends BaseJettyTest { - - @Test - public void testJettyAsync() throws Exception { - getMockEndpoint("mock:try").expectedBodiesReceived("Hello Camel"); - getMockEndpoint("mock:catch").expectedBodiesReceived("Hello Camel"); - getMockEndpoint("mock:finally").expectedBodiesReceived("Bye Camel"); - 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) - .doTry() - .to("mock:try") - .throwException(new IllegalArgumentException("Damn")) - .doCatch(IllegalArgumentException.class) - .to("mock:catch") - .to("async:bye:camel") - .doFinally() - .to("mock:finally") - .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/MyAsyncComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncComponent.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncComponent.java deleted file mode 100644 index 7daa4d4..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncComponent.java +++ /dev/null @@ -1,48 +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.Map; - -import org.apache.camel.Endpoint; -import org.apache.camel.impl.DefaultComponent; - -/** - * @version - */ -public class MyAsyncComponent extends DefaultComponent { - - @Override - protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - MyAsyncEndpoint answer = new MyAsyncEndpoint(uri, this); - answer.setReply(prepareReply(remaining)); - setProperties(answer, parameters); - return answer; - } - - private String prepareReply(String value) { - // to make URIs valid we make the conventions of using ':' for ' ' and - // capitalize words - String[] words = value.split(":"); - String result = ""; - for (String word : words) { - result += result.isEmpty() ? "" : " "; - result += word.substring(0, 1).toUpperCase() + word.substring(1); - } - return result; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncEndpoint.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncEndpoint.java deleted file mode 100644 index de729cc..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncEndpoint.java +++ /dev/null @@ -1,74 +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.Component; -import org.apache.camel.Consumer; -import org.apache.camel.Processor; -import org.apache.camel.Producer; -import org.apache.camel.impl.DefaultEndpoint; - -/** - * @version - */ -public class MyAsyncEndpoint extends DefaultEndpoint { - - private String reply; - private long delay = 1000; - private int failFirstAttempts; - - public MyAsyncEndpoint(String endpointUri, Component component) { - super(endpointUri, component); - } - - public Producer createProducer() throws Exception { - return new MyAsyncProducer(this); - } - - public Consumer createConsumer(Processor processor) throws Exception { - throw new UnsupportedOperationException("Consumer not supported"); - } - - public boolean isSingleton() { - return false; - } - - public String getReply() { - return reply; - } - - public void setReply(String reply) { - this.reply = reply; - } - - public long getDelay() { - return delay; - } - - public void setDelay(long delay) { - this.delay = delay; - } - - public int getFailFirstAttempts() { - return failFirstAttempts; - } - - public void setFailFirstAttempts(int failFirstAttempts) { - this.failFirstAttempts = failFirstAttempts; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncProducer.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncProducer.java deleted file mode 100644 index 2af5747..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/async/MyAsyncProducer.java +++ /dev/null @@ -1,75 +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.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.CamelExchangeException; -import org.apache.camel.Exchange; -import org.apache.camel.impl.DefaultAsyncProducer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @version - */ -public class MyAsyncProducer extends DefaultAsyncProducer { - - private static final Logger LOG = LoggerFactory.getLogger(MyAsyncProducer.class); - private final ExecutorService executor = Executors.newCachedThreadPool(); - private final AtomicInteger counter = new AtomicInteger(); - - public MyAsyncProducer(MyAsyncEndpoint endpoint) { - super(endpoint); - } - - public MyAsyncEndpoint getEndpoint() { - return (MyAsyncEndpoint) super.getEndpoint(); - } - - public boolean process(final Exchange exchange, final AsyncCallback callback) { - executor.submit(new Callable<Object>() { - public Object call() throws Exception { - LOG.info("Simulating a task which takes " + getEndpoint().getDelay() + " millis to reply"); - Thread.sleep(getEndpoint().getDelay()); - - int count = counter.incrementAndGet(); - if (getEndpoint().getFailFirstAttempts() >= count) { - LOG.info("Simulating a failure at attempt " + count); - exchange.setException(new CamelExchangeException("Simulated error at attempt " + count, exchange)); - } else { - String reply = getEndpoint().getReply(); - exchange.getOut().setBody(reply); - LOG.info("Setting reply " + reply); - } - - LOG.info("Callback done(false)"); - callback.done(false); - return null; - } - }); - - // indicate from this point forward its being routed asynchronously - LOG.info("Task submitted, now tell Camel routing engine to that this Exchange is being continued asynchronously"); - return false; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/file/JettyFileConsumerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/file/JettyFileConsumerTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/file/JettyFileConsumerTest.java deleted file mode 100644 index 6dce131..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/file/JettyFileConsumerTest.java +++ /dev/null @@ -1,106 +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.file; - -import java.io.File; -import java.io.FileInputStream; - -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Before; -import org.junit.Test; - -public class JettyFileConsumerTest extends BaseJettyTest { - - @Override - @Before - public void setUp() throws Exception { - deleteDirectory("target/binary"); - deleteDirectory("target/test"); - super.setUp(); - } - - private void testingSendingFile(File src) throws Exception { - deleteDirectory("target/test"); - FileInputStream fis = new FileInputStream(src); - String response = template.requestBody("http://localhost:{{port}}/myapp/myservice", fis, String.class); - assertEquals("Response should be OK ", "OK", response); - File des = new File("target/test/temp.xml"); - assertTrue("The uploaded file should exists", des.exists()); - assertEquals("This two file should have same size", src.length(), des.length()); - } - - @Test - public void testSending4K() throws Exception { - File src = new File("src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java"); - testingSendingFile(src); - } - - @Test - public void testSending18k() throws Exception { - File src = new File("src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java"); - testingSendingFile(src); - } - - @Test - public void testSendBinaryFile() throws Exception { - deleteDirectory("target/test"); - File jpg = new File("src/test/resources/java.jpg"); - String response = template.requestBody("http://localhost:{{port}}/myapp/myservice2", jpg, String.class); - assertEquals("Response should be OK ", "OK", response); - File des = new File("target/test/java.jpg"); - assertTrue("The uploaded file should exists", des.exists()); - assertEquals("This two file should have same size", jpg.length(), des.length()); - } - - @Test - public void testSendBinaryFileUsingCamelRoute() throws Exception { - getMockEndpoint("mock:result").expectedMessageCount(1); - - File jpg = new File("src/test/resources/java.jpg"); - template.sendBodyAndHeader("file://target/binary", jpg, Exchange.FILE_NAME, "java.jpg"); - - assertMockEndpointsSatisfied(); - Thread.sleep(1000); - - File des = new File("target/test/java.jpg"); - assertTrue("The uploaded file should exists", des.exists()); - assertEquals("This two file should have same size", jpg.length(), des.length()); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("jetty:http://localhost:{{port}}/myapp/myservice") - .to("file://target/test?fileName=temp.xml") - .setBody(constant("OK")); - - from("jetty:http://localhost:{{port}}/myapp/myservice2") - .to("log:foo?showAll=true") - .to("file://target/test?fileName=java.jpg") - .setBody(constant("OK")); - - from("file://target/binary?noop=true") - .to("http://localhost:{{port}}/myapp/myservice2") - .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/javabody/HttpJavaBodyTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java deleted file mode 100644 index b55d938..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java +++ /dev/null @@ -1,126 +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.javabody; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.http.HttpConstants; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * @version - */ -public class HttpJavaBodyTest extends BaseJettyTest { - - @Override - public boolean isUseRouteBuilder() { - return false; - } - - @Test - public void testHttpSendJavaBodyAndReceiveString() throws Exception { - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("jetty:http://localhost:{{port}}/myapp/myservice") - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - MyCoolBean cool = exchange.getIn().getBody(MyCoolBean.class); - assertNotNull(cool); - - assertEquals(123, cool.getId()); - assertEquals("Camel", cool.getName()); - - // we send back plain test - exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "text/plain"); - exchange.getOut().setBody("OK"); - } - }); - } - }); - context.start(); - - MyCoolBean cool = new MyCoolBean(123, "Camel"); - - String reply = template.requestBodyAndHeader("http://localhost:{{port}}/myapp/myservice", cool, - Exchange.CONTENT_TYPE, HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, String.class); - - assertEquals("OK", reply); - } - - @Test - public void testHttpSendJavaBodyAndReceiveJavaBody() throws Exception { - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("jetty:http://localhost:{{port}}/myapp/myservice") - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - MyCoolBean cool = exchange.getIn().getBody(MyCoolBean.class); - assertNotNull(cool); - - assertEquals(123, cool.getId()); - assertEquals("Camel", cool.getName()); - - MyCoolBean reply = new MyCoolBean(456, "Camel rocks"); - exchange.getOut().setBody(reply); - exchange.getOut().setHeader(Exchange.CONTENT_TYPE, HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT); - } - }); - } - }); - context.start(); - - MyCoolBean cool = new MyCoolBean(123, "Camel"); - - MyCoolBean reply = template.requestBodyAndHeader("http://localhost:{{port}}/myapp/myservice", cool, - Exchange.CONTENT_TYPE, HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, MyCoolBean.class); - - assertEquals(456, reply.getId()); - assertEquals("Camel rocks", reply.getName()); - } - - @Test - public void testHttpSendStringAndReceiveJavaBody() throws Exception { - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("jetty:http://localhost:{{port}}/myapp/myservice") - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - String body = exchange.getIn().getBody(String.class); - assertNotNull(body); - assertEquals("Hello World", body); - - MyCoolBean reply = new MyCoolBean(456, "Camel rocks"); - exchange.getOut().setBody(reply); - exchange.getOut().setHeader(Exchange.CONTENT_TYPE, HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT); - } - }); - } - }); - context.start(); - - MyCoolBean reply = template.requestBody("http://localhost:{{port}}/myapp/myservice", "Hello World", MyCoolBean.class); - - assertEquals(456, reply.getId()); - assertEquals("Camel rocks", reply.getName()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/MyCoolBean.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/MyCoolBean.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/MyCoolBean.java deleted file mode 100644 index 0700fca..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/MyCoolBean.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.javabody; - -import java.io.Serializable; - -/** - * @version - */ -public class MyCoolBean implements Serializable { - - private static final long serialVersionUID = 1L; - private final int id; - private final String name; - - public MyCoolBean(int id, String name) { - this.id = id; - this.name = name; - } - - public int getId() { - return id; - } - - public String getName() { - return name; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerRecipientListCustomThreadPoolTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerRecipientListCustomThreadPoolTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerRecipientListCustomThreadPoolTest.java deleted file mode 100644 index 1036a35..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerRecipientListCustomThreadPoolTest.java +++ /dev/null @@ -1,70 +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.jettyproducer; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * @version - */ -public class HttpJettyProducerRecipientListCustomThreadPoolTest extends BaseJettyTest { - - @Test - public void testRecipientList() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - Exchange a = template.request("direct:a", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("slip", "jetty://http://localhost:" + getPort() + "/myapp?foo=123&bar=cheese&httpClientMinThreads=4&httpClientMaxThreads=8"); - } - }); - assertNotNull(a); - - assertEquals("Bye cheese", a.getOut().getBody(String.class)); - assertEquals(246, a.getOut().getHeader("foo", Integer.class).intValue()); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:a").recipientList(header("slip")); - - from("jetty://http://localhost:{{port}}/myapp").process(new Processor() { - public void process(Exchange exchange) throws Exception { - int foo = exchange.getIn().getHeader("foo", Integer.class); - String bar = exchange.getIn().getHeader("bar", String.class); - - exchange.getOut().setHeader("foo", foo * 2); - exchange.getOut().setBody("Bye " + bar); - } - }); - } - }; - } -} \ 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/jettyproducer/HttpJettyProducerRecipientListTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerRecipientListTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerRecipientListTest.java deleted file mode 100644 index 89d817e..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerRecipientListTest.java +++ /dev/null @@ -1,70 +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.jettyproducer; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * @version - */ -public class HttpJettyProducerRecipientListTest extends BaseJettyTest { - - @Test - public void testRecipientList() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - Exchange a = template.request("direct:a", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader("slip", "jetty://http://localhost:" + getPort() + "/myapp?foo=123&bar=cheese"); - } - }); - assertNotNull(a); - - assertEquals("Bye cheese", a.getOut().getBody(String.class)); - assertEquals(246, a.getOut().getHeader("foo", Integer.class).intValue()); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:a").recipientList(header("slip")); - - from("jetty://http://localhost:{{port}}/myapp").process(new Processor() { - public void process(Exchange exchange) throws Exception { - int foo = exchange.getIn().getHeader("foo", Integer.class); - String bar = exchange.getIn().getHeader("bar", String.class); - - exchange.getOut().setHeader("foo", foo * 2); - exchange.getOut().setBody("Bye " + bar); - } - }); - } - }; - } -} \ 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/jettyproducer/HttpJettyProducerTwoEndpointTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerTwoEndpointTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerTwoEndpointTest.java deleted file mode 100644 index bae3655..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerTwoEndpointTest.java +++ /dev/null @@ -1,76 +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.jettyproducer; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * @version - */ -public class HttpJettyProducerTwoEndpointTest extends BaseJettyTest { - - @Test - public void testTwoEndpoints() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - Exchange a = template.request("direct:a", null); - assertNotNull(a); - - Exchange b = template.request("direct:b", null); - assertNotNull(b); - - assertEquals("Bye cheese", a.getOut().getBody(String.class)); - assertEquals(246, a.getOut().getHeader("foo", Integer.class).intValue()); - - assertEquals("Bye cake", b.getOut().getBody(String.class)); - assertEquals(912, b.getOut().getHeader("foo", Integer.class).intValue()); - - assertEquals(5, context.getEndpoints().size()); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:a").to("jetty://http://localhost:{{port}}/myapp?foo=123&bar=cheese"); - - from("direct:b").to("jetty://http://localhost:{{port}}/myapp?foo=456&bar=cake"); - - from("jetty://http://localhost:{{port}}/myapp").process(new Processor() { - public void process(Exchange exchange) throws Exception { - int foo = exchange.getIn().getHeader("foo", Integer.class); - String bar = exchange.getIn().getHeader("bar", String.class); - - exchange.getOut().setHeader("foo", foo * 2); - exchange.getOut().setBody("Bye " + bar); - } - }); - } - }; - } -} \ 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/jettyproducer/HttpJettyProducerTwoParametersWithSameKeyTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerTwoParametersWithSameKeyTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerTwoParametersWithSameKeyTest.java deleted file mode 100644 index 0b9ea95..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyProducerTwoParametersWithSameKeyTest.java +++ /dev/null @@ -1,119 +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.jettyproducer; - -import java.util.ArrayList; -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.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * - */ -public class HttpJettyProducerTwoParametersWithSameKeyTest extends BaseJettyTest { - - @Test - public void testTwoParametersWithSameKey() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - Exchange out = template.request("jetty:http://localhost:{{port}}/myapp?from=me&to=foo&to=bar", null); - - assertNotNull(out); - assertFalse("Should not fail", out.isFailed()); - assertEquals("OK", out.getOut().getBody(String.class)); - assertEquals("yes", out.getOut().getHeader("bar")); - - List<?> foo = out.getOut().getHeader("foo", List.class); - assertEquals(2, foo.size()); - assertEquals("123", foo.get(0)); - assertEquals("456", foo.get(1)); - } - - @Test - public void testTwoHeadersWithSameKeyHeader() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - Exchange out = template.request("jetty:http://localhost:{{port}}/myapp", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setBody(null); - exchange.getIn().setHeader("from", "me"); - List<String> list = new ArrayList<String>(); - list.add("foo"); - list.add("bar"); - exchange.getIn().setHeader("to", list); - } - }); - - assertNotNull(out); - assertFalse("Should not fail", out.isFailed()); - assertEquals("OK", out.getOut().getBody(String.class)); - assertEquals("yes", out.getOut().getHeader("bar")); - - List<?> foo = out.getOut().getHeader("foo", List.class); - assertNotNull(foo); - assertEquals(2, foo.size()); - assertEquals("123", foo.get(0)); - assertEquals("456", foo.get(1)); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("jetty://http://localhost:{{port}}/myapp").process(new Processor() { - public void process(Exchange exchange) throws Exception { - String from = exchange.getIn().getHeader("from", String.class); - assertEquals("me", from); - - List<?> values = exchange.getIn().getHeader("to", List.class); - assertNotNull(values); - assertEquals(2, values.size()); - assertEquals("foo", values.get(0)); - assertEquals("bar", values.get(1)); - - // response - exchange.getOut().setBody("OK"); - // use multiple values for the foo header in the reply - List<Integer> list = new ArrayList<Integer>(); - list.add(123); - list.add(456); - exchange.getOut().setHeader("foo", list); - exchange.getOut().setHeader("bar", "yes"); - } - }); - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyUrlRewriteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyUrlRewriteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyUrlRewriteTest.java deleted file mode 100644 index e5f4fd8..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/HttpJettyUrlRewriteTest.java +++ /dev/null @@ -1,65 +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.jettyproducer; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.apache.camel.component.jetty.MyUrlRewrite; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.impl.JndiRegistry; -import org.junit.Test; - -public class HttpJettyUrlRewriteTest extends BaseJettyTest { - - private int port1; - private int port2; - - @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry jndi = super.createRegistry(); - jndi.bind("myRewrite", new MyUrlRewrite()); - return jndi; - } - - @Test - public void testUrlRewrite() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMessageCount(1); - - String response = template.requestBody("jetty:http://localhost:" + port1 + "/foo?phrase=Bye", "Camel", String.class); - assertEquals("Get a wrong response", "Bye Camel", response); - - assertMockEndpointsSatisfied(); - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() { - port1 = getPort(); - port2 = getNextPort(); - - from("jetty:http://localhost:" + port1 + "?matchOnUriPrefix=true") - .to("jetty:http://localhost:" + port2 + "?throwExceptionOnFailure=false&bridgeEndpoint=true&urlRewrite=#myRewrite"); - - from("jetty://http://localhost:" + port2 + "/bar") - .transform().simple("${header.phrase} ${body}") - .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/jettyproducer/JettyHttpProderReturnFaultTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java deleted file mode 100644 index 628cd5b..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java +++ /dev/null @@ -1,70 +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.jettyproducer; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.http.HttpOperationFailedException; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * @version - */ -public class JettyHttpProderReturnFaultTest extends BaseJettyTest { - - @Test - public void testHttpFault() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - Exchange exchange = template.request("jetty://http://localhost:{{port}}/test", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setBody("Hello World!"); - } - - }); - assertTrue(exchange.isFailed()); - HttpOperationFailedException exception = exchange.getException(HttpOperationFailedException.class); - assertNotNull(exception); - assertEquals("This is a fault", exception.getResponseBody()); - assertEquals(500, exception.getStatusCode()); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("jetty://http://localhost:{{port}}/test") - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setFault(true); - exchange.getOut().setBody("This is a fault"); - } - }); - } - }; - } -} \ 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/jettyproducer/JettyHttpProducerAsyncTimeoutTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTimeoutTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTimeoutTest.java deleted file mode 100644 index b84bc7a..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsyncTimeoutTest.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.jettyproducer; - -import org.apache.camel.ExchangeTimedOutException; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * @version - */ -public class JettyHttpProducerAsyncTimeoutTest extends BaseJettyTest { - - private String url = "jetty://http://0.0.0.0:" + getPort() + "/timeout?httpClient.timeout=2000"; - - @Test - public void testTimeout() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - getMockEndpoint("mock:result").expectedMessageCount(0); - getMockEndpoint("mock:error").expectedMessageCount(0); - getMockEndpoint("mock:timeout").expectedMessageCount(1); - - template.sendBody("direct:start", null); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - onException(Exception.class).handled(true).to("mock:error"); - onException(ExchangeTimedOutException.class).handled(true).to("mock:timeout"); - - from("direct:start").to(url).to("mock:result"); - - from(url).delay(5000).transform(constant("Bye World")); - } - }; - } -} \ 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/jettyproducer/JettyHttpProducerAsynchronousTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsynchronousTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsynchronousTest.java deleted file mode 100644 index 98ed6c5..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerAsynchronousTest.java +++ /dev/null @@ -1,97 +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.jettyproducer; - -import javax.servlet.http.HttpServletResponse; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * @version - */ -public class JettyHttpProducerAsynchronousTest extends BaseJettyTest { - - private static String thread1; - private static String thread2; - - private String url = "jetty://http://0.0.0.0:" + getPort() + "/foo"; - - @Test - public void testAsynchronous() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - thread1 = ""; - thread2 = ""; - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMessageCount(1); - mock.message(0).body().isEqualTo("Bye World"); - - Object body = null; - template.sendBody("direct:start", body); - - assertMockEndpointsSatisfied(); - - assertNotSame("Should not use same threads", thread1, thread2); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start").process(new Processor() { - public void process(Exchange exchange) throws Exception { - thread1 = Thread.currentThread().getName(); - } - }).to(url).process(new Processor() { - public void process(Exchange exchange) throws Exception { - thread2 = Thread.currentThread().getName(); - } - }).to("mock:result"); - - from(url).process(new Processor() { - public void process(Exchange exchange) throws Exception { - HttpServletResponse res = exchange.getIn().getBody(HttpServletResponse.class); - res.setStatus(200); - res.setHeader("customer", "gold"); - - // write empty string to force flushing - res.getWriter().write(""); - res.flushBuffer(); - - Thread.sleep(2000); - - res.getWriter().write("Bye World"); - res.flushBuffer(); - } - }); - } - }; - } -} \ 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/jettyproducer/JettyHttpProducerBridgePathWithSpacesAtEndTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgePathWithSpacesAtEndTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgePathWithSpacesAtEndTest.java deleted file mode 100644 index e33e2df..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgePathWithSpacesAtEndTest.java +++ /dev/null @@ -1,65 +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.jettyproducer; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * As {@link JettyHttpProducerBridgePathWithSpacesTest} but content path ends with a space - */ -public class JettyHttpProducerBridgePathWithSpacesAtEndTest extends BaseJettyTest { - - private int port1; - private int port2; - - @Test - public void testProxy() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(2000); - - String reply = template.requestBody("jetty:http://0.0.0.0:" + port1 + "/foo ", "World", String.class); - assertEquals("Bye World", reply); - - // and with more spaces - String reply2 = template.requestBody("jetty:http://0.0.0.0:" + port1 + "/foo /bar baz", "Camel", String.class); - assertEquals("Bye Camel", reply2); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - port1 = getPort(); - port2 = getNextPort(); - - from("jetty:http://0.0.0.0:" + port1 + "/foo ?matchOnUriPrefix=true") - .to("jetty:http://0.0.0.0:" + port2 + "/proxy foo ?bridgeEndpoint=true&throwExceptionOnFailure=false"); - - from("jetty:http://0.0.0.0:" + port2 + "/proxy foo ?matchOnUriPrefix=true") - .transform().simple("Bye ${body}"); - } - }; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgePathWithSpacesTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgePathWithSpacesTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgePathWithSpacesTest.java deleted file mode 100644 index 14033c6..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgePathWithSpacesTest.java +++ /dev/null @@ -1,61 +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.jettyproducer; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * - */ -public class JettyHttpProducerBridgePathWithSpacesTest extends BaseJettyTest { - - private int port1; - private int port2; - - @Test - public void testProxy() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(2000); - - String reply = template.requestBody("jetty:http://0.0.0.0:" + port1 + "/foo bar", "World", String.class); - assertEquals("Bye World", reply); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - port1 = getPort(); - port2 = getNextPort(); - - from("jetty:http://0.0.0.0:" + port1 + "/foo bar?matchOnUriPrefix=true") - .to("jetty:http://0.0.0.0:" + port2 + "/proxy bar?bridgeEndpoint=true&throwExceptionOnFailure=false"); - - from("jetty:http://0.0.0.0:" + port2 + "/proxy bar?matchOnUriPrefix=true") - .transform().simple("Bye ${body}"); - } - }; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java deleted file mode 100644 index 569c668..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java +++ /dev/null @@ -1,61 +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.jettyproducer; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * - */ -public class JettyHttpProducerBridgeTest extends BaseJettyTest { - - private int port1; - private int port2; - - @Test - public void testProxy() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(2000); - - String reply = template.requestBody("jetty:http://0.0.0.0:" + port1 + "/foo", "World", String.class); - assertEquals("Bye World", reply); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - port1 = getPort(); - port2 = getNextPort(); - - from("jetty:http://0.0.0.0:" + port1 + "/foo") - .to("jetty:http://0.0.0.0:" + port2 + "/bar?bridgeEndpoint=true&throwExceptionOnFailure=false"); - - from("jetty:http://0.0.0.0:" + port2 + "/bar") - .transform().simple("Bye ${body}"); - } - }; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a59becd7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java deleted file mode 100644 index 7289539..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java +++ /dev/null @@ -1,110 +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.jettyproducer; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.junit.Test; - -/** - * Jetty HTTP producer concurrent test. - * - * @version - */ -public class JettyHttpProducerConcurrentTest extends BaseJettyTest { - - @Test - public void testNoConcurrentProducers() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(2000); - - doSendMessages(1, 1); - } - - @Test - public void testConcurrentProducers() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(2000); - - doSendMessages(10, 5); - } - - private void doSendMessages(int files, int poolSize) throws Exception { - getMockEndpoint("mock:result").expectedMessageCount(files); - getMockEndpoint("mock:result").assertNoDuplicates(body()); - - ExecutorService executor = Executors.newFixedThreadPool(poolSize); - // we access the responses Map below only inside the main thread, - // so no need for a thread-safe Map implementation - Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>(); - for (int i = 0; i < files; i++) { - final int index = i; - Future<String> out = executor.submit(new Callable<String>() { - public String call() throws Exception { - return template.requestBody("jetty://http://localhost:{{port}}/echo", "" + index, String.class); - } - }); - responses.put(index, out); - } - - assertMockEndpointsSatisfied(); - - assertEquals(files, responses.size()); - - // get all responses - Set<String> unique = new HashSet<String>(); - for (Future<String> future : responses.values()) { - unique.add(future.get()); - } - - // should be 'files' unique responses - assertEquals("Should be " + files + " unique responses", files, unique.size()); - executor.shutdownNow(); - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - // expose a echo service - from("jetty:http://localhost:{{port}}/echo") - .convertBodyTo(String.class) - .to("log:input") - .transform(body().append(body())).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/jettyproducer/JettyHttpProducerConnectionFailureTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConnectionFailureTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConnectionFailureTest.java deleted file mode 100644 index afadc21..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConnectionFailureTest.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.jettyproducer; - -import java.io.IOException; - -import org.apache.camel.CamelExchangeException; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Unit test to verify that we can have URI options for external system (endpoint is lenient) - */ -public class JettyHttpProducerConnectionFailureTest extends BaseJettyTest { - - private String serverUri = "jetty://http://localhost:{{port}}/myservice"; - - @Test - public void testHttpGetWithParamsViaURI() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMessageCount(0); - - // give Jetty time to startup properly - Thread.sleep(1000); - - // use another port with no connection - try { - template.requestBody("jetty://http://localhost:9999/myservice", null, Object.class); - fail("Should have thrown an exception"); - } catch (Exception e) { - CamelExchangeException cause = assertIsInstanceOf(CamelExchangeException.class, e.getCause()); - assertIsInstanceOf(IOException.class, cause.getCause()); - } - - assertMockEndpointsSatisfied(); - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from(serverUri).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/jettyproducer/JettyHttpProducerContentBasedRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerContentBasedRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerContentBasedRouteTest.java deleted file mode 100644 index 53fd3a0..0000000 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerContentBasedRouteTest.java +++ /dev/null @@ -1,81 +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.jettyproducer; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jetty.BaseJettyTest; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Unit test with a simple route test. - */ -public class JettyHttpProducerContentBasedRouteTest extends BaseJettyTest { - - private String serverUri = "jetty://http://localhost:" + getPort() + "/myservice"; - - @Test - public void testSendOne() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - MockEndpoint mock = getMockEndpoint("mock:one"); - - mock.expectedHeaderReceived("one", "true"); - - template.requestBody(serverUri + "?one=true", null, Object.class); - - assertMockEndpointsSatisfied(); - } - - @Test - public void testSendOther() throws Exception { - // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } - - // give Jetty time to startup properly - Thread.sleep(1000); - - MockEndpoint mock = getMockEndpoint("mock:other"); - - mock.expectedHeaderReceived("two", "true"); - - template.requestBody(serverUri + "?two=true", null, Object.class); - - assertMockEndpointsSatisfied(); - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from(serverUri) - .choice() - .when().simple("${header.one}").to("mock:one") - .otherwise() - .to("mock:other"); - } - }; - } - -} \ No newline at end of file