Repository: camel Updated Branches: refs/heads/camel-2.15.x b7aeb46a9 -> 4f0de9ad4 refs/heads/camel-2.16.x f7530e5d8 -> 284cc14a8 refs/heads/master 883795ec1 -> 4e283f797
Added some unit test as sample code Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/be5478ad Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/be5478ad Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/be5478ad Branch: refs/heads/master Commit: be5478ad7fbf1048d24fb5d7ce801a48ce14376a Parents: 883795e Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Jan 12 11:04:30 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Jan 12 11:04:30 2016 +0100 ---------------------------------------------------------------------- .../test/patterns/SimpleMockEndpointsTest.java | 52 +++++++++++++++++ .../camel/test/patterns/SimpleMockTest.java | 46 +++++++++++++++ .../patterns/SimpleWeaveAddMockLastTest.java | 60 ++++++++++++++++++++ 3 files changed, 158 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/be5478ad/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockEndpointsTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockEndpointsTest.java b/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockEndpointsTest.java new file mode 100644 index 0000000..0af26aa --- /dev/null +++ b/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockEndpointsTest.java @@ -0,0 +1,52 @@ +/** + * 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.test.patterns; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class SimpleMockEndpointsTest extends CamelTestSupport { + + @Override + public String isMockEndpointsAndSkip() { + return "seda:queue"; + } + + @Test + public void testMockAndSkip() throws Exception { + getMockEndpoint("mock:seda:queue").expectedBodiesReceived("Bye Camel"); + + template.sendBody("seda:start", "Camel"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("seda:start") + .transform(simple("Bye ${body}")) + .to("seda:queue"); + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/be5478ad/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockTest.java b/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockTest.java new file mode 100644 index 0000000..1c3e00b --- /dev/null +++ b/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockTest.java @@ -0,0 +1,46 @@ +/** + * 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.test.patterns; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class SimpleMockTest extends CamelTestSupport { + + @Test + public void testMock() throws Exception { + getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .to("mock:result"); + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/be5478ad/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleWeaveAddMockLastTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleWeaveAddMockLastTest.java b/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleWeaveAddMockLastTest.java new file mode 100644 index 0000000..125491b --- /dev/null +++ b/components/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleWeaveAddMockLastTest.java @@ -0,0 +1,60 @@ +/** + * 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.test.patterns; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class SimpleWeaveAddMockLastTest extends CamelTestSupport { + + public boolean isUseAdviceWith() { + return true; + } + + @Test + public void testWeaveAddMockLast() throws Exception { + context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { + @Override + public void configure() throws Exception { + weaveAddLast().to("mock:result"); + } + }); + context.start(); + + getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel"); + + template.sendBody("seda:start", "Camel"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("seda:start") + .transform(simple("Bye ${body}")) + .to("seda:queue"); + } + }; + } + +}