Repository: camel Updated Branches: refs/heads/master d3d75d287 -> 0421c24df
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextC.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextC.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextC.java new file mode 100644 index 0000000..d4de27d --- /dev/null +++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextC.java @@ -0,0 +1,28 @@ +/** + * 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.cdi; + +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.cdi.CdiCamelContext; +import org.apache.camel.cdi.ContextName; + +@ApplicationScoped +@ContextName("contextC") +public class CamelContextC extends CdiCamelContext { + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextD.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextD.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextD.java new file mode 100644 index 0000000..0934241 --- /dev/null +++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextD.java @@ -0,0 +1,28 @@ +/** + * 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.cdi; + +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.cdi.CdiCamelContext; +import org.apache.camel.cdi.ContextName; + +@ApplicationScoped +@ContextName("contextD") +public class CamelContextD extends CdiCamelContext { + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java index 4a55f51..a9db087 100644 --- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java +++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java @@ -28,29 +28,31 @@ import org.apache.camel.component.mock.MockEndpoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * Uses contextA with explicit context names on all Camel annotations - */ @ContextName("contextA") public class RoutesContextA extends RouteBuilder { - private static final Logger LOG = LoggerFactory.getLogger(RoutesContextA.class); - @EndpointInject(uri = "mock:A.b", context = "contextA") - public MockEndpoint b; + private static final Logger LOG = LoggerFactory.getLogger(RoutesContextA.class); - @Inject @Uri(value = "seda:A.a", context = "contextA") + @Inject + @ContextName("contextA") + @Uri(value = "seda:A.a") Endpoint a; - @Inject @Uri(value = "seda:A.a", context = "contextA") + @EndpointInject(uri = "mock:A.b", context = "contextA") + MockEndpoint b; + + @Inject + @ContextName("contextA") + @Uri(value = "seda:A.a") ProducerTemplate producer; @Override - public void configure() throws Exception { + public void configure() { LOG.info("Adding route from " + a + " to " + b); from(a).to(b); } - public void sendMessages() { + void sendMessages() { for (Object expectedBody : Constants.EXPECTED_BODIES_A) { LOG.info("Sending " + expectedBody + " to " + producer.getDefaultEndpoint()); producer.sendBody(expectedBody); http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java index 5679527..89e0933 100644 --- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java +++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java @@ -28,20 +28,22 @@ import org.apache.camel.component.mock.MockEndpoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * Uses contextB with explicit context names on all Camel annotations - */ @ContextName("contextB") public class RoutesContextB extends RouteBuilder { - private static final Logger LOG = LoggerFactory.getLogger(RoutesContextB.class); - @EndpointInject(uri = "mock:B.b", context = "contextB") - public MockEndpoint b; + private static final Logger LOG = LoggerFactory.getLogger(RoutesContextB.class); - @Inject @Uri(value = "seda:B.a", context = "contextB") + @Inject + @ContextName("contextB") + @Uri(value = "seda:B.a") Endpoint a; - @Inject @Uri(value = "seda:B.a", context = "contextB") + @EndpointInject(uri = "mock:B.b", context = "contextB") + MockEndpoint b; + + @Inject + @ContextName("contextB") + @Uri(value = "seda:B.a") ProducerTemplate producer; @Override @@ -50,7 +52,7 @@ public class RoutesContextB extends RouteBuilder { from(a).to(b); } - public void sendMessages() { + void sendMessages() { for (Object expectedBody : Constants.EXPECTED_BODIES_B) { LOG.info("Sending " + expectedBody + " to " + producer.getDefaultEndpoint()); producer.sendBody(expectedBody); http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java index cb9e96d..507a1d4 100644 --- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java +++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java @@ -28,21 +28,22 @@ import org.apache.camel.component.mock.MockEndpoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * Uses contextC implicitly using that context for all injection points without - * having to mention them on each camel annotation - */ @ContextName("contextC") public class RoutesContextC extends RouteBuilder { + private static final Logger LOG = LoggerFactory.getLogger(RoutesContextC.class); - @Inject @Uri("seda:C.a") + @Inject + @ContextName("contextC") + @Uri("seda:C.a") Endpoint a; - @EndpointInject(uri = "mock:C.b") + @EndpointInject(uri = "mock:C.b", context = "contextC") MockEndpoint b; - @Inject @Uri("seda:C.a") + @Inject + @ContextName("contextC") + @Uri("seda:C.a") ProducerTemplate producer; @Override @@ -50,7 +51,7 @@ public class RoutesContextC extends RouteBuilder { from(a).to(b); } - public void sendMessages() { + void sendMessages() { for (Object expectedBody : Constants.EXPECTED_BODIES_C) { LOG.info("Sending " + expectedBody + " to " + producer.getDefaultEndpoint()); producer.sendBody(expectedBody); http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java index a36b8a8..2b7f172 100644 --- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java +++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java @@ -28,29 +28,30 @@ import org.apache.camel.component.mock.MockEndpoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * Uses contextD implicitly using that context for all injection points without - * having to mention them on each camel annotation - */ @ContextName("contextD") public class RoutesContextD extends RouteBuilder { + private static final Logger LOG = LoggerFactory.getLogger(RoutesContextD.class); - @Inject @Uri("seda:D.a") + @Inject + @ContextName("contextD") + @Uri("seda:D.a") Endpoint a; - @EndpointInject(uri = "mock:D.b") + @EndpointInject(uri = "mock:D.b", context = "contextD") MockEndpoint b; - @Inject @Uri("seda:D.a") + @Inject + @ContextName("contextD") + @Uri("seda:D.a") ProducerTemplate producer; @Override - public void configure() throws Exception { + public void configure() { from(a).to(b); } - public void sendMessages() { + void sendMessages() { for (Object expectedBody : Constants.EXPECTED_BODIES_D) { LOG.info("Sending " + expectedBody + " to " + producer.getDefaultEndpoint()); producer.sendBody(expectedBody); http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel1Config.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel1Config.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel1Config.java deleted file mode 100644 index dcc1a03..0000000 --- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel1Config.java +++ /dev/null @@ -1,38 +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.cdi.properties; - -import org.apache.deltaspike.core.api.config.PropertyFileConfig; - -/** - * Registers new properties configuration. - */ -public class Camel1Config implements PropertyFileConfig { - - private static final long serialVersionUID = 1L; - - @Override - public String getPropertyFileName() { - return "camel1.properties"; - } - - @Override - public boolean isOptional() { - return false; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel2Config.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel2Config.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel2Config.java deleted file mode 100644 index db03ff6..0000000 --- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel2Config.java +++ /dev/null @@ -1,38 +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.cdi.properties; - -import org.apache.deltaspike.core.api.config.PropertyFileConfig; - -/** - * Registers new properties configuration. - */ -public class Camel2Config implements PropertyFileConfig { - - private static final long serialVersionUID = 1L; - - @Override - public String getPropertyFileName() { - return "camel2.properties"; - }; - - @Override - public boolean isOptional() { - return false; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java index ce4ab38..23261ad 100644 --- a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java +++ b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java @@ -17,20 +17,18 @@ package org.apache.camel.itest.cdi; import java.util.Map; -import java.util.Set; +import javax.enterprise.inject.Any; +import javax.enterprise.inject.Instance; import javax.inject.Inject; import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; import org.apache.camel.ProducerTemplate; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.ContextName; import org.apache.camel.cdi.Uri; -import org.apache.camel.cdi.internal.CamelContextMap; -import org.apache.camel.cdi.internal.CamelExtension; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.util.CamelContextHelper; -import org.apache.deltaspike.core.impl.scope.conversation.ConversationBeanHolder; -import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessBeanHolder; -import org.apache.deltaspike.core.impl.scope.window.WindowBeanHolder; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -46,27 +44,49 @@ import static org.junit.Assert.assertTrue; @RunWith(Arquillian.class) public class CamelCdiTest { + private static final Logger LOG = LoggerFactory.getLogger(CamelCdiTest.class); + @Any @Inject - CamelContextMap camelContextMap; + Instance<CamelContext> camelContexts; + @Inject + @ContextName("contextA") RoutesContextA routesA; @Inject + @ContextName("contextB") RoutesContextB routesB; @Inject + @ContextName("contextC") RoutesContextC routesC; @Inject + @ContextName("contextD") RoutesContextD routesD; - - @Inject @Uri(value = "seda:foo", context = "contextD") + + @Inject + @ContextName("contextD") + @Uri(value = "seda:foo") ProducerTemplate producerD; + @Deployment + public static JavaArchive createDeployment() { + return ShrinkWrap.create(JavaArchive.class) + .addPackage(CdiCamelExtension.class.getPackage()) + .addClasses(CamelContextA.class, RoutesContextA.class, + CamelContextB.class, RoutesContextB.class, + CamelContextC.class, RoutesContextC.class, + CamelContextD.class, RoutesContextD.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + @Test public void checkContextsHaveCorrectEndpointsAndRoutes() throws Exception { - Set<Map.Entry<String, CamelContext>> entries = camelContextMap.getCamelContextMap().entrySet(); - for (Map.Entry<String, CamelContext> entry : entries) { - LOG.info("CamelContext " + entry.getKey() + " has endpoints: " + entry.getValue().getEndpointMap().keySet()); + assertNotNull("camelContexts not injected!", camelContexts); + + for (CamelContext camelContext : camelContexts) { + LOG.info("CamelContext " + camelContext + " has endpoints: " + camelContext.getEndpointMap().keySet()); + camelContext.start(); } CamelContext contextA = assertCamelContext("contextA"); @@ -85,7 +105,6 @@ public class CamelCdiTest { routesB.sendMessages(); mockEndpointB.assertIsSatisfied(); - // lets check the routes where we default the context from the @ContextName CamelContext contextC = assertCamelContext("contextC"); assertHasEndpoints(contextC, "seda://C.a", "mock://C.b"); @@ -122,21 +141,8 @@ public class CamelCdiTest { } protected CamelContext assertCamelContext(String contextName) { - assertNotNull("camelContextMap not injected!", camelContextMap); - CamelContext answer = camelContextMap.getMandatoryCamelContext(contextName); + CamelContext answer = camelContexts.select(new ContextName.Literal(contextName)).get(); assertTrue("CamelContext '" + contextName + "' is not started", answer.getStatus().isStarted()); return answer; } - - @Deployment - public static JavaArchive createDeployment() { - return ShrinkWrap.create(JavaArchive.class) - .addPackage(CamelExtension.class.getPackage()) - .addPackage(RoutesContextA.class.getPackage()) - // add a bunch of deltaspike packages so we can find those cdi beans to make arquillian happy - .addPackage(WindowBeanHolder.class.getPackage()) - .addPackage(ConversationBeanHolder.class.getPackage()) - .addPackage(ViewAccessBeanHolder.class.getPackage()) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - } } http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/PropertiesConfigurationTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/PropertiesConfigurationTest.java b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/PropertiesConfigurationTest.java new file mode 100644 index 0000000..2ac0b4d --- /dev/null +++ b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/PropertiesConfigurationTest.java @@ -0,0 +1,75 @@ +/** + * 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.cdi; + +import java.util.Properties; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.camel.CamelContext; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.component.properties.PropertiesComponent; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +/** + * Verify {@link CdiCamelExtension} with custom properties. + */ +@RunWith(Arquillian.class) +public class PropertiesConfigurationTest { + + @Inject + private CamelContext camelContext; + + @Produces + @ApplicationScoped + @Named("properties") + private static PropertiesComponent propertiesComponent() { + Properties configuration = new Properties(); + configuration.put("property", "value"); + PropertiesComponent component = new PropertiesComponent(); + component.setInitialProperties(configuration); + component.setLocation("classpath:camel1.properties,classpath:camel2.properties"); + return component; + } + + @Deployment + public static JavaArchive createDeployment() { + return ShrinkWrap.create(JavaArchive.class) + .addPackage(CdiCamelExtension.class.getPackage()) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void checkContext() throws Exception { + assertNotNull(camelContext); + + assertEquals("value1", camelContext.resolvePropertyPlaceholders("{{property1}}")); + assertEquals("value2", camelContext.resolvePropertyPlaceholders("{{property2}}")); + assertEquals("value1_value2", camelContext.resolvePropertyPlaceholders("{{property1}}_{{property2}}")); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/properties/PropertiesConfigurationTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/properties/PropertiesConfigurationTest.java b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/properties/PropertiesConfigurationTest.java deleted file mode 100644 index c463cd9..0000000 --- a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/properties/PropertiesConfigurationTest.java +++ /dev/null @@ -1,69 +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.cdi.properties; - -import javax.inject.Inject; - -import org.apache.camel.CamelContext; -import org.apache.camel.cdi.component.properties.CdiPropertiesComponent; -import org.apache.camel.cdi.internal.CamelExtension; -import org.apache.deltaspike.core.impl.scope.conversation.ConversationBeanHolder; -import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessBeanHolder; -import org.apache.deltaspike.core.impl.scope.window.WindowBeanHolder; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Verify if {@link CamelExtension} with custom properties. - */ -@RunWith(Arquillian.class) -public class PropertiesConfigurationTest { - - @Inject - private CamelContext camelContext; - - @Test - public void checkContext() throws Exception { - assertNotNull(camelContext); - - assertEquals("value1", camelContext.resolvePropertyPlaceholders("{{property1}}")); - assertEquals("value2", camelContext.resolvePropertyPlaceholders("{{property2}}")); - assertEquals("value1_value2", camelContext.resolvePropertyPlaceholders("{{property1}}_{{property2}}")); - } - - @Deployment - public static JavaArchive createDeployment() { - return ShrinkWrap.create(JavaArchive.class) - .addPackage(CamelExtension.class.getPackage()) - .addPackage(CdiPropertiesComponent.class.getPackage()) - .addClass(Camel1Config.class) - .addClass(Camel2Config.class) - // add a bunch of deltaspike packages so we can find those cdi beans to make arquillian happy - .addPackage(WindowBeanHolder.class.getPackage()) - .addPackage(ConversationBeanHolder.class.getPackage()) - .addPackage(ViewAccessBeanHolder.class.getPackage()) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml ---------------------------------------------------------------------- diff --git a/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml index b797ba7..970a5b6 100644 --- a/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml +++ b/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml @@ -25,7 +25,7 @@ <defaultValue>${project.version}</defaultValue> </requiredProperty> <requiredProperty key="cdi-api-version"> - <defaultValue>1.2</defaultValue> + <defaultValue>${cdi-api-1.2-version}</defaultValue> </requiredProperty> <requiredProperty key="deltaspike-version"> <defaultValue>${deltaspike-version}</defaultValue> @@ -77,7 +77,7 @@ <fileSet filtered="true" encoding="UTF-8"> <directory></directory> <includes> - <include>ReadMe.txt</include> + <include>ReadMe.md</include> </includes> </fileSet> </fileSets> http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml ---------------------------------------------------------------------- diff --git a/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml b/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml index 3bd0efe..e08fb5f 100644 --- a/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml +++ b/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml @@ -41,7 +41,7 @@ <version>${camel-version}</version> </dependency> - <!-- cdi api --> + <!-- CDI API --> <dependency> <groupId>javax.enterprise</groupId> <artifactId>cdi-api</artifactId> @@ -62,9 +62,16 @@ <version>${weld2-version}</version> </dependency> <dependency> + <groupId>org.apache.deltaspike.core</groupId> + <artifactId>deltaspike-core-api</artifactId> + <version>${deltaspike-version}</version> + <scope>runtime</scope> + </dependency> + <dependency> <groupId>org.apache.deltaspike.cdictrl</groupId> <artifactId>deltaspike-cdictrl-weld</artifactId> <version>${deltaspike-version}</version> + <scope>runtime</scope> </dependency> <!-- logging --> @@ -72,11 +79,13 @@ <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j-version}</version> + <scope>runtime</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j-version}</version> + <scope>runtime</scope> </dependency> <!-- testing --> http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java ---------------------------------------------------------------------- diff --git a/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java b/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java index 03c8740..1592037 100644 --- a/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java +++ b/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java @@ -26,7 +26,6 @@ import org.apache.camel.cdi.Uri; /** * Configures all our Camel routes, components, endpoints and beans */ -@ContextName("myCdiCamelContext") public class MyRoutes extends RouteBuilder { @Inject @@ -38,7 +37,7 @@ public class MyRoutes extends RouteBuilder { private Endpoint resultEndpoint; @Override - public void configure() throws Exception { + public void configure() { // you can configure the route rule with Java DSL here from(inputEndpoint)