From 93631c85f4250b3843a7ada987c99aeed909a11d Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Tue, 23 Feb 2016 12:30:05 +0100 Subject: [PATCH 1/6] CAMEL-9201: Improved support for programmatic lookup --- components/camel-cdi/pom.xml | 17 ++++ .../apache/camel/cdi/CdiCamelExtension.java | 4 +- .../org/apache/camel/cdi/CdiSpiHelper.java | 4 + .../main/java/org/apache/camel/cdi/Uri.java | 26 ++++++ .../cdi/test/ProgrammaticLookupTest.java | 89 +++++++++++++++++++ 5 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ProgrammaticLookupTest.java diff --git a/components/camel-cdi/pom.xml b/components/camel-cdi/pom.xml index 6c10e00a3578a..fb23bce39b2c4 100644 --- a/components/camel-cdi/pom.xml +++ b/components/camel-cdi/pom.xml @@ -264,6 +264,8 @@ **/*Cdi12Test.java **/UnstoppedCamelContext*Test.java + + **/ProgrammaticLookupTest.java @@ -317,6 +319,21 @@ owb-1.2 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + **/ProgrammaticLookupTest.java + + + + + + diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java index 9f80a0f5af417..4cacd4a8ba94a 100755 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java @@ -172,7 +172,7 @@ private void camelFactoryProducers(@Observes ProcessAnnotatedType type = CdiSpiHelper.getRawType(am.getBaseType()); if (Endpoint.class.isAssignableFrom(type) || ProducerTemplate.class.equals(type)) { Set qualifiers = CdiSpiHelper.getQualifiers(am, manager); - producerQualifiers.put(am.getJavaMember(), qualifiers.isEmpty() ? Collections.singleton(DefaultLiteral.INSTANCE) : qualifiers); + producerQualifiers.put(am.getJavaMember(), qualifiers); Set annotations = new HashSet<>(am.getAnnotations()); annotations.removeAll(qualifiers); annotations.add(Excluded.INSTANCE); @@ -239,7 +239,7 @@ private void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager ma } } else { if (Endpoint.class.isAssignableFrom(type) || ProducerTemplate.class.isAssignableFrom(type)) { - qualifiers.addAll(CdiSpiHelper.excludeElementOfTypes(contextQualifiers, Any.class, Default.class, Named.class)); + qualifiers.addAll(CdiSpiHelper.excludeElementOfTypes(contextQualifiers, Default.class, Named.class)); } } // TODO: would be more correct to add a bean for each Camel context bean diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiSpiHelper.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiSpiHelper.java index d2cb4afa96096..8a7c8c5622717 100644 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiSpiHelper.java +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiSpiHelper.java @@ -138,6 +138,10 @@ static Set getQualifiers(Annotated annotated, BeanManager manager) { qualifiers.add(annotation); } } + if (qualifiers.isEmpty()) { + qualifiers.add(DefaultLiteral.INSTANCE); + } + qualifiers.add(AnyLiteral.INSTANCE); return qualifiers; } } \ No newline at end of file diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java index 0fff3d18965e5..538f882da6726 100755 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java @@ -20,6 +20,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.enterprise.util.AnnotationLiteral; import javax.enterprise.util.Nonbinding; import javax.inject.Qualifier; @@ -60,4 +61,29 @@ */ @Deprecated @Nonbinding String context() default ""; + + final class Literal extends AnnotationLiteral implements Uri { + + private static final long serialVersionUID = 1L; + + private final String uri; + + private Literal(String uri) { + this.uri = uri; + } + + public static Literal of(String uri) { + return new Literal(uri); + } + + @Override + public String value() { + return uri; + } + + @Override + public String context() { + return ""; + } + } } diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ProgrammaticLookupTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ProgrammaticLookupTest.java new file mode 100644 index 0000000000000..eb1eb18db3b95 --- /dev/null +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ProgrammaticLookupTest.java @@ -0,0 +1,89 @@ +/** + * 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.inject.Any; +import javax.enterprise.inject.Instance; +import javax.inject.Inject; + +import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.ServiceStatus; +import org.apache.camel.cdi.CdiCamelExtension; +import org.apache.camel.cdi.Uri; +import org.apache.camel.cdi.bean.EndpointInjectRoute; +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; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +@RunWith(Arquillian.class) +public class ProgrammaticLookupTest { + + @Any + @Inject + Instance contexts; + + @Any + @Inject + private Instance producers; + + @Any + @Inject + private Instance endpoints; + + @Deployment + public static Archive deployment() { + return ShrinkWrap.create(JavaArchive.class) + // Camel CDI + .addPackage(CdiCamelExtension.class.getPackage()) + // Test class + .addClass(EndpointInjectRoute.class) + // Bean archive deployment descriptor + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void verifyCamelContext() { + assertThat("Context instance status is incorrect!", contexts.get().getStatus(), is(equalTo(ServiceStatus.Started))); + } + + @Test + public void sendMessageToInbound() throws InterruptedException { + ProducerTemplate inbound = producers.select(Uri.Literal.of("direct:inbound")).get(); + MockEndpoint outbound = endpoints.select(MockEndpoint.class, Uri.Literal.of("mock:outbound")).get(); + + outbound.expectedMessageCount(1); + outbound.expectedBodiesReceived("test"); + + inbound.sendBody("test"); + + assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); + } +} From 64cbbf00fd8fec123f7404a8c4a2924b02884d4a Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Tue, 23 Feb 2016 12:40:35 +0100 Subject: [PATCH 2/6] CAMEL-9201: Consistent style for qualifier literals --- .../org/apache/camel/cdi/CdiCamelBeanPostProcessor.java | 2 +- .../src/main/java/org/apache/camel/cdi/ContextName.java | 6 +++++- .../camel/cdi/test/MultiContextEventEndpointTest.java | 6 +++--- .../test/java/org/apache/camel/itest/cdi/CamelCdiTest.java | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java index 85284fc2ec898..7d1a1b81c0abd 100644 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java @@ -110,7 +110,7 @@ private CamelPostProcessorHelper getPostProcessorHelper(String contextName) { private CamelContext getOrLookupCamelContext(String contextName) { // TODO: proper support for custom context qualifiers - return BeanManagerHelper.getReferenceByType(manager, CamelContext.class, contextName.isEmpty() ? DefaultLiteral.INSTANCE : new ContextName.Literal(contextName)); + return BeanManagerHelper.getReferenceByType(manager, CamelContext.class, contextName.isEmpty() ? DefaultLiteral.INSTANCE : ContextName.Literal.of(contextName)); } @Override diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java index 2006e71779f2a..1ca4e1f74962d 100644 --- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java +++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java @@ -79,10 +79,14 @@ final class Literal extends AnnotationLiteral implements ContextNam private final String name; - public Literal(String name) { + private Literal(String name) { this.name = name; } + public static Literal of(String name) { + return new Literal(name); + } + @Override public String value() { return name; diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java index c6b51af9de347..af54917ee63da 100644 --- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java +++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java @@ -113,9 +113,9 @@ public void sendEventsToConsumers() throws InterruptedException { secondConsumeString.expectedMessageCount(2); secondConsumeString.expectedBodiesReceived("testSecond1", "testSecond2"); - objectEvent.select(String.class, new ContextName.Literal("first")).fire("testFirst"); - objectEvent.select(String.class, new ContextName.Literal("second")).fire("testSecond1"); - objectEvent.select(String.class, new ContextName.Literal("second")).fire("testSecond2"); + objectEvent.select(String.class, ContextName.Literal.of("first")).fire("testFirst"); + objectEvent.select(String.class, ContextName.Literal.of("second")).fire("testSecond1"); + objectEvent.select(String.class, ContextName.Literal.of("second")).fire("testSecond2"); assertIsSatisfied(2L, TimeUnit.SECONDS, firstConsumeString, secondConsumeString); } diff --git a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java index bee190527a74b..39aa97112e14c 100644 --- a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java +++ b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java @@ -142,7 +142,7 @@ public static void assertHasEndpoints(CamelContext context, String... uris) { } protected CamelContext assertCamelContext(String contextName) { - CamelContext answer = camelContexts.select(new ContextName.Literal(contextName)).get(); + CamelContext answer = camelContexts.select(ContextName.Literal.of(contextName)).get(); assertTrue("CamelContext '" + contextName + "' is not started", answer.getStatus().isStarted()); return answer; } From a03797159af6e3d376a1e384036c9f90098c29b6 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Tue, 23 Feb 2016 12:43:45 +0100 Subject: [PATCH 3/6] Fix Maven warning --- examples/camel-example-cdi-osgi/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/camel-example-cdi-osgi/pom.xml b/examples/camel-example-cdi-osgi/pom.xml index 890ae7e832ec4..706b0b2df2275 100755 --- a/examples/camel-example-cdi-osgi/pom.xml +++ b/examples/camel-example-cdi-osgi/pom.xml @@ -227,7 +227,7 @@ - ${artifactId} + ${project.artifactId} From b7e661f16848d14703c4ef0f5c37c2e460618a75 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Tue, 23 Feb 2016 13:02:24 +0100 Subject: [PATCH 4/6] Polish Camel CDI examples READMEs --- examples/camel-example-cdi-metrics/README.md | 10 ++++-- examples/camel-example-cdi-osgi/README.md | 2 +- .../camel-example-cdi-properties/README.md | 10 ++++-- .../camel-example-cdi-rest-servlet/README.md | 10 ++++-- examples/camel-example-cdi/README.md | 32 +++++++++++-------- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/examples/camel-example-cdi-metrics/README.md b/examples/camel-example-cdi-metrics/README.md index bf161d1104124..ecf330d2bcd6e 100644 --- a/examples/camel-example-cdi-metrics/README.md +++ b/examples/camel-example-cdi-metrics/README.md @@ -24,13 +24,17 @@ of generated events. You will need to build this example first: - mvn install +```sh +$ mvn install +``` ### Run You can run this example using: - mvn compile camel:run +```sh +$ mvn compile camel:run +``` When the Camel application runs, you should see the calls to the 'unreliable-service' being logged to the console, e.g.: ``` @@ -64,7 +68,7 @@ The Camel application can be stopped pressing ctrl+c in th ### Forum, Help, etc If you hit an problems please let us know on the Camel Forums - + Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy! diff --git a/examples/camel-example-cdi-osgi/README.md b/examples/camel-example-cdi-osgi/README.md index 3d8d74047ec37..f1c6db6599b9e 100644 --- a/examples/camel-example-cdi-osgi/README.md +++ b/examples/camel-example-cdi-osgi/README.md @@ -193,7 +193,7 @@ shutdown: ### Forum, Help, etc If you hit an problems please let us know on the Camel Forums - + Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy! diff --git a/examples/camel-example-cdi-properties/README.md b/examples/camel-example-cdi-properties/README.md index 8099292717ba7..2eb2328c5ca08 100644 --- a/examples/camel-example-cdi-properties/README.md +++ b/examples/camel-example-cdi-properties/README.md @@ -21,13 +21,17 @@ though you can run the application in any CDI compliant container. You will need to build this example first: - mvn install +```sh +$ mvn install +``` ### Run You can run this example using: - mvn compile camel:run +```sh +$ mvn compile camel:run +``` When the Camel application runs, you should see the following messages being logged to the console, e.g.: @@ -46,7 +50,7 @@ The Camel application can be stopped pressing ctrl+c in th ### Forum, Help, etc If you hit an problems please let us know on the Camel Forums - + Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy! diff --git a/examples/camel-example-cdi-rest-servlet/README.md b/examples/camel-example-cdi-rest-servlet/README.md index 93552824daa0d..e3211dd42c7ba 100644 --- a/examples/camel-example-cdi-rest-servlet/README.md +++ b/examples/camel-example-cdi-rest-servlet/README.md @@ -19,13 +19,17 @@ in any CDI compliant container and Servlet container. You can build this example using: - mvn package +```sh +$ mvn package +``` ### Run You can run this example using: - mvn jetty:run +```sh +$ mvn jetty:run +``` When the Camel application runs, you should see the following messages being logged to the console, e.g.: @@ -72,7 +76,7 @@ The Camel application can be stopped pressing ctrl+c in th ### Forum, Help, etc If you hit an problems please let us know on the Camel Forums - + Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy! diff --git a/examples/camel-example-cdi/README.md b/examples/camel-example-cdi/README.md index e1e0ed80df3c8..da83e757d6875 100644 --- a/examples/camel-example-cdi/README.md +++ b/examples/camel-example-cdi/README.md @@ -5,35 +5,39 @@ This example shows how to work with Camel using CDI to configure components, endpoints and beans. -A timer triggers a Camel route to run every 5th second which creates a message that is logged to the console. +A timer triggers a Camel route to run every 5th second which creates a message +that is logged to the console. ### Build You will need to compile this example first: - - mvn compile + +```sh +$ mvn compile +``` ### Run -To run the example type - - mvn camel:run - +To run the example, type: + +```sh +$ mvn camel:run +``` + You can see the routing rules by looking at the java code in the - `src/main/java` directory +`src/main/java` directory. - To stop the example hit ctrl+c - -When we launch the example using the camel maven plugin, a local CDI container +To stop the example hit ctrl+c. + +When we launch the example using the Camel Maven plugin, a standalone CDI container is created and started. ### Forum, Help, etc If you hit an problems please let us know on the Camel Forums - + Please help us make Apache Camel better - we appreciate any feedback you may -have. Enjoy! - +have. Enjoy! The Camel riders! From 91d1abeed333c323a4b38e148559cc8001adc8ca Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Tue, 23 Feb 2016 13:09:05 +0100 Subject: [PATCH 5/6] Avoid warning about missing DeltaSpike dependency --- components/camel-cdi/src/main/resources/META-INF/beans.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/camel-cdi/src/main/resources/META-INF/beans.xml b/components/camel-cdi/src/main/resources/META-INF/beans.xml index dd78a5dbc45fc..14deb9979df74 100644 --- a/components/camel-cdi/src/main/resources/META-INF/beans.xml +++ b/components/camel-cdi/src/main/resources/META-INF/beans.xml @@ -20,5 +20,9 @@ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_0.xsd" version="1.0" bean-discovery-mode="all"> - + + + + + \ No newline at end of file From 5fbf7c5d6e83428cbee7babd227860ce541bb327 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Tue, 23 Feb 2016 13:16:38 +0100 Subject: [PATCH 6/6] Rename CDI examples test classes to avoid clashes in IDEs and polish --- .../{ApplicationTest.java => CdiMetricsTest.java} | 10 +++++++--- .../org/apache/camel/example/cdi/osgi/CdiOsgiIT.java | 6 ++++-- .../{ApplicationTest.java => CdiPropertiesTest.java} | 5 +++-- .../{RestCdiTest.java => CdiRestServletTest.java} | 8 +++++--- 4 files changed, 19 insertions(+), 10 deletions(-) rename examples/camel-example-cdi-metrics/src/test/java/org/apache/camel/example/cdi/metrics/{ApplicationTest.java => CdiMetricsTest.java} (88%) rename examples/camel-example-cdi-properties/src/test/java/org/apache/camel/example/cdi/properties/{ApplicationTest.java => CdiPropertiesTest.java} (94%) rename examples/camel-example-cdi-rest-servlet/src/test/java/org/apache/camel/example/cdi/rest/servlet/{RestCdiTest.java => CdiRestServletTest.java} (92%) diff --git a/examples/camel-example-cdi-metrics/src/test/java/org/apache/camel/example/cdi/metrics/ApplicationTest.java b/examples/camel-example-cdi-metrics/src/test/java/org/apache/camel/example/cdi/metrics/CdiMetricsTest.java similarity index 88% rename from examples/camel-example-cdi-metrics/src/test/java/org/apache/camel/example/cdi/metrics/ApplicationTest.java rename to examples/camel-example-cdi-metrics/src/test/java/org/apache/camel/example/cdi/metrics/CdiMetricsTest.java index 623c519e9055e..ff7665e26572e 100644 --- a/examples/camel-example-cdi-metrics/src/test/java/org/apache/camel/example/cdi/metrics/ApplicationTest.java +++ b/examples/camel-example-cdi-metrics/src/test/java/org/apache/camel/example/cdi/metrics/CdiMetricsTest.java @@ -37,7 +37,7 @@ import static org.junit.Assert.assertThat; @RunWith(Arquillian.class) -public class ApplicationTest { +public class CdiMetricsTest { @Inject private Meter generated; @@ -83,8 +83,12 @@ public void testMetricsValues() throws Exception { // And stop the Camel context so that inflight exchanges get completed context.stop(); - assertThat("Meter counts are not consistent!", attempt.getCount() - redelivery.getCount() - success.getCount() - error.getCount(), is(equalTo(0L))); + assertThat("Meter counts are not consistent!", + attempt.getCount() - redelivery.getCount() - success.getCount() - error.getCount(), + is(equalTo(0L))); - assertThat("Success rate gauge value is incorrect!", ratio.getValue(), is(equalTo(success.getOneMinuteRate() / generated.getOneMinuteRate()))); + assertThat("Success rate gauge value is incorrect!", + ratio.getValue(), + is(equalTo(success.getOneMinuteRate() / generated.getOneMinuteRate()))); } } diff --git a/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java index a05b3fdbc0e47..2d7aaba86af78 100644 --- a/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java +++ b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java @@ -82,13 +82,15 @@ public Option[] config() throws IOException { @Test public void testRouteStatus() { - assertThat("Route status is incorrect!", context.getRouteStatus("consumer-route"), equalTo(ServiceStatus.Started)); + assertThat("Route status is incorrect!", + context.getRouteStatus("consumer-route"), equalTo(ServiceStatus.Started)); } @Test public void testExchangesCompleted() throws Exception { ManagedRouteMBean route = context.getManagedRoute(context.getRoute("consumer-route").getId(), ManagedRouteMBean.class); - assertThat("Number of exchanges completed is incorrect!", route.getExchangesCompleted(), equalTo(1L)); + assertThat("Number of exchanges completed is incorrect!", + route.getExchangesCompleted(), equalTo(1L)); } @Test diff --git a/examples/camel-example-cdi-properties/src/test/java/org/apache/camel/example/cdi/properties/ApplicationTest.java b/examples/camel-example-cdi-properties/src/test/java/org/apache/camel/example/cdi/properties/CdiPropertiesTest.java similarity index 94% rename from examples/camel-example-cdi-properties/src/test/java/org/apache/camel/example/cdi/properties/ApplicationTest.java rename to examples/camel-example-cdi-properties/src/test/java/org/apache/camel/example/cdi/properties/CdiPropertiesTest.java index c092a434a71c0..b7ef16e8fad01 100644 --- a/examples/camel-example-cdi-properties/src/test/java/org/apache/camel/example/cdi/properties/ApplicationTest.java +++ b/examples/camel-example-cdi-properties/src/test/java/org/apache/camel/example/cdi/properties/CdiPropertiesTest.java @@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.is; @RunWith(Arquillian.class) -public class ApplicationTest { +public class CdiPropertiesTest { @Deployment public static Archive deployment() { @@ -67,6 +67,7 @@ public void configure() { @Test public void testMessage(@Uri("mock:outbound") MockEndpoint outbound) { assertThat("Exchange count is incorrect!", outbound.getExchanges(), hasSize(1)); - assertThat("Exchange body is incorrect!", outbound.getExchanges().get(0).getIn().getBody(String.class), is(equalTo("Hello"))); + assertThat("Exchange body is incorrect!", + outbound.getExchanges().get(0).getIn().getBody(String.class), is(equalTo("Hello"))); } } \ No newline at end of file diff --git a/examples/camel-example-cdi-rest-servlet/src/test/java/org/apache/camel/example/cdi/rest/servlet/RestCdiTest.java b/examples/camel-example-cdi-rest-servlet/src/test/java/org/apache/camel/example/cdi/rest/servlet/CdiRestServletTest.java similarity index 92% rename from examples/camel-example-cdi-rest-servlet/src/test/java/org/apache/camel/example/cdi/rest/servlet/RestCdiTest.java rename to examples/camel-example-cdi-rest-servlet/src/test/java/org/apache/camel/example/cdi/rest/servlet/CdiRestServletTest.java index 318803592a914..e9eb33705f9df 100644 --- a/examples/camel-example-cdi-rest-servlet/src/test/java/org/apache/camel/example/cdi/rest/servlet/RestCdiTest.java +++ b/examples/camel-example-cdi-rest-servlet/src/test/java/org/apache/camel/example/cdi/rest/servlet/CdiRestServletTest.java @@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.is; @RunWith(Arquillian.class) -public class RestCdiTest { +public class CdiRestServletTest { @Deployment public static Archive createTestArchive() { @@ -50,12 +50,14 @@ public static Archive createTestArchive() { @Test @RunAsClient public void testWithPath(@ArquillianResource URL url) throws Exception { - assertThat(IOHelper.loadText(new URL(url, "camel/say/hello").openStream()), is(equalTo("Hello World!\n"))); + assertThat(IOHelper.loadText(new URL(url, "camel/say/hello").openStream()), + is(equalTo("Hello World!\n"))); } @Test @RunAsClient public void testWithUriTemplate(@ArquillianResource URL url) throws Exception { - assertThat(IOHelper.loadText(new URL(url, "camel/say/hello/Antonin").openStream()), is(equalTo("Hello Antonin, I'm CamelContext(hello)!\n"))); + assertThat(IOHelper.loadText(new URL(url, "camel/say/hello/Antonin").openStream()), + is(equalTo("Hello Antonin, I'm CamelContext(hello)!\n"))); } } \ No newline at end of file