http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java new file mode 100644 index 0000000..8cb284c --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java @@ -0,0 +1,88 @@ +/** + * 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.cdi.test; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.camel.ProducerTemplate; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.CustomPropertiesCamelContext; +import org.apache.camel.cdi.bean.PropertyEndpointRoute; +import org.apache.camel.component.mock.MockEndpoint; +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.Archive; +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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; + +@RunWith(Arquillian.class) +public class PropertyEndpointTest { + + @Inject + @Uri("direct:{{from}}") + private ProducerTemplate inbound; + + @Inject + @Uri("mock:outbound") + private MockEndpoint outbound; + + @Produces + @ApplicationScoped + @Named("properties") + private static PropertiesComponent configuration() { + Properties properties = new Properties(); + properties.put("from", "inbound"); + properties.put("to", "mock:outbound"); + PropertiesComponent component = new PropertiesComponent(); + component.setInitialProperties(properties); + return component; + } + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test classes + .addClasses(CustomPropertiesCamelContext.class, PropertyEndpointRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void sendMessageToInbound() throws InterruptedException { + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + outbound.expectedHeaderReceived("header", "message from file"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } +}
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.java new file mode 100644 index 0000000..ac77ea4 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.java @@ -0,0 +1,101 @@ +/** + * 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.cdi.test; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; +import javax.inject.Named; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.PropertyInjectBean; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.component.properties.PropertiesComponent; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.junit.InSequence; +import org.jboss.shrinkwrap.api.Archive; +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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +@RunWith(Arquillian.class) +public class PropertyInjectTest { + + @Produces + @ApplicationScoped + @Named("properties") + private static PropertiesComponent configuration() { + Properties properties = new Properties(); + properties.put("property", "value"); + PropertiesComponent component = new PropertiesComponent(); + component.setInitialProperties(properties); + return component; + } + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClass(PropertyInjectBean.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + @InSequence(1) + public void configureCamelContext(CamelContext context) throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:in").bean(PropertyInjectBean.class).to("mock:out"); + } + }); + } + + @Test + @InSequence(2) + public void sendMessageToInbound(@Uri("direct:in") ProducerTemplate in, @Uri("mock:out") MockEndpoint out) throws InterruptedException { + out.expectedMessageCount(1); + out.expectedBodiesReceived("test"); + out.expectedHeaderReceived("header", "value"); + + in.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, out); + } + + @Test + @InSequence(3) + public void retrieveContextualReference(PropertyInjectBean bean) { + assertThat(bean.getProperty(), is(equalTo("value"))); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedCamelContextTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedCamelContextTest.java new file mode 100644 index 0000000..14b6e85 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedCamelContextTest.java @@ -0,0 +1,100 @@ +/** + * 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.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.Endpoint; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.qualifier.BarQualifier; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.impl.DefaultCamelContext; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; + +@RunWith(Arquillian.class) +public class QualifiedCamelContextTest { + + @Inject + @BarQualifier + @Uri("direct:start") + private ProducerTemplate inbound; + + @Inject + @BarQualifier + @Uri("mock:result") + private MockEndpoint outbound; + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClass(QualifiedCamelContext.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void sendMessageToInbound() throws InterruptedException { + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } + + @BarQualifier + public static class CamelRoute extends RouteBuilder { + + @Inject + @BarQualifier + @Uri("direct:start") + private Endpoint directEP; + + @Inject + @BarQualifier + @Uri("mock:result") + private MockEndpoint mockEP; + + @Override + public void configure() { + from(directEP).to(mockEP); + } + } +} + +@BarQualifier +@ApplicationScoped +class QualifiedCamelContext extends DefaultCamelContext { + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java new file mode 100644 index 0000000..6ae1dca --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java @@ -0,0 +1,173 @@ +/** + * 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.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.ContextName; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.DefaultCamelContextBean; +import org.apache.camel.cdi.bean.FirstCamelContextRoute; +import org.apache.camel.cdi.bean.UriEndpointRoute; +import org.apache.camel.cdi.qualifier.BarQualifier; +import org.apache.camel.cdi.qualifier.FooQualifier; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.impl.DefaultCamelContext; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.junit.InSequence; +import org.jboss.shrinkwrap.api.Archive; +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.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext; +import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +@RunWith(Arquillian.class) +public class QualifiedMultiCamelContextTest { + + @Inject + private CamelContext defaultCamelContext; + + @Inject @Uri("direct:inbound") + private ProducerTemplate defaultInbound; + + @Inject @Uri("mock:outbound") + private MockEndpoint defaultOutbound; + + @Inject @FooQualifier + private CamelContext firstCamelContext; + + @Inject @FooQualifier @Uri("direct:inbound") + private ProducerTemplate firstInbound; + + @Inject @FooQualifier @Uri("mock:outbound") + private MockEndpoint firstOutbound; + + @Inject @BarQualifier + private CamelContext secondCamelContext; + + @Inject @BarQualifier @Uri("direct:inbound") + private ProducerTemplate secondInbound; + + @Inject @BarQualifier @Uri("mock:outbound") + private MockEndpoint secondOutbound; + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test classes + .addClasses( + DefaultCamelContextBean.class, + UriEndpointRoute.class, + FooCamelContext.class, + FirstCamelContextRoute.class, + BarCamelContext.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + @InSequence(1) + public void verifyCamelContexts() { + assertThat(defaultCamelContext.getName(), is(equalTo("camel-cdi"))); + assertThat(firstCamelContext.getName(), is(equalTo("first"))); + assertThat(secondCamelContext.getName(), is(equalTo("second"))); + + assertThat(defaultOutbound.getCamelContext().getName(), is(equalTo(defaultCamelContext.getName()))); + assertThat(firstOutbound.getCamelContext().getName(), is(equalTo(firstCamelContext.getName()))); + assertThat(secondOutbound.getCamelContext().getName(), is(equalTo(secondCamelContext.getName()))); + } + + @Test + @InSequence(2) + public void configureCamelContexts() throws Exception { + secondCamelContext.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:inbound").setHeader("context").constant("second").to("mock:outbound"); + } + }); + } + + @Test + @InSequence(3) + public void sendMessageToDefaultCamelContextInbound() throws InterruptedException { + defaultOutbound.expectedMessageCount(1); + defaultOutbound.expectedBodiesReceived("test-default"); + defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi")); + + defaultInbound.sendBody("test-default"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound); + } + + @Test + @InSequence(4) + public void sendMessageToFirstCamelContextInbound() throws InterruptedException { + firstOutbound.expectedMessageCount(1); + firstOutbound.expectedBodiesReceived("test-first"); + firstOutbound.expectedHeaderReceived("context", "first"); + firstOutbound.message(0).exchange().matches(fromCamelContext("first")); + + firstInbound.sendBody("test-first"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound); + } + + @Test + @InSequence(5) + public void sendMessageToSecondCamelContextInbound() throws InterruptedException { + secondOutbound.expectedMessageCount(1); + secondOutbound.expectedBodiesReceived("test-second"); + secondOutbound.expectedHeaderReceived("context", "second"); + secondOutbound.message(0).exchange().matches(fromCamelContext("second")); + + secondInbound.sendBody("test-second"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound); + } +} + +@FooQualifier +@ContextName("first") +@ApplicationScoped +class FooCamelContext extends DefaultCamelContext { + +} + +@BarQualifier +@Named("second") +@ApplicationScoped +class BarCamelContext extends DefaultCamelContext { + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RawEventEndpointTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RawEventEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RawEventEndpointTest.java new file mode 100644 index 0000000..65aa4d0 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RawEventEndpointTest.java @@ -0,0 +1,110 @@ +/** + * 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.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Event; +import javax.enterprise.event.Observes; +import javax.inject.Inject; + +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.CdiEventEndpoint; +import org.apache.camel.cdi.Uri; +import org.apache.camel.component.mock.MockEndpoint; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; + +@RunWith(Arquillian.class) +public class RawEventEndpointTest { + + @Inject + private MockEndpoint consumed; + + @Inject + private MockEndpoint produced; + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test classes + .addClasses(RawEventRoute.class, RawEventObserver.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Before + public void resetMock() { + consumed.reset(); + } + + @Test + public void sendEventToConsumer(Event<Object> event) throws InterruptedException { + consumed.expectedMessageCount(1); + consumed.expectedBodiesReceived("test"); + + event.select(String.class).fire("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, consumed); + } + + @Test + public void sendMessageToProducer(@Uri("direct:produce") ProducerTemplate producer) throws InterruptedException { + long random = Math.round(Math.random() * Long.MAX_VALUE); + produced.expectedMessageCount(1); + produced.expectedBodiesReceived(random); + consumed.expectedMessageCount(1); + consumed.expectedBodiesReceived(random); + + producer.sendBody(random); + + assertIsSatisfied(2L, TimeUnit.SECONDS, consumed, produced); + } +} + +class RawEventRoute extends RouteBuilder { + + @Inject + private CdiEventEndpoint rawEventEndpoint; + + @Override + public void configure() { + from(rawEventEndpoint).to("mock:consumed"); + from("direct:produce").to(rawEventEndpoint); + } +} + +@ApplicationScoped +class RawEventObserver { + + void collectEvents(@Observes long event, @Uri("mock:produced") ProducerTemplate producer) { + producer.sendBody(event); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RecipientListMethodTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RecipientListMethodTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RecipientListMethodTest.java new file mode 100644 index 0000000..a37e656 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RecipientListMethodTest.java @@ -0,0 +1,77 @@ +/** + * 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.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.inject.Inject; + +import org.apache.camel.ProducerTemplate; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.RecipientListMethodBean; +import org.apache.camel.component.mock.MockEndpoint; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; + +@RunWith(Arquillian.class) +public class RecipientListMethodTest { + + @Inject + @Uri("direct:inbound") + private ProducerTemplate inbound; + + @Inject + @Uri("mock:outbound1") + private MockEndpoint outbound1; + + @Inject + @Uri("mock:outbound2") + private MockEndpoint outbound2; + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClass(RecipientListMethodBean.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void consumeAnnotation() throws InterruptedException { + outbound1.expectedMessageCount(1); + outbound1.expectedBodiesReceived("test"); + + outbound2.expectedMessageCount(1); + outbound2.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound1); + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound2); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java new file mode 100644 index 0000000..70e291c --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java @@ -0,0 +1,78 @@ +/** + * 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.cdi.test; + +import java.io.InputStream; +import java.util.concurrent.TimeUnit; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.model.ModelHelper; +import org.apache.camel.model.RoutesDefinition; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; + +@RunWith(Arquillian.class) +public class RouteDefinitionsFromXmlTest { + + @Inject + @Uri("direct:inbound") + private ProducerTemplate inbound; + + @Inject + @Uri("mock:outbound") + private MockEndpoint outbound; + + @Produces + private RoutesDefinition routes(CamelContext context) throws Exception { + try (InputStream routes = getClass().getResourceAsStream("/routes.xml")) { + return ModelHelper.createModelFromXml(context, routes, RoutesDefinition.class); + } + } + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void sendMessageToInbound() throws InterruptedException { + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UndefinedPropertyTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UndefinedPropertyTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UndefinedPropertyTest.java new file mode 100644 index 0000000..8b88667 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UndefinedPropertyTest.java @@ -0,0 +1,83 @@ +/** + * 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.cdi.test; + +import java.util.Properties; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; +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.Archive; +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.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +@RunWith(Arquillian.class) +public class UndefinedPropertyTest { + + @Produces + @ApplicationScoped + @Named("properties") + private static PropertiesComponent configuration() { + Properties properties = new Properties(); + properties.put("from", "inbound"); + // Do not add the looked up property for test purpose + //properties.put("to", "mock:outbound"); + PropertiesComponent component = new PropertiesComponent(); + component.setInitialProperties(properties); + return component; + } + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void lookupDefinedProperty(CamelContext context) throws Exception { + assertThat("Resolved property value is incorrect", context.resolvePropertyPlaceholders("{{from}}"), is(equalTo("inbound"))); + } + + @Test + public void lookupUndefinedProperty(CamelContext context) { + try { + context.resolvePropertyPlaceholders("{{to}}"); + fail("No exception is thrown!"); + } catch (Exception cause) { + assertThat("Exception thrown is incorrect", cause, is(instanceOf(IllegalArgumentException.class))); + assertThat("Exception message is incorrect", cause.getMessage(), is(equalTo("Property with key [to] not found in properties from text: {{to}}"))); + } + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java new file mode 100644 index 0000000..4e7da7a --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java @@ -0,0 +1,58 @@ +/** + * 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.cdi.test; + +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.bean.EndpointInjectWrongContextRoute; +import org.apache.camel.cdi.rule.ExpectedDeploymentException; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; + +import static org.hamcrest.Matchers.containsString; + +@RunWith(Arquillian.class) +public class UnsatisfiedContextForEndpointInjectTest { + + @ClassRule + public static TestRule exception = ExpectedDeploymentException.none() + .expect(RuntimeException.class) + .expectMessage(containsString("Error adding routes of type [" + EndpointInjectWrongContextRoute.class.getName() + "] to Camel context")) + .expectMessage(containsString("No Camel context with name [foo] is deployed!")); + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClass(EndpointInjectWrongContextRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void test() { + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java new file mode 100644 index 0000000..306d71c --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java @@ -0,0 +1,87 @@ +/** + * 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.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.ProducerTemplate; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.SimpleCamelRoute; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.impl.DefaultCamelContext; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.Verifier; +import org.junit.runner.RunWith; + +import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +@RunWith(Arquillian.class) +public class UnstoppedCamelContextBeanTest { + + @ClassRule + public static Verifier verifier = new Verifier() { + @Override + protected void verify() { + assertThat("Camel CDI hasn't stopped Camel context!", UnstoppedCamelContext.isStopCalled, is(equalTo(true))); + } + }; + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClasses(UnstoppedCamelContext.class, SimpleCamelRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void sendMessageToInbound(@Uri("direct:start") ProducerTemplate inbound, @Uri("mock:result") MockEndpoint outbound) throws InterruptedException { + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } +} + +@ApplicationScoped +class UnstoppedCamelContext extends DefaultCamelContext { + + static boolean isStopCalled; + + @Override + public void stop() throws Exception { + super.stop(); + isStopCalled = true; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerFieldTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerFieldTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerFieldTest.java new file mode 100644 index 0000000..42da48b --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerFieldTest.java @@ -0,0 +1,82 @@ +/** + * 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.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.ServiceStatus; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.SimpleCamelRoute; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.impl.DefaultCamelContext; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.Verifier; +import org.junit.runner.RunWith; + +import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +@RunWith(Arquillian.class) +public class UnstoppedCamelContextProducerFieldTest { + + @ClassRule + public static Verifier verifier = new Verifier() { + @Override + protected void verify() { + assertThat("Camel CDI hasn't stopped Camel context!", context.getStatus(), is(equalTo(ServiceStatus.Stopped))); + } + }; + + @Produces + @ApplicationScoped + private static CamelContext context = new DefaultCamelContext(); + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClass(SimpleCamelRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void sendMessageToInbound(@Uri("direct:start") ProducerTemplate inbound, @Uri("mock:result") MockEndpoint outbound) throws InterruptedException { + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerMethodTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerMethodTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerMethodTest.java new file mode 100644 index 0000000..59db1cd --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerMethodTest.java @@ -0,0 +1,88 @@ +/** + * 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.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.ServiceStatus; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.SimpleCamelRoute; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.impl.DefaultCamelContext; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.Verifier; +import org.junit.runner.RunWith; + +import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +@RunWith(Arquillian.class) +public class UnstoppedCamelContextProducerMethodTest { + + @ClassRule + public static Verifier verifier = new Verifier() { + @Override + protected void verify() { + assertThat("Camel CDI hasn't stopped Camel context!", context.getStatus(), is(equalTo(ServiceStatus.Stopped))); + } + }; + + private static DefaultCamelContext context = new DefaultCamelContext(); + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClass(SimpleCamelRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void sendMessageToInbound(@Uri("direct:start") ProducerTemplate inbound, + @Uri("mock:result") MockEndpoint outbound) throws InterruptedException { + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } + + @Produces + @ApplicationScoped + private CamelContext produceAndStartContext() { + context.setName("unstopped-context"); + return context; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriEndpointTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriEndpointTest.java new file mode 100644 index 0000000..2f47ef2 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriEndpointTest.java @@ -0,0 +1,69 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.inject.Inject; + +import org.apache.camel.ProducerTemplate; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.UriEndpointRoute; +import org.apache.camel.component.mock.MockEndpoint; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; + +@RunWith(Arquillian.class) +public class UriEndpointTest { + + @Inject + @Uri("direct:inbound") + private ProducerTemplate inbound; + + @Inject + @Uri("mock:outbound") + private MockEndpoint outbound; + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClass(UriEndpointRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void sendMessageToInbound() throws InterruptedException { + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriQualifierWithContextTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriQualifierWithContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriQualifierWithContextTest.java new file mode 100644 index 0000000..5e17b1d --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriQualifierWithContextTest.java @@ -0,0 +1,90 @@ +/** + * 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.cdi.test; + +import java.util.concurrent.TimeUnit; +import javax.inject.Inject; + +import org.apache.camel.Endpoint; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.ContextName; +import org.apache.camel.cdi.Mock; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.FirstCamelContextBean; +import org.apache.camel.component.mock.MockEndpoint; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; + +@RunWith(Arquillian.class) +public class UriQualifierWithContextTest { + + @Inject + @Uri(value = "mock:outbound", context = "first") + private MockEndpoint outbound; + + @Inject + @Uri(value = "direct:inbound", context = "first") + private ProducerTemplate inbound; + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test classes + .addClasses(FirstCamelContextBean.class, UriWithContextRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void sendMessageToInbound() throws InterruptedException { + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } +} + +@ContextName("first") +class UriWithContextRoute extends RouteBuilder { + + @Inject + @Uri(value = "direct:inbound", context = "first") + Endpoint inbound; + + @Inject + @Mock(value = "mock:outbound", context = "first") + MockEndpoint outbound; + + @Override + public void configure() { + from(inbound).to(outbound); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java new file mode 100644 index 0000000..e6297ab --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java @@ -0,0 +1,78 @@ +/** + * 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.cdi.test; + +import javax.inject.Inject; + +import org.apache.camel.Endpoint; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.ContextName; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.FirstCamelContextBean; +import org.apache.camel.cdi.rule.ExpectedDeploymentException; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; + +import static org.hamcrest.Matchers.containsString; + +@RunWith(Arquillian.class) +public class UriWithWrongContextTest { + + @ClassRule + public static TestRule exception = ExpectedDeploymentException.none() + .expect(RuntimeException.class) + .expectMessage(containsString("Error adding routes of type [" + UriWithWrongContextRoute.class.getName() + "] to Camel context [first]")) + .expectMessage(containsString("Error injecting endpoint annotated with @org.apache.camel.cdi.Uri")) + .expectMessage(containsString("No Camel context with name [second] is deployed!")); + + @Deployment + public static Archive<?> deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test classes + .addClasses(FirstCamelContextBean.class, UriWithWrongContextRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void test() { + } +} + +@ContextName("first") +class UriWithWrongContextRoute extends RouteBuilder { + + @Inject + @Uri(value = "direct:inbound", context = "second") + Endpoint inbound; + + @Override + public void configure() { + from(inbound).to("mock:outbound"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/resources/META-INF/beans.xml b/components/camel-cdi/src/test/resources/META-INF/beans.xml deleted file mode 100644 index 112d56d..0000000 --- a/components/camel-cdi/src/test/resources/META-INF/beans.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<beans/> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/META-INF/camel.properties ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/resources/META-INF/camel.properties b/components/camel-cdi/src/test/resources/META-INF/camel.properties deleted file mode 100644 index cb8d83f..0000000 --- a/components/camel-cdi/src/test/resources/META-INF/camel.properties +++ /dev/null @@ -1 +0,0 @@ -directEndpoint=direct:inject \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/bar.properties ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/resources/bar.properties b/components/camel-cdi/src/test/resources/bar.properties new file mode 100644 index 0000000..a55747a --- /dev/null +++ b/components/camel-cdi/src/test/resources/bar.properties @@ -0,0 +1,18 @@ +## ------------------------------------------------------------------------ +## 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. +## ------------------------------------------------------------------------ + +bar.property=bar.value \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/foo.properties ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/resources/foo.properties b/components/camel-cdi/src/test/resources/foo.properties new file mode 100644 index 0000000..a969a68 --- /dev/null +++ b/components/camel-cdi/src/test/resources/foo.properties @@ -0,0 +1,18 @@ +## ------------------------------------------------------------------------ +## 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. +## ------------------------------------------------------------------------ + +foo.property=foo.value \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/resources/log4j.properties b/components/camel-cdi/src/test/resources/log4j.properties index c026599..712a8a5 100644 --- a/components/camel-cdi/src/test/resources/log4j.properties +++ b/components/camel-cdi/src/test/resources/log4j.properties @@ -1,40 +1,37 @@ -## --------------------------------------------------------------------------- +## ------------------------------------------------------------------------ ## 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. -## --------------------------------------------------------------------------- +## ------------------------------------------------------------------------ # -# The logging properties used during tests.. +# The logging properties used for eclipse testing, We want to see debug output on the console. # log4j.rootLogger=INFO, file -#log4j.logger.org.apache.camel.component.cdi=DEBUG -#log4j.logger.org.apache.openwebbeans=DEBUG +#log4j.logger.org.jboss.weld=DEBUG +#log4j.logger.org.apache.webbeans=DEBUG +#log4j.logger.org.apache.camel=DEBUG +#log4j.logger.org.apache.camel.cdi=DEBUG # CONSOLE appender not used by default log4j.appender.out=org.apache.log4j.ConsoleAppender log4j.appender.out.layout=org.apache.log4j.PatternLayout log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -# MDC -#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %-10.10X{camel.breadcrumbId} - %-10.10X{camel.exchangeId} - %-10.10X{camel.correlationId} - %-10.10X{camel.routeId} - %m%n # File appender log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n log4j.appender.file.file=target/camel-cdi-test.log -log4j.appender.file.append=true -log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -# MDC -#log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %-10.10X{camel.breadcrumbId} - %-10.10X{camel.exchangeId} - %-10.10X{camel.correlationId} - %-10.10X{camel.routeId} - %m%n http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/logging.properties ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/resources/logging.properties b/components/camel-cdi/src/test/resources/logging.properties new file mode 100644 index 0000000..6051671 --- /dev/null +++ b/components/camel-cdi/src/test/resources/logging.properties @@ -0,0 +1,50 @@ +# +# +# 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. +# +# +############################################################ +# Default Logging Configuration File +# +# You can use a different file by specifying a filename +# with the java.util.logging.config.file system property. +# For example java -Djava.util.logging.config.file=myfile +############################################################ + +############################################################ +# Global properties +############################################################ + +# "handlers" specifies a comma separated list of log Handler +# classes. These handlers will be installed during VM startup. +# Note that these classes must be on the system classpath. +# By default we only configure a ConsoleHandler, which will only +# show messages at the INFO and above levels. +#handlers= java.util.logging.ConsoleHandler + +# To also add the FileHandler, use the following line instead. +#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler +handlers=org.slf4j.bridge.SLF4JBridgeHandler + +# Default global logging level. +# This specifies which kinds of events are logged across +# all loggers. For any given facility this global level +# can be overriden by a facility specific level +# Note that the ConsoleHandler also has a separate level +# setting to limit messages printed to the console. +.level=ALL \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/placeholder.properties ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/resources/placeholder.properties b/components/camel-cdi/src/test/resources/placeholder.properties new file mode 100644 index 0000000..8f3f0f5 --- /dev/null +++ b/components/camel-cdi/src/test/resources/placeholder.properties @@ -0,0 +1,18 @@ +## ------------------------------------------------------------------------ +## 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. +## ------------------------------------------------------------------------ + +header.message=message from file \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/routes.xml ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/resources/routes.xml b/components/camel-cdi/src/test/resources/routes.xml index 3506cff..29b3a21 100644 --- a/components/camel-cdi/src/test/resources/routes.xml +++ b/components/camel-cdi/src/test/resources/routes.xml @@ -1,8 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> -<routes xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <to uri="mock:results"/> - </route> -</routes> +<!-- + 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. +--> + +<routes id="routes" xmlns="http://camel.apache.org/schema/spring"> + <route id="xml-route"> + <from uri="direct:inbound"/> + <to uri="mock:outbound"/> + </route> +</routes> http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-sjms/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-sjms/pom.xml b/components/camel-sjms/pom.xml index f35f70b..db3fcd2 100644 --- a/components/camel-sjms/pom.xml +++ b/components/camel-sjms/pom.xml @@ -66,7 +66,7 @@ <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-annotation_1.0_spec</artifactId> - <version>${geronimo-annotation-spec-version}</version> + <version>${geronimo-annotation-1.0-spec-version}</version> <scope>provided</scope> </dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/examples/camel-example-cdi/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-cdi/pom.xml b/examples/camel-example-cdi/pom.xml index 4b05146..c555807 100644 --- a/examples/camel-example-cdi/pom.xml +++ b/examples/camel-example-cdi/pom.xml @@ -35,11 +35,11 @@ <artifactId>camel-cdi</artifactId> </dependency> - <!-- cdi api --> + <!-- CDI API --> <dependency> <groupId>javax.enterprise</groupId> <artifactId>cdi-api</artifactId> - <version>1.2</version> + <version>${cdi-api-1.2-version}</version> <scope>provided</scope> </dependency> @@ -56,19 +56,28 @@ <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> <!-- use log4j as logger --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> + <scope>runtime</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> + <scope>runtime</scope> </dependency> </dependencies> http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java b/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java index c95de3c..246b5e8 100644 --- a/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java +++ b/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java @@ -20,13 +20,11 @@ import javax.inject.Inject; import org.apache.camel.Endpoint; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.cdi.ContextName; import org.apache.camel.cdi.Uri; /** * Configures all our Camel routes, components, endpoints and beans */ -@ContextName public class MyRoutes extends RouteBuilder { @Inject @@ -38,7 +36,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) http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index d8d0495..e9c7346 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -50,7 +50,7 @@ <aries-blueprint-proxy-version>1.0.1</aries-blueprint-proxy-version> <aries-blueprint-proxy-impl-version>1.0.4</aries-blueprint-proxy-impl-version> <aries-util-version>1.1.0</aries-util-version> - <arquillian-junit-container-version>1.1.10.Final</arquillian-junit-container-version> + <arquillian-version>1.1.10.Final</arquillian-version> <arquillian-weld-se-embedded-version>1.0.0.CR9</arquillian-weld-se-embedded-version> <asm-bundle-version>3.3.1_1</asm-bundle-version> <asm-version>3.3.1</asm-version> @@ -88,7 +88,9 @@ <cassandra-unit-version>2.2.2.1</cassandra-unit-version> <castor-version>1.3.3</castor-version> <castor-bundle-version>1.3.3_1</castor-bundle-version> - <cdi-api-version>1.1</cdi-api-version> + <cdi-api-1.0-version>1.0-SP4</cdi-api-1.0-version> + <cdi-api-1.1-version>1.1</cdi-api-1.1-version> + <cdi-api-1.2-version>1.2</cdi-api-1.2-version> <cglib-bundle-version>3.2.0_1</cglib-bundle-version> <cglib-version>3.2.0</cglib-version> <chunk-templates-version>3.1.3</chunk-templates-version> @@ -174,15 +176,18 @@ <freemarker-version>2.3.23</freemarker-version> <gentlyweb-bundle-version>1.5_1</gentlyweb-bundle-version> <geocoder-java-version>0.16</geocoder-java-version> - <geronimo-annotation-spec-version>1.1.1</geronimo-annotation-spec-version> + <geronimo-annotation-1.0-spec-version>1.1.1</geronimo-annotation-1.0-spec-version> + <geronimo-annotation-1.2-spec-version>1.0</geronimo-annotation-1.2-spec-version> <geronimo-atinject-1.0-spec-version>1.0</geronimo-atinject-1.0-spec-version> <geronimo-ejb_3.1_spec-version>1.0.2</geronimo-ejb_3.1_spec-version> <geronimo-el-spec-version>1.0.1</geronimo-el-spec-version> <geronimo-interceptor-1.1-spec-version>1.0</geronimo-interceptor-1.1-spec-version> + <geronimo-interceptor-1.2-spec-version>1.0</geronimo-interceptor-1.2-spec-version> <geronimo-j2ee-connector-spec-version>2.0.0</geronimo-j2ee-connector-spec-version> <geronimo-j2ee-jacc-spec-version>1.1</geronimo-j2ee-jacc-spec-version> <geronimo-j2ee-management-spec-version>1.1</geronimo-j2ee-management-spec-version> <geronimo-jcdi-1.0-spec-version>1.0</geronimo-jcdi-1.0-spec-version> + <geronimo-jcdi-1.1-spec-version>1.0</geronimo-jcdi-1.1-spec-version> <geronimo-jms-spec-version>1.1.1</geronimo-jms-spec-version> <geronimo-jpa2-spec-version>1.1</geronimo-jpa2-spec-version> <geronimo-jsp-spec-version>1.1</geronimo-jsp-spec-version> @@ -400,7 +405,8 @@ <netty-version>4.0.33.Final</netty-version> <noggit-bundle-version>0.5_1</noggit-bundle-version> <!-- should be in-sync with deltaspike --> - <openwebbeans-version>1.2.0</openwebbeans-version> + <openwebbeans1-version>1.2.7</openwebbeans1-version> + <openwebbeans-version>1.6.2</openwebbeans-version> <oauth-provider-bundle-version>20100527_1</oauth-provider-bundle-version> <olingo2-version>2.0.5</olingo2-version> <olingo-odata2-core-bundle-version>2.0.5_1</olingo-odata2-core-bundle-version> @@ -459,6 +465,7 @@ <servlet-api-3.0-version>1.0</servlet-api-3.0-version> <servlet-version-range>[2.5,4)</servlet-version-range> <shiro-version>1.2.4</shiro-version> + <shrinkwrap-descriptors-version>2.0.0-alpha-8</shrinkwrap-descriptors-version> <sip-api-version>1.1</sip-api-version> <slf4j-api-version>1.7.13</slf4j-api-version> <slf4j-version>1.7.13</slf4j-version> @@ -533,6 +540,7 @@ <velocity-version>1.7</velocity-version> <vertx-version>3.2.0</vertx-version> <vysper-version>0.7</vysper-version> + <weld1-version>1.1.28.Final</weld1-version> <weld2-version>2.3.2.Final</weld2-version> <werken-xpath-bundle-version>0.9.4_5</werken-xpath-bundle-version> <woodstox-version>4.4.1</woodstox-version> http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/platforms/karaf/features/src/main/resources/features.xml ---------------------------------------------------------------------- diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml index 1ce577d..75ebde4 100644 --- a/platforms/karaf/features/src/main/resources/features.xml +++ b/platforms/karaf/features/src/main/resources/features.xml @@ -874,7 +874,9 @@ <bundle>mvn:org.apache.camel/camel-josql/${project.version}</bundle> </feature> <feature name='camel-jpa' version='${project.version}' resolver='(obr)' start-level='50'> - <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-annotation_1.0_spec/${geronimo-annotation-spec-version}</bundle> + <bundle dependency='true'> + mvn:org.apache.geronimo.specs/geronimo-annotation_1.0_spec/${geronimo-annotation-1.0-spec-version} + </bundle> <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-jpa_2.0_spec/${geronimo-jpa2-spec-version}</bundle> <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-servlet_3.0_spec/${geronimo-servlet-spec-version}</bundle> <feature version='${spring-version-range-karaf}'>spring-tx</feature> http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/pom.xml ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/pom.xml b/tests/camel-itest-cdi/pom.xml index 2fda15c..fb954e9 100644 --- a/tests/camel-itest-cdi/pom.xml +++ b/tests/camel-itest-cdi/pom.xml @@ -34,11 +34,11 @@ <artifactId>camel-cdi</artifactId> </dependency> - <!-- cdi api --> + <!-- CDI API --> <dependency> <groupId>javax.enterprise</groupId> <artifactId>cdi-api</artifactId> - <version>${cdi-api-version}</version> + <version>${cdi-api-1.1-version}</version> </dependency> <!-- logging --> @@ -53,14 +53,6 @@ <!-- for testing --> <dependency> - <groupId>org.apache.deltaspike.core</groupId> - <artifactId>deltaspike-core-impl</artifactId> - <version>${deltaspike-version}</version> - <scope>test</scope> - </dependency> - - <!-- for testing --> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> @@ -68,7 +60,7 @@ <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> - <version>${arquillian-junit-container-version}</version> + <version>${arquillian-version}</version> <scope>test</scope> </dependency> </dependencies> @@ -76,33 +68,21 @@ <profiles> <profile> - <id>weld2</id> + <id>weld-1.2</id> <activation> <activeByDefault>true</activeByDefault> </activation> <dependencies> <dependency> - <groupId>org.apache.deltaspike.cdictrl</groupId> - <artifactId>deltaspike-cdictrl-weld</artifactId> - <version>${deltaspike-version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.jboss.weld.se</groupId> - <artifactId>weld-se-core</artifactId> + <groupId>org.jboss.weld</groupId> + <artifactId>weld-core-impl</artifactId> <version>${weld2-version}</version> - <scope>provided</scope> + <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.arquillian.container</groupId> <artifactId>arquillian-weld-se-embedded-1.1</artifactId> <version>${arquillian-weld-se-embedded-version}</version> - <exclusions> - <exclusion> - <groupId>org.jboss.arquillian.container</groupId> - <artifactId>arquillian-container-spi</artifactId> - </exclusion> - </exclusions> <scope>test</scope> </dependency> </dependencies> http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextA.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextA.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextA.java new file mode 100644 index 0000000..3ca839c --- /dev/null +++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextA.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("contextA") +public class CamelContextA 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/CamelContextB.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextB.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextB.java new file mode 100644 index 0000000..2889cbd --- /dev/null +++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextB.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("contextB") +public class CamelContextB extends CdiCamelContext { + +}