You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/03/10 16:43:44 UTC

[camel] branch master updated: Make the test more stable and only run if enabled via maven profile.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 15da1bc  Make the test more stable and only run if enabled via maven profile.
15da1bc is described below

commit 15da1bca1bbf2d8bdf55cfb256063c2320925c60
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Mar 10 17:43:27 2018 +0100

    Make the test more stable and only run if enabled via maven profile.
---
 .../camel-example-artemis-amqp-blueprint/README.md | 11 ++++----
 .../camel-example-artemis-amqp-blueprint/pom.xml   | 31 ++++++++++++++++++++++
 .../resources/OSGI-INF/blueprint/camel-context.xml | 18 ++++++-------
 ...rtemisAmqpTest.java => ArtemisAmqpIntTest.java} | 24 ++++++++++-------
 4 files changed, 58 insertions(+), 26 deletions(-)

diff --git a/examples/camel-example-artemis-amqp-blueprint/README.md b/examples/camel-example-artemis-amqp-blueprint/README.md
index 480863e..efa9bcb 100644
--- a/examples/camel-example-artemis-amqp-blueprint/README.md
+++ b/examples/camel-example-artemis-amqp-blueprint/README.md
@@ -1,7 +1,5 @@
 # Camel Artemis AMQP Messaging
 
-### Introduction
-
 This example shows how to produce/consume messages between Apache Camel and ActiveMQ Artemis using the AMQP component based on the JMS 2.0 Apache Qpid Proton client library.
 
 One benefit of using Camel's AMQP component is to allow connectivity to Qpid's Dispatch Router enabling flexible and scalable interconnect between any AMQP endpoints.
@@ -14,7 +12,7 @@ When deployed in a running environment, Camel will attempt to connect to an alre
 
 The JUnit with an included embedded Artemis Broker can be triggered using Maven.
 
-    mvn test
+    mvn test -P itest
 
 ### Install ActiveMQ Artemis
 
@@ -41,15 +39,15 @@ Start the Camel application:
 
     mvn camel:run -DskipTests=true
 
-Once started, Camel will be listening for HTTP requests (default port 8080) as a trigger mechanism to fire AMQP messages to Artemis.
+Once started, Camel will be listening for HTTP requests (port 9090) as a trigger mechanism to fire AMQP messages to Artemis.
 
 From your prefered browser hit the following URL:
 
-    http://localhost:8080/message
+    http://localhost:9090/message
     
 Or alternatively, using cURL:
 
-    curl http://localhost:8080/message
+    curl http://localhost:9090/message
     
 The above actions should render on screen:
 
@@ -63,6 +61,7 @@ You can browse the Artemis web console: <http://localhost:8161/console>
 to see activity such as number of consumers and producers or acknoledged messages.
 
 ### Run with Karaf
+
 You will need to install this example first to your local maven repository with:
 
 	mvn install
diff --git a/examples/camel-example-artemis-amqp-blueprint/pom.xml b/examples/camel-example-artemis-amqp-blueprint/pom.xml
index 8ed33da..5782be9 100644
--- a/examples/camel-example-artemis-amqp-blueprint/pom.xml
+++ b/examples/camel-example-artemis-amqp-blueprint/pom.xml
@@ -162,6 +162,37 @@
         </executions>
       </plugin>
 
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>**/*IntTest*</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
+
+  <!-- to run the test you need to enable this profile:  mvn test -P itest -->
+  <profiles>
+    <profile>
+      <id>itest</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <excludes>
+                <exclude>**/*.xml</exclude>
+              </excludes>
+              <includes>
+                <include>**/*IntTest*</include>
+              </includes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
 </project>
diff --git a/examples/camel-example-artemis-amqp-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml b/examples/camel-example-artemis-amqp-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml
index 0f61b15..b47508c 100644
--- a/examples/camel-example-artemis-amqp-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml
+++ b/examples/camel-example-artemis-amqp-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml
@@ -18,9 +18,9 @@
 
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
-       xsi:schemaLocation="
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+           xsi:schemaLocation="
          http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
          http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
          http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
@@ -28,27 +28,25 @@
   <!-- blueprint property placeholders -->
   <cm:property-placeholder persistent-id="my-placeholders" update-strategy="reload">
     <cm:default-properties>
-      <cm:property name="netty.port" value="8080" />
+      <cm:property name="netty.port" value="9090"/>
     </cm:default-properties>
   </cm:property-placeholder>
 
-
   <!-- JMS QPid Proton Configuration -->
   <bean id="jmsConnectionFactory" class="org.apache.qpid.jms.JmsConnectionFactory">
-    <property name="remoteURI" value="amqp://localhost:5672" />
+    <property name="remoteURI" value="amqp://localhost:5672"/>
   </bean>
-   
+
   <!-- Camel AMQP Component configuration -->
   <bean id="amqp" class="org.apache.camel.component.amqp.AMQPComponent">
-      <property name="connectionFactory" ref="jmsConnectionFactory" />
+    <property name="connectionFactory" ref="jmsConnectionFactory"/>
   </bean>
 
-
   <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/blueprint">
 
     <!-- AMQP producer example (HTTP triggered) -->
     <route id="amqp-producer">
-      <from uri="netty4-http:localhost:{{netty.port}}/message"/>
+      <from uri="netty4-http:http:localhost:{{netty.port}}/message"/>
       <log message="got Netty request, about to send AMQP message."/>
       <to uri="amqp:queue:myqueue"/>
     </route>
diff --git a/examples/camel-example-artemis-amqp-blueprint/src/test/java/org/apache/camel/example/artemis/amqp/ArtemisAmqpTest.java b/examples/camel-example-artemis-amqp-blueprint/src/test/java/org/apache/camel/example/artemis/amqp/ArtemisAmqpIntTest.java
similarity index 73%
rename from examples/camel-example-artemis-amqp-blueprint/src/test/java/org/apache/camel/example/artemis/amqp/ArtemisAmqpTest.java
rename to examples/camel-example-artemis-amqp-blueprint/src/test/java/org/apache/camel/example/artemis/amqp/ArtemisAmqpIntTest.java
index 44eda3d..f65d69c 100644
--- a/examples/camel-example-artemis-amqp-blueprint/src/test/java/org/apache/camel/example/artemis/amqp/ArtemisAmqpTest.java
+++ b/examples/camel-example-artemis-amqp-blueprint/src/test/java/org/apache/camel/example/artemis/amqp/ArtemisAmqpIntTest.java
@@ -20,10 +20,9 @@ import java.util.Dictionary;
 
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class ArtemisAmqpTest extends CamelBlueprintTestSupport {
+public class ArtemisAmqpIntTest extends CamelBlueprintTestSupport {
 
     @Override
     protected String getBlueprintDescriptor() {
@@ -36,19 +35,24 @@ public class ArtemisAmqpTest extends CamelBlueprintTestSupport {
     @Override
     protected String useOverridePropertiesWithConfigAdmin(Dictionary props) { 
         //obtain an available port
-        int port = AvailablePortFinder.getNextAvailable(8080);
-
-        //override the netty port to use
-        props.put("netty.port", "" + port);
-
-        //return the PID of the config-admin we are using in the blueprint xml file
-        return "my-placeholders";
+        int port = AvailablePortFinder.getNextAvailable(9090);
+
+        if (port != 9090) {
+            //override the netty port to use
+            props.put("netty.port", "" + port);
+
+            //return the PID of the config-admin we are using in the blueprint xml file
+            return "my-placeholders";
+        } else {
+            // no update needed
+            return null;
+        }
     }
 
     @Test
     public void testEmbeddedBroker() throws Exception {
         //trigger
-        String response = template.requestBody("netty4-http:localhost:{{netty.port}}/message", null, String.class);
+        String response = template.requestBody("netty4-http:http://localhost:{{netty.port}}/message", null, String.class);
 
         //response validation
         assertEquals("not expected", "Hello from Camel's AMQP example", response);

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.