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 2020/09/23 07:34:35 UTC

[camel] branch master updated (42e3fde -> fe9d91a)

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 42e3fde  Update rxjava.adoc
     new cfab57c  Camel-AWS2-Eventbridge: Added Localstack testcontainers support
     new 5fd0881  Camel-AWS2-Eventbridge: Regen
     new fe9d91a  Camel-AWS2-Eventbridge: Fixed log configuration for tests

The 3 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-aws2-eventbridge/pom.xml          | 70 ++++++++++++++++++++++
 .../localstack/Aws2EventbridgeBaseTest.java}       | 26 ++++----
 .../EventbridgePutRuleLocalstackTest.java}         | 19 +-----
 .../src/test/resources/log4j2.properties           |  2 +-
 4 files changed, 86 insertions(+), 31 deletions(-)
 copy components/{camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/localstack/Aws2SNSBaseTest.java => camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java} (73%)
 copy components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/{integration/EventbridgePutRuleIntegrationTest.java => localstack/EventbridgePutRuleLocalstackTest.java} (77%)


[camel] 01/03: Camel-AWS2-Eventbridge: Added Localstack testcontainers support

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 cfab57cea4c1b93646222777bc8f4d0ad5f19a34
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 23 09:27:46 2020 +0200

    Camel-AWS2-Eventbridge: Added Localstack testcontainers support
---
 components/camel-aws2-eventbridge/pom.xml          | 70 +++++++++++++++++
 .../localstack/Aws2EventbridgeBaseTest.java        | 77 ++++++++++++++++++
 .../EventbridgePutRuleLocalstackTest.java          | 90 ++++++++++++++++++++++
 .../src/test/resources/log4j2.properties           |  2 +-
 4 files changed, 238 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws2-eventbridge/pom.xml b/components/camel-aws2-eventbridge/pom.xml
index 0170ff2..36a3d4e 100644
--- a/components/camel-aws2-eventbridge/pom.xml
+++ b/components/camel-aws2-eventbridge/pom.xml
@@ -66,5 +66,75 @@
             <artifactId>log4j-slf4j-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-testcontainers-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
+
+    <profiles>
+        <profile>
+            <id>aws2-eventbridge-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>aws2-eventbridge-tests-docker-file</id>
+            <activation>
+                <file>
+                    <exists>/var/run/docker.sock</exists>
+                </file>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>${skipTests}</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>aws2-eventbridge-tests-docker-env</id>
+            <activation>
+                <property>
+                    <name>env.DOCKER_HOST</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>${skipTests}</skipTests>
+                            <systemPropertyVariables>
+                                <visibleassertions.silence>true</visibleassertions.silence>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>
diff --git a/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java b/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java
new file mode 100644
index 0000000..2c0edd7
--- /dev/null
+++ b/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.eventbridge.localstack;
+
+import java.net.URI;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.aws2.eventbridge.EventbridgeComponent;
+import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport;
+import org.apache.camel.test.testcontainers.junit5.Wait;
+import org.junit.jupiter.api.TestInstance;
+import org.testcontainers.containers.GenericContainer;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.eventbridge.EventBridgeClient;
+import software.amazon.awssdk.services.eventbridge.model.CreateEventBusRequest;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class Aws2EventbridgeBaseTest extends ContainerAwareTestSupport {
+
+    public static final String CONTAINER_IMAGE = "localstack/localstack:0.11.4";
+    public static final String CONTAINER_NAME = "eventbridge";
+
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return localstackContainer();
+    }
+
+    public static GenericContainer localstackContainer() {
+        return new GenericContainer(CONTAINER_IMAGE)
+                .withNetworkAliases(CONTAINER_NAME)
+                .withEnv("SERVICES", "events")
+                .withExposedPorts(4566)
+                .waitingFor(Wait.forListeningPort())
+                .waitingFor(Wait.forLogMessageContaining("Ready.", 1));
+    }
+
+    public String getEventbridgeUrl() {
+        return String.format(
+                "%s:%d",
+                getContainerHost(CONTAINER_NAME),
+                getContainerPort(CONTAINER_NAME, 4566));
+    }
+
+    public EventBridgeClient getEventbridgeClient() {
+    	EventBridgeClient eventbridgeClient = EventBridgeClient
+                .builder()
+                .endpointOverride(URI.create("http://" + getEventbridgeUrl()))
+                .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxx", "yyy")))
+                .region(Region.EU_WEST_1)
+                .build();
+        return eventbridgeClient;
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        EventbridgeComponent eventbridgeComponent = context.getComponent("aws2-eventbridge", EventbridgeComponent.class);
+        eventbridgeComponent.getConfiguration().setEventbridgeClient(getEventbridgeClient());
+        return context;
+    }
+}
diff --git a/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgePutRuleLocalstackTest.java b/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgePutRuleLocalstackTest.java
new file mode 100644
index 0000000..5a1bef1
--- /dev/null
+++ b/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgePutRuleLocalstackTest.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.eventbridge.localstack;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.aws2.eventbridge.EventbridgeConstants;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import software.amazon.awssdk.services.eventbridge.model.CreateEventBusRequest;
+import software.amazon.awssdk.services.eventbridge.model.Target;
+
+public class EventbridgePutRuleLocalstackTest extends Aws2EventbridgeBaseTest {
+
+    @EndpointInject
+    private ProducerTemplate template;
+
+    @EndpointInject("mock:result")
+    private MockEndpoint result;
+
+    @EndpointInject("mock:result1")
+    private MockEndpoint result1;
+    
+
+    @Test
+    public void sendIn() throws Exception {
+        result.expectedMessageCount(1);
+        result1.expectedMessageCount(1);
+
+        template.send("direct:evs", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(EventbridgeConstants.RULE_NAME, "firstrule");
+            }
+        });
+
+        template.send("direct:evs-targets", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(EventbridgeConstants.RULE_NAME, "firstrule");
+                Target target = Target.builder().id("sqs-queue").arn("arn:aws:sqs:eu-west-1:780410022472:camel-connector-test")
+                        .build();
+                List<Target> targets = new ArrayList<Target>();
+                targets.add(target);
+                exchange.getIn().setHeader(EventbridgeConstants.TARGETS, targets);
+            }
+        });
+        assertMockEndpointsSatisfied();
+
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String awsEndpoint
+                        = "aws2-eventbridge://default?operation=putRule&eventPatternFile=file:src/test/resources/eventpattern.json";
+                String target = "aws2-eventbridge://default?operation=putTargets";
+                from("direct:evs").to(awsEndpoint).log("${body}").to("mock:result");
+                from("direct:evs-targets").to(target).log("${body}").to("mock:result1");
+            }
+        };
+    }
+}
diff --git a/components/camel-aws2-eventbridge/src/test/resources/log4j2.properties b/components/camel-aws2-eventbridge/src/test/resources/log4j2.properties
index 668bde98..bea2995 100644
--- a/components/camel-aws2-eventbridge/src/test/resources/log4j2.properties
+++ b/components/camel-aws2-eventbridge/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


[camel] 02/03: Camel-AWS2-Eventbridge: Regen

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 5fd08810dbd742bec6a845f82f5ef4cf79ed99e2
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 23 09:31:33 2020 +0200

    Camel-AWS2-Eventbridge: Regen
---
 .../aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java         | 3 +--
 .../eventbridge/localstack/EventbridgePutRuleLocalstackTest.java     | 5 -----
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java b/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java
index 2c0edd7..58515d8 100644
--- a/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java
+++ b/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java
@@ -28,7 +28,6 @@ import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
 import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.eventbridge.EventBridgeClient;
-import software.amazon.awssdk.services.eventbridge.model.CreateEventBusRequest;
 
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 public class Aws2EventbridgeBaseTest extends ContainerAwareTestSupport {
@@ -58,7 +57,7 @@ public class Aws2EventbridgeBaseTest extends ContainerAwareTestSupport {
     }
 
     public EventBridgeClient getEventbridgeClient() {
-    	EventBridgeClient eventbridgeClient = EventBridgeClient
+        EventBridgeClient eventbridgeClient = EventBridgeClient
                 .builder()
                 .endpointOverride(URI.create("http://" + getEventbridgeUrl()))
                 .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxx", "yyy")))
diff --git a/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgePutRuleLocalstackTest.java b/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgePutRuleLocalstackTest.java
index 5a1bef1..32fbc76 100644
--- a/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgePutRuleLocalstackTest.java
+++ b/components/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgePutRuleLocalstackTest.java
@@ -26,11 +26,7 @@ import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws2.eventbridge.EventbridgeConstants;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.BeforeClass;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
-
-import software.amazon.awssdk.services.eventbridge.model.CreateEventBusRequest;
 import software.amazon.awssdk.services.eventbridge.model.Target;
 
 public class EventbridgePutRuleLocalstackTest extends Aws2EventbridgeBaseTest {
@@ -43,7 +39,6 @@ public class EventbridgePutRuleLocalstackTest extends Aws2EventbridgeBaseTest {
 
     @EndpointInject("mock:result1")
     private MockEndpoint result1;
-    
 
     @Test
     public void sendIn() throws Exception {


[camel] 03/03: Camel-AWS2-Eventbridge: Fixed log configuration for 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 fe9d91a0d9307edb625903e11e0c3bcdb070c1f1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 23 09:33:50 2020 +0200

    Camel-AWS2-Eventbridge: Fixed log configuration for tests
---
 .../camel-aws2-eventbridge/src/test/resources/log4j2.properties       | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws2-eventbridge/src/test/resources/log4j2.properties b/components/camel-aws2-eventbridge/src/test/resources/log4j2.properties
index bea2995..7ba0114 100644
--- a/components/camel-aws2-eventbridge/src/test/resources/log4j2.properties
+++ b/components/camel-aws2-eventbridge/src/test/resources/log4j2.properties
@@ -17,12 +17,12 @@
 
 appender.file.type = File
 appender.file.name = file
-appender.file.fileName = target/camel-aws2-sts-test.log
+appender.file.fileName = target/camel-aws2-eventbridge-test.log
 appender.file.layout.type = PatternLayout
 appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
 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 = DEBUG
+rootLogger.level = INFO
 rootLogger.appenderRef.file.ref = file