You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by va...@apache.org on 2020/10/03 07:51:02 UTC

[camel-kafka-connector] 02/02: Refactor per-tests-rebbitmq to depend on itests-rabbitmq.

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

valdar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git

commit 993322a0aa6c6ac591647250d5c39d4dfd99cd3a
Author: Andrea Tarocchi <an...@gmail.com>
AuthorDate: Fri Oct 2 22:46:32 2020 +0200

    Refactor per-tests-rebbitmq to depend on itests-rabbitmq.
---
 tests/itests-rabbitmq/pom.xml                      | 20 ++++---
 tests/perf-tests-rabbitmq/pom.xml                  |  9 +++
 .../rabbitmq/services/ConnectionProperties.java    | 25 --------
 .../services/RabbitMQLocalContainerService.java    | 67 ----------------------
 .../rabbitmq/services/RabbitMQRemoteService.java   | 37 ------------
 .../rabbitmq/services/RabbitMQService.java         | 54 -----------------
 .../rabbitmq/services/RabbitMQServiceFactory.java  | 45 ---------------
 7 files changed, 21 insertions(+), 236 deletions(-)

diff --git a/tests/itests-rabbitmq/pom.xml b/tests/itests-rabbitmq/pom.xml
index 4365c68..baa2a18 100644
--- a/tests/itests-rabbitmq/pom.xml
+++ b/tests/itests-rabbitmq/pom.xml
@@ -57,14 +57,18 @@
 
     <build>
         <plugins>
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-failsafe-plugin</artifactId>-->
-<!--                <configuration>-->
-<!--                    <argLine>${common.failsafe.args} ${jvm.user.settings} -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=${rmi.server} -Dcom.sun.management.jmxremote.rmi.port=${jmx.port}</argLine>-->
-<!--                    <skipTests>${skipIntegrationTests}</skipTests>-->
-<!--                </configuration>-->
-<!--            </plugin>-->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>test-compile</phase>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 
diff --git a/tests/perf-tests-rabbitmq/pom.xml b/tests/perf-tests-rabbitmq/pom.xml
index 5d73fce..887abef 100644
--- a/tests/perf-tests-rabbitmq/pom.xml
+++ b/tests/perf-tests-rabbitmq/pom.xml
@@ -53,6 +53,15 @@
             <artifactId>rabbitmq</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel.kafkaconnector</groupId>
+            <artifactId>itests-rabbitmq</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
     <build>
diff --git a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/ConnectionProperties.java b/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/ConnectionProperties.java
deleted file mode 100644
index 15b7f8d..0000000
--- a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/ConnectionProperties.java
+++ /dev/null
@@ -1,25 +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.kafkaconnector.rabbitmq.services;
-
-public interface ConnectionProperties {
-    String username();
-    String password();
-    String hostname();
-    int port();
-}
diff --git a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQLocalContainerService.java b/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQLocalContainerService.java
deleted file mode 100644
index b6ae6d1..0000000
--- a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQLocalContainerService.java
+++ /dev/null
@@ -1,67 +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.kafkaconnector.rabbitmq.services;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.RabbitMQContainer;
-
-public class RabbitMQLocalContainerService implements RabbitMQService {
-    private static final Logger LOG = LoggerFactory.getLogger(RabbitMQLocalContainerService.class);
-
-    private final RabbitMQContainer container = new RabbitMQContainer("rabbitmq:3.8-management");
-
-    public RabbitMQLocalContainerService() {
-        container.start();
-    }
-
-    @Override
-    public ConnectionProperties connectionProperties() {
-        return new ConnectionProperties() {
-            @Override
-            public String username() {
-                return container.getAdminUsername();
-            }
-
-            @Override
-            public String password() {
-                return container.getAdminPassword();
-            }
-
-            @Override
-            public String hostname() {
-                return container.getHost();
-            }
-
-            @Override
-            public int port() {
-                return container.getAmqpPort();
-            }
-        };
-    }
-
-    @Override
-    public void initialize() {
-        LOG.info("RabbitMQ container running on {}", container.getAmqpUrl());
-    }
-
-    @Override
-    public void shutdown() {
-        container.stop();
-    }
-}
diff --git a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQRemoteService.java b/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQRemoteService.java
deleted file mode 100644
index b6957be..0000000
--- a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQRemoteService.java
+++ /dev/null
@@ -1,37 +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.kafkaconnector.rabbitmq.services;
-
-public class RabbitMQRemoteService implements RabbitMQService {
-
-
-    @Override
-    public ConnectionProperties connectionProperties() {
-        return null;
-    }
-
-    @Override
-    public void initialize() {
-
-    }
-
-    @Override
-    public void shutdown() {
-
-    }
-}
diff --git a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQService.java b/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQService.java
deleted file mode 100644
index 94e12bd..0000000
--- a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQService.java
+++ /dev/null
@@ -1,54 +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.kafkaconnector.rabbitmq.services;
-
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-public interface RabbitMQService extends BeforeAllCallback, AfterAllCallback {
-
-
-    /**
-     * The connection properties for the service
-     * @return
-     */
-    ConnectionProperties connectionProperties();
-
-
-    /**
-     * Perform any initialization necessary
-     */
-    void initialize();
-
-    /**
-     * Shuts down the service after the test has completed
-     */
-    void shutdown();
-
-
-    @Override
-    default void afterAll(ExtensionContext extensionContext) throws Exception {
-        shutdown();
-    }
-
-    @Override
-    default void beforeAll(ExtensionContext extensionContext) throws Exception {
-        initialize();
-    }
-}
diff --git a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQServiceFactory.java b/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQServiceFactory.java
deleted file mode 100644
index 50013dd..0000000
--- a/tests/perf-tests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/services/RabbitMQServiceFactory.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.kafkaconnector.rabbitmq.services;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class RabbitMQServiceFactory {
-    private static final Logger LOG = LoggerFactory.getLogger(RabbitMQServiceFactory.class);
-
-    private RabbitMQServiceFactory() {
-
-    }
-
-    public static RabbitMQService createService() {
-        String instanceType = System.getProperty("rabbitmq.instance.type");
-
-        if (instanceType == null || instanceType.equals("local-rabbitmq-container")) {
-            return new RabbitMQLocalContainerService();
-        }
-
-        if (instanceType.equals("remote")) {
-            return new RabbitMQRemoteService();
-        }
-
-        LOG.error("rabbit-mq instance must be one of 'local-rabbitmq-container' or 'remote");
-        throw new UnsupportedOperationException(String.format("Invalid rabbitmq instance type: %s", instanceType));
-
-    }
-}