http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bindy/MyRoutes.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bindy/MyRoutes.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bindy/MyRoutes.java deleted file mode 100644 index 3e0623c..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bindy/MyRoutes.java +++ /dev/null @@ -1,34 +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.itest.osgi.bindy; - -import org.apache.camel.builder.RouteBuilder; - -/** - * - */ -public class MyRoutes extends RouteBuilder { - - @Override - public void configure() throws Exception { - from("direct:unmarshal").unmarshal("myBindy") - .split(simple("body")).to("mock:bindy-unmarshal"); - - from("direct:marshal").marshal("myBindy") - .to("mock:bindy-marshal"); - } -}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/AbstractIntegrationTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/AbstractIntegrationTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/AbstractIntegrationTest.java deleted file mode 100644 index ce2e5f4..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/AbstractIntegrationTest.java +++ /dev/null @@ -1,164 +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.itest.osgi.blueprint; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Dictionary; -import java.util.Enumeration; - -import javax.inject.Inject; - -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.ops4j.pax.exam.CoreOptions; - -import org.ops4j.pax.exam.options.MavenArtifactProvisionOption; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.Filter; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -public abstract class AbstractIntegrationTest extends OSGiIntegrationTestSupport { - - public static final long DEFAULT_TIMEOUT = 30000; - - @Inject - protected BundleContext bundleContext; - - protected <T> T getOsgiService(Class<T> type, long timeout) { - return getOsgiService(type, null, timeout); - } - - protected <T> T getOsgiService(Class<T> type) { - return getOsgiService(type, null, DEFAULT_TIMEOUT); - } - - protected <T> T getOsgiService(Class<T> type, String filter, long timeout) { - ServiceTracker<T, T> tracker; - try { - String flt; - if (filter != null) { - if (filter.startsWith("(")) { - flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")" + filter + ")"; - } else { - flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")(" + filter + "))"; - } - } else { - flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")"; - } - Filter osgiFilter = FrameworkUtil.createFilter(flt); - tracker = new ServiceTracker<T, T>(bundleContext, osgiFilter, null); - tracker.open(true); - // Note that the tracker is not closed to keep the reference - // This is buggy, as the service reference may change i think - T svc = tracker.waitForService(timeout); - if (svc == null) { - @SuppressWarnings("rawtypes") - Dictionary dic = bundleContext.getBundle().getHeaders(); - LOG.warn("Test bundle headers: " + explode(dic)); - - for (ServiceReference<?> ref : asCollection(bundleContext.getAllServiceReferences(null, null))) { - LOG.warn("ServiceReference: " + ref); - } - - for (ServiceReference<?> ref : asCollection(bundleContext.getAllServiceReferences(null, flt))) { - LOG.warn("Filtered ServiceReference: " + ref); - } - - throw new RuntimeException("Gave up waiting for service " + flt); - } - return svc; - } catch (InvalidSyntaxException e) { - throw new IllegalArgumentException("Invalid filter", e); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - protected Bundle installBundle(String groupId, String artifactId) throws Exception { - MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId); - return bundleContext.installBundle(mvnUrl.getURL()); - } - - protected Bundle getInstalledBundle(String symbolicName) { - for (Bundle b : bundleContext.getBundles()) { - if (b.getSymbolicName().equals(symbolicName)) { - return b; - } - } - for (Bundle b : bundleContext.getBundles()) { - LOG.warn("Bundle: " + b.getSymbolicName()); - } - throw new RuntimeException("Bundle " + symbolicName + " does not exist"); - } - - /* - * Explode the dictionary into a ,-delimited list of key=value pairs - */ - private static String explode(Dictionary<?, ?> dictionary) { - Enumeration<?> keys = dictionary.keys(); - StringBuilder result = new StringBuilder(); - while (keys.hasMoreElements()) { - Object key = keys.nextElement(); - result.append(String.format("%s=%s", key, dictionary.get(key))); - if (keys.hasMoreElements()) { - result.append(", "); - } - } - return result.toString(); - } - - /* - * Provides an iterable collection of references, even if the original array is null - */ - private static Collection<ServiceReference<?>> asCollection(ServiceReference<?>[] references) { - return references != null ? Arrays.asList(references) : Collections.<ServiceReference<?>>emptyList(); - } - - /** - * Create an provisioning option for the specified maven artifact - * (groupId and artifactId), using the version found in the list - * of dependencies of this maven project. - * - * @param groupId the groupId of the maven bundle - * @param artifactId the artifactId of the maven bundle - * @return the provisioning option for the given bundle - */ - protected static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId) { - return CoreOptions.mavenBundle(groupId, artifactId).versionAsInProject(); - } - - /** - * Create an provisioning option for the specified maven artifact - * (groupId and artifactId), using the version found in the list - * of dependencies of this maven project. - * - * @param groupId the groupId of the maven bundle - * @param artifactId the artifactId of the maven bundle - * @param version the version of the maven bundle - * @return the provisioning option for the given bundle - */ - protected static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId, String version) { - return CoreOptions.mavenBundle(groupId, artifactId).version(version); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintExplicitPropertiesRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintExplicitPropertiesRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintExplicitPropertiesRouteTest.java deleted file mode 100644 index 7316da9..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintExplicitPropertiesRouteTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * - */ -@RunWith(PaxExam.class) -public class BlueprintExplicitPropertiesRouteTest extends OSGiBlueprintTestSupport { - - private String name = BlueprintExplicitPropertiesRouteTest.class.getName(); - - @Test - public void testBlueprintProperties() throws Exception { - // start bundle - getInstalledBundle(name).start(); - - // must use the camel context from osgi - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=" + name + ")", 10000); - - ProducerTemplate myTemplate = ctx.createProducerTemplate(); - myTemplate.start(); - - // do our testing - MockEndpoint foo = ctx.getEndpoint("mock:foo", MockEndpoint.class); - foo.expectedMessageCount(1); - MockEndpoint result = ctx.getEndpoint("mock:result", MockEndpoint.class); - result.expectedMessageCount(1); - - myTemplate.sendBody("direct:start", "Hello World"); - - foo.assertIsSatisfied(); - result.assertIsSatisfied(); - - myTemplate.stop(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", BlueprintExplicitPropertiesRouteTest.class.getResource("blueprint-16.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, BlueprintExplicitPropertiesRouteTest.class.getName()) - .set(Constants.BUNDLE_VERSION, "1.0.0") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesCustomPrefixRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesCustomPrefixRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesCustomPrefixRouteTest.java deleted file mode 100644 index d705e5a..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesCustomPrefixRouteTest.java +++ /dev/null @@ -1,84 +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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.options.extra.VMOption; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * - */ -@RunWith(PaxExam.class) -public class BlueprintPropertiesCustomPrefixRouteTest extends OSGiBlueprintTestSupport { - - private String name = BlueprintPropertiesCustomPrefixRouteTest.class.getName(); - - @Test - public void testBlueprintCustomPrefixProperties() throws Exception { - // start bundle - getInstalledBundle(name).start(); - - // must use the camel context from osgi - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=" + name + ")", 10000); - - ProducerTemplate myTemplate = ctx.createProducerTemplate(); - myTemplate.start(); - - // do our testing - MockEndpoint result = ctx.getEndpoint("mock:result", MockEndpoint.class); - result.expectedMessageCount(1); - result.expectedBodyReceived().constant("Test Value"); - - myTemplate.sendBody("direct:start", "Irrelevant"); - - result.assertIsSatisfied(); - - myTemplate.stop(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - new VMOption("-Dcontainer.stage=test"), - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", BlueprintPropertiesCustomPrefixRouteTest.class.getResource("blueprint-27.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, BlueprintPropertiesCustomPrefixRouteTest.class.getName()) - .set(Constants.BUNDLE_VERSION, "1.0.0") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - loadCamelFeatures("camel-blueprint")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesJasyptRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesJasyptRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesJasyptRouteTest.java deleted file mode 100644 index cd81b0f..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesJasyptRouteTest.java +++ /dev/null @@ -1,86 +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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * - */ -@RunWith(PaxExam.class) -public class BlueprintPropertiesJasyptRouteTest extends OSGiBlueprintTestSupport { - - private String name = BlueprintPropertiesJasyptRouteTest.class.getName(); - - @Test - public void testBlueprintJasyptProperties() throws Exception { - // start bundle - getInstalledBundle(name).start(); - - // must use the camel context from osgi - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=" + name + ")", 10000); - - ProducerTemplate myTemplate = ctx.createProducerTemplate(); - myTemplate.start(); - - // do our testing - MockEndpoint foo = ctx.getEndpoint("mock:foo", MockEndpoint.class); - foo.expectedMessageCount(1); - MockEndpoint tiger = ctx.getEndpoint("mock:tiger", MockEndpoint.class); - tiger.expectedMessageCount(1); - - myTemplate.sendBody("direct:start", "Hello World"); - - foo.assertIsSatisfied(); - tiger.assertIsSatisfied(); - - myTemplate.stop(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", BlueprintPropertiesJasyptRouteTest.class.getResource("blueprint-26.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, BlueprintPropertiesJasyptRouteTest.class.getName()) - .set(Constants.BUNDLE_VERSION, "1.0.0") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint", "camel-jasypt")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesRouteTest.java deleted file mode 100644 index 13f7f67..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintPropertiesRouteTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * - */ -@RunWith(PaxExam.class) -public class BlueprintPropertiesRouteTest extends OSGiBlueprintTestSupport { - - private String name = BlueprintPropertiesRouteTest.class.getName(); - - @Test - public void testBlueprintProperties() throws Exception { - // start bundle - getInstalledBundle(name).start(); - - // must use the camel context from osgi - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=" + name + ")", 10000); - - ProducerTemplate myTemplate = ctx.createProducerTemplate(); - myTemplate.start(); - - // do our testing - MockEndpoint foo = ctx.getEndpoint("mock:foo", MockEndpoint.class); - foo.expectedMessageCount(1); - MockEndpoint result = ctx.getEndpoint("mock:result", MockEndpoint.class); - result.expectedMessageCount(1); - - myTemplate.sendBody("direct:start", "Hello World"); - - foo.assertIsSatisfied(); - result.assertIsSatisfied(); - - myTemplate.stop(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", BlueprintPropertiesRouteTest.class.getResource("blueprint-17.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, BlueprintPropertiesRouteTest.class.getName()) - .set(Constants.BUNDLE_VERSION, "1.0.0") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerRefTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerRefTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerRefTest.java deleted file mode 100644 index 89f387e..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerRefTest.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.itest.osgi.blueprint; - -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class BlueprintTracerRefTest extends BlueprintTracerTest { - - // implicitly inherit the test method from super - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", BlueprintTracerRefTest.class.getResource("blueprint-30.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, BlueprintTracerRefTest.class.getName()) - .set(Constants.BUNDLE_VERSION, "1.0.0") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - // do eagerly register the Camel context so that OsgiCamelContextPublisher can publish it early enough as an OSGi service - org.ops4j.pax.exam.CoreOptions.systemProperty("registerBlueprintCamelContextEager").value("true"), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java deleted file mode 100644 index 4794299..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java +++ /dev/null @@ -1,100 +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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.processor.interceptor.DefaultTraceEventMessage; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class BlueprintTracerTest extends OSGiBlueprintTestSupport { - - @Test - public void testTracer() throws Exception { - final String name = getClass().getName(); - - // start bundle - getInstalledBundle(name).start(); - - // must use the camel context from osgi - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=" + name + ")", 30000); - - ProducerTemplate myTemplate = ctx.createProducerTemplate(); - myTemplate.start(); - - // do our testing - MockEndpoint result = ctx.getEndpoint("mock:result", MockEndpoint.class); - result.expectedMessageCount(1); - - MockEndpoint tracer = ctx.getEndpoint("mock:traced", MockEndpoint.class); - - myTemplate.sendBody("direct:start", "Hello World"); - - result.assertIsSatisfied(); - - DefaultTraceEventMessage em = tracer.getReceivedExchanges().get(0).getIn().getBody(DefaultTraceEventMessage.class); - assertEquals("Hello World", em.getBody()); - - assertEquals("String", em.getBodyType()); - assertEquals(null, em.getCausedByException()); - assertNotNull(em.getExchangeId()); - assertNotNull(em.getShortExchangeId()); - assertNotNull(em.getExchangePattern()); - assertEquals("direct://start", em.getFromEndpointUri()); - // there is always a breadcrumb header - assertNotNull(em.getHeaders()); - assertNotNull(em.getProperties()); - assertNull(em.getOutBody()); - assertNull(em.getOutBodyType()); - assertNull(em.getOutHeaders()); - assertNull(em.getPreviousNode()); - assertNotNull(em.getToNode()); - assertNotNull(em.getTimestamp()); - - myTemplate.stop(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", BlueprintTracerTest.class.getResource("blueprint-29.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, BlueprintTracerTest.class.getName()) - .set(Constants.BUNDLE_VERSION, "1.0.0") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint2Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint2Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint2Test.java deleted file mode 100644 index 7854fd9..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint2Test.java +++ /dev/null @@ -1,122 +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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.DeadLetterChannelBuilder; -import org.apache.camel.model.RouteDefinition; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; -import org.osgi.service.blueprint.container.BlueprintContainer; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprint2Test extends OSGiBlueprintTestSupport { - - @Test - public void testRouteContext() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle11").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle11)", 10000); - assertEquals(3, ctx.getRoutes().size()); - } - - @Test - @Ignore("TODO: Does not work") - public void testProxy() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle12").start(); - BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle12)", 10000); - Object proxy = ctn.getComponentInstance("myProxySender"); - assertNotNull(proxy); - assertEquals(1, proxy.getClass().getInterfaces().length); - assertEquals(TestProxySender.class.getName(), proxy.getClass().getInterfaces()[0].getName()); - } - - @SuppressWarnings("deprecation") - @Test - public void testErrorHandler() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle14").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle14)", 10000); - assertEquals(1, ctx.getRoutes().size()); - RouteDefinition rd = ctx.getRouteDefinitions().get(0); - assertNotNull(rd.getErrorHandlerRef()); - Object eh = ctx.getRegistry().lookup(rd.getErrorHandlerRef()); - assertEquals(DeadLetterChannelBuilder.class.getName(), eh.getClass().getName()); - } - - @Test - public void testRouteWithNonStdComponentFromBlueprint() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle15").start(); - BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle15)", 10000); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle15)", 10000); - assertEquals(1, ctx.getRoutes().size()); - assertSame(ctn.getComponentInstance("mycomp"), ctx.getComponent("mycomp")); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-11.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle11") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-12.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle12") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-14.xml")) - .add(TestProxySender.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle14") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-15.xml")) - .add(TestProxySender.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle15") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint", "camel-mail", "camel-jaxb", "camel-jms")); - - // for remote debugging - // vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5008")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint3Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint3Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint3Test.java deleted file mode 100644 index bb56db6..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint3Test.java +++ /dev/null @@ -1,111 +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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; -import org.osgi.service.blueprint.container.BlueprintContainer; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprint3Test extends OSGiBlueprintTestSupport { - - @Test - public void testRouteWithComponentFromBlueprint() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle6").start(); - BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle6)", 10000); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle6)", 10000); - assertEquals(1, ctx.getRoutes().size()); - assertSame(ctn.getComponentInstance("seda"), ctx.getComponent("seda")); - } - - @Test - public void testRouteWithInterceptStrategy() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle7").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle7)", 10000); - assertEquals(1, ctx.getRoutes().size()); - assertEquals(1, ctx.getInterceptStrategies().size()); - assertEquals(TestInterceptStrategy.class.getName(), ctx.getInterceptStrategies().get(0).getClass().getName()); - } - - @Test - public void testComponentProperties() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle8").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle8)", 10000); - assertEquals(1, ctx.getRoutes().size()); - assertEquals("direct://start", ctx.getRoutes().get(0).getEndpoint().getEndpointUri()); - } - - @Test - public void testRouteBuilderRef() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle9").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle9)", 10000); - assertEquals(1, ctx.getRoutes().size()); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-6.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle6") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-7.xml")) - .add(TestInterceptStrategy.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle7") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-8.xml")) - .add("org/apache/camel/component/properties/cheese.properties", OSGiBlueprintTestSupport.class.getResource("cheese.properties")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle8") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-9.xml")) - .add(TestRouteBuilder.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle9") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint", "camel-ftp", "camel-jackson", "camel-jms")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java deleted file mode 100644 index bebe4f2..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java +++ /dev/null @@ -1,141 +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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerSuite; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -@ExamReactorStrategy(PerSuite.class) -public class CamelBlueprint4Test extends OSGiBlueprintTestSupport { - - @Test - public void testRouteWithXSLT() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle19").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle19)", 10000); - - ProducerTemplate template = ctx.createProducerTemplate(); - - MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class); - mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>"); - mock.message(0).body().isInstanceOf(String.class); - - template.sendBody("direct:start", "<hello>world!</hello>"); - - mock.assertIsSatisfied(); - template.stop(); - } - - @Test - public void testRouteWithVelocity() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle20").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle20)", 10000); - - ProducerTemplate template = ctx.createProducerTemplate(); - Object out = template.requestBody("direct:a", "world"); - assertEquals("<hello>world</hello>", out); - template.stop(); - } - - @Test - public void testSetHeaderXPathResultType() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle21").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle21)", 10000); - - ProducerTemplate template = ctx.createProducerTemplate(); - - MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.message(0).header("foo").isInstanceOf(Boolean.class); - mock.message(0).header("foo").isEqualTo(true); - mock.message(0).header("bar").isInstanceOf(Boolean.class); - mock.message(0).header("bar").isEqualTo(false); - - template.sendBody("direct:start", "<hello>World</hello>"); - - mock.assertIsSatisfied(); - template.stop(); - } - - @Test - public void testGetApplicationContextClassloader() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle22").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle22)", 10000); - - // test the application context classloader - assertNotNull("The application context classloader should not be null", ctx.getApplicationContextClassLoader()); - ClassLoader cl = ctx.getApplicationContextClassLoader(); - assertNotNull("It should load the TestRouteBuilder class", cl.getResource("OSGI-INF/blueprint/test.xml")); - assertNotNull("It should load the TestRouteBuilder class", cl.loadClass("org.apache.camel.itest.osgi.blueprint.TestRouteBuilder")); - - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-19.xml")) - .add("org/apache/camel/itest/osgi/blueprint/example.xsl", OSGiBlueprintTestSupport.class.getResource("example.xsl")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle19") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-20.xml")) - .add("org/apache/camel/itest/osgi/blueprint/example.vm", OSGiBlueprintTestSupport.class.getResource("example.vm")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle20") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-21.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle21") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-13.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle22") - .add(TestRouteBuilder.class) - .set(Constants.EXPORT_PACKAGE, TestRouteBuilder.class.getPackage().getName()) - .build(TinyBundles.withBnd())).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint", "camel-velocity")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint5Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint5Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint5Test.java deleted file mode 100644 index de039a5..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint5Test.java +++ /dev/null @@ -1,79 +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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprint5Test extends OSGiBlueprintTestSupport { - - @Test - public void testTryCatch() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle23").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle23)", 10000); - - ProducerTemplate template = ctx.createProducerTemplate(); - - MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class); - mock.expectedMessageCount(1); - - MockEndpoint error = ctx.getEndpoint("mock:error", MockEndpoint.class); - error.expectedMessageCount(1); - - template.sendBody("direct:start", "Hello World"); - template.sendBody("direct:start", "Kaboom"); - - mock.assertIsSatisfied(); - error.assertIsSatisfied(); - template.stop(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-23.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle23") - .add(MyException.class) - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint6Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint6Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint6Test.java deleted file mode 100644 index f30fbca..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint6Test.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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprint6Test extends OSGiBlueprintTestSupport { - - @Test - public void testErrorHandler() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle24").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle24)", 10000); - - ProducerTemplate template = ctx.createProducerTemplate(); - - MockEndpoint mock = ctx.getEndpoint("mock:dead", MockEndpoint.class); - mock.expectedMessageCount(1); - - template.sendBody("direct:start", "Hello World"); - - mock.assertIsSatisfied(); - template.stop(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-24.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle24") - .add("org/apache/camel/component/properties/cheese.properties", OSGiBlueprintTestSupport.class.getResource("cheese.properties")) - .add(MyErrorBean.class) - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint7Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint7Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint7Test.java deleted file mode 100644 index d0ea4da..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint7Test.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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprint7Test extends OSGiBlueprintTestSupport { - - @Test - public void testErrorHandler() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle25").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle25)", 10000); - - ProducerTemplate template = ctx.createProducerTemplate(); - - MockEndpoint mock = ctx.getEndpoint("mock:dead", MockEndpoint.class); - mock.expectedMessageCount(1); - - template.sendBody("direct:start", "Hello World"); - - mock.assertIsSatisfied(); - template.stop(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-25.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle25") - .add("org/apache/camel/component/properties/cheese.properties", OSGiBlueprintTestSupport.class.getResource("cheese.properties")) - .add(MyErrorBean.class) - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java deleted file mode 100644 index 78ec14b..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint8Test.java +++ /dev/null @@ -1,118 +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.itest.osgi.blueprint; - -import java.lang.reflect.Method; - -import org.apache.camel.util.jsse.SSLContextParameters; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; -import org.osgi.service.blueprint.container.BlueprintContainer; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprint8Test extends OSGiBlueprintTestSupport { - - @Test - public void testEndpointInjection() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle10").start(); - BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle10)", 10000); - Object producer = ctn.getComponentInstance("producer"); - assertNotNull(producer); - assertEquals(TestProducer.class.getName(), producer.getClass().getName()); - Method mth = producer.getClass().getMethod("getTestEndpoint"); - assertNotNull(mth.invoke(producer)); - } - - @Test - public void testJsseUtilNamespace() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle18").start(); - BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle18)", 10000); - - SSLContextParameters scp = (SSLContextParameters) ctn.getComponentInstance("sslContextParameters"); - - assertEquals("TLS", scp.getSecureSocketProtocol()); - - assertNotNull(scp.getKeyManagers()); - assertEquals("changeit", scp.getKeyManagers().getKeyPassword()); - assertNull(scp.getKeyManagers().getProvider()); - assertNotNull(scp.getKeyManagers().getKeyStore()); - assertNull(scp.getKeyManagers().getKeyStore().getType()); - - assertNotNull(scp.getTrustManagers()); - assertNull(scp.getTrustManagers().getProvider()); - assertNotNull(scp.getTrustManagers().getKeyStore()); - assertNull(scp.getTrustManagers().getKeyStore().getType()); - - assertNull(scp.getSecureRandom()); - - assertNull(scp.getClientParameters()); - - assertNull(scp.getServerParameters()); - - assertEquals("test", scp.getCamelContext().getName()); - - assertNotNull(scp.getCamelContext()); - assertNotNull(scp.getKeyManagers().getCamelContext()); - assertNotNull(scp.getKeyManagers().getKeyStore().getCamelContext()); - assertNotNull(scp.getTrustManagers().getCamelContext()); - assertNotNull(scp.getTrustManagers().getKeyStore().getCamelContext()); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-10.xml")) - .add(TestProducer.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle10") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-18.xml")) - .add(JsseUtilTester.class) - .add("localhost.ks", OSGiBlueprintTestSupport.class.getResourceAsStream("/org/apache/camel/itest/osgi/util/jsse/localhost.ks")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle18") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - // for remote debugging - // vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5008")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.java deleted file mode 100644 index 8ea3f94..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.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.itest.osgi.blueprint; - -import javax.management.MBeanServer; -import javax.management.ObjectName; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprintManagedNamePatternFixedTest extends OSGiBlueprintTestSupport { - - @Test - public void testManagedNamePatternFixed() throws Exception { - getInstalledBundle("CamelBlueprintTestBundleFixed").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundleFixed)", 10000); - - ProducerTemplate template = ctx.createProducerTemplate(); - - MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class); - template.sendBody("direct:start", "World"); - mock.assertIsSatisfied(); - - MBeanServer mbeanServer = ctx.getManagementStrategy().getManagementAgent().getMBeanServer(); - - assertEquals("cool", ctx.getManagementName()); - - ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + ctx.getManagementName() - + ",type=context,name=\"" + ctx.getName() + "\""); - assertTrue("Should be registered", mbeanServer.isRegistered(on)); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-fixed.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundleFixed") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTcclTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTcclTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTcclTest.java deleted file mode 100644 index d5d36a5..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTcclTest.java +++ /dev/null @@ -1,118 +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.itest.osgi.blueprint; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Bundle; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * Test cases to ensure that the Blueprint component is correctly setting the Thread's context classloader when starting - * the routes - * - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprintTcclTest extends OSGiBlueprintTestSupport { - - private static final String BUNDLE_SYMBOLICNAME = "CamelBlueprintTcclTestBundle"; - - @Test - public void testCorrectTcclSetForRoutes() throws Exception { - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTcclTestBundle)", 10000); - assertBundleDelegatingClassLoader(ctx.getApplicationContextClassLoader()); - - ProducerTemplate template = ctx.createProducerTemplate(); - - MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class); - mock.expectedMessageCount(1); - - template.sendBody("direct:start", "<hello>world!</hello>"); - - mock.assertIsSatisfied(); - - ClassLoader tccl = mock.getExchanges().get(0).getProperty(ThreadContextClassLoaderBean.THREAD_CONTEXT_CLASS_LOADER, ClassLoader.class); - assertNotNull("Exchange property containing TCCL should have been set", tccl); - assertBundleDelegatingClassLoader(tccl); - - template.stop(); - } - - private void assertBundleDelegatingClassLoader(ClassLoader tccl) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { - // camel-blueprint does not export the BundleDelegatingClassLoader package so we need a little pinch of reflection here - assertTrue("Expected a BundleDelegatingClassLoader instance", tccl.getClass().getName().contains("BundleDelegatingClassLoader")); - Method getBundle = tccl.getClass().getMethod("getBundle"); - Bundle bundle = (Bundle) getBundle.invoke(tccl); - - assertEquals(BUNDLE_SYMBOLICNAME, bundle.getSymbolicName()); - } - - @Configuration - public static Option[] configure() throws Exception { - return combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-tccl.xml")) - .add(ThreadContextClassLoaderBean.class) - .set(Constants.BUNDLE_SYMBOLICNAME, BUNDLE_SYMBOLICNAME) - .set(Constants.IMPORT_PACKAGE, "org.apache.camel") - .build()), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint")); - - - - } - - /** - * Camel {@link Processor} that injects startup thread context classloader into the exchange for testing purposes - */ - public static final class ThreadContextClassLoaderBean implements Processor { - - public static final String THREAD_CONTEXT_CLASS_LOADER = "CamelThreadContextClassLoader"; - - private final ClassLoader tccl; - - public ThreadContextClassLoaderBean() { - tccl = Thread.currentThread().getContextClassLoader(); - } - - @Override - public void process(Exchange exchange) throws Exception { - exchange.setProperty(THREAD_CONTEXT_CLASS_LOADER, tccl); - } - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.java deleted file mode 100644 index d4ae39e..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintTest.java +++ /dev/null @@ -1,155 +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.itest.osgi.blueprint; - -import org.apache.camel.CamelContext; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; -import org.osgi.service.blueprint.container.BlueprintContainer; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class CamelBlueprintTest extends OSGiBlueprintTestSupport { - - @Test - public void testRouteWithAllComponents() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle1").stop(); - try { - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle1)", 1000); - fail("The blueprint container should not be available"); - } catch (Exception e) { - } - getInstalledBundle("CamelBlueprintTestBundle1").start(); - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle1)", 10000); - getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle1)", 10000); - } - - @Test - public void testRouteWithMissingComponent() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle2").stop(); - getInstalledBundle("org.apache.camel.camel-ftp").stop(); - try { - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle2)", 500); - fail("The blueprint container should not be available"); - } catch (Exception e) { - } - getInstalledBundle("CamelBlueprintTestBundle2").start(); - try { - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle2)", 500); - fail("The blueprint container should not be available"); - } catch (Exception e) { - } - getInstalledBundle("org.apache.camel.camel-ftp").start(); - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle2)", 10000); - getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle2)", 10000); - - } - - @Test - public void testRouteWithMissingDataFormat() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle3").stop(); - getInstalledBundle("org.apache.camel.camel-jackson").stop(); - try { - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle3)", 500); - fail("The blueprint container should not be available"); - } catch (Exception e) { - } - getInstalledBundle("CamelBlueprintTestBundle3").start(); - try { - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle3)", 500); - fail("The blueprint container should not be available"); - } catch (Exception e) { - } - - getInstalledBundle("org.apache.camel.camel-jackson").start(); - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle3)", 10000); - getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle3)", 10000); - } - - @Test - public void testRouteWithPackage() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle4").start(); - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle4)", 10000); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle4)", 10000); - assertEquals(1, ctx.getRoutes().size()); - } - - @Test - public void testRouteWithPackageScan() throws Exception { - getInstalledBundle("CamelBlueprintTestBundle5").start(); - getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle5)", 10000); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle5)", 10000); - assertEquals(1, ctx.getRoutes().size()); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-1.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle1") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-2.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle2") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-3.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle3") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-4.xml")) - .add(TestRouteBuilder.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle4") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", OSGiBlueprintTestSupport.class.getResource("blueprint-5.xml")) - .add(TestRouteBuilder.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintTestBundle5") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart(), - - // using the features to install the camel components - loadCamelFeatures("camel-blueprint", "camel-ftp", "camel-jackson", "camel-jms")); - - - return options; - } - -}