You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2021/01/13 09:14:25 UTC

[camel-kafka-connector] 02/03: Convert Azure storage queue tests to the new test infra

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

commit 1ac7ec3213cd9e08f0eda32aedc443d17dfc917b
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Wed Jan 13 08:57:33 2021 +0100

    Convert Azure storage queue tests to the new test infra
---
 tests/itests-azure-storage-queue/pom.xml           | 33 ++++++++++----
 .../sink/CamelSinkAzureStorageQueueITCase.java     |  6 +--
 .../storage/services/AzureStorageClientUtils.java  |  3 +-
 .../AzureStorageQueueLocalContainerService.java    | 41 -----------------
 .../services/AzureStorageQueueRemoteService.java   | 51 ----------------------
 .../services/AzureStorageQueueServiceFactory.java  | 45 -------------------
 6 files changed, 30 insertions(+), 149 deletions(-)

diff --git a/tests/itests-azure-storage-queue/pom.xml b/tests/itests-azure-storage-queue/pom.xml
index 096d963..618eac0 100644
--- a/tests/itests-azure-storage-queue/pom.xml
+++ b/tests/itests-azure-storage-queue/pom.xml
@@ -41,14 +41,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.camel.kafkaconnector</groupId>
-            <artifactId>itests-azure-common</artifactId>
-            <version>${project.version}</version>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-
         <!--
             NOTE: the only reason we have this one here is because there is a conflict between the
             version of Netty used by the azure client and the one used within Kafka Connect.
@@ -68,6 +60,31 @@
             <artifactId>camel-azure-storage-queue</artifactId>
         </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-azure-common</artifactId>
+            <version>${camel.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-azure-storage-queue</artifactId>
+            <version>${camel.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
 
diff --git a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/queue/sink/CamelSinkAzureStorageQueueITCase.java b/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/queue/sink/CamelSinkAzureStorageQueueITCase.java
index 0c73300..2a49dcc 100644
--- a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/queue/sink/CamelSinkAzureStorageQueueITCase.java
+++ b/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/queue/sink/CamelSinkAzureStorageQueueITCase.java
@@ -26,14 +26,14 @@ import com.azure.storage.queue.QueueClient;
 import com.azure.storage.queue.QueueServiceClient;
 import com.azure.storage.queue.models.PeekedMessageItem;
 import org.apache.camel.kafkaconnector.CamelSinkTask;
-import org.apache.camel.kafkaconnector.azure.common.AzureCredentialsHolder;
-import org.apache.camel.kafkaconnector.azure.common.services.AzureService;
 import org.apache.camel.kafkaconnector.azure.storage.services.AzureStorageClientUtils;
-import org.apache.camel.kafkaconnector.azure.storage.services.AzureStorageQueueServiceFactory;
 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.azure.common.AzureCredentialsHolder;
+import org.apache.camel.test.infra.azure.common.services.AzureService;
+import org.apache.camel.test.infra.azure.storage.queue.services.AzureStorageQueueServiceFactory;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
diff --git a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageClientUtils.java b/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageClientUtils.java
index f5cb089..5d69064 100644
--- a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageClientUtils.java
+++ b/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageClientUtils.java
@@ -23,8 +23,9 @@ import com.azure.storage.common.StorageSharedKeyCredential;
 import com.azure.storage.queue.QueueServiceClient;
 import com.azure.storage.queue.QueueServiceClientBuilder;
 import com.azure.storage.queue.QueueServiceVersion;
-import org.apache.camel.kafkaconnector.azure.common.AzureConfigs;
+import org.apache.camel.test.infra.azure.common.AzureConfigs;
 
+@Deprecated
 public final class AzureStorageClientUtils {
 
     private AzureStorageClientUtils() {
diff --git a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueLocalContainerService.java b/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueLocalContainerService.java
deleted file mode 100644
index d5323d2..0000000
--- a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueLocalContainerService.java
+++ /dev/null
@@ -1,41 +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.azure.storage.services;
-
-import org.apache.camel.kafkaconnector.azure.common.AzureConfigs;
-import org.apache.camel.kafkaconnector.azure.common.AzureCredentialsHolder;
-import org.apache.camel.kafkaconnector.azure.common.services.AzureServices;
-import org.apache.camel.kafkaconnector.azure.common.services.AzureStorageService;
-
-public class AzureStorageQueueLocalContainerService extends AzureStorageService {
-
-    @Override
-    public void initialize() {
-        super.initialize();
-
-        System.setProperty(AzureConfigs.ACCOUNT_NAME, getContainer().azureCredentials().accountName());
-        System.setProperty(AzureConfigs.ACCOUNT_KEY, getContainer().azureCredentials().accountKey());
-        System.setProperty(AzureConfigs.HOST, getContainer().getContainerIpAddress());
-        System.setProperty(AzureConfigs.PORT, String.valueOf(getContainer().getMappedPort(AzureServices.QUEUE_SERVICE)));
-    }
-
-    @Override
-    public AzureCredentialsHolder azureCredentials() {
-        return getContainer().azureCredentials();
-    }
-}
diff --git a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueRemoteService.java b/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueRemoteService.java
deleted file mode 100644
index 60e79f0..0000000
--- a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueRemoteService.java
+++ /dev/null
@@ -1,51 +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.azure.storage.services;
-
-import org.apache.camel.kafkaconnector.azure.common.AzureConfigs;
-import org.apache.camel.kafkaconnector.azure.common.AzureCredentialsHolder;
-import org.apache.camel.kafkaconnector.azure.common.services.AzureService;
-
-public class AzureStorageQueueRemoteService implements AzureService {
-
-    @Override
-    public void initialize() {
-        // NO-OP
-    }
-
-    @Override
-    public void shutdown() {
-        // NO-OP
-    }
-
-    @Override
-    public AzureCredentialsHolder azureCredentials() {
-        // Default credentials for Azurite
-        return new AzureCredentialsHolder() {
-            @Override
-            public String accountName() {
-                return System.getProperty(AzureConfigs.ACCOUNT_NAME);
-            }
-
-            @Override
-            public String accountKey() {
-                return System.getProperty(AzureConfigs.ACCOUNT_KEY);
-            }
-        };
-    }
-}
diff --git a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueServiceFactory.java b/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueServiceFactory.java
deleted file mode 100644
index 71c15d6..0000000
--- a/tests/itests-azure-storage-queue/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageQueueServiceFactory.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.azure.storage.services;
-
-import org.apache.camel.kafkaconnector.azure.common.services.AzureService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class AzureStorageQueueServiceFactory {
-    private static final Logger LOG = LoggerFactory.getLogger(AzureStorageQueueServiceFactory.class);
-
-    private AzureStorageQueueServiceFactory() {
-
-    }
-
-    public static AzureService createAzureService() {
-        String instanceType = System.getProperty("azure.instance.type");
-
-        if (instanceType == null || instanceType.equals("local-azure-container")) {
-            return new AzureStorageQueueLocalContainerService();
-        }
-
-        if (instanceType.equals("remote")) {
-            return new AzureStorageQueueRemoteService();
-        }
-
-        LOG.error("Azure instance must be one of 'local-azure-container' or 'remote");
-        throw new UnsupportedOperationException(String.format("Invalid Azure instance type: %s", instanceType));
-    }
-}