You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/07/20 07:55:14 UTC

[camel] branch master updated (48539d7 -> 98b25c8)

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

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


    from 48539d7  CAMEL-12660: spring-boot auto configuration options are now all included in the docs and we validate that they all have documentation, and if they dont the build fails.
     new 8d08221  Camel-Nats: Introduce usage of camel-testcontainers in tests
     new 98b25c8  Camel-Nats: Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 components/camel-nats/pom.xml                      | 83 ++++++++++++++++++----
 .../camel/component/nats/NatsConsumerLoadTest.java | 11 ++-
 .../nats/NatsConsumerMaxMessagesQueueTest.java     | 11 ++-
 .../nats/NatsConsumerMaxMessagesTest.java          |  9 +--
 .../camel/component/nats/NatsConsumerTest.java     |  9 +--
 .../camel/component/nats/NatsProducerTest.java     |  7 +-
 .../camel/component/nats/NatsTestSupport.java      | 46 ++++++++++++
 .../src/test/resources/log4j2.properties           |  2 +-
 8 files changed, 134 insertions(+), 44 deletions(-)
 create mode 100644 components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsTestSupport.java


[camel] 02/02: Camel-Nats: Fixed CS

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 98b25c89b920afc1e8c60729c78503f32ef4d708
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Jul 20 09:53:50 2018 +0200

    Camel-Nats: Fixed CS
---
 .../apache/camel/component/nats/NatsTestSupport.java   | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsTestSupport.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsTestSupport.java
index 6d146bb..aeb27a1 100644
--- a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsTestSupport.java
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsTestSupport.java
@@ -1,10 +1,26 @@
+/**
+ * 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.component.nats;
 
 import org.apache.camel.test.testcontainers.ContainerAwareTestSupport;
 import org.apache.camel.test.testcontainers.Wait;
 import org.testcontainers.containers.GenericContainer;
 
-public class NatsTestSupport extends ContainerAwareTestSupport{
+public class NatsTestSupport extends ContainerAwareTestSupport {
 
     public static final String CONTAINER_IMAGE = "nats:1.2.0";
     public static final String CONTAINER_NAME = "nats";


[camel] 01/02: Camel-Nats: Introduce usage of camel-testcontainers in tests

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8d08221425d336f8b8136e3c2b670a16a71e3cdb
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Jul 20 09:49:36 2018 +0200

    Camel-Nats: Introduce usage of camel-testcontainers in tests
---
 components/camel-nats/pom.xml                      | 83 ++++++++++++++++++----
 .../camel/component/nats/NatsConsumerLoadTest.java | 11 ++-
 .../nats/NatsConsumerMaxMessagesQueueTest.java     | 11 ++-
 .../nats/NatsConsumerMaxMessagesTest.java          |  9 +--
 .../camel/component/nats/NatsConsumerTest.java     |  9 +--
 .../camel/component/nats/NatsProducerTest.java     |  7 +-
 .../camel/component/nats/NatsTestSupport.java      | 30 ++++++++
 .../src/test/resources/log4j2.properties           |  2 +-
 8 files changed, 118 insertions(+), 44 deletions(-)

diff --git a/components/camel-nats/pom.xml b/components/camel-nats/pom.xml
index a796989..cff9dd9 100644
--- a/components/camel-nats/pom.xml
+++ b/components/camel-nats/pom.xml
@@ -68,18 +68,77 @@
       <artifactId>log4j-slf4j-impl</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-testcontainers</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   
-  <build>
-    <plugins>
-      <plugin>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <forkCount>1</forkCount>
-          <reuseForks>false</reuseForks>
-          <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
+
+
+  <profiles>
+    <profile>
+      <id>nats-skip-tests</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>true</skipTests>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <!-- activate test if the docker socket file is accessible -->
+    <profile>
+      <id>nats-tests-docker-file</id>
+      <activation>
+        <file>
+          <exists>/var/run/docker.sock</exists>
+        </file>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>false</skipTests>
+              <systemPropertyVariables>
+                <visibleassertions.silence>true</visibleassertions.silence>
+              </systemPropertyVariables>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <!-- activate test if the DOCKER_HOST env var is set -->
+    <profile>
+      <id>nats-tests-docker-env</id>
+      <activation>
+        <property>
+          <name>env.DOCKER_HOST</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>false</skipTests>
+              <systemPropertyVariables>
+                <visibleassertions.silence>true</visibleassertions.silence>
+              </systemPropertyVariables>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
 </project>
diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerLoadTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerLoadTest.java
index 830e031..831f9b6 100644
--- a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerLoadTest.java
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerLoadTest.java
@@ -26,12 +26,9 @@ import io.nats.client.Options;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
 import org.junit.Test;
 
-@Ignore("Require a running Nats server")
-public class NatsConsumerLoadTest extends CamelTestSupport {
+public class NatsConsumerLoadTest extends NatsTestSupport {
     
     @EndpointInject(uri = "mock:result")
     protected MockEndpoint mockResultEndpoint;
@@ -39,7 +36,7 @@ public class NatsConsumerLoadTest extends CamelTestSupport {
     @Test
     public void testLoadConsumer() throws InterruptedException, IOException, TimeoutException {
         mockResultEndpoint.setExpectedMessageCount(10000);
-        Options options = new Options.Builder().server("nats://localhost:4222").build();
+        Options options = new Options.Builder().server("nats://" + getNatsUrl()).build();
         Connection connection = Nats.connect(options);
 
         for (int i = 0; i < 10000; i++) {
@@ -54,8 +51,8 @@ public class NatsConsumerLoadTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:send").to("nats://localhost:4222?topic=test");
-                from("nats://localhost:4222?topic=test").to(mockResultEndpoint);
+                from("direct:send").to("nats://"  + getNatsUrl() +  "?topic=test");
+                from("nats://"  + getNatsUrl() + "?topic=test").to(mockResultEndpoint);
             }
         };
     }
diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerMaxMessagesQueueTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerMaxMessagesQueueTest.java
index 5c42eae..de99eb5 100644
--- a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerMaxMessagesQueueTest.java
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerMaxMessagesQueueTest.java
@@ -21,12 +21,9 @@ import java.io.IOException;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
 import org.junit.Test;
 
-@Ignore("Require a running Nats server")
-public class NatsConsumerMaxMessagesQueueTest extends CamelTestSupport {
+public class NatsConsumerMaxMessagesQueueTest extends NatsTestSupport {
 
     @EndpointInject(uri = "mock:result")
     protected MockEndpoint mockResultEndpoint;
@@ -46,9 +43,9 @@ public class NatsConsumerMaxMessagesQueueTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:send").to("nats://localhost:4222?topic=test");
-                from("nats://localhost:4222?topic=test&maxMessages=5&queueName=test").routeId("cons1").to(mockResultEndpoint);
-                from("nats://localhost:4222?topic=test&maxMessages=6&queueName=test").routeId("cons2").to(mockResultEndpoint);
+                from("direct:send").to("nats://" + getNatsUrl() + "?topic=test");
+                from("nats://"  + getNatsUrl() +  "?topic=test&maxMessages=5&queueName=test").routeId("cons1").to(mockResultEndpoint);
+                from("nats://" + getNatsUrl() + "?topic=test&maxMessages=6&queueName=test").routeId("cons2").to(mockResultEndpoint);
             }
         };
     }
diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerMaxMessagesTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerMaxMessagesTest.java
index d822a97..f1d2059 100644
--- a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerMaxMessagesTest.java
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerMaxMessagesTest.java
@@ -21,12 +21,9 @@ import java.io.IOException;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
 import org.junit.Test;
 
-@Ignore("Require a running Nats server")
-public class NatsConsumerMaxMessagesTest extends CamelTestSupport {
+public class NatsConsumerMaxMessagesTest extends NatsTestSupport {
 
     @EndpointInject(uri = "mock:result")
     protected MockEndpoint mockResultEndpoint;
@@ -54,8 +51,8 @@ public class NatsConsumerMaxMessagesTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:send").to("nats://localhost:4222?topic=test");
-                from("nats://localhost:4222?topic=test&maxMessages=5").to(mockResultEndpoint);
+                from("direct:send").to("nats://" + getNatsUrl() + "?topic=test");
+                from("nats://" + getNatsUrl() + "?topic=test&maxMessages=5").to(mockResultEndpoint);
             }
         };
     }
diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerTest.java
index 86294f1..19c36c0 100644
--- a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerTest.java
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerTest.java
@@ -21,12 +21,9 @@ import java.io.IOException;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
 import org.junit.Test;
 
-@Ignore("Require a running Nats server")
-public class NatsConsumerTest extends CamelTestSupport {
+public class NatsConsumerTest extends NatsTestSupport {
 
     @EndpointInject(uri = "mock:result")
     protected MockEndpoint mockResultEndpoint;
@@ -44,8 +41,8 @@ public class NatsConsumerTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:send").to("nats://localhost:4222?topic=test&flushConnection=true");
-                from("nats://localhost:4222?topic=test&flushConnection=true").to(mockResultEndpoint);
+                from("direct:send").to("nats://"  + getNatsUrl() + "?topic=test&flushConnection=true");
+                from("nats://" + getNatsUrl() + "?topic=test&flushConnection=true").to(mockResultEndpoint);
             }
         };
     }
diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsProducerTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsProducerTest.java
index 4a22551..b3bd3bb 100644
--- a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsProducerTest.java
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsProducerTest.java
@@ -17,12 +17,9 @@
 package org.apache.camel.component.nats;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
 import org.junit.Test;
 
-@Ignore("Require a running Nats server")
-public class NatsProducerTest extends CamelTestSupport {
+public class NatsProducerTest extends NatsTestSupport {
     
     @Test
     public void sendTest() throws Exception {
@@ -35,7 +32,7 @@ public class NatsProducerTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:send").to("nats://localhost:4222?topic=test");
+                from("direct:send").to("nats://" + getNatsUrl() + "?topic=test");
             }
         };
     }
diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsTestSupport.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsTestSupport.java
new file mode 100644
index 0000000..6d146bb
--- /dev/null
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsTestSupport.java
@@ -0,0 +1,30 @@
+package org.apache.camel.component.nats;
+
+import org.apache.camel.test.testcontainers.ContainerAwareTestSupport;
+import org.apache.camel.test.testcontainers.Wait;
+import org.testcontainers.containers.GenericContainer;
+
+public class NatsTestSupport extends ContainerAwareTestSupport{
+
+    public static final String CONTAINER_IMAGE = "nats:1.2.0";
+    public static final String CONTAINER_NAME = "nats";
+    
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return natsContainer();
+    }
+
+    public static GenericContainer natsContainer() {
+        return new GenericContainer(CONTAINER_IMAGE)
+            .withNetworkAliases(CONTAINER_NAME)
+            .waitingFor(Wait.forLogMessageContaining("Listening for route connections", 1));
+    }
+    
+    public String getNatsUrl() {
+        return String.format(
+            "%s:%d",
+            getContainerHost(CONTAINER_NAME),
+            getContainerPort(CONTAINER_NAME, 4222)
+        );
+    }
+}
diff --git a/components/camel-nats/src/test/resources/log4j2.properties b/components/camel-nats/src/test/resources/log4j2.properties
index f71156a..b243975 100644
--- a/components/camel-nats/src/test/resources/log4j2.properties
+++ b/components/camel-nats/src/test/resources/log4j2.properties
@@ -24,5 +24,5 @@ appender.out.type = Console
 appender.out.name = out
 appender.out.layout.type = PatternLayout
 appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-rootLogger.level = INFO
+rootLogger.level = DEBUG
 rootLogger.appenderRef.file.ref = file