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.git
The following commit(s) were added to refs/heads/master by this push: new e9ca967 Added test infra for Azure services (#4595) e9ca967 is described below commit e9ca96760358f29219e6f2a8b0e1f92166a4e906 Author: Otavio Rodolfo Piske <orpi...@users.noreply.github.com> AuthorDate: Thu Nov 12 11:49:38 2020 +0100 Added test infra for Azure services (#4595) Includes: - service for Azure storage queue - service for Azure storage blob --- test-infra/camel-test-infra-azure-common/pom.xml | 53 ++++++++++++++++++ .../src/main/resources/META-INF/MANIFEST.MF | 0 .../test/infra/azure/common/AzureConfigs.java | 29 ++++++++++ .../infra/azure/common/AzureCredentialsHolder.java | 24 ++++++++ .../infra/azure/common/services/AzureService.java | 44 +++++++++++++++ .../infra/azure/common/services/AzureServices.java | 26 +++++++++ .../azure/common/services/AzureStorageService.java | 57 +++++++++++++++++++ .../azure/common/services/AzuriteContainer.java | 57 +++++++++++++++++++ .../camel-test-infra-azure-storage-blob/pom.xml | 65 ++++++++++++++++++++++ .../src/main/resources/META-INF/MANIFEST.MF | 0 .../AzureStorageBlobLocalContainerService.java | 38 +++++++++++++ .../services/AzureStorageBlobRemoteService.java | 51 +++++++++++++++++ .../services/AzureStorageBlobServiceFactory.java | 45 +++++++++++++++ .../camel-test-infra-azure-storage-queue/pom.xml | 65 ++++++++++++++++++++++ .../src/main/resources/META-INF/MANIFEST.MF | 0 .../AzureStorageQueueLocalContainerService.java | 38 +++++++++++++ .../services/AzureStorageQueueRemoteService.java | 51 +++++++++++++++++ .../services/AzureStorageQueueServiceFactory.java | 45 +++++++++++++++ test-infra/pom.xml | 3 + 19 files changed, 691 insertions(+) diff --git a/test-infra/camel-test-infra-azure-common/pom.xml b/test-infra/camel-test-infra-azure-common/pom.xml new file mode 100644 index 0000000..6ec336b --- /dev/null +++ b/test-infra/camel-test-infra-azure-common/pom.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>camel-test-infra-parent</artifactId> + <groupId>org.apache.camel</groupId> + <relativePath>../camel-test-infra-parent/pom.xml</relativePath> + <version>3.7.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <name>Camel :: Test Infra :: Azure Common</name> + <artifactId>camel-test-infra-azure-common</artifactId> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-infra-common</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + </plugins> + </build> + + +</project> \ No newline at end of file diff --git a/test-infra/camel-test-infra-azure-common/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-azure-common/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..e69de29 diff --git a/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/AzureConfigs.java b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/AzureConfigs.java new file mode 100644 index 0000000..8398e5a --- /dev/null +++ b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/AzureConfigs.java @@ -0,0 +1,29 @@ +/* + * 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.test.infra.azure.common; + +public final class AzureConfigs { + public static final String HOST = "azure.storage.host"; + public static final String PORT = "azure.storage.port"; + public static final String ACCOUNT_NAME = "azure.storage.account.name"; + public static final String ACCOUNT_KEY = "azure.storage.account.key"; + + private AzureConfigs() { + + } +} diff --git a/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/AzureCredentialsHolder.java b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/AzureCredentialsHolder.java new file mode 100644 index 0000000..01bd3d9 --- /dev/null +++ b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/AzureCredentialsHolder.java @@ -0,0 +1,24 @@ +/* + * 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.test.infra.azure.common; + +public interface AzureCredentialsHolder { + String accountName(); + + String accountKey(); +} diff --git a/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureService.java b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureService.java new file mode 100644 index 0000000..ae0d6fb --- /dev/null +++ b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureService.java @@ -0,0 +1,44 @@ +/* + * 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.test.infra.azure.common.services; + +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; +import org.apache.camel.test.infra.common.services.TestService; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; + +public interface AzureService extends TestService, BeforeAllCallback, AfterAllCallback { + + /** + * Gets the credentials for the test service + * + * @return + */ + AzureCredentialsHolder azureCredentials(); + + @Override + default void beforeAll(ExtensionContext extensionContext) throws Exception { + initialize(); + } + + @Override + default void afterAll(ExtensionContext extensionContext) throws Exception { + shutdown(); + } +} diff --git a/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureServices.java b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureServices.java new file mode 100644 index 0000000..9ff85d3 --- /dev/null +++ b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureServices.java @@ -0,0 +1,26 @@ +/* + * 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.test.infra.azure.common.services; + +public final class AzureServices { + public static final int BLOB_SERVICE = 10000; + public static final int QUEUE_SERVICE = 10001; + + private AzureServices() { + } +} diff --git a/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureStorageService.java b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureStorageService.java new file mode 100644 index 0000000..82cf72a --- /dev/null +++ b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzureStorageService.java @@ -0,0 +1,57 @@ +/* + * 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.test.infra.azure.common.services; + +import org.apache.camel.test.infra.azure.common.AzureConfigs; +import org.apache.camel.test.infra.common.services.ContainerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class AzureStorageService implements AzureService, ContainerService<AzuriteContainer> { + private static final Logger LOG = LoggerFactory.getLogger(AzureStorageService.class); + private final AzuriteContainer container = new AzuriteContainer(); + + public AzureStorageService() { + container.start(); + } + + public AzuriteContainer getContainer() { + return container; + } + + protected void registerProperties() { + System.setProperty(AzureConfigs.ACCOUNT_NAME, container.azureCredentials().accountName()); + System.setProperty(AzureConfigs.ACCOUNT_KEY, container.azureCredentials().accountKey()); + System.setProperty(AzureConfigs.HOST, container.getContainerIpAddress()); + } + + @Override + public void initialize() { + LOG.info("Azurite local blob service running at address {}:{}", container.getHost(), + container.getMappedPort(AzureServices.BLOB_SERVICE)); + LOG.info("Azurite local queue service running at address {}:{}", container.getHost(), + container.getMappedPort(AzureServices.QUEUE_SERVICE)); + + registerProperties(); + } + + @Override + public void shutdown() { + container.stop(); + } +} diff --git a/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzuriteContainer.java b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzuriteContainer.java new file mode 100644 index 0000000..b135242 --- /dev/null +++ b/test-infra/camel-test-infra-azure-common/src/test/java/org/apache/camel/test/infra/azure/common/services/AzuriteContainer.java @@ -0,0 +1,57 @@ +/* + * 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.test.infra.azure.common.services; + +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; + +public class AzuriteContainer extends GenericContainer<AzuriteContainer> { + public static final String DEFAULT_ACCOUNT_NAME = "devstoreaccount1"; + public static final String DEFAULT_ACCOUNT_KEY + = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; + + private static final String CONTAINER_NAME = "mcr.microsoft.com/azure-storage/azurite:3.8.0"; + + public AzuriteContainer() { + this(CONTAINER_NAME); + } + + public AzuriteContainer(String containerName) { + super(containerName); + + withExposedPorts(AzureServices.BLOB_SERVICE, AzureServices.QUEUE_SERVICE); + + waitingFor(Wait.forListeningPort()); + } + + public AzureCredentialsHolder azureCredentials() { + // Default credentials for Azurite + return new AzureCredentialsHolder() { + @Override + public String accountName() { + return DEFAULT_ACCOUNT_NAME; + } + + @Override + public String accountKey() { + return DEFAULT_ACCOUNT_KEY; + } + }; + } +} diff --git a/test-infra/camel-test-infra-azure-storage-blob/pom.xml b/test-infra/camel-test-infra-azure-storage-blob/pom.xml new file mode 100644 index 0000000..12e2493 --- /dev/null +++ b/test-infra/camel-test-infra-azure-storage-blob/pom.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>camel-test-infra-parent</artifactId> + <groupId>org.apache.camel</groupId> + <relativePath>../camel-test-infra-parent/pom.xml</relativePath> + <version>3.7.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <name>Camel :: Test Infra :: Azure Storage Blob</name> + <artifactId>camel-test-infra-azure-storage-blob</artifactId> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-infra-common</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-infra-azure-common</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file diff --git a/test-infra/camel-test-infra-azure-storage-blob/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-azure-storage-blob/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..e69de29 diff --git a/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobLocalContainerService.java b/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobLocalContainerService.java new file mode 100644 index 0000000..176af14 --- /dev/null +++ b/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobLocalContainerService.java @@ -0,0 +1,38 @@ +/* + * 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.test.infra.azure.storage.blob.services; + +import org.apache.camel.test.infra.azure.common.AzureConfigs; +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; +import org.apache.camel.test.infra.azure.common.services.AzureServices; +import org.apache.camel.test.infra.azure.common.services.AzureStorageService; + +public class AzureStorageBlobLocalContainerService extends AzureStorageService { + + @Override + protected void registerProperties() { + super.registerProperties(); + + System.setProperty(AzureConfigs.PORT, String.valueOf(getContainer().getMappedPort(AzureServices.BLOB_SERVICE))); + } + + @Override + public AzureCredentialsHolder azureCredentials() { + return getContainer().azureCredentials(); + } +} diff --git a/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobRemoteService.java b/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobRemoteService.java new file mode 100644 index 0000000..53a450a --- /dev/null +++ b/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobRemoteService.java @@ -0,0 +1,51 @@ +/* + * 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.test.infra.azure.storage.blob.services; + +import org.apache.camel.test.infra.azure.common.AzureConfigs; +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; +import org.apache.camel.test.infra.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/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobServiceFactory.java b/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobServiceFactory.java new file mode 100644 index 0000000..75a4ef9 --- /dev/null +++ b/test-infra/camel-test-infra-azure-storage-blob/src/test/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobServiceFactory.java @@ -0,0 +1,45 @@ +/* + * 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.test.infra.azure.storage.blob.services; + +import org.apache.camel.test.infra.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)); + } +} diff --git a/test-infra/camel-test-infra-azure-storage-queue/pom.xml b/test-infra/camel-test-infra-azure-storage-queue/pom.xml new file mode 100644 index 0000000..61e420d --- /dev/null +++ b/test-infra/camel-test-infra-azure-storage-queue/pom.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>camel-test-infra-parent</artifactId> + <groupId>org.apache.camel</groupId> + <relativePath>../camel-test-infra-parent/pom.xml</relativePath> + <version>3.7.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <name>Camel :: Test Infra :: Azure Storage Queue</name> + <artifactId>camel-test-infra-azure-storage-queue</artifactId> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-infra-common</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-infra-azure-common</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file diff --git a/test-infra/camel-test-infra-azure-storage-queue/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-azure-storage-queue/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..e69de29 diff --git a/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueLocalContainerService.java b/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueLocalContainerService.java new file mode 100644 index 0000000..7bb4d73 --- /dev/null +++ b/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueLocalContainerService.java @@ -0,0 +1,38 @@ +/* + * 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.test.infra.azure.storage.queue.services; + +import org.apache.camel.test.infra.azure.common.AzureConfigs; +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; +import org.apache.camel.test.infra.azure.common.services.AzureServices; +import org.apache.camel.test.infra.azure.common.services.AzureStorageService; + +public class AzureStorageQueueLocalContainerService extends AzureStorageService { + + @Override + protected void registerProperties() { + super.registerProperties(); + + System.setProperty(AzureConfigs.PORT, String.valueOf(getContainer().getMappedPort(AzureServices.QUEUE_SERVICE))); + } + + @Override + public AzureCredentialsHolder azureCredentials() { + return getContainer().azureCredentials(); + } +} diff --git a/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueRemoteService.java b/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueRemoteService.java new file mode 100644 index 0000000..8372f6c --- /dev/null +++ b/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueRemoteService.java @@ -0,0 +1,51 @@ +/* + * 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.test.infra.azure.storage.queue.services; + +import org.apache.camel.test.infra.azure.common.AzureConfigs; +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; +import org.apache.camel.test.infra.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/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueServiceFactory.java b/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueServiceFactory.java new file mode 100644 index 0000000..034ee93 --- /dev/null +++ b/test-infra/camel-test-infra-azure-storage-queue/src/test/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueServiceFactory.java @@ -0,0 +1,45 @@ +/* + * 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.test.infra.azure.storage.queue.services; + +import org.apache.camel.test.infra.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)); + } +} diff --git a/test-infra/pom.xml b/test-infra/pom.xml index c83bbad..c5871f1 100644 --- a/test-infra/pom.xml +++ b/test-infra/pom.xml @@ -45,5 +45,8 @@ <module>camel-test-infra-couchbase</module> <module>camel-test-infra-mongodb</module> <module>camel-test-infra-rabbitmq</module> + <module>camel-test-infra-azure-common</module> + <module>camel-test-infra-azure-storage-blob</module> + <module>camel-test-infra-azure-storage-queue</module> </modules> </project> \ No newline at end of file