Added an unit test for BlueprintPackageScanBuilder
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/51b64401 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/51b64401 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/51b64401 Branch: refs/heads/master Commit: 51b64401a65f1a740df84ea835e784a7a5f13cbe Parents: 69fad4f Author: Willem Jiang <[email protected]> Authored: Sun Oct 20 12:25:24 2013 +0800 Committer: Willem Jiang <[email protected]> Committed: Sun Oct 20 12:25:24 2013 +0800 ---------------------------------------------------------------------- .../BlueprintPackageScanBuilderTest.java | 40 ++++++++++++++++++++ .../blueprint/builder/AbstractRouteBuilder.java | 30 +++++++++++++++ .../blueprint/builder/my/MyRouteBuilder.java | 30 +++++++++++++++ .../camel/test/blueprint/packagescan3.xml | 27 +++++++++++++ 4 files changed, 127 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/51b64401/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPackageScanBuilderTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPackageScanBuilderTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPackageScanBuilderTest.java new file mode 100644 index 0000000..aaa6828 --- /dev/null +++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPackageScanBuilderTest.java @@ -0,0 +1,40 @@ +/** + * 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.blueprint; + +import org.junit.Test; + +public class BlueprintPackageScanBuilderTest extends CamelBlueprintTestSupport { + + @Override + protected String getBlueprintDescriptor() { + return "org/apache/camel/test/blueprint/packagescan3.xml"; + } + + // here we have regular Junit @Test method + @Test + public void testRoute() throws Exception { + // set mock expectations + getMockEndpoint("mock:result").expectedMessageCount(1); + + // send a message + template.sendBody("direct:start", "World"); + + // assert mocks + assertMockEndpointsSatisfied(); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/51b64401/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/builder/AbstractRouteBuilder.java ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/builder/AbstractRouteBuilder.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/builder/AbstractRouteBuilder.java new file mode 100644 index 0000000..145f5a8 --- /dev/null +++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/builder/AbstractRouteBuilder.java @@ -0,0 +1,30 @@ +/** + * 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.blueprint.builder; + +import org.apache.camel.builder.RouteBuilder; + +public abstract class AbstractRouteBuilder extends RouteBuilder { + + protected abstract String getResult(); + + @Override + public void configure() throws Exception { + from("direct:start").to(getResult()); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/51b64401/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/builder/my/MyRouteBuilder.java ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/builder/my/MyRouteBuilder.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/builder/my/MyRouteBuilder.java new file mode 100644 index 0000000..159c025 --- /dev/null +++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/builder/my/MyRouteBuilder.java @@ -0,0 +1,30 @@ +/** + * 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.blueprint.builder.my; + +import org.apache.camel.test.blueprint.builder.AbstractRouteBuilder; + +public class MyRouteBuilder extends AbstractRouteBuilder { + + @Override + protected String getResult() { + return "mock:result"; + } + + + +} http://git-wip-us.apache.org/repos/asf/camel/blob/51b64401/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/packagescan3.xml ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/packagescan3.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/packagescan3.xml new file mode 100644 index 0000000..b924d8b --- /dev/null +++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/packagescan3.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> + + <camelContext xmlns="http://camel.apache.org/schema/blueprint"> + <package>org.apache.camel.test.blueprint.builder</package> + </camelContext> + +</blueprint>
