This is an automated email from the ASF dual-hosted git repository. acosentino 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 b017abe Revert "First spike" b017abe is described below commit b017abe23334dca40109d5a51752683752040843 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Feb 28 11:22:22 2019 +0100 Revert "First spike" This reverts commit 8ec674489c37c6a3f6ca0c75f1613f9c09cf09e8. --- components/camel-aws-msk/pom.xml | 81 --------- .../src/main/docs/aws-kms-component.adoc | 182 --------------------- .../camel/component/aws/kms/MSKComponent.java | 121 -------------- .../aws/kms/MSKComponentVerifierExtension.java | 89 ---------- .../camel/component/aws/kms/MSKConfiguration.java | 137 ---------------- .../camel/component/aws/kms/MSKConstants.java | 25 --- .../camel/component/aws/kms/MSKEndpoint.java | 121 -------------- .../camel/component/aws/kms/MSKOperations.java | 27 --- .../camel/component/aws/kms/MSKProducer.java | 103 ------------ .../component/aws/kms/AmazonMKSClientMock.java | 29 ---- .../component/aws/kms/KMSProducerSpringTest.java | 147 ----------------- .../camel/component/aws/kms/KMSProducerTest.java | 181 -------------------- .../aws/kms/MSKComponentConfigurationTest.java | 51 ------ .../aws/kms/MSKComponentVerifierExtensionTest.java | 73 --------- .../src/test/resources/log4j2.properties | 28 ---- .../aws/kms/KMSComponentSpringTest-context.xml | 60 ------- 16 files changed, 1455 deletions(-) diff --git a/components/camel-aws-msk/pom.xml b/components/camel-aws-msk/pom.xml deleted file mode 100644 index c29ca1d..0000000 --- a/components/camel-aws-msk/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ -<?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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel</groupId> - <artifactId>components</artifactId> - <version>3.0.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-aws-msk</artifactId> - <packaging>jar</packaging> - - <name>Camel :: AWS MSK</name> - <description>A Camel Amazon MSK Web Service Component</description> - - <properties> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-support</artifactId> - </dependency> - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk-kafka</artifactId> - <version>${aws-java-sdk-version}</version> - </dependency> - - <!-- for testing --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/components/camel-aws-msk/src/main/docs/aws-kms-component.adoc b/components/camel-aws-msk/src/main/docs/aws-kms-component.adoc deleted file mode 100644 index 77f8a26..0000000 --- a/components/camel-aws-msk/src/main/docs/aws-kms-component.adoc +++ /dev/null @@ -1,182 +0,0 @@ -[[aws-kms-component]] -== AWS KMS Component - -*Available as of Camel version 2.21* - -The KMS component supports create, run, start, stop and terminate -https://aws.amazon.com/it/kms/[AWS KMS] instances. - -Prerequisites - -You must have a valid Amazon Web Services developer account, and be -signed up to use Amazon KMS. More information are available at -https://aws.amazon.com/it/mq/[Amazon KMS]. - -### URI Format - -[source,java] -------------------------- -aws-kms://label[?options] -------------------------- - -You can append query options to the URI in the following format, -?options=value&option2=value&... - -### URI Options - - -// component options: START -The AWS KMS component supports 5 options, which are listed below. - - - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *configuration* (advanced) | The AWS KMS default configuration | | KMSConfiguration -| *accessKey* (producer) | Amazon AWS Access Key | | String -| *secretKey* (producer) | Amazon AWS Secret Key | | String -| *region* (producer) | The region in which KMS client needs to work | | String -| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean -|=== -// component options: END - - - - -// endpoint options: START -The AWS KMS endpoint is configured using URI syntax: - ----- -aws-kms:label ----- - -with the following path and query parameters: - -==== Path Parameters (1 parameters): - - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *label* | *Required* Logical name | | String -|=== - - -==== Query Parameters (8 parameters): - - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *accessKey* (producer) | Amazon AWS Access Key | | String -| *kmsClient* (producer) | To use a existing configured AWS KMS as client | | AWSKMS -| *operation* (producer) | *Required* The operation to perform | | KMSOperations -| *proxyHost* (producer) | To define a proxy host when instantiating the KMS client | | String -| *proxyPort* (producer) | To define a proxy port when instantiating the KMS client | | Integer -| *region* (producer) | The region in which KMS client needs to work | | String -| *secretKey* (producer) | Amazon AWS Secret Key | | String -| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean -|=== -// endpoint options: END -// spring-boot-auto-configure options: START -=== Spring Boot Auto-Configuration - -When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration: - -[source,xml] ----- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-aws-kms-starter</artifactId> - <version>x.x.x</version> - <!-- use the same version as your Camel core version --> -</dependency> ----- - - -The component supports 12 options, which are listed below. - - - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *camel.component.aws-kms.access-key* | Amazon AWS Access Key | | String -| *camel.component.aws-kms.configuration.access-key* | Amazon AWS Access Key | | String -| *camel.component.aws-kms.configuration.kms-client* | To use a existing configured AWS KMS as client | | AWSKMS -| *camel.component.aws-kms.configuration.operation* | The operation to perform | | KMSOperations -| *camel.component.aws-kms.configuration.proxy-host* | To define a proxy host when instantiating the KMS client | | String -| *camel.component.aws-kms.configuration.proxy-port* | To define a proxy port when instantiating the KMS client | | Integer -| *camel.component.aws-kms.configuration.region* | The region in which KMS client needs to work | | String -| *camel.component.aws-kms.configuration.secret-key* | Amazon AWS Secret Key | | String -| *camel.component.aws-kms.enabled* | Whether to enable auto configuration of the aws-kms component. This is enabled by default. | | Boolean -| *camel.component.aws-kms.region* | The region in which KMS client needs to work | | String -| *camel.component.aws-kms.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean -| *camel.component.aws-kms.secret-key* | Amazon AWS Secret Key | | String -|=== -// spring-boot-auto-configure options: END - - - - -Required KMS component options - -You have to provide the amazonKmsClient in the -Registry or your accessKey and secretKey to access -the https://aws.amazon.com/it/kms/[Amazon KMS] service. - -### Usage - -#### Message headers evaluated by the MQ producer - -[width="100%",cols="10%,10%,80%",options="header",] -|======================================================================= -|Header |Type |Description - -|`CamelAwsKMSLimit` |`Integer` |The limit number of keys to return while performing a listKeys operation - -|`CamelAwsKMSOperation` |`String` |The operation we want to perform - -|`CamelAwsKMSDescription` |`String` |A key description to use while performing a createKey operation - -|`CamelAwsKMSKeyId` |`String` |The key Id -|======================================================================= - -#### KMS Producer operations - -Camel-AWS KMS component provides the following operation on the producer side: - -- listKeys -- createKey -- disableKey -- scheduleKeyDeletion -- describeKey -- enableKey - -Dependencies - -Maven users will need to add the following dependency to their pom.xml. - -*pom.xml* - -[source,xml] ---------------------------------------- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-aws-kms</artifactId> - <version>${camel-version}</version> -</dependency> ---------------------------------------- - -where `${camel-version`} must be replaced by the actual version of Camel -(2.16 or higher). - -### See Also - -* Configuring Camel -* Component -* Endpoint -* Getting Started - -* AWS Component diff --git a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKComponent.java b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKComponent.java deleted file mode 100644 index b1fd972..0000000 --- a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKComponent.java +++ /dev/null @@ -1,121 +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.component.aws.kms; - -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; - -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.annotations.Component; -import org.apache.camel.support.DefaultComponent; -import org.apache.camel.util.ObjectHelper; - -/** - * For working with Amazon KMS. - */ -@Component("aws-msk") -public class MSKComponent extends DefaultComponent { - - @Metadata - private String accessKey; - @Metadata - private String secretKey; - @Metadata - private String region; - @Metadata(label = "advanced") - private MSKConfiguration configuration; - - public MSKComponent() { - this(null); - } - - public MSKComponent(CamelContext context) { - super(context); - - this.configuration = new MSKConfiguration(); - registerExtension(new MSKComponentVerifierExtension()); - } - - @Override - protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - MSKConfiguration configuration = this.configuration.copy(); - setProperties(configuration, parameters); - - if (ObjectHelper.isEmpty(configuration.getAccessKey())) { - setAccessKey(accessKey); - } - if (ObjectHelper.isEmpty(configuration.getSecretKey())) { - setSecretKey(secretKey); - } - if (ObjectHelper.isEmpty(configuration.getRegion())) { - setRegion(region); - } - if (configuration.getMskClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { - throw new IllegalArgumentException("Amazon msk client or accessKey and secretKey must be specified"); - } - - MSKEndpoint endpoint = new MSKEndpoint(uri, this, configuration); - return endpoint; - } - - public MSKConfiguration getConfiguration() { - return configuration; - } - - /** - * The AWS KMS default configuration - */ - public void setConfiguration(MSKConfiguration configuration) { - this.configuration = configuration; - } - - public String getAccessKey() { - return configuration.getAccessKey(); - } - - /** - * Amazon AWS Access Key - */ - public void setAccessKey(String accessKey) { - configuration.setAccessKey(accessKey); - } - - public String getSecretKey() { - return configuration.getSecretKey(); - } - - /** - * Amazon AWS Secret Key - */ - public void setSecretKey(String secretKey) { - configuration.setSecretKey(secretKey); - } - - public String getRegion() { - return configuration.getRegion(); - } - - /** - * The region in which KMS client needs to work - */ - public void setRegion(String region) { - configuration.setRegion(region); - } - -} diff --git a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKComponentVerifierExtension.java b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKComponentVerifierExtension.java deleted file mode 100644 index bbf54d0..0000000 --- a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKComponentVerifierExtension.java +++ /dev/null @@ -1,89 +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.component.aws.kms; - -import java.util.Map; - -import com.amazonaws.SdkClientException; -import com.amazonaws.auth.AWSCredentials; -import com.amazonaws.auth.AWSCredentialsProvider; -import com.amazonaws.auth.AWSStaticCredentialsProvider; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.regions.Regions; -import com.amazonaws.services.kafka.AWSKafka; -import com.amazonaws.services.kafka.AWSKafkaClientBuilder; -import com.amazonaws.services.kafka.model.ListClustersRequest; - -import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExtension; -import org.apache.camel.component.extension.verifier.ResultBuilder; -import org.apache.camel.component.extension.verifier.ResultErrorBuilder; -import org.apache.camel.component.extension.verifier.ResultErrorHelper; - -public class MSKComponentVerifierExtension extends DefaultComponentVerifierExtension { - - public MSKComponentVerifierExtension() { - this("aws-msk"); - } - - public MSKComponentVerifierExtension(String scheme) { - super(scheme); - } - - // ********************************* - // Parameters validation - // ********************************* - - @Override - protected Result verifyParameters(Map<String, Object> parameters) { - - ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.PARAMETERS).error(ResultErrorHelper.requiresOption("accessKey", parameters)) - .error(ResultErrorHelper.requiresOption("secretKey", parameters)).error(ResultErrorHelper.requiresOption("region", parameters)); - - // Validate using the catalog - - super.verifyParametersAgainstCatalog(builder, parameters); - - return builder.build(); - } - - // ********************************* - // Connectivity validation - // ********************************* - - @Override - protected Result verifyConnectivity(Map<String, Object> parameters) { - ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY); - - try { - MSKConfiguration configuration = setProperties(new MSKConfiguration(), parameters); - AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey()); - AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); - ListClustersRequest request = new ListClustersRequest(); - AWSKafka client = AWSKafkaClientBuilder.standard().withCredentials(credentialsProvider).withRegion(Regions.valueOf(configuration.getRegion())).build(); - client.listClusters(request); - } catch (SdkClientException e) { - ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage()) - .detail("aws_mks_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName()) - .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e); - - builder.error(errorBuilder.build()); - } catch (Exception e) { - builder.error(ResultErrorBuilder.withException(e).build()); - } - return builder.build(); - } -} diff --git a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKConfiguration.java b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKConfiguration.java deleted file mode 100644 index e4aa8f2..0000000 --- a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKConfiguration.java +++ /dev/null @@ -1,137 +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.component.aws.kms; - -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.UriParam; -import org.apache.camel.spi.UriParams; -import org.apache.camel.spi.UriPath; - -import com.amazonaws.services.kafka.AWSKafka; - -@UriParams -public class MSKConfiguration implements Cloneable { - - @UriPath(description = "Logical name") - @Metadata(required = true) - private String label; - @UriParam(label = "producer") - private AWSKafka mskClient; - @UriParam(label = "producer", secret = true) - private String accessKey; - @UriParam(label = "producer", secret = true) - private String secretKey; - @UriParam(label = "producer") - @Metadata(required = true) - private MSKOperations operation; - @UriParam(label = "producer") - private String proxyHost; - @UriParam(label = "producer") - private Integer proxyPort; - @UriParam - private String region; - - public AWSKafka getMskClient() { - return mskClient; - } - - /** - * To use a existing configured AWS MSK as client - */ - public void setMskClient(AWSKafka mskClient) { - this.mskClient = mskClient; - } - - public String getAccessKey() { - return accessKey; - } - - /** - * Amazon AWS Access Key - */ - public void setAccessKey(String accessKey) { - this.accessKey = accessKey; - } - - public String getSecretKey() { - return secretKey; - } - - /** - * Amazon AWS Secret Key - */ - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - - public MSKOperations getOperation() { - return operation; - } - - /** - * The operation to perform - */ - public void setOperation(MSKOperations operation) { - this.operation = operation; - } - - public String getProxyHost() { - return proxyHost; - } - - /** - * To define a proxy host when instantiating the KMS client - */ - public void setProxyHost(String proxyHost) { - this.proxyHost = proxyHost; - } - - public Integer getProxyPort() { - return proxyPort; - } - - /** - * To define a proxy port when instantiating the KMS client - */ - public void setProxyPort(Integer proxyPort) { - this.proxyPort = proxyPort; - } - - public String getRegion() { - return region; - } - - /** - * The region in which KMS client needs to work - */ - public void setRegion(String region) { - this.region = region; - } - - // ************************************************* - // - // ************************************************* - - public MSKConfiguration copy() { - try { - return (MSKConfiguration)super.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeCamelException(e); - } - } -} diff --git a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKConstants.java b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKConstants.java deleted file mode 100644 index 4596f97..0000000 --- a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKConstants.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.component.aws.kms; - -/** - * Constants used in Camel AWS MSK module - */ -public interface MSKConstants { - String OPERATION = "CamelAwsMSKOperation"; - String CLUSTERS_FILTER = "CamelAwsMSKClusterFilter"; -} diff --git a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKEndpoint.java b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKEndpoint.java deleted file mode 100644 index aba55bd..0000000 --- a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKEndpoint.java +++ /dev/null @@ -1,121 +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.component.aws.kms; - -import com.amazonaws.ClientConfiguration; -import com.amazonaws.auth.AWSCredentials; -import com.amazonaws.auth.AWSCredentialsProvider; -import com.amazonaws.auth.AWSStaticCredentialsProvider; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.kafka.AWSKafka; -import com.amazonaws.services.kafka.AWSKafkaClientBuilder; - -import org.apache.camel.Component; -import org.apache.camel.Consumer; -import org.apache.camel.Processor; -import org.apache.camel.Producer; -import org.apache.camel.spi.UriEndpoint; -import org.apache.camel.spi.UriParam; -import org.apache.camel.support.ScheduledPollEndpoint; -import org.apache.camel.util.ObjectHelper; - -/** - * The aws-kms is used for managing Amazon KMS - */ -@UriEndpoint(firstVersion = "3.0.0", scheme = "aws-msk", title = "AWS MSK", syntax = "aws-msk:label", producerOnly = true, label = "cloud,management") -public class MSKEndpoint extends ScheduledPollEndpoint { - - private AWSKafka mskClient; - - @UriParam - private MSKConfiguration configuration; - - public MSKEndpoint(String uri, Component component, MSKConfiguration configuration) { - super(uri, component); - this.configuration = configuration; - } - - public Consumer createConsumer(Processor processor) throws Exception { - throw new UnsupportedOperationException("You cannot receive messages from this endpoint"); - } - - public Producer createProducer() throws Exception { - return new MSKProducer(this); - } - - public boolean isSingleton() { - return true; - } - - @Override - public void doStart() throws Exception { - super.doStart(); - - mskClient = configuration.getMskClient() != null ? configuration.getMskClient() : createMSKClient(); - } - - @Override - public void doStop() throws Exception { - if (ObjectHelper.isEmpty(configuration.getMskClient())) { - if (mskClient != null) { - mskClient.shutdown(); - } - } - super.doStop(); - } - - public MSKConfiguration getConfiguration() { - return configuration; - } - - public AWSKafka getMskClient() { - return mskClient; - } - - AWSKafka createMSKClient() { - AWSKafka client = null; - ClientConfiguration clientConfiguration = null; - AWSKafkaClientBuilder clientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - clientConfiguration = new ClientConfiguration(); - clientConfiguration.setProxyHost(configuration.getProxyHost()); - clientConfiguration.setProxyPort(configuration.getProxyPort()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey()); - AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); - if (isClientConfigFound) { - clientBuilder = AWSKafkaClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider); - } else { - clientBuilder = AWSKafkaClientBuilder.standard().withCredentials(credentialsProvider); - } - } else { - if (isClientConfigFound) { - clientBuilder = AWSKafkaClientBuilder.standard(); - } else { - clientBuilder = AWSKafkaClientBuilder.standard().withClientConfiguration(clientConfiguration); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.withRegion(configuration.getRegion()); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKOperations.java b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKOperations.java deleted file mode 100644 index 77f02a8..0000000 --- a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKOperations.java +++ /dev/null @@ -1,27 +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.component.aws.kms; - -public enum MSKOperations { - - listKeys, - createKey, - disableKey, - scheduleKeyDeletion, - describeKey, - enableKey -} diff --git a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKProducer.java b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKProducer.java deleted file mode 100644 index 56ae005..0000000 --- a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/kms/MSKProducer.java +++ /dev/null @@ -1,103 +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.component.aws.kms; - -import com.amazonaws.AmazonServiceException; -import com.amazonaws.services.kafka.AWSKafka; -import com.amazonaws.services.kafka.model.ListClustersRequest; -import com.amazonaws.services.kafka.model.ListClustersResult; - -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.Message; -import org.apache.camel.support.DefaultProducer; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.URISupport; - -/** - * A Producer which sends messages to the Amazon MSK Service - * <a href="http://aws.amazon.com/msk/">AWS MSK</a> - */ -public class MSKProducer extends DefaultProducer { - - private transient String mskProducerToString; - - public MSKProducer(Endpoint endpoint) { - super(endpoint); - } - - public void process(Exchange exchange) throws Exception { - switch (determineOperation(exchange)) { - case listKeys: - listClusters(getEndpoint().getMskClient(), exchange); - break; - default: - throw new IllegalArgumentException("Unsupported operation"); - } - } - - private MSKOperations determineOperation(Exchange exchange) { - MSKOperations operation = exchange.getIn().getHeader(MSKConstants.OPERATION, MSKOperations.class); - if (operation == null) { - operation = getConfiguration().getOperation(); - } - return operation; - } - - protected MSKConfiguration getConfiguration() { - return getEndpoint().getConfiguration(); - } - - @Override - public String toString() { - if (mskProducerToString == null) { - mskProducerToString = "MSKProducer[" + URISupport.sanitizeUri(getEndpoint().getEndpointUri()) + "]"; - } - return mskProducerToString; - } - - @Override - public MSKEndpoint getEndpoint() { - return (MSKEndpoint)super.getEndpoint(); - } - - private void listClusters(AWSKafka mskClient, Exchange exchange) { - ListClustersRequest request = new ListClustersRequest(); - if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MSKConstants.CLUSTERS_FILTER))) { - String filter = exchange.getIn().getHeader(MSKConstants.CLUSTERS_FILTER, String.class); - request.withClusterNameFilter(filter); - } - ListClustersResult result; - try { - result = mskClient.listClusters(request); - } catch (AmazonServiceException ase) { - log.trace("List Clusters command returned the error code {}", ase.getErrorCode()); - throw ase; - } - Message message = getMessageForResponse(exchange); - message.setBody(result); - } - - public static Message getMessageForResponse(final Exchange exchange) { - if (exchange.getPattern().isOutCapable()) { - Message out = exchange.getOut(); - out.copyFrom(exchange.getIn()); - return out; - } - return exchange.getIn(); - } -} \ No newline at end of file diff --git a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/AmazonMKSClientMock.java b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/AmazonMKSClientMock.java deleted file mode 100644 index 3b9534e..0000000 --- a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/AmazonMKSClientMock.java +++ /dev/null @@ -1,29 +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.component.aws.kms; - -import com.amazonaws.services.kafka.AbstractAWSKafka; - - -public class AmazonMKSClientMock extends AbstractAWSKafka { - - public AmazonMKSClientMock() { - super(); - } - - -} diff --git a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/KMSProducerSpringTest.java b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/KMSProducerSpringTest.java deleted file mode 100644 index 87b0df2..0000000 --- a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/KMSProducerSpringTest.java +++ /dev/null @@ -1,147 +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.component.aws.kms; - -import com.amazonaws.services.kms.model.CreateKeyResult; -import com.amazonaws.services.kms.model.DescribeKeyResult; -import com.amazonaws.services.kms.model.ListKeysResult; -import com.amazonaws.services.kms.model.ScheduleKeyDeletionResult; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.spring.CamelSpringTestSupport; -import org.junit.Test; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class KMSProducerSpringTest extends CamelSpringTestSupport { - - @EndpointInject(uri = "mock:result") - private MockEndpoint mock; - - @Test - public void mqListBrokersTest() throws Exception { - - mock.expectedMessageCount(1); - Exchange exchange = template.request("direct:listKeys", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.listKeys); - } - }); - - assertMockEndpointsSatisfied(); - - ListKeysResult resultGet = (ListKeysResult) exchange.getIn().getBody(); - assertEquals(1, resultGet.getKeys().size()); - assertEquals("keyId", resultGet.getKeys().get(0).getKeyId()); - } - - @Test - public void kmsCreateKeyTest() throws Exception { - - mock.expectedMessageCount(1); - Exchange exchange = template.request("direct:createKey", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.createKey); - } - }); - - assertMockEndpointsSatisfied(); - - CreateKeyResult resultGet = (CreateKeyResult) exchange.getIn().getBody(); - assertEquals("test", resultGet.getKeyMetadata().getKeyId()); - assertEquals(true, resultGet.getKeyMetadata().isEnabled()); - } - - @Test - public void kmsDisableKeyTest() throws Exception { - - mock.expectedMessageCount(1); - template.request("direct:disableKey", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.disableKey); - exchange.getIn().setHeader(MSKConstants.KEY_ID, "test"); - } - }); - - assertMockEndpointsSatisfied(); - - } - - @Test - public void kmsEnableKeyTest() throws Exception { - - mock.expectedMessageCount(1); - template.request("direct:enableKey", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.enableKey); - exchange.getIn().setHeader(MSKConstants.KEY_ID, "test"); - } - }); - - assertMockEndpointsSatisfied(); - - } - - @Test - public void kmsScheduleKeyDeletionTest() throws Exception { - - mock.expectedMessageCount(1); - Exchange exchange = template.request("direct:scheduleDelete", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.scheduleKeyDeletion); - exchange.getIn().setHeader(MSKConstants.KEY_ID, "test"); - } - }); - - assertMockEndpointsSatisfied(); - - ScheduleKeyDeletionResult resultGet = (ScheduleKeyDeletionResult) exchange.getIn().getBody(); - assertEquals("test", resultGet.getKeyId()); - } - - @Test - public void kmsDescribeKeyTest() throws Exception { - - mock.expectedMessageCount(1); - Exchange exchange = template.request("direct:describeKey", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.describeKey); - exchange.getIn().setHeader(MSKConstants.KEY_ID, "test"); - } - }); - - assertMockEndpointsSatisfied(); - - DescribeKeyResult resultGet = exchange.getIn().getBody(DescribeKeyResult.class); - assertEquals("test", resultGet.getKeyMetadata().getKeyId()); - assertEquals("MyCamelKey", resultGet.getKeyMetadata().getDescription()); - assertFalse(resultGet.getKeyMetadata().isEnabled()); - } - - @Override - protected ClassPathXmlApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("org/apache/camel/component/aws/kms/KMSComponentSpringTest-context.xml"); - } -} \ No newline at end of file diff --git a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/KMSProducerTest.java b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/KMSProducerTest.java deleted file mode 100644 index e492b5b..0000000 --- a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/KMSProducerTest.java +++ /dev/null @@ -1,181 +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.component.aws.kms; - -import com.amazonaws.services.kms.model.CreateKeyResult; -import com.amazonaws.services.kms.model.DescribeKeyResult; -import com.amazonaws.services.kms.model.ListKeysResult; -import com.amazonaws.services.kms.model.ScheduleKeyDeletionResult; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; - -public class KMSProducerTest extends CamelTestSupport { - - @EndpointInject(uri = "mock:result") - private MockEndpoint mock; - - @Test - public void kmsListKeysTest() throws Exception { - - mock.expectedMessageCount(1); - Exchange exchange = template.request("direct:listKeys", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.listKeys); - } - }); - - assertMockEndpointsSatisfied(); - - ListKeysResult resultGet = (ListKeysResult) exchange.getIn().getBody(); - assertEquals(1, resultGet.getKeys().size()); - assertEquals("keyId", resultGet.getKeys().get(0).getKeyId()); - } - - @Test - public void kmsCreateKeyTest() throws Exception { - - mock.expectedMessageCount(1); - Exchange exchange = template.request("direct:createKey", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.createKey); - } - }); - - assertMockEndpointsSatisfied(); - - CreateKeyResult resultGet = (CreateKeyResult) exchange.getIn().getBody(); - assertEquals("test", resultGet.getKeyMetadata().getKeyId()); - assertEquals(true, resultGet.getKeyMetadata().isEnabled()); - } - - @Test - public void kmsDisableKeyTest() throws Exception { - - mock.expectedMessageCount(1); - template.request("direct:disableKey", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.disableKey); - exchange.getIn().setHeader(MSKConstants.KEY_ID, "test"); - } - }); - - assertMockEndpointsSatisfied(); - - } - - @Test - public void kmsEnableKeyTest() throws Exception { - - mock.expectedMessageCount(1); - template.request("direct:enableKey", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.enableKey); - exchange.getIn().setHeader(MSKConstants.KEY_ID, "test"); - } - }); - - assertMockEndpointsSatisfied(); - - } - - @Test - public void kmsScheduleKeyDeletionTest() throws Exception { - - mock.expectedMessageCount(1); - Exchange exchange = template.request("direct:scheduleDelete", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.scheduleKeyDeletion); - exchange.getIn().setHeader(MSKConstants.KEY_ID, "test"); - } - }); - - assertMockEndpointsSatisfied(); - - ScheduleKeyDeletionResult resultGet = (ScheduleKeyDeletionResult) exchange.getIn().getBody(); - assertEquals("test", resultGet.getKeyId()); - } - - @Test - public void kmsDescribeKeyTest() throws Exception { - - mock.expectedMessageCount(1); - Exchange exchange = template.request("direct:describeKey", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(MSKConstants.OPERATION, MSKOperations.describeKey); - exchange.getIn().setHeader(MSKConstants.KEY_ID, "test"); - } - }); - - assertMockEndpointsSatisfied(); - - DescribeKeyResult resultGet = exchange.getIn().getBody(DescribeKeyResult.class); - assertEquals("test", resultGet.getKeyMetadata().getKeyId()); - assertEquals("MyCamelKey", resultGet.getKeyMetadata().getDescription()); - assertFalse(resultGet.getKeyMetadata().isEnabled()); - } - - @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); - - AmazonMKSClientMock clientMock = new AmazonMKSClientMock(); - - registry.bind("amazonKmsClient", clientMock); - - return registry; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:listKeys") - .to("aws-kms://test?kmsClient=#amazonKmsClient&operation=listKeys") - .to("mock:result"); - from("direct:createKey") - .to("aws-kms://test?kmsClient=#amazonKmsClient&operation=createKey") - .to("mock:result"); - from("direct:disableKey") - .to("aws-kms://test?kmsClient=#amazonKmsClient&operation=disableKey") - .to("mock:result"); - from("direct:enableKey") - .to("aws-kms://test?kmsClient=#amazonKmsClient&operation=enableKey") - .to("mock:result"); - from("direct:scheduleDelete") - .to("aws-kms://test?kmsClient=#amazonKmsClient&operation=scheduleKeyDeletion") - .to("mock:result"); - from("direct:describeKey") - .to("aws-kms://test?kmsClient=#amazonKmsClient&operation=describeKey") - .to("mock:result"); - } - }; - } -} \ No newline at end of file diff --git a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/MSKComponentConfigurationTest.java b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/MSKComponentConfigurationTest.java deleted file mode 100644 index 1cb9393..0000000 --- a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/MSKComponentConfigurationTest.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.component.aws.kms; - -import com.amazonaws.regions.Regions; - -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; - -public class MSKComponentConfigurationTest extends CamelTestSupport { - - - @Test - public void createEndpointWithComponentElements() throws Exception { - MSKComponent component = new MSKComponent(context); - component.setAccessKey("XXX"); - component.setSecretKey("YYY"); - MSKEndpoint endpoint = (MSKEndpoint)component.createEndpoint("aws-msk://label"); - - assertEquals("XXX", endpoint.getConfiguration().getAccessKey()); - assertEquals("YYY", endpoint.getConfiguration().getSecretKey()); - } - - @Test - public void createEndpointWithComponentAndEndpointElements() throws Exception { - MSKComponent component = new MSKComponent(context); - component.setAccessKey("XXX"); - component.setSecretKey("YYY"); - component.setRegion(Regions.US_WEST_1.toString()); - MSKEndpoint endpoint = (MSKEndpoint)component.createEndpoint("aws-msk://label?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1"); - - assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey()); - assertEquals("yyyyy", endpoint.getConfiguration().getSecretKey()); - assertEquals("US_EAST_1", endpoint.getConfiguration().getRegion()); - } - -} diff --git a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/MSKComponentVerifierExtensionTest.java b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/MSKComponentVerifierExtensionTest.java deleted file mode 100644 index 363dc4e..0000000 --- a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/kms/MSKComponentVerifierExtensionTest.java +++ /dev/null @@ -1,73 +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.component.aws.kms; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.Component; -import org.apache.camel.component.extension.ComponentVerifierExtension; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Assert; -import org.junit.Test; - -public class MSKComponentVerifierExtensionTest extends CamelTestSupport { - - // ************************************************* - // Tests (parameters) - // ************************************************* - @Override - public boolean isUseRouteBuilder() { - return false; - } - - @Test - public void testParameters() throws Exception { - Component component = context().getComponent("aws-mks"); - - ComponentVerifierExtension verifier = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new); - - Map<String, Object> parameters = new HashMap<>(); - parameters.put("secretKey", "l"); - parameters.put("accessKey", "k"); - parameters.put("region", "l"); - parameters.put("label", "test"); - parameters.put("operation", MSKOperations.listKeys); - - ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - - Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); - } - - @Test - public void testConnectivity() throws Exception { - Component component = context().getComponent("aws-mks"); - ComponentVerifierExtension verifier = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new); - - Map<String, Object> parameters = new HashMap<>(); - parameters.put("secretKey", "l"); - parameters.put("accessKey", "k"); - parameters.put("region", "US_EAST_1"); - parameters.put("label", "test"); - parameters.put("operation", MSKOperations.listKeys); - - ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - } - -} diff --git a/components/camel-aws-msk/src/test/resources/log4j2.properties b/components/camel-aws-msk/src/test/resources/log4j2.properties deleted file mode 100644 index 986f470..0000000 --- a/components/camel-aws-msk/src/test/resources/log4j2.properties +++ /dev/null @@ -1,28 +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. -## --------------------------------------------------------------------------- - -appender.file.type = File -appender.file.name = file -appender.file.fileName = target/camel-aws-kms-test.log -appender.file.layout.type = PatternLayout -appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -appender.out.type = Console -appender.out.name = out -appender.out.layout.type = PatternLayout -appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -rootLogger.level = INFO -rootLogger.appenderRef.file.ref = file diff --git a/components/camel-aws-msk/src/test/resources/org/apache/camel/component/aws/kms/KMSComponentSpringTest-context.xml b/components/camel-aws-msk/src/test/resources/org/apache/camel/component/aws/kms/KMSComponentSpringTest-context.xml deleted file mode 100644 index 42eccfd..0000000 --- a/components/camel-aws-msk/src/test/resources/org/apache/camel/component/aws/kms/KMSComponentSpringTest-context.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?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. - ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> - - <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:listKeys"/> - <to uri="aws-kms://Test?kmsClient=#amazonKmsClient&operation=listKeys"/> - <to uri="mock:result"/> - </route> - <route> - <from uri="direct:createKey"/> - <to uri="aws-kms://Test?kmsClient=#amazonKmsClient&operation=createKey"/> - <to uri="mock:result"/> - </route> - <route> - <from uri="direct:disableKey"/> - <to uri="aws-kms://Test?kmsClient=#amazonKmsClient&operation=disableKey"/> - <to uri="mock:result"/> - </route> - <route> - <from uri="direct:enableKey"/> - <to uri="aws-kms://Test?kmsClient=#amazonKmsClient&operation=enableKey"/> - <to uri="mock:result"/> - </route> - <route> - <from uri="direct:scheduleDelete"/> - <to uri="aws-kms://Test?kmsClient=#amazonKmsClient&operation=scheduleKeyDeletion"/> - <to uri="mock:result"/> - </route> - <route> - <from uri="direct:describeKey"/> - <to uri="aws-kms://Test?kmsClient=#amazonKmsClient&operation=describeKey"/> - <to uri="mock:result"/> - </route> - </camelContext> - - <bean id="amazonKmsClient" class="org.apache.camel.component.aws.kms.AmazonKMSClientMock"/> -</beans> \ No newline at end of file