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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2224c26  Align Cassandra tests with test infra from Camel 3.7
2224c26 is described below

commit 2224c26eec1939d1caeaabcc9f2389c8330e602d
Author: Otavio Rodolfo Piske <opi...@redhat.com>
AuthorDate: Thu Dec 17 09:18:57 2020 +0100

    Align Cassandra tests with test infra from Camel 3.7
---
 tests/itests-cassandra/pom.xml                     | 17 +++++++
 .../cassandra/services/CassandraContainer.java     | 45 -----------------
 .../services/CassandraLocalContainerService.java   | 57 ----------------------
 .../cassandra/services/CassandraService.java       | 56 ---------------------
 .../services/CassandraServiceFactory.java          | 45 -----------------
 .../cassandra/services/RemoteCassandraService.java | 50 -------------------
 .../cassandra/sink/CamelSinkCassandraITCase.java   |  6 +--
 .../source/CamelSourceCassandraITCase.java         |  4 +-
 8 files changed, 21 insertions(+), 259 deletions(-)

diff --git a/tests/itests-cassandra/pom.xml b/tests/itests-cassandra/pom.xml
index d3d4afc..c9c5b6c 100644
--- a/tests/itests-cassandra/pom.xml
+++ b/tests/itests-cassandra/pom.xml
@@ -37,6 +37,23 @@
             <scope>test</scope>
         </dependency>
 
+        <!-- test infra -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-common</artifactId>
+            <version>${camel.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-cassandra</artifactId>
+            <version>${camel.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-cassandraql</artifactId>
diff --git 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraContainer.java
 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraContainer.java
deleted file mode 100644
index d8d94f5..0000000
--- 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraContainer.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.cassandra.services;
-
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.wait.strategy.Wait;
-
-/**
- * A local instance of Apache Cassandra
- */
-public class CassandraContainer extends GenericContainer<CassandraContainer> {
-    private static final String CASSANDRA_IMAGE = "cassandra:3.11";
-    private static final int CQL3_PORT = 9042;
-
-    public CassandraContainer() {
-        super(CASSANDRA_IMAGE);
-
-        withExposedPorts(CQL3_PORT);
-
-        waitingFor(Wait.forListeningPort());
-    }
-
-    public int getCQL3Port() {
-        return getMappedPort(CQL3_PORT);
-    }
-
-    public String getCassandraHost() {
-        return getContainerIpAddress();
-    }
-
-}
diff --git 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraLocalContainerService.java
 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraLocalContainerService.java
deleted file mode 100644
index 9972c2b..0000000
--- 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraLocalContainerService.java
+++ /dev/null
@@ -1,57 +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.cassandra.services;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * A service for a local instance of Apache Cassandra running with 
TestContainers
- */
-public class CassandraLocalContainerService implements CassandraService {
-    private static final Logger LOG = 
LoggerFactory.getLogger(CassandraLocalContainerService.class);
-
-    private CassandraContainer container;
-
-    public CassandraLocalContainerService() {
-        container = new CassandraContainer();
-
-        container.start();
-    }
-
-    @Override
-    public int getCQL3Port() {
-        return container.getCQL3Port();
-    }
-
-    @Override
-    public String getCassandraHost() {
-        return container.getCassandraHost();
-    }
-
-    @Override
-    public void initialize() {
-        LOG.info("Cassandra server running at address {}", getCQL3Endpoint());
-    }
-
-    @Override
-    public void shutdown() {
-        LOG.info("Stopping the Cassandra container");
-        container.stop();
-    }
-}
diff --git 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraService.java
 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraService.java
deleted file mode 100644
index 49526ea..0000000
--- 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraService.java
+++ /dev/null
@@ -1,56 +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.cassandra.services;
-
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-/**
- * Represents an endpoint to a Cassandra instnace
- */
-public interface CassandraService extends BeforeAllCallback, AfterAllCallback {
-
-    int getCQL3Port();
-
-    default String getCQL3Endpoint() {
-        return getCassandraHost() + ":" + getCQL3Port();
-    }
-
-    String getCassandraHost();
-
-    /**
-     * Perform any initialization necessary
-     */
-    void initialize();
-
-    /**
-     * Shuts down the service after the test has completed
-     */
-    void shutdown();
-
-    @Override
-    default void beforeAll(ExtensionContext extensionContext) throws Exception 
{
-        initialize();
-    }
-
-    @Override
-    default void afterAll(ExtensionContext extensionContext) throws Exception {
-        shutdown();
-    }
-}
diff --git 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraServiceFactory.java
 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraServiceFactory.java
deleted file mode 100644
index 2ad4c8d..0000000
--- 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/CassandraServiceFactory.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.cassandra.services;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class CassandraServiceFactory {
-    private static final Logger LOG = 
LoggerFactory.getLogger(CassandraServiceFactory.class);
-
-    private CassandraServiceFactory() {
-
-    }
-
-    public static CassandraService createService() {
-        String instanceType = System.getProperty("cassandra.instance.type");
-
-
-        if (instanceType == null || 
instanceType.equals("local-cassandra-container")) {
-            return new CassandraLocalContainerService();
-        }
-
-        if (instanceType.equals("remote")) {
-            return new RemoteCassandraService();
-        }
-
-        LOG.error("Cassandra instance must be one of 
'local-cassandra-container' or 'remote");
-        throw new UnsupportedOperationException("Invalid Cassandra instance 
type");
-
-    }
-}
diff --git 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/RemoteCassandraService.java
 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/RemoteCassandraService.java
deleted file mode 100644
index b9d5ecb..0000000
--- 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/services/RemoteCassandraService.java
+++ /dev/null
@@ -1,50 +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.cassandra.services;
-
-/**
- * A remote instance of Apache Cassandra
- */
-public class RemoteCassandraService implements CassandraService {
-    private static final int DEFAULT_CQL_PORT = 9042;
-
-    @Override
-    public int getCQL3Port() {
-        String strPort = System.getProperty("cassandra.cql3.port");
-
-        if (strPort != null) {
-            return Integer.parseInt(strPort);
-        }
-
-        return DEFAULT_CQL_PORT;
-    }
-
-    @Override
-    public String getCassandraHost() {
-        return System.getProperty("cassandra.host");
-    }
-
-    @Override
-    public void initialize() {
-        // NO-OP
-    }
-
-    @Override
-    public void shutdown() {
-        // NO-OP
-    }
-}
diff --git 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/sink/CamelSinkCassandraITCase.java
 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/sink/CamelSinkCassandraITCase.java
index 0fbae41..8f20475 100644
--- 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/sink/CamelSinkCassandraITCase.java
+++ 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/sink/CamelSinkCassandraITCase.java
@@ -25,12 +25,12 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.kafkaconnector.cassandra.clients.CassandraClient;
 import org.apache.camel.kafkaconnector.cassandra.clients.dao.TestDataDao;
-import org.apache.camel.kafkaconnector.cassandra.services.CassandraService;
-import 
org.apache.camel.kafkaconnector.cassandra.services.CassandraServiceFactory;
 import org.apache.camel.kafkaconnector.common.AbstractKafkaTest;
 import org.apache.camel.kafkaconnector.common.ConnectorPropertyFactory;
 import org.apache.camel.kafkaconnector.common.clients.kafka.KafkaClient;
 import org.apache.camel.kafkaconnector.common.utils.TestUtils;
+import org.apache.camel.test.infra.cassandra.services.CassandraService;
+import org.apache.camel.test.infra.cassandra.services.CassandraServiceFactory;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -38,12 +38,10 @@ import org.junit.jupiter.api.Timeout;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testcontainers.junit.jupiter.Testcontainers;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
-@Testcontainers
 public class CamelSinkCassandraITCase extends AbstractKafkaTest {
     @RegisterExtension
     public static CassandraService cassandraService = 
CassandraServiceFactory.createService();
diff --git 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/source/CamelSourceCassandraITCase.java
 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/source/CamelSourceCassandraITCase.java
index 00ce194..5f339f7 100644
--- 
a/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/source/CamelSourceCassandraITCase.java
+++ 
b/tests/itests-cassandra/src/test/java/org/apache/camel/kafkaconnector/cassandra/source/CamelSourceCassandraITCase.java
@@ -23,12 +23,12 @@ import com.datastax.oss.driver.api.core.cql.Row;
 import org.apache.camel.kafkaconnector.cassandra.clients.CassandraClient;
 import org.apache.camel.kafkaconnector.cassandra.clients.dao.TestDataDao;
 import 
org.apache.camel.kafkaconnector.cassandra.clients.dao.TestResultSetConversionStrategy;
-import org.apache.camel.kafkaconnector.cassandra.services.CassandraService;
-import 
org.apache.camel.kafkaconnector.cassandra.services.CassandraServiceFactory;
 import org.apache.camel.kafkaconnector.common.AbstractKafkaTest;
 import org.apache.camel.kafkaconnector.common.ConnectorPropertyFactory;
 import org.apache.camel.kafkaconnector.common.clients.kafka.KafkaClient;
 import org.apache.camel.kafkaconnector.common.utils.TestUtils;
+import org.apache.camel.test.infra.cassandra.services.CassandraService;
+import org.apache.camel.test.infra.cassandra.services.CassandraServiceFactory;
 import org.apache.kafka.clients.consumer.ConsumerRecord;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;

Reply via email to