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 2017/11/21 10:46:42 UTC

[camel] branch master updated (e7fd657 -> d2da0d1)

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 e7fd657  CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - CW Component
     new 4d6386a  CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - DDB Component
     new d2da0d1  CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - DDBStream Component

The 2 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:
 .../camel/component/aws/ddb/DdbComponent.java      | 10 +++++----
 .../DdbComponentVerifierExtension.java}            | 24 ++++++++++++----------
 .../aws/ddbstream/DdbStreamComponent.java          | 11 ++++++----
 .../DdbComponentVerifierExtensionTest.java}        | 12 +++++------
 .../DdbStreamComponentVerifierExtensionTest.java}  | 12 +++++------
 5 files changed, 38 insertions(+), 31 deletions(-)
 copy components/camel-aws/src/main/java/org/apache/camel/component/aws/{sdb/SdbComponentVerifierExtension.java => ddb/DdbComponentVerifierExtension.java} (82%)
 copy components/camel-aws/src/test/java/org/apache/camel/component/aws/{swf/SwfComponentVerifierExtensionTest.java => ddb/DdbComponentVerifierExtensionTest.java} (88%)
 copy components/camel-aws/src/test/java/org/apache/camel/component/aws/{ses/SesComponentVerifierExtensionTest.java => ddbstream/DdbStreamComponentVerifierExtensionTest.java} (87%)

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].

[camel] 02/02: CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - DDBStream Component

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 d2da0d16874d2b5f800a1589aeaa15e541923f6b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 21 11:46:23 2017 +0100

    CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - DDBStream Component
---
 .../aws/ddbstream/DdbStreamComponent.java          | 11 ++--
 .../DdbStreamComponentVerifierExtensionTest.java   | 71 ++++++++++++++++++++++
 2 files changed, 78 insertions(+), 4 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 ed384e4..a0ef0a7 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,19 +19,22 @@ 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.impl.UriEndpointComponent;
+import org.apache.camel.component.aws.ddb.DdbComponentVerifierExtension;
+import org.apache.camel.impl.DefaultComponent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class DdbStreamComponent extends UriEndpointComponent {
+public class DdbStreamComponent extends DefaultComponent {
     private static final Logger LOG = LoggerFactory.getLogger(DdbStreamComponent.class);
 
     public DdbStreamComponent() {
-        super(DdbStreamEndpoint.class);
+        this(null);
     }
 
     public DdbStreamComponent(CamelContext context) {
-        super(context, DdbStreamEndpoint.class);
+        super(context);
+        
+        registerExtension(new DdbComponentVerifierExtension());
     }
 
     @Override
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponentVerifierExtensionTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponentVerifierExtensionTest.java
new file mode 100644
index 0000000..da0115b
--- /dev/null
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddbstream/DdbStreamComponentVerifierExtensionTest.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.ddbstream;
+
+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 DdbStreamComponentVerifierExtensionTest extends CamelTestSupport {
+
+    // *************************************************
+    // Tests (parameters)
+    // *************************************************
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        Component component = context().getComponent("aws-ddbstream");
+
+        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("tableName", "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-ddbstream");
+        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("tableName", "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
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 01/02: CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - DDB Component

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 4d6386ac505e63b0fe0bbddebf5944966507fd6f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 21 11:34:10 2017 +0100

    CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - DDB Component
---
 .../camel/component/aws/ddb/DdbComponent.java      | 10 ++-
 .../aws/ddb/DdbComponentVerifierExtension.java     | 88 ++++++++++++++++++++++
 .../aws/ddb/DdbComponentVerifierExtensionTest.java | 71 +++++++++++++++++
 3 files changed, 165 insertions(+), 4 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java
index 156ff4d..a49fae1 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java
@@ -20,16 +20,18 @@ import java.util.Map;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.impl.DefaultComponent;
 
-public class DdbComponent extends UriEndpointComponent {
+public class DdbComponent extends DefaultComponent {
 
     public DdbComponent() {
-        super(DdbEndpoint.class);
+        this(null);
     }
 
     public DdbComponent(CamelContext context) {
-        super(context, DdbEndpoint.class);
+        super(context);
+        
+        registerExtension(new DdbComponentVerifierExtension());
     }
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponentVerifierExtension.java
new file mode 100644
index 0000000..e5ad1d8
--- /dev/null
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponentVerifierExtension.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.ddb;
+
+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.cloudwatch.AmazonCloudWatch;
+import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder;
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
+
+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 DdbComponentVerifierExtension extends DefaultComponentVerifierExtension {
+
+    public DdbComponentVerifierExtension() {
+        this("aws-ddb");
+    }
+
+    public DdbComponentVerifierExtension(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 {
+            DdbConfiguration configuration = setProperties(new DdbConfiguration(), parameters);
+            AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
+            AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
+            AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withCredentials(credentialsProvider).withRegion(configuration.getRegion()).build();
+            client.listTables();
+        } 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/ddb/DdbComponentVerifierExtensionTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentVerifierExtensionTest.java
new file mode 100644
index 0000000..23c7617
--- /dev/null
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentVerifierExtensionTest.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.ddb;
+
+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 DdbComponentVerifierExtensionTest extends CamelTestSupport {
+
+    // *************************************************
+    // Tests (parameters)
+    // *************************************************
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        Component component = context().getComponent("aws-ddb");
+
+        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("tableName", "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-ddb");
+        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("tableName", "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
"commits@camel.apache.org" <co...@camel.apache.org>.