You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/01/24 13:01:55 UTC

[camel] branch master updated (b6957fa -> 249fed6)

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

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from b6957fa  CAMEL-12186 - Camel-AWS S3: Support KMS in S3 Producer related operations
     new 3d0d9a7  CAMEL-12187 - Camel-AWS DDBStream: Add a ComponentVerifier
     new 81d6320  CAMEL-12189 - Camel-AWS Kinesis Firehose: Add a ComponentVerifier
     new e946880  CAMEL-12188 - Camel-AWS Kinesis: Add a ComponentVerifier
     new c66efa5  CAMEL-12189 - Camel-AWS Kinesis Firehose: Add a ComponentVerifier
     new 249fed6  CAMEL-12188 - Fixed CS

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../aws/ddbstream/DdbStreamComponent.java          |  3 +--
 .../DdbStreamComponentVerifierExtension.java}      | 23 +++++++++---------
 .../aws/firehose/KinesisFirehoseComponent.java     |  1 +
 ...KinesisFirehoseComponentVerifierExtension.java} | 27 ++++++++++++----------
 .../component/aws/kinesis/KinesisComponent.java    |  1 +
 .../KinesisComponentVerifierExtension.java}        | 25 ++++++++++----------
 ...sisFirehoseComponentVerifierExtensionTest.java} | 12 +++++-----
 .../KinesisComponentVerifierExtensionTest.java}    | 12 +++++-----
 8 files changed, 55 insertions(+), 49 deletions(-)
 copy components/camel-aws/src/main/java/org/apache/camel/component/aws/{cw/CwComponentVerifierExtension.java => ddbstream/DdbStreamComponentVerifierExtension.java} (75%)
 copy components/camel-aws/src/main/java/org/apache/camel/component/aws/{cw/CwComponentVerifierExtension.java => firehose/KinesisFirehoseComponentVerifierExtension.java} (71%)
 copy components/camel-aws/src/main/java/org/apache/camel/component/aws/{cw/CwComponentVerifierExtension.java => kinesis/KinesisComponentVerifierExtension.java} (76%)
 copy components/camel-aws/src/test/java/org/apache/camel/component/aws/{ddbstream/DdbStreamComponentVerifierExtensionTest.java => firehose/KinesisFirehoseComponentVerifierExtensionTest.java} (86%)
 copy components/camel-aws/src/test/java/org/apache/camel/component/aws/{ses/SesComponentVerifierExtensionTest.java => kinesis/KinesisComponentVerifierExtensionTest.java} (87%)

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 05/05: CAMEL-12188 - Fixed CS

Posted by ac...@apache.org.
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

commit 249fed6492d7e54559523f714fcee90fff90467a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 24 13:58:18 2018 +0100

    CAMEL-12188 - Fixed CS
---
 .../camel/component/aws/kinesis/KinesisComponentVerifierExtension.java   | 1 -
 1 file changed, 1 deletion(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtension.java
index 711da23..9cd365b 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtension.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtension.java
@@ -26,7 +26,6 @@ import com.amazonaws.auth.BasicAWSCredentials;
 import com.amazonaws.services.kinesis.AmazonKinesis;
 import com.amazonaws.services.kinesis.AmazonKinesisClientBuilder;
 
-import org.apache.camel.component.aws.kinesis.KinesisConfiguration;
 import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExtension;
 import org.apache.camel.component.extension.verifier.ResultBuilder;
 import org.apache.camel.component.extension.verifier.ResultErrorBuilder;

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 03/05: CAMEL-12188 - Camel-AWS Kinesis: Add a ComponentVerifier

Posted by ac...@apache.org.
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

commit e946880bb15369adcd3cda2a0eea53d5072448b8
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 24 13:55:11 2018 +0100

    CAMEL-12188 - Camel-AWS Kinesis: Add a ComponentVerifier
---
 .../component/aws/kinesis/KinesisComponent.java    |  1 +
 .../kinesis/KinesisComponentVerifierExtension.java | 88 ++++++++++++++++++++++
 .../KinesisComponentVerifierExtensionTest.java     | 71 +++++++++++++++++
 3 files changed, 160 insertions(+)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponent.java
index a5d8c1c..5e8d6ac 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponent.java
@@ -43,6 +43,7 @@ public class KinesisComponent extends DefaultComponent {
         super(context);
         
         this.configuration = new KinesisConfiguration();
+        registerExtension(new KinesisComponentVerifierExtension());
     }
 
     @Override
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtension.java
new file mode 100644
index 0000000..711da23
--- /dev/null
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtension.java
@@ -0,0 +1,88 @@
+/**
+ * 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.kinesis;
+
+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.services.kinesis.AmazonKinesis;
+import com.amazonaws.services.kinesis.AmazonKinesisClientBuilder;
+
+import org.apache.camel.component.aws.kinesis.KinesisConfiguration;
+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 KinesisComponentVerifierExtension extends DefaultComponentVerifierExtension {
+
+    public KinesisComponentVerifierExtension() {
+        this("aws-kinesis");
+    }
+
+    public KinesisComponentVerifierExtension(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))
+            .error(ResultErrorHelper.requiresOption("streamName", 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 {
+            KinesisConfiguration configuration = setProperties(new KinesisConfiguration(), parameters);
+            AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
+            AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
+            AmazonKinesis client = AmazonKinesisClientBuilder.standard().withCredentials(credentialsProvider).withRegion(configuration.getRegion()).build();
+            client.listStreams();
+        } catch (SdkClientException e) {
+            ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
+                .detail("aws_kinesis_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/src/test/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtensionTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtensionTest.java
new file mode 100644
index 0000000..b4a57a6
--- /dev/null
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/kinesis/KinesisComponentVerifierExtensionTest.java
@@ -0,0 +1,71 @@
+/**
+ * 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.kinesis;
+
+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 KinesisComponentVerifierExtensionTest extends CamelTestSupport {
+
+    // *************************************************
+    // Tests (parameters)
+    // *************************************************
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        Component component = context().getComponent("aws-kinesis");
+
+        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("streamName", "test");
+
+        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-kinesis");
+        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("streamName", "test");
+
+        ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
+
+        Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 01/05: CAMEL-12187 - Camel-AWS DDBStream: Add a ComponentVerifier

Posted by ac...@apache.org.
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

commit 3d0d9a76123eb9f9fbb612ef92811ed8e35a0fe0
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 24 11:54:35 2018 +0100

    CAMEL-12187 - Camel-AWS DDBStream: Add a ComponentVerifier
---
 .../aws/ddbstream/DdbStreamComponent.java          |  3 +-
 .../DdbStreamComponentVerifierExtension.java       | 87 ++++++++++++++++++++++
 2 files changed, 88 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponent.java
index a9586a1..b64eaf7 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponent.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.aws.ddbstream;
 import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
-import org.apache.camel.component.aws.ddb.DdbComponentVerifierExtension;
 import org.apache.camel.impl.DefaultComponent;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.util.ObjectHelper;
@@ -43,7 +42,7 @@ public class DdbStreamComponent extends DefaultComponent {
         super(context);
         
         this.configuration = new DdbStreamConfiguration();
-        registerExtension(new DdbComponentVerifierExtension());
+        registerExtension(new DdbStreamComponentVerifierExtension());
     }
 
     @Override
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponentVerifierExtension.java
new file mode 100644
index 0000000..ebfba2d
--- /dev/null
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponentVerifierExtension.java
@@ -0,0 +1,87 @@
+/**
+ * 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.ddbstream;
+
+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.services.dynamodbv2.AmazonDynamoDBStreams;
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDBStreamsClientBuilder;
+import com.amazonaws.services.dynamodbv2.model.ListStreamsRequest;
+
+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 DdbStreamComponentVerifierExtension extends DefaultComponentVerifierExtension {
+
+    public DdbStreamComponentVerifierExtension() {
+        this("aws-ddbstream");
+    }
+
+    public DdbStreamComponentVerifierExtension(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 {
+            DdbStreamConfiguration configuration = setProperties(new DdbStreamConfiguration(), parameters);
+            AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
+            AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
+            AmazonDynamoDBStreams client = AmazonDynamoDBStreamsClientBuilder.standard().withCredentials(credentialsProvider).withRegion(configuration.getRegion()).build();
+            client.listStreams(new ListStreamsRequest());
+        } catch (SdkClientException e) {
+            ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
+                .detail("aws_ddb_stream_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();
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 02/05: CAMEL-12189 - Camel-AWS Kinesis Firehose: Add a ComponentVerifier

Posted by ac...@apache.org.
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

commit 81d63207ce9f164e1151b348971958110ca23fa3
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 24 12:10:31 2018 +0100

    CAMEL-12189 - Camel-AWS Kinesis Firehose: Add a ComponentVerifier
---
 .../aws/firehose/KinesisFirehoseComponent.java     |  1 +
 .../KinesisFirehoseComponentVerifierExtension.java | 89 ++++++++++++++++++++++
 ...esisFirehoseComponentVerifierExtensionTest.java | 71 +++++++++++++++++
 3 files changed, 161 insertions(+)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponent.java
index 065fc9f..e6e5819 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponent.java
@@ -43,6 +43,7 @@ public class KinesisFirehoseComponent extends DefaultComponent {
         super(context);
         
         this.configuration = new KinesisFirehoseConfiguration();
+        registerExtension(new KinesisFirehoseComponentVerifierExtension());
     }
 
     @Override
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtension.java
new file mode 100644
index 0000000..09cde5f
--- /dev/null
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtension.java
@@ -0,0 +1,89 @@
+/**
+ * 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.firehose;
+
+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.services.kinesisfirehose.AmazonKinesisFirehose;
+import com.amazonaws.services.kinesisfirehose.AmazonKinesisFirehoseClientBuilder;
+import com.amazonaws.services.kinesisfirehose.model.ListDeliveryStreamsRequest;
+
+import org.apache.camel.component.aws.kinesis.KinesisConfiguration;
+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 KinesisFirehoseComponentVerifierExtension extends DefaultComponentVerifierExtension {
+
+    public KinesisFirehoseComponentVerifierExtension() {
+        this("aws-kinesis-firehose");
+    }
+
+    public KinesisFirehoseComponentVerifierExtension(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))
+            .error(ResultErrorHelper.requiresOption("streamName", 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 {
+            KinesisFirehoseConfiguration configuration = setProperties(new KinesisFirehoseConfiguration(), parameters);
+            AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
+            AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
+            AmazonKinesisFirehose client = AmazonKinesisFirehoseClientBuilder.standard().withCredentials(credentialsProvider).withRegion(configuration.getRegion()).build();
+            client.listDeliveryStreams(new ListDeliveryStreamsRequest());
+        } catch (SdkClientException e) {
+            ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
+                .detail("aws_ddb_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/src/test/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtensionTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtensionTest.java
new file mode 100644
index 0000000..202ba8a
--- /dev/null
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtensionTest.java
@@ -0,0 +1,71 @@
+/**
+ * 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.firehose;
+
+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 KinesisFirehoseComponentVerifierExtensionTest extends CamelTestSupport {
+
+    // *************************************************
+    // Tests (parameters)
+    // *************************************************
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        Component component = context().getComponent("aws-kinesis-firehose");
+
+        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("streamName", "test");
+
+        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-kinesis-firehose");
+        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("streamName", "test");
+
+        ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
+
+        Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 04/05: CAMEL-12189 - Camel-AWS Kinesis Firehose: Add a ComponentVerifier

Posted by ac...@apache.org.
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

commit c66efa561cfb143cd32bc4c0d6c05dabaa4f0f50
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 24 13:56:29 2018 +0100

    CAMEL-12189 - Camel-AWS Kinesis Firehose: Add a ComponentVerifier
---
 .../aws/firehose/KinesisFirehoseComponentVerifierExtension.java         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtension.java
index 09cde5f..eea12d5 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtension.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/firehose/KinesisFirehoseComponentVerifierExtension.java
@@ -77,7 +77,7 @@ public class KinesisFirehoseComponentVerifierExtension extends DefaultComponentV
             client.listDeliveryStreams(new ListDeliveryStreamsRequest());
         } catch (SdkClientException e) {
             ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
-                .detail("aws_ddb_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName())
+                .detail("aws_kinesis_firehose_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName())
                 .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);
 
             builder.error(errorBuilder.build());

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.