[2/3] camel git commit: Added test based on user forum issue
Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/91ccd598 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/91ccd598 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/91ccd598 Branch: refs/heads/master Commit: 91ccd598faa46a5432ec9adf491a9f844a4bcecc Parents: a90d28d Author: Claus IbsenAuthored: Tue Jan 17 13:41:39 2017 +0100 Committer: Claus Ibsen Committed: Tue Jan 17 13:44:06 2017 +0100 -- .../component/jetty/HttpAcceptHeaderTest.java | 43 1 file changed, 43 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/91ccd598/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAcceptHeaderTest.java -- diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAcceptHeaderTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAcceptHeaderTest.java new file mode 100644 index 000..8f4aa74 --- /dev/null +++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAcceptHeaderTest.java @@ -0,0 +1,43 @@ +/** + * 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; + +/** + * Test HTTP client sends Accept header in HTTP GET + */ +public class HttpAcceptHeaderTest extends BaseJettyTest { + +@Test +public void testAccept() throws Exception { +String out = template.requestBodyAndHeader("http://localhost:{{port}}/myaccept;, null, "Accept", "application/myjson", String.class); +assertEquals("You called me as GET and accepted: application/myjson", out); +} + +@Override +protected RouteBuilder createRouteBuilder() throws Exception { +return new RouteBuilder() { +public void configure() throws Exception { +from("jetty:http://localhost:{{port}}/myaccept;) +.transform().simple("You called me as ${header.CamelHttpMethod} and accepted: ${header.Accept}"); +} +}; +} + +}
camel git commit: Added test based on user forum issue
Repository: camel Updated Branches: refs/heads/master 68e1a5431 -> 5eb64737e Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5eb64737 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5eb64737 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5eb64737 Branch: refs/heads/master Commit: 5eb64737e4a132bc5443e99ded9b86c801854652 Parents: 68e1a54 Author: Claus IbsenAuthored: Fri Dec 2 09:38:13 2016 +0100 Committer: Claus Ibsen Committed: Fri Dec 2 09:40:12 2016 +0100 -- .../apache/camel/component/jms/JmsToDTest.java | 66 ++ .../apache/camel/component/jms/JmsToTest.java | 70 2 files changed, 136 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/5eb64737/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsToDTest.java -- diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsToDTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsToDTest.java new file mode 100644 index 000..6ce004c --- /dev/null +++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsToDTest.java @@ -0,0 +1,66 @@ +/** + * 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.jms; + +import javax.jms.ConnectionFactory; + +import org.apache.camel.CamelContext; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge; + +/** + * @version + */ +public class JmsToDTest extends CamelTestSupport { + +@Test +public void testToD() throws Exception { +getMockEndpoint("mock:bar").expectedBodiesReceived("Hello bar"); +getMockEndpoint("mock:beer").expectedBodiesReceived("Hello beer"); + +template.sendBodyAndHeader("direct:start", "Hello bar", "where", "bar"); +template.sendBodyAndHeader("direct:start", "Hello beer", "where", "beer"); + +assertMockEndpointsSatisfied(); +} + +protected CamelContext createCamelContext() throws Exception { +CamelContext camelContext = super.createCamelContext(); + +ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); +camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory)); + +return camelContext; +} + +@Override +protected RouteBuilder createRouteBuilder() throws Exception { +return new RouteBuilder() { +@Override +public void configure() throws Exception { +// route message dynamic using toD +from("direct:start").toD("activemq:queue:${header.where}"); + +from("activemq:queue:bar").to("mock:bar"); +from("activemq:queue:beer").to("mock:beer"); +} +}; +} +} http://git-wip-us.apache.org/repos/asf/camel/blob/5eb64737/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsToTest.java -- diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsToTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsToTest.java new file mode 100644 index 000..dbfe541 --- /dev/null +++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsToTest.java @@ -0,0 +1,70 @@ +/** + * 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
[3/4] camel git commit: Added test based on user forum issue
Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7ae4a18b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7ae4a18b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7ae4a18b Branch: refs/heads/camel-2.18.x Commit: 7ae4a18bdae6c595ae710a854cfe17b7bc5c85d4 Parents: bc67290 Author: Claus IbsenAuthored: Sat Oct 29 13:20:32 2016 +0200 Committer: Claus Ibsen Committed: Sat Oct 29 13:25:01 2016 +0200 -- .../java/org/apache/camel/language/simple/SimpleTest.java| 8 1 file changed, 8 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/7ae4a18b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java -- diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java index 2e58195..357a903 100644 --- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java +++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java @@ -1467,6 +1467,14 @@ public class SimpleTest extends LanguageTestSupport { assertExpression("${body.length}", 3); } +public void testIntArrayLength() throws Exception { +exchange.getIn().setBody(new int[]{1, 20, 300}); +assertExpression("${body[0]}", 1); +assertExpression("${body[1]}", 20); +assertExpression("${body[2]}", 300); +assertExpression("${body.length}", 3); +} + public void testSimpleMapBoolean() throws Exception { Map map = new HashMap (); exchange.getIn().setBody(map);
[3/3] camel git commit: Added test based on user forum issue
Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f554c483 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f554c483 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f554c483 Branch: refs/heads/master Commit: f554c483effb3342dde7ffcd04cf063f2e9887f8 Parents: 024898d Author: Claus IbsenAuthored: Sat Oct 29 13:20:32 2016 +0200 Committer: Claus Ibsen Committed: Sat Oct 29 13:20:32 2016 +0200 -- .../java/org/apache/camel/language/simple/SimpleTest.java| 8 1 file changed, 8 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/f554c483/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java -- diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java index 2e58195..357a903 100644 --- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java +++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java @@ -1467,6 +1467,14 @@ public class SimpleTest extends LanguageTestSupport { assertExpression("${body.length}", 3); } +public void testIntArrayLength() throws Exception { +exchange.getIn().setBody(new int[]{1, 20, 300}); +assertExpression("${body[0]}", 1); +assertExpression("${body[1]}", 20); +assertExpression("${body[2]}", 300); +assertExpression("${body.length}", 3); +} + public void testSimpleMapBoolean() throws Exception { Map map = new HashMap (); exchange.getIn().setBody(map);
[1/2] camel git commit: Added test based on user forum issue
Repository: camel Updated Branches: refs/heads/master 642f16b7b -> ab7d838b4 Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f23d5625 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f23d5625 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f23d5625 Branch: refs/heads/master Commit: f23d56258a63fa5e5e40d7bf745fe4a39c4c3e01 Parents: 642f16b Author: Claus IbsenAuthored: Fri Mar 4 13:38:17 2016 +0100 Committer: Claus Ibsen Committed: Fri Mar 4 13:38:17 2016 +0100 -- .../netty4/http/NettyHttpRedeliveryTest.java| 73 .../src/test/resources/log4j.properties | 8 +-- 2 files changed, 77 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/camel/blob/f23d5625/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpRedeliveryTest.java -- diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpRedeliveryTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpRedeliveryTest.java new file mode 100644 index 000..0f65024 --- /dev/null +++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpRedeliveryTest.java @@ -0,0 +1,73 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.netty4.http; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.apache.camel.CamelExecutionException; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; +import org.junit.Test; + +public class NettyHttpRedeliveryTest extends BaseNettyTest { + +private final CountDownLatch latch = new CountDownLatch(5); + +@Test +public void testHttpRedelivery() throws Exception { +getMockEndpoint("mock:result").expectedBodiesReceived("Bye World"); + +assertTrue(latch.await(5, TimeUnit.SECONDS)); + +context.startRoute("bar"); + +assertMockEndpointsSatisfied(); + +context.stopRoute("foo"); + +assertEquals(0, context.getInflightRepository().size()); +} + +@Override +protected RouteBuilder createRouteBuilder() throws Exception { +return new RouteBuilder() { +@Override +public void configure() throws Exception { +onException(Exception.class) + .maximumRedeliveries(50).redeliveryDelay(100).onExceptionOccurred(new Processor() { +@Override +public void process(Exchange exchange) throws Exception { +// signal to start the route (after 5 attempts) +latch.countDown(); +// and there is only 1 inflight +assertEquals(1, context.getInflightRepository().size()); +} +}); + +from("timer:foo").routeId("foo") + .to("netty4-http:http://0.0.0.0:{{port}}/bar?keepAlive=false=true;) +.to("mock:result"); + + from("netty4-http:http://0.0.0.0:{{port}}/bar;).routeId("bar").autoStartup(false) +.setBody().constant("Bye World"); +} +}; +} + +} http://git-wip-us.apache.org/repos/asf/camel/blob/f23d5625/components/camel-netty4-http/src/test/resources/log4j.properties -- diff --git a/components/camel-netty4-http/src/test/resources/log4j.properties b/components/camel-netty4-http/src/test/resources/log4j.properties index a9d61c7..6c00420 100644 --- a/components/camel-netty4-http/src/test/resources/log4j.properties +++ b/components/camel-netty4-http/src/test/resources/log4j.properties @@ -30,14 +30,14 @@
[2/2] camel git commit: Added test based on user forum issue
Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/54f1ea07 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/54f1ea07 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/54f1ea07 Branch: refs/heads/camel-2.16.x Commit: 54f1ea076d83912021df8fe27a9151ab993f1068 Parents: 618f8f7 Author: Claus IbsenAuthored: Mon Dec 14 10:19:24 2015 +0100 Committer: Claus Ibsen Committed: Mon Dec 14 10:19:42 2015 +0100 -- .../sql/SqlProducerWhereIssueTest.java | 84 1 file changed, 84 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/54f1ea07/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerWhereIssueTest.java -- diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerWhereIssueTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerWhereIssueTest.java new file mode 100644 index 000..bd41bb3 --- /dev/null +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerWhereIssueTest.java @@ -0,0 +1,84 @@ +/** + * 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.sql; + +import java.util.List; +import java.util.Map; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; + +public class SqlProducerWhereIssueTest extends CamelTestSupport { + +private EmbeddedDatabase db; + +@Before +public void setUp() throws Exception { +db = new EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build(); + +super.setUp(); +} + +@After +public void tearDown() throws Exception { +super.tearDown(); + +db.shutdown(); +} + +@Test +public void testQueryWhereIssue() throws InterruptedException { +MockEndpoint mock = getMockEndpoint("mock:query"); +mock.expectedMessageCount(1); + +template.requestBodyAndHeader("direct:query", "Hi there!", "lowId", "1"); + +assertMockEndpointsSatisfied(); + +List list = mock.getReceivedExchanges().get(0).getIn().getBody(List.class); +Map row = (Map) list.get(0); +assertEquals("ASF", row.get("LICENSE")); +assertEquals(2, row.get("ROWCOUNT")); +row = (Map) list.get(1); +assertEquals("XXX", row.get("LICENSE")); +assertEquals(1, row.get("ROWCOUNT")); +} + +@Override +protected RouteBuilder createRouteBuilder() throws Exception { +return new RouteBuilder() { +@Override +public void configure() throws Exception { +// required for the sql component +getContext().getComponent("sql", SqlComponent.class).setDataSource(db); + +from("direct:query") +.to("sql:select count(*) rowcount, license from projects where id=:#lowId or id=2 or id=3 group by license") +.to("log:query") +.to("mock:query"); +} +}; +} +}
[1/2] camel git commit: Added test based on user forum issue
Repository: camel Updated Branches: refs/heads/camel-2.16.x 618f8f7fb -> 54f1ea076 refs/heads/master 2f3b75bb4 -> c2c2cdd4e Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c2c2cdd4 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c2c2cdd4 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c2c2cdd4 Branch: refs/heads/master Commit: c2c2cdd4ec12ad0ca22bc2ac5317d866b74e7e44 Parents: 2f3b75b Author: Claus IbsenAuthored: Mon Dec 14 10:19:24 2015 +0100 Committer: Claus Ibsen Committed: Mon Dec 14 10:19:24 2015 +0100 -- .../sql/SqlProducerWhereIssueTest.java | 84 1 file changed, 84 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/c2c2cdd4/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerWhereIssueTest.java -- diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerWhereIssueTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerWhereIssueTest.java new file mode 100644 index 000..bd41bb3 --- /dev/null +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerWhereIssueTest.java @@ -0,0 +1,84 @@ +/** + * 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.sql; + +import java.util.List; +import java.util.Map; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; + +public class SqlProducerWhereIssueTest extends CamelTestSupport { + +private EmbeddedDatabase db; + +@Before +public void setUp() throws Exception { +db = new EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build(); + +super.setUp(); +} + +@After +public void tearDown() throws Exception { +super.tearDown(); + +db.shutdown(); +} + +@Test +public void testQueryWhereIssue() throws InterruptedException { +MockEndpoint mock = getMockEndpoint("mock:query"); +mock.expectedMessageCount(1); + +template.requestBodyAndHeader("direct:query", "Hi there!", "lowId", "1"); + +assertMockEndpointsSatisfied(); + +List list = mock.getReceivedExchanges().get(0).getIn().getBody(List.class); +Map row = (Map) list.get(0); +assertEquals("ASF", row.get("LICENSE")); +assertEquals(2, row.get("ROWCOUNT")); +row = (Map) list.get(1); +assertEquals("XXX", row.get("LICENSE")); +assertEquals(1, row.get("ROWCOUNT")); +} + +@Override +protected RouteBuilder createRouteBuilder() throws Exception { +return new RouteBuilder() { +@Override +public void configure() throws Exception { +// required for the sql component +getContext().getComponent("sql", SqlComponent.class).setDataSource(db); + +from("direct:query") +.to("sql:select count(*) rowcount, license from projects where id=:#lowId or id=2 or id=3 group by license") +.to("log:query") +.to("mock:query"); +} +}; +} +}
camel git commit: Added test based on user forum issue
Repository: camel Updated Branches: refs/heads/master d37ef3577 -> 2f3b75bb4 Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2f3b75bb Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2f3b75bb Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2f3b75bb Branch: refs/heads/master Commit: 2f3b75bb46310d4a9c34cbd70448a46d814b0020 Parents: d37ef35 Author: Claus IbsenAuthored: Mon Dec 14 10:03:14 2015 +0100 Committer: Claus Ibsen Committed: Mon Dec 14 10:03:14 2015 +0100 -- .../SqlProducerOutputHeaderWithQueryTest.java | 74 1 file changed, 74 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/2f3b75bb/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderWithQueryTest.java -- diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderWithQueryTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderWithQueryTest.java new file mode 100644 index 000..6d103f9 --- /dev/null +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderWithQueryTest.java @@ -0,0 +1,74 @@ +/** + * 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.sql; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; + +public class SqlProducerOutputHeaderWithQueryTest extends CamelTestSupport { + +private EmbeddedDatabase db; + +@Before +public void setUp() throws Exception { +db = new EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build(); + +super.setUp(); +} + +@After +public void tearDown() throws Exception { +super.tearDown(); + +db.shutdown(); +} + +@Test +public void testQueryOutputHeader() throws InterruptedException { +MockEndpoint mock = getMockEndpoint("mock:query"); +mock.expectedMessageCount(1); +mock.expectedHeaderReceived(SqlConstants.SQL_ROW_COUNT, 1); +mock.expectedHeaderReceived("TheProjectID", 1); +mock.message(0).body().isEqualTo("Hi there!"); + +template.requestBodyAndHeader("direct:query", "Hi there!", "myProject", "Camel"); + +assertMockEndpointsSatisfied(); +} + +@Override +protected RouteBuilder createRouteBuilder() throws Exception { +return new RouteBuilder() { +@Override +public void configure() throws Exception { +// required for the sql component +getContext().getComponent("sql", SqlComponent.class).setDataSource(db); + +from("direct:query") +.to("sql:select id from projects where project = :#myProject?outputType=SelectOne=TheProjectID").to("mock:query"); +} +}; +} +}
camel git commit: Added test based on user forum issue
Repository: camel Updated Branches: refs/heads/camel-2.16.x 0105fec84 -> 618f8f7fb Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/618f8f7f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/618f8f7f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/618f8f7f Branch: refs/heads/camel-2.16.x Commit: 618f8f7fbf092691ac5808b1b304efd4e74fd274 Parents: 0105fec Author: Claus IbsenAuthored: Mon Dec 14 10:03:14 2015 +0100 Committer: Claus Ibsen Committed: Mon Dec 14 10:03:54 2015 +0100 -- .../SqlProducerOutputHeaderWithQueryTest.java | 74 1 file changed, 74 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/618f8f7f/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderWithQueryTest.java -- diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderWithQueryTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderWithQueryTest.java new file mode 100644 index 000..6d103f9 --- /dev/null +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderWithQueryTest.java @@ -0,0 +1,74 @@ +/** + * 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.sql; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; + +public class SqlProducerOutputHeaderWithQueryTest extends CamelTestSupport { + +private EmbeddedDatabase db; + +@Before +public void setUp() throws Exception { +db = new EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build(); + +super.setUp(); +} + +@After +public void tearDown() throws Exception { +super.tearDown(); + +db.shutdown(); +} + +@Test +public void testQueryOutputHeader() throws InterruptedException { +MockEndpoint mock = getMockEndpoint("mock:query"); +mock.expectedMessageCount(1); +mock.expectedHeaderReceived(SqlConstants.SQL_ROW_COUNT, 1); +mock.expectedHeaderReceived("TheProjectID", 1); +mock.message(0).body().isEqualTo("Hi there!"); + +template.requestBodyAndHeader("direct:query", "Hi there!", "myProject", "Camel"); + +assertMockEndpointsSatisfied(); +} + +@Override +protected RouteBuilder createRouteBuilder() throws Exception { +return new RouteBuilder() { +@Override +public void configure() throws Exception { +// required for the sql component +getContext().getComponent("sql", SqlComponent.class).setDataSource(db); + +from("direct:query") +.to("sql:select id from projects where project = :#myProject?outputType=SelectOne=TheProjectID").to("mock:query"); +} +}; +} +}
camel git commit: Added test based on user forum issue
Repository: camel Updated Branches: refs/heads/master b925b0174 -> 1a7cce0f2 Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1a7cce0f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1a7cce0f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1a7cce0f Branch: refs/heads/master Commit: 1a7cce0f26fba19ef9e870f66efc8b7c0f85f4f5 Parents: b925b01 Author: Claus IbsenAuthored: Thu Dec 10 16:59:42 2015 +0100 Committer: Claus Ibsen Committed: Thu Dec 10 16:59:42 2015 +0100 -- .../component/sql/SpringSqlMultilineTest.java | 45 .../component/sql/SpringSqlMultilineTest.xml| 43 +++ 2 files changed, 88 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/1a7cce0f/components/camel-sql/src/test/java/org/apache/camel/component/sql/SpringSqlMultilineTest.java -- diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SpringSqlMultilineTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SpringSqlMultilineTest.java new file mode 100755 index 000..536ba0f --- /dev/null +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SpringSqlMultilineTest.java @@ -0,0 +1,45 @@ +/** + * 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.sql; + +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.spring.CamelSpringTestSupport; +import org.junit.Test; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @version + */ +public class SpringSqlMultilineTest extends CamelSpringTestSupport { + +@Override +protected AbstractApplicationContext createApplicationContext() { +return new ClassPathXmlApplicationContext("org/apache/camel/component/sql/SpringSqlMultilineTest.xml"); +} + +@Test +public void testSQLEndpoint() throws Exception { +MockEndpoint mock = getMockEndpoint("mock:result"); +mock.expectedMessageCount(2); + +template.sendBody("direct:start", ""); + +assertMockEndpointsSatisfied(); +} + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/1a7cce0f/components/camel-sql/src/test/resources/org/apache/camel/component/sql/SpringSqlMultilineTest.xml -- diff --git a/components/camel-sql/src/test/resources/org/apache/camel/component/sql/SpringSqlMultilineTest.xml b/components/camel-sql/src/test/resources/org/apache/camel/component/sql/SpringSqlMultilineTest.xml new file mode 100644 index 000..bef92b9 --- /dev/null +++ b/components/camel-sql/src/test/resources/org/apache/camel/component/sql/SpringSqlMultilineTest.xml @@ -0,0 +1,43 @@ + + +http://www.springframework.org/schema/beans; + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; + xmlns:jdbc="http://www.springframework.org/schema/jdbc; + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd;> + + + + + + + http://camel.apache.org/schema/spring;> + + + + + +body + + + + + +
camel git commit: Added test based on user forum issue
Repository: camel Updated Branches: refs/heads/master 76b4f4db5 - fc08511dd Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fc08511d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fc08511d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fc08511d Branch: refs/heads/master Commit: fc08511dd7cbff9009976721a232b775af6a4aeb Parents: 76b4f4d Author: Claus Ibsen davscl...@apache.org Authored: Sat Jun 6 11:40:12 2015 +0200 Committer: Claus Ibsen davscl...@apache.org Committed: Sat Jun 6 11:40:12 2015 +0200 -- .../apache/camel/language/simple/SimpleTest.java | 18 ++ 1 file changed, 18 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/fc08511d/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java -- diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java index 5545dc2..c73fbfe 100644 --- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java +++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java @@ -1422,6 +1422,24 @@ public class SimpleTest extends LanguageTestSupport { assertPredicate(${body['isCredit']} == false, true); } +public void testSimpleRegexp() throws Exception { +exchange.getIn().setBody(12345678); +assertPredicate(${body} regex '\\d+', true); +assertPredicate(${body} regex '\\w{1,4}', false); + +exchange.getIn().setBody(tel:+97444549697); +assertPredicate(${body} regex '^(tel:\\+)(974)(44)(\\d+)|^(974)(44)(\\d+)', true); + +exchange.getIn().setBody(97444549697); +assertPredicate(${body} regex '^(tel:\\+)(974)(44)(\\d+)|^(974)(44)(\\d+)', true); + +exchange.getIn().setBody(tel:+87444549697); +assertPredicate(${body} regex '^(tel:\\+)(974)(44)(\\d+)|^(974)(44)(\\d+)', false); + +exchange.getIn().setBody(87444549697); +assertPredicate(${body} regex '^(tel:\\+)(974)(44)(\\d+)|^(974)(44)(\\d+)', false); +} + protected String getLanguageName() { return simple; }
camel git commit: Added test based on user forum issue
Repository: camel Updated Branches: refs/heads/master 601ea3afd - 76c6a275e Added test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/76c6a275 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/76c6a275 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/76c6a275 Branch: refs/heads/master Commit: 76c6a275e49960a6011c0c13102877c0ccf61366 Parents: 601ea3a Author: Claus Ibsen davscl...@apache.org Authored: Thu Jan 15 09:43:38 2015 +0100 Committer: Claus Ibsen davscl...@apache.org Committed: Thu Jan 15 09:43:51 2015 +0100 -- .../NettyCustomCodecRequestTimeoutTest.java | 69 1 file changed, 69 insertions(+) -- http://git-wip-us.apache.org/repos/asf/camel/blob/76c6a275/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyCustomCodecRequestTimeoutTest.java -- diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyCustomCodecRequestTimeoutTest.java b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyCustomCodecRequestTimeoutTest.java new file mode 100644 index 000..2f28f67 --- /dev/null +++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyCustomCodecRequestTimeoutTest.java @@ -0,0 +1,69 @@ +/** + * 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.netty; + +import org.apache.camel.CamelExecutionException; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.impl.JndiRegistry; +import org.jboss.netty.handler.timeout.ReadTimeoutException; +import org.junit.Test; + +public class NettyCustomCodecRequestTimeoutTest extends BaseNettyTest { + +private String uri = netty:tcp://localhost:{{port}}?sync=true ++ decoders=#myCustomDecoder,#myCustomDecoder2encoder=#myCustomEncoderrequestTimeout=1000; + +// use reaadble bytes +private byte[] data = new byte[]{65, 66, 67, 68, 69, 70, 71, 72, 73, 0, 0}; + +@Override +protected JndiRegistry createRegistry() throws Exception { +JndiRegistry jndi = super.createRegistry(); +jndi.bind(myCustomDecoder, MyCustomCodec.createMyCustomDecoder()); +jndi.bind(myCustomDecoder2, MyCustomCodec.createMyCustomDecoder2()); +jndi.bind(myCustomEncoder, MyCustomCodec.createMyCustomEncoder()); +return jndi; +} + +@Test +public void testRequestTimeout() throws Exception { +try { +template.requestBody(direct:start, data, String.class); +fail(Should have thrown exception); +} catch (CamelExecutionException e) { +ReadTimeoutException cause = assertIsInstanceOf(ReadTimeoutException.class, e.getCause()); +assertNotNull(cause); +} +} + +@Override +protected RouteBuilder createRouteBuilder() throws Exception { +return new RouteBuilder() { +@Override +public void configure() throws Exception { +from(direct:start) +.to(uri) +.to(log:result); + +from(uri) +.to(log:before) +.delayer(2000) +.to(log:after); +} +}; +} +}