http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointDefinedUsingConfigPropertyTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointDefinedUsingConfigPropertyTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointDefinedUsingConfigPropertyTest.java deleted file mode 100644 index d254ccf..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointDefinedUsingConfigPropertyTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.cdi; - -import java.util.ArrayList; -import java.util.List; -import javax.inject.Inject; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.cdi.store.Item; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.deltaspike.core.api.config.ConfigProperty; -import org.junit.Test; - -public class EndpointDefinedUsingConfigPropertyTest extends CdiContextTestSupport { - - @Inject @ConfigProperty(name = "directEndpoint") - String directInjectEndpoint; - - @EndpointInject(uri = "mock:result") - MockEndpoint mockResultEndpoint; - - @Produce(uri = "direct:inject") - ProducerTemplate myProducer; - - @Test - public void beanShouldBeInjected() throws InterruptedException { - mockResultEndpoint.expectedMessageCount(1); - myProducer.sendBody("hello"); - - assertMockEndpointsSatisfied(); - - Exchange exchange = mockResultEndpoint.getExchanges().get(0); - List<?> results = exchange.getIn().getBody(List.class); - List<Item> expected = itemsExpected(); - assertNotNull(results); - assertNotNull(expected); - assertEquals(expected.size(), results.size()); - assertEquals(expected, results); - } - - private List<Item> itemsExpected() { - List<Item> products = new ArrayList<Item>(); - for (int i = 1; i < 10; i++) { - products.add(new Item("Item-" + i, 1500L * i)); - } - return products; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from(directInjectEndpoint) - .bean("shoppingBean", "listAllProducts") - .to(mockResultEndpoint); - } - }; - } -}
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointInjectTest.java deleted file mode 100644 index df83848..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointInjectTest.java +++ /dev/null @@ -1,43 +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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.Endpoint; -import org.apache.camel.cdi.support.EndpointInjectedBean; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Test endpoint injection - */ -public class EndpointInjectTest extends CdiTestSupport { - - @Inject - private EndpointInjectedBean bean; - - @Test - public void shouldInjectEndpoint() { - assertNotNull(bean); - Endpoint endpoint = bean.getEndpoint(); - assertNotNull("Could not find injected endpoint!", endpoint); - assertTrue("Endpoint should be a MockEndpoint but was " + endpoint, endpoint instanceof MockEndpoint); - assertEquals("Endpoint URI", "mock://blah", endpoint.getEndpointUri()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointNamedInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointNamedInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointNamedInjectTest.java deleted file mode 100644 index 30f73c4..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointNamedInjectTest.java +++ /dev/null @@ -1,39 +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.cdi; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.apache.camel.Endpoint; -import org.junit.Test; - -/** - * Test endpoint injection by @Named - */ -public class EndpointNamedInjectTest extends CdiTestSupport { - - @Inject @Named("myNamedEndpoint") - private Endpoint endpoint; - - @Test - public void shouldInjectEndpoint() { - assertNotNull("Could not find injected endpoint!", endpoint); - assertEquals("Endpoint URI", "mock:nameInjected", endpoint.getEndpointUri()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java deleted file mode 100644 index 3e9a174..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java +++ /dev/null @@ -1,43 +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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.Endpoint; -import org.apache.camel.cdi.support.EndpointUriPropertyInjectedBean; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Test endpoint injection using a dynamic property expression - */ -public class EndpointPropertyInjectTest extends CdiTestSupport { - - @Inject - private EndpointUriPropertyInjectedBean bean; - - @Test - public void shouldInjectEndpointByProperty() { - assertNotNull(bean); - Endpoint endpoint = bean.getEndpoint(); - assertNotNull("Could not find injected endpoint!", endpoint); - assertTrue("Endpoint should be a MockEndpoint but was " + endpoint, endpoint instanceof MockEndpoint); - assertEquals("Endpoint URI", "mock://injectedByProperty", endpoint.getEndpointUri()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java deleted file mode 100644 index d4daead..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java +++ /dev/null @@ -1,47 +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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.Endpoint; -import org.apache.camel.cdi.support.EndpointUriInjectedBean; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Test endpoint injection - */ -public class EndpointUriInjectTest extends CdiTestSupport { - - @Inject - private EndpointUriInjectedBean bean; - - @Test - public void shouldInjectEndpoint() { - assertNotNull(bean); - Endpoint endpoint = bean.getEndpoint(); - assertNotNull("Could not find injected endpoint!", endpoint); - assertTrue("Endpoint should be a MockEndpoint but was " + endpoint, endpoint instanceof MockEndpoint); - assertEquals("Endpoint URI", "mock://uriInjected", endpoint.getEndpointUri()); - - Endpoint endpoint2 = bean.getEndpoint2(); - assertNotNull("Could not find injected endpoint2!", endpoint2); - assertEquals("Endpoint URI", "mock://anotherEndpoint", endpoint2.getEndpointUri()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/InjectCamelAnnotationsTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/InjectCamelAnnotationsTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/InjectCamelAnnotationsTest.java deleted file mode 100644 index 5d6bce7..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/InjectCamelAnnotationsTest.java +++ /dev/null @@ -1,78 +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.cdi; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.camel.Endpoint; -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.cdi.store.Item; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -public class InjectCamelAnnotationsTest extends CdiContextTestSupport { - - @EndpointInject(uri = "direct:inject") - Endpoint directInjectEndpoint; - - @EndpointInject(uri = "mock:result") - MockEndpoint mockResultEndpoint; - - @Produce(uri = "direct:inject") - ProducerTemplate myProducer; - - @Test - public void beanShouldBeInjected() throws InterruptedException { - mockResultEndpoint.expectedMessageCount(1); - myProducer.sendBody("hello"); - - assertMockEndpointsSatisfied(); - - Exchange exchange = mockResultEndpoint.getExchanges().get(0); - List<?> results = exchange.getIn().getBody(List.class); - List<Item> expected = itemsExpected(); - assertNotNull(results); - assertNotNull(expected); - assertEquals(expected.size(), results.size()); - assertEquals(expected, results); - } - - private List<Item> itemsExpected() { - List<Item> products = new ArrayList<Item>(); - for (int i = 1; i < 10; i++) { - products.add(new Item("Item-" + i, 1500L * i)); - } - return products; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from(directInjectEndpoint) - .bean("shoppingBean", "listAllProducts") - .to(mockResultEndpoint); - } - }; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/MockEndpointInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/MockEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/MockEndpointInjectTest.java deleted file mode 100644 index f2af675..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/MockEndpointInjectTest.java +++ /dev/null @@ -1,45 +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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.cdi.support.MockEndpointInjectedBean; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Test mock endpoint injection - */ -public class MockEndpointInjectTest extends CdiTestSupport { - - @Inject - private MockEndpointInjectedBean bean; - - @Test - public void shouldInjectMockEndpoint() { - assertNotNull(bean); - MockEndpoint foo = bean.getFoo(); - MockEndpoint bar = bean.getBar(); - assertNotNull("Could not find injected foo endpoint!", foo); - assertNotNull("Could not find injected bar endpoint!", bar); - - assertEquals("foo URI", "mock://foo", foo.getEndpointUri()); - assertEquals("bar URI", "mock://something", bar.getEndpointUri()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java deleted file mode 100644 index 1d56233..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java +++ /dev/null @@ -1,45 +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.cdi; - -import javax.inject.Inject; - -import org.apache.camel.ProducerTemplate; -import org.apache.camel.cdi.support.ProduceInjectedBean; -import org.junit.Test; - -/** - * Test endpoint injection - */ -public class ProduceInjectTest extends CdiTestSupport { - - @Inject - private ProduceInjectedBean bean; - - @Test - public void shouldInjectEndpoint() { - assertNotNull(bean); - ProducerTemplate producer = bean.getProducer(); - assertNotNull("Could not find injected producer!", producer); - assertEquals("producer default URI", "mock://foo", producer.getDefaultEndpoint().getEndpointUri()); - - ProducerTemplate producer2 = bean.getProducer2(); - assertNotNull("Could not find injected producer2!", producer2); - assertEquals("producer2 default URI", "mock://bar", producer2.getDefaultEndpoint().getEndpointUri()); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/RegistryLookupAndInjectorTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/RegistryLookupAndInjectorTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/RegistryLookupAndInjectorTest.java deleted file mode 100644 index 34844e7..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/RegistryLookupAndInjectorTest.java +++ /dev/null @@ -1,94 +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.cdi; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.cdi.store.Item; -import org.apache.camel.cdi.store.ShoppingBean; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -public class RegistryLookupAndInjectorTest extends CdiContextTestSupport { - - private MockEndpoint resultEndpoint; - - @Override - public void setUp() throws Exception { - super.setUp(); - - resultEndpoint = getMockEndpoint("mock:result"); - } - - @Test - public void shouldLookupBeanByName() throws InterruptedException { - resultEndpoint.expectedMessageCount(1); - template.sendBody("direct:injectByName", "hello"); - - assertMockEndpointsSatisfied(); - - Exchange exchange = resultEndpoint.getExchanges().get(0); - List<?> results = exchange.getIn().getBody(List.class); - List<Item> expected = itemsExpected(); - assertNotNull(results); - assertNotNull(expected); - assertEquals(expected.size(), results.size()); - assertEquals(expected, results); - } - - @Test - public void shouldLookupBeanByTypeAndInjectFields() throws InterruptedException { - resultEndpoint.expectedMessageCount(1); - template.sendBody("direct:injectByType", "hello"); - - assertMockEndpointsSatisfied(); - - Exchange exchange = resultEndpoint.getExchanges().get(0); - List<?> results = exchange.getIn().getBody(List.class); - List<Item> expected = itemsExpected(); - assertNotNull(results); - assertNotNull(expected); - assertEquals(expected.size(), results.size()); - assertEquals(expected, results); - } - - private List<Item> itemsExpected() { - List<Item> products = new ArrayList<Item>(); - for (int i = 1; i < 10; i++) { - products.add(new Item("Item-" + i, 1500L * i)); - } - return products; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:injectByName") - .bean("shoppingBean", "listAllProducts") - .to("mock:result"); - from("direct:injectByType") - .bean(ShoppingBean.class, "listAllProducts") - .to("mock:result"); - } - }; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromClassPathTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromClassPathTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromClassPathTest.java deleted file mode 100644 index 1c6abfa..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromClassPathTest.java +++ /dev/null @@ -1,60 +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.cdi; - -import javax.enterprise.inject.Produces; -import javax.inject.Inject; - -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.model.RoutesDefinition; -import org.junit.Test; - -/** - * Checks we can load XML routes from the classpath and use then with CDI - */ -public class XmlRoutesFromClassPathTest extends CdiTestSupport { - @Inject - @Mock - MockEndpoint results; - - @Inject - @Uri("direct:start") - ProducerTemplate producer; - - Object[] expectedBodies = {"body:1", "body:2"}; - - @Produces - @ContextName - public RoutesDefinition createRoutes() throws Exception { - return RoutesXml.loadRoutesFromClasspath(new CdiCamelContext(), "routes.xml"); - } - - @Test - public void xmlRoutesWorkOnClassPath() throws Exception { - assertNotNull("results not injected", results); - assertNotNull("producer not injected", producer); - - results.expectedBodiesReceived(expectedBodies); - - for (Object body : expectedBodies) { - producer.sendBody(body); - } - - results.assertIsSatisfied(); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromURLTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromURLTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromURLTest.java deleted file mode 100644 index 7603aca..0000000 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromURLTest.java +++ /dev/null @@ -1,44 +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.cdi; - -import java.io.File; -import java.net.URL; - -import org.apache.camel.model.RoutesDefinition; - -/** - * Tests loading of routes as XML from a URL - */ -public class XmlRoutesFromURLTest extends XmlRoutesFromClassPathTest { - - @Override - public RoutesDefinition createRoutes() throws Exception { - String[] prefixes = {"camel-cdi", "components"}; - String fileName = "src/test/resources/routes.xml"; - File file = new File(fileName); - for (String prefix : prefixes) { - if (file.exists()) { - break; - } - file = new File(prefix, file.getPath()); - } - assertTrue("The file " + file.getPath() + " does not exist", file.exists()); - URL url = file.toURI().toURL(); - return RoutesXml.loadRoutesFromURL(new CdiCamelContext(), url); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/BeanInjectBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/BeanInjectBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/BeanInjectBean.java new file mode 100644 index 0000000..8d3194d --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/BeanInjectBean.java @@ -0,0 +1,47 @@ +/** + * 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.bean; + +import org.apache.camel.BeanInject; + +public class BeanInjectBean { + + @BeanInject + private PropertyInjectBean injectBeanField; + + private PropertyInjectBean injectBeanMethod; + + @BeanInject("beanName") + private NamedCamelBean injectBeanNamed; + + public PropertyInjectBean getInjectBeanField() { + return injectBeanField; + } + + @BeanInject + public void setInjectBeanMethod(PropertyInjectBean bean) { + injectBeanMethod = bean; + } + + public PropertyInjectBean getInjectBeanMethod() { + return injectBeanMethod; + } + + public NamedCamelBean getInjectBeanNamed() { + return injectBeanNamed; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextAwareBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextAwareBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextAwareBean.java new file mode 100644 index 0000000..bf74ae3 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextAwareBean.java @@ -0,0 +1,38 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.CamelContext; +import org.apache.camel.CamelContextAware; + +@ApplicationScoped +public class CamelContextAwareBean implements CamelContextAware { + + private CamelContext camelContext; + + @Override + public void setCamelContext(CamelContext camelContext) { + this.camelContext = camelContext; + } + + @Override + public CamelContext getCamelContext() { + return camelContext; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextProducerMethod.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextProducerMethod.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextProducerMethod.java new file mode 100644 index 0000000..3d24a39 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextProducerMethod.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.cdi.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; + +import org.apache.camel.CamelContext; +import org.apache.camel.impl.DefaultCamelContext; + +public class CamelContextProducerMethod { + + @Produces + @ApplicationScoped + CamelContext createAndStartContext() throws Exception { + DefaultCamelContext context = new DefaultCamelContext(); + context.setName("camel-producer-method"); + context.start(); + return context; + } + + void stopContext(@Disposes CamelContext context) throws Exception { + context.stop(); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ConsumeMethodBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ConsumeMethodBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ConsumeMethodBean.java new file mode 100644 index 0000000..728696b --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ConsumeMethodBean.java @@ -0,0 +1,38 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.Body; +import org.apache.camel.Consume; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.cdi.Uri; + +@ApplicationScoped +public class ConsumeMethodBean { + + @Inject + @Uri("mock:outbound") + private ProducerTemplate producer; + + @Consume(uri = "seda:inbound") + public void consume(@Body String body) { + producer.sendBody(body); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomLifecycleCamelContext.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomLifecycleCamelContext.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomLifecycleCamelContext.java new file mode 100644 index 0000000..5603fc5 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomLifecycleCamelContext.java @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.cdi.bean; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.cdi.CdiCamelContext; +import org.apache.camel.util.ObjectHelper; + +@ApplicationScoped +public class CustomLifecycleCamelContext extends CdiCamelContext { + + @Inject + CustomLifecycleCamelContext() { + setName("custom"); + } + + @PostConstruct + void postConstruct() { + try { + super.start(); + } catch (Exception cause) { + throw ObjectHelper.wrapRuntimeCamelException(cause); + } + } + + @PreDestroy + void preDestroy() { + try { + super.stop(); + } catch (Exception cause) { + throw ObjectHelper.wrapRuntimeCamelException(cause); + } + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomPropertiesCamelContext.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomPropertiesCamelContext.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomPropertiesCamelContext.java new file mode 100644 index 0000000..26ab25a --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomPropertiesCamelContext.java @@ -0,0 +1,32 @@ +/** + * 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.bean; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.component.properties.PropertiesComponent; +import org.apache.camel.impl.DefaultCamelContext; + +@ApplicationScoped +public class CustomPropertiesCamelContext extends DefaultCamelContext { + + @PostConstruct + void addPropertiesLocation() { + getComponent("properties", PropertiesComponent.class).setLocation("classpath:placeholder.properties"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/DefaultCamelContextBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/DefaultCamelContextBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/DefaultCamelContextBean.java new file mode 100644 index 0000000..a700d74 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/DefaultCamelContextBean.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.cdi.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; + +import org.apache.camel.impl.DefaultCamelContext; + +@Named("camel-cdi") +@ApplicationScoped +public class DefaultCamelContextBean extends DefaultCamelContext { + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectRoute.java new file mode 100644 index 0000000..ee76bd0 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectRoute.java @@ -0,0 +1,35 @@ +/** + * 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.bean; + +import org.apache.camel.Endpoint; +import org.apache.camel.EndpointInject; +import org.apache.camel.builder.RouteBuilder; + +public class EndpointInjectRoute extends RouteBuilder { + + @EndpointInject(uri = "direct:inbound") + private Endpoint inbound; + + @EndpointInject(uri = "mock:outbound") + private Endpoint 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/bean/EndpointInjectWrongContextRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java new file mode 100644 index 0000000..d75cc10 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java @@ -0,0 +1,36 @@ +/** + * 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.bean; + +import org.apache.camel.Endpoint; +import org.apache.camel.EndpointInject; +import org.apache.camel.builder.RouteBuilder; + +public class EndpointInjectWrongContextRoute extends RouteBuilder { + + @EndpointInject(uri = "direct:inbound") + private Endpoint inbound; + + // Wrong context name should lead to resolution exception + @EndpointInject(uri = "mock:outbound", context = "foo") + private Endpoint 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/bean/EventConsumingRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRoute.java new file mode 100644 index 0000000..3978dda --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRoute.java @@ -0,0 +1,65 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiEventEndpoint; +import org.apache.camel.cdi.pojo.EventPayload; +import org.apache.camel.cdi.qualifier.BarQualifier; +import org.apache.camel.cdi.qualifier.FooQualifier; + +@ApplicationScoped +public class EventConsumingRoute extends RouteBuilder { + + @Inject + private CdiEventEndpoint<Object> objectCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<String> stringCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<EventPayload<String>> stringPayloadCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<EventPayload<Integer>> integerPayloadCdiEventEndpoint; + + @Inject + @FooQualifier + private CdiEventEndpoint<Long> fooQualifierCdiEventEndpoint; + + @Inject + @BarQualifier + private CdiEventEndpoint<Long> barQualifierCdiEventEndpoint; + + @Override + public void configure() { + from(objectCdiEventEndpoint).to("mock:consumeObject"); + + from(stringCdiEventEndpoint).to("mock:consumeString"); + + from(stringPayloadCdiEventEndpoint).to("mock:consumeStringPayload"); + + from(integerPayloadCdiEventEndpoint).to("mock:consumeIntegerPayload"); + + from(fooQualifierCdiEventEndpoint).to("mock:consumeFooQualifier"); + + from(barQualifierCdiEventEndpoint).to("mock:consumeBarQualifier"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRouteCdi10.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRouteCdi10.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRouteCdi10.java new file mode 100644 index 0000000..59bac31 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRouteCdi10.java @@ -0,0 +1,66 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiEventEndpoint; +import org.apache.camel.cdi.pojo.EventPayloadInteger; +import org.apache.camel.cdi.pojo.EventPayloadString; +import org.apache.camel.cdi.qualifier.BarQualifier; +import org.apache.camel.cdi.qualifier.FooQualifier; + +@ApplicationScoped +public class EventConsumingRouteCdi10 extends RouteBuilder { + + @Inject + private CdiEventEndpoint<Object> objectCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<String> stringCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<EventPayloadString> stringPayloadCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<EventPayloadInteger> integerPayloadCdiEventEndpoint; + + @Inject + @FooQualifier + private CdiEventEndpoint<Long> fooQualifierCdiEventEndpoint; + + @Inject + @BarQualifier + private CdiEventEndpoint<Long> barQualifierCdiEventEndpoint; + + @Override + public void configure() { + from(objectCdiEventEndpoint).to("mock:consumeObject"); + + from(stringCdiEventEndpoint).to("mock:consumeString"); + + from(stringPayloadCdiEventEndpoint).to("mock:consumeStringPayload"); + + from(integerPayloadCdiEventEndpoint).to("mock:consumeIntegerPayload"); + + from(fooQualifierCdiEventEndpoint).to("mock:consumeFooQualifier"); + + from(barQualifierCdiEventEndpoint).to("mock:consumeBarQualifier"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRoute.java new file mode 100644 index 0000000..a662c4b --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRoute.java @@ -0,0 +1,65 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiEventEndpoint; +import org.apache.camel.cdi.pojo.EventPayload; +import org.apache.camel.cdi.qualifier.BarQualifier; +import org.apache.camel.cdi.qualifier.FooQualifier; + +@ApplicationScoped +public class EventProducingRoute extends RouteBuilder { + + @Inject + private CdiEventEndpoint<Object> objectCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<String> stringCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<EventPayload<String>> stringPayloadCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<EventPayload<Integer>> integerPayloadCdiEventEndpoint; + + @Inject + @FooQualifier + private CdiEventEndpoint<Long> fooQualifierCdiEventEndpoint; + + @Inject + @BarQualifier + private CdiEventEndpoint<Long> barQualifierCdiEventEndpoint; + + @Override + public void configure() { + from("direct:produceObject").to(objectCdiEventEndpoint); + + from("direct:produceString").to(stringCdiEventEndpoint); + + from("direct:produceStringPayload").to(stringPayloadCdiEventEndpoint); + + from("direct:produceIntegerPayload").to(integerPayloadCdiEventEndpoint); + + from("direct:produceFooQualifier").to(fooQualifierCdiEventEndpoint); + + from("direct:produceBarQualifier").to(barQualifierCdiEventEndpoint); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRouteCdi10.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRouteCdi10.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRouteCdi10.java new file mode 100644 index 0000000..b0b3031 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRouteCdi10.java @@ -0,0 +1,66 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; + +import javax.inject.Inject; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiEventEndpoint; +import org.apache.camel.cdi.pojo.EventPayloadInteger; +import org.apache.camel.cdi.pojo.EventPayloadString; +import org.apache.camel.cdi.qualifier.BarQualifier; +import org.apache.camel.cdi.qualifier.FooQualifier; + +@ApplicationScoped +public class EventProducingRouteCdi10 extends RouteBuilder { + + @Inject + private CdiEventEndpoint<Object> objectCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<String> stringCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<EventPayloadString> stringPayloadCdiEventEndpoint; + + @Inject + private CdiEventEndpoint<EventPayloadInteger> integerPayloadCdiEventEndpoint; + + @Inject + @FooQualifier + private CdiEventEndpoint<Long> fooQualifierCdiEventEndpoint; + + @Inject + @BarQualifier + private CdiEventEndpoint<Long> barQualifierCdiEventEndpoint; + + @Override + public void configure() { + from("direct:produceObject").to(objectCdiEventEndpoint); + + from("direct:produceString").to(stringCdiEventEndpoint); + + from("direct:produceStringPayload").to(stringPayloadCdiEventEndpoint); + + from("direct:produceIntegerPayload").to(integerPayloadCdiEventEndpoint); + + from("direct:produceFooQualifier").to(fooQualifierCdiEventEndpoint); + + from("direct:produceBarQualifier").to(barQualifierCdiEventEndpoint); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextBean.java new file mode 100644 index 0000000..22f5819 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextBean.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.cdi.bean; + +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.cdi.ContextName; +import org.apache.camel.impl.DefaultCamelContext; + +@ApplicationScoped +@ContextName("first") +public class FirstCamelContextBean extends DefaultCamelContext { + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEndpointInjectRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEndpointInjectRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEndpointInjectRoute.java new file mode 100644 index 0000000..a85e8e5 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEndpointInjectRoute.java @@ -0,0 +1,34 @@ +/** + * 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.bean; + +import org.apache.camel.Endpoint; +import org.apache.camel.EndpointInject; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.ContextName; + +@ContextName("first") +public class FirstCamelContextEndpointInjectRoute extends RouteBuilder { + + @EndpointInject(uri = "direct:inbound", context = "first") + private Endpoint inbound; + + @Override + public void configure() { + from(inbound).setHeader("context").constant("first").to("mock:outbound"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventConsumingRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventConsumingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventConsumingRoute.java new file mode 100644 index 0000000..8de6978 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventConsumingRoute.java @@ -0,0 +1,38 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiEventEndpoint; +import org.apache.camel.cdi.ContextName; + +@ApplicationScoped +@ContextName("first") +public class FirstCamelContextEventConsumingRoute extends RouteBuilder { + + @Inject + @ContextName("first") + private CdiEventEndpoint<String> stringCdiEventEndpoint; + + @Override + public void configure() { + from(stringCdiEventEndpoint).to("mock:consumeString"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventProducingRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventProducingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventProducingRoute.java new file mode 100644 index 0000000..b3aa140 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventProducingRoute.java @@ -0,0 +1,38 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.CdiEventEndpoint; +import org.apache.camel.cdi.ContextName; + +@ApplicationScoped +@ContextName("first") +public class FirstCamelContextEventProducingRoute extends RouteBuilder { + + @Inject + @ContextName("first") + private CdiEventEndpoint<String> stringCdiEventEndpoint; + + @Override + public void configure() { + from("direct:produceString").to(stringCdiEventEndpoint); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java new file mode 100644 index 0000000..85583bb --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java @@ -0,0 +1,30 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.cdi.bean; + +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; + +public class FirstCamelContextProduceTemplateBean { + + @Produce(uri = "mock:outbound", context = "first") + private ProducerTemplate producer; + + public void sendToProducer(String body) { + producer.sendBody(body + "-first"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java new file mode 100644 index 0000000..3ae6a22 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java @@ -0,0 +1,38 @@ +/** + * 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.bean; + +import java.util.Map; + +import org.apache.camel.Handler; +import org.apache.camel.Headers; +import org.apache.camel.PropertyInject; + +public class FirstCamelContextPropertyInjectBean { + + @PropertyInject(value = "property", context = "first") + private String property; + + @Handler + public void process(@Headers Map<String, Object> headers) { + headers.put("header", property); + } + + public String getProperty() { + return property; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextRoute.java new file mode 100644 index 0000000..14ae3f6 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextRoute.java @@ -0,0 +1,29 @@ +/** + * 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.bean; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.ContextName; + +@ContextName("first") +public class FirstCamelContextRoute extends RouteBuilder { + + @Override + public void configure() { + from("direct:inbound").setHeader("context").constant("first").to("mock:outbound"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextBean.java new file mode 100644 index 0000000..254ade6 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextBean.java @@ -0,0 +1,29 @@ +/** + * 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.bean; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; + +import org.apache.camel.cdi.ContextName; +import org.apache.camel.impl.DefaultCamelContext; + +@ApplicationScoped +@Named("first") +@ContextName("first") +public class FirstNamedCamelContextBean extends DefaultCamelContext { +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextRoute.java new file mode 100644 index 0000000..2db055f --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextRoute.java @@ -0,0 +1,29 @@ +/** + * 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.bean; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.ContextName; + +@ContextName("first") +public class FirstNamedCamelContextRoute extends RouteBuilder { + + @Override + public void configure() { + from("direct:in").transform(body().prepend("first-")).to("direct:out"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedEndpointRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedEndpointRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedEndpointRoute.java new file mode 100644 index 0000000..a0f742b --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedEndpointRoute.java @@ -0,0 +1,35 @@ +/** + * 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.bean; + +import javax.inject.Inject; + +import org.apache.camel.Endpoint; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.Uri; + +public class InjectedEndpointRoute extends RouteBuilder { + + @Inject + @Uri("direct:inbound") + private 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/java/org/apache/camel/cdi/bean/InjectedTypeConverterRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedTypeConverterRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedTypeConverterRoute.java new file mode 100644 index 0000000..c8d3ca5 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedTypeConverterRoute.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.cdi.bean; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.pojo.TypeConverterOutput; + +public class InjectedTypeConverterRoute extends RouteBuilder { + + @Override + public void configure() { + from("direct:inbound").convertBodyTo(TypeConverterOutput.class).to("mock:outbound"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualCamelRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualCamelRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualCamelRoute.java new file mode 100644 index 0000000..4bdc130 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualCamelRoute.java @@ -0,0 +1,29 @@ +/** + * 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.bean; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.qualifier.Manual; + +@Manual +public class ManualCamelRoute extends RouteBuilder { + + @Override + public void configure() { + from("direct:manual").routeId("manual").to("mock:manual"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualStartupCamelContext.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualStartupCamelContext.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualStartupCamelContext.java new file mode 100644 index 0000000..005b96c --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualStartupCamelContext.java @@ -0,0 +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. + */ +package org.apache.camel.cdi.bean; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.apache.camel.impl.DefaultCamelContext; + +@ApplicationScoped +public class ManualStartupCamelContext extends DefaultCamelContext { + + @Inject + ManualStartupCamelContext() { + setName("manual-startup"); + } + + @PostConstruct + void postConstruct() { + setAutoStartup(false); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/MockAnnotationRoute.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/MockAnnotationRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/MockAnnotationRoute.java new file mode 100644 index 0000000..78aff0c --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/MockAnnotationRoute.java @@ -0,0 +1,41 @@ +/** + * 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.bean; + +import javax.inject.Inject; + +import org.apache.camel.Endpoint; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cdi.Mock; +import org.apache.camel.cdi.Uri; +import org.apache.camel.component.mock.MockEndpoint; + +public class MockAnnotationRoute extends RouteBuilder { + + @Inject + @Uri("direct:start") + private Endpoint directEP; + + @Inject + @Mock("mock:result") + private MockEndpoint mockEP; + + @Override + public void configure() { + from(directEP).to(mockEP); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/NamedCamelBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/NamedCamelBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/NamedCamelBean.java new file mode 100644 index 0000000..3177dd9 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/NamedCamelBean.java @@ -0,0 +1,27 @@ +/** + * 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.bean; + +import javax.inject.Named; + +@Named("beanName") +public class NamedCamelBean { + + public String processBody(String body) { + return body + "-processed"; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ProduceTemplateBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ProduceTemplateBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ProduceTemplateBean.java new file mode 100644 index 0000000..834f050 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ProduceTemplateBean.java @@ -0,0 +1,30 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.cdi.bean; + +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; + +public class ProduceTemplateBean { + + @Produce(uri = "mock:outbound") + private ProducerTemplate producer; + + public void sendToProducer(String body) { + producer.sendBody(body + "-processed"); + } +}