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.gitcommit b6b73c7f05f63a0a639061c8c4c5fc358ea76f9e
Author: Otavio Rodolfo Piske <
[hidden email]>
AuthorDate: Wed Jan 13 08:56:06 2021 +0100
Convert Azure storage blob tests to the new test infra
---
tests/itests-azure-storage-blob/pom.xml | 33 +++++++++---
.../blob/sink/CamelSinkAzureStorageBlobITCase.java | 8 +--
.../storage/blob/sink/TestBlobConfiguration.java | 2 +-
.../services/AzureStorageBlobClientUtils.java | 63 ----------------------
.../AzureStorageBlobLocalContainerService.java | 41 --------------
.../services/AzureStorageBlobRemoteService.java | 51 ------------------
.../services/AzureStorageBlobServiceFactory.java | 45 ----------------
7 files changed, 30 insertions(+), 213 deletions(-)
diff --git a/tests/itests-azure-storage-blob/pom.xml b/tests/itests-azure-storage-blob/pom.xml
index 69dccbc..5f145d2 100644
--- a/tests/itests-azure-storage-blob/pom.xml
+++ b/tests/itests-azure-storage-blob/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-blob</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-blob</artifactId>
+ <version>${camel.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
diff --git a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/blob/sink/CamelSinkAzureStorageBlobITCase.java b/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/blob/sink/CamelSinkAzureStorageBlobITCase.java
index a0452e2..e7e5b81 100644
--- a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/blob/sink/CamelSinkAzureStorageBlobITCase.java
+++ b/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/blob/sink/CamelSinkAzureStorageBlobITCase.java
@@ -28,14 +28,14 @@ import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.models.BlobItem;
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.AzureStorageBlobClientUtils;
-import org.apache.camel.kafkaconnector.azure.storage.services.AzureStorageBlobServiceFactory;
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.blob.clients.AzureStorageBlobClientUtils;
+import org.apache.camel.test.infra.azure.storage.blob.services.AzureStorageBlobServiceFactory;
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-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/blob/sink/TestBlobConfiguration.java b/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/blob/sink/TestBlobConfiguration.java
index 93e1cb8..c0e98dd 100644
--- a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/blob/sink/TestBlobConfiguration.java
+++ b/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/blob/sink/TestBlobConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.camel.kafkaconnector.azure.storage.blob.sink;
import com.azure.storage.blob.BlobServiceClient;
import org.apache.camel.component.azure.storage.blob.BlobConfiguration;
-import org.apache.camel.kafkaconnector.azure.storage.services.AzureStorageBlobClientUtils;
+import org.apache.camel.test.infra.azure.storage.blob.clients.AzureStorageBlobClientUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobClientUtils.java b/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobClientUtils.java
deleted file mode 100644
index 82f45a1..0000000
--- a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobClientUtils.java
+++ /dev/null
@@ -1,63 +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 com.azure.core.http.policy.HttpLogDetailLevel;
-import com.azure.core.http.policy.HttpLogOptions;
-import com.azure.storage.blob.BlobServiceClient;
-import com.azure.storage.blob.BlobServiceClientBuilder;
-import com.azure.storage.blob.BlobServiceVersion;
-import com.azure.storage.common.StorageSharedKeyCredential;
-import org.apache.camel.kafkaconnector.azure.common.AzureConfigs;
-
-public final class AzureStorageBlobClientUtils {
-
- private AzureStorageBlobClientUtils() {
-
- }
-
- public static BlobServiceClient getClient() {
- String instanceType = System.getProperty("azure.instance.type");
-
- String accountName = System.getProperty(AzureConfigs.ACCOUNT_NAME);
- String accountKey = System.getProperty(AzureConfigs.ACCOUNT_KEY);
- StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey);
-
- String host = System.getProperty(AzureConfigs.HOST);
- String port = System.getProperty(AzureConfigs.PORT);
-
- String endpoint;
-
- if (instanceType == null || instanceType.equals("local-azure-container")) {
- endpoint = String.format("<a href="http://%s:%s/%s">http://%s:%s/%s", host, port, accountName);
- } else {
- if (host == null || host.isEmpty()) {
- endpoint = String.format("<a href="https://%s.blob.core.windows.net/%s">https://%s.blob.core.windows.net/%s", accountName, accountKey);
- } else {
- endpoint = String.format("<a href="http://%s:%s/%s">http://%s:%s/%s", host, port, accountName);
- }
- }
-
- return new BlobServiceClientBuilder()
- .endpoint(endpoint)
- .credential(credential)
- .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS).setPrettyPrintBody(true))
- .serviceVersion(BlobServiceVersion.V2019_12_12)
- .buildClient();
- }
-}
diff --git a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobLocalContainerService.java b/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobLocalContainerService.java
deleted file mode 100644
index 09285ab..0000000
--- a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobLocalContainerService.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 AzureStorageBlobLocalContainerService 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.BLOB_SERVICE)));
- }
-
- @Override
- public AzureCredentialsHolder azureCredentials() {
- return getContainer().azureCredentials();
- }
-}
diff --git a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobRemoteService.java b/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobRemoteService.java
deleted file mode 100644
index aee525c..0000000
--- a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobRemoteService.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 AzureStorageBlobRemoteService 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-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobServiceFactory.java b/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobServiceFactory.java
deleted file mode 100644
index d55774a..0000000
--- a/tests/itests-azure-storage-blob/src/test/java/org/apache/camel/kafkaconnector/azure/storage/services/AzureStorageBlobServiceFactory.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 AzureStorageBlobServiceFactory {
- private static final Logger LOG = LoggerFactory.getLogger(AzureStorageBlobServiceFactory.class);
-
- private AzureStorageBlobServiceFactory() {
-
- }
-
- public static AzureService createAzureService() {
- String instanceType = System.getProperty("azure.instance.type");
-
- if (instanceType == null || instanceType.equals("local-azure-container")) {
- return new AzureStorageBlobLocalContainerService();
- }
-
- if (instanceType.equals("remote")) {
- return new AzureStorageBlobRemoteService();
- }
-
- LOG.error("Azure instance must be one of 'local-azure-container' or 'remote");
- throw new UnsupportedOperationException(String.format("Invalid Azure instance type: %s", instanceType));
- }
-}