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/20 17:34:56 UTC

[camel] branch master updated (318b4fe -> 5d994ee)

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 318b4fe  CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - SES component
     new c8ed545  CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - SNS component
     new 5d994ee  CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - SQS 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/sns/SnsComponent.java      |  9 +++++---
 .../SnsComponentVerifierExtension.java}            | 24 ++++++++++++----------
 .../camel/component/aws/sqs/SqsComponent.java      | 10 +++++----
 .../SqsComponentVerifierExtension.java}            | 22 ++++++++++----------
 .../SnsComponentVerifierExtensionTest.java}        | 12 +++++------
 .../SqsComponentVerifierExtensionTest.java}        | 12 +++++------
 6 files changed, 48 insertions(+), 41 deletions(-)
 copy components/camel-aws/src/main/java/org/apache/camel/component/aws/{ses/SesComponentVerifierExtension.java => sns/SnsComponentVerifierExtension.java} (80%)
 copy components/camel-aws/src/main/java/org/apache/camel/component/aws/{sdb/SdbComponentVerifierExtension.java => sqs/SqsComponentVerifierExtension.java} (81%)
 copy components/camel-aws/src/test/java/org/apache/camel/component/aws/{sdb/SdbComponentVerifierExtensionTest.java => sns/SnsComponentVerifierExtensionTest.java} (88%)
 copy components/camel-aws/src/test/java/org/apache/camel/component/aws/{sdb/SdbComponentVerifierExtensionTest.java => sqs/SqsComponentVerifierExtensionTest.java} (88%)

-- 
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 - SQS 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 5d994eef8a961fef06d7cca1b3920e378657a4d5
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Nov 20 18:29:02 2017 +0100

    CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - SQS Component
---
 .../camel/component/aws/sqs/SqsComponent.java      | 10 ++-
 .../aws/sqs/SqsComponentVerifierExtension.java     | 86 ++++++++++++++++++++++
 .../aws/sqs/SqsComponentVerifierExtensionTest.java | 71 ++++++++++++++++++
 3 files changed, 163 insertions(+), 4 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
index 75fabdc..06da6f8 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
@@ -20,17 +20,19 @@ 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;
 import org.apache.camel.util.ObjectHelper;
 
-public class SqsComponent extends UriEndpointComponent {
+public class SqsComponent extends DefaultComponent {
     
     public SqsComponent() {
-        super(SqsEndpoint.class);
+        this(null);
     }
 
     public SqsComponent(CamelContext context) {
-        super(context, SqsEndpoint.class);
+        super(context);
+        
+        registerExtension(new SqsComponentVerifierExtension());
     }
 
     @Override
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponentVerifierExtension.java
new file mode 100644
index 0000000..2402a85
--- /dev/null
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponentVerifierExtension.java
@@ -0,0 +1,86 @@
+/**
+ * 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.sqs;
+
+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.sqs.AmazonSQS;
+import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
+
+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 SqsComponentVerifierExtension extends DefaultComponentVerifierExtension {
+
+    public SqsComponentVerifierExtension() {
+        this("aws-sqs");
+    }
+
+    public SqsComponentVerifierExtension(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 {
+            SqsConfiguration configuration = setProperties(new SqsConfiguration(), parameters);
+            AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
+            AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
+            AmazonSQS client = AmazonSQSClientBuilder.standard().withCredentials(credentialsProvider).withRegion(configuration.getRegion()).build();
+            client.listQueues();
+        } catch (SdkClientException e) {
+            ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
+                .detail("aws_sqs_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/sqs/SqsComponentVerifierExtensionTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentVerifierExtensionTest.java
new file mode 100644
index 0000000..6b93bc8
--- /dev/null
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentVerifierExtensionTest.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.sqs;
+
+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 SqsComponentVerifierExtensionTest extends CamelTestSupport {
+
+    // *************************************************
+    // Tests (parameters)
+    // *************************************************
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        Component component = context().getComponent("aws-sqs");
+
+        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("queueNameOrArn", "bucket1");
+
+        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-sqs");
+        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("queueNameOrArn", "test12");
+
+        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 - SNS 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 c8ed545b9f6c6779de95bc9cb3ebcf55fb9ee078
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Nov 20 18:10:45 2017 +0100

    CAMEL-12012 - Camel-AWS: Add component verifiers like S3 for all the AWS components - SNS component
---
 .../camel/component/aws/sns/SnsComponent.java      |  9 ++-
 .../aws/sns/SnsComponentVerifierExtension.java     | 88 ++++++++++++++++++++++
 .../aws/sns/SnsComponentVerifierExtensionTest.java | 71 +++++++++++++++++
 3 files changed, 165 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
index da6b311..449b6f9 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
@@ -20,16 +20,19 @@ import java.util.Map;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
 import org.apache.camel.impl.UriEndpointComponent;
 
-public class SnsComponent extends UriEndpointComponent {
+public class SnsComponent extends DefaultComponent {
     
     public SnsComponent() {
-        super(SnsEndpoint.class);
+        this(null);
     }
 
     public SnsComponent(CamelContext context) {
-        super(context, SnsEndpoint.class);
+        super(context);
+        
+        registerExtension(new SnsComponentVerifierExtension());
     }
 
     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/sns/SnsComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponentVerifierExtension.java
new file mode 100644
index 0000000..c72a563
--- /dev/null
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponentVerifierExtension.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.sns;
+
+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.s3.AmazonS3;
+import com.amazonaws.services.s3.AmazonS3ClientBuilder;
+import com.amazonaws.services.sns.AmazonSNS;
+import com.amazonaws.services.sns.AmazonSNSClientBuilder;
+
+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 SnsComponentVerifierExtension extends DefaultComponentVerifierExtension {
+
+    public SnsComponentVerifierExtension() {
+        this("aws-sns");
+    }
+
+    public SnsComponentVerifierExtension(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 {
+            SnsConfiguration configuration = setProperties(new SnsConfiguration(), parameters);
+            AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
+            AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
+            AmazonSNS client = AmazonSNSClientBuilder.standard().withCredentials(credentialsProvider).withRegion(configuration.getRegion()).build();
+            client.listSubscriptions();
+        } catch (SdkClientException e) {
+            ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
+                .detail("aws_sns_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/sns/SnsComponentVerifierExtensionTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentVerifierExtensionTest.java
new file mode 100644
index 0000000..180ea9b
--- /dev/null
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentVerifierExtensionTest.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.sns;
+
+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 SnsComponentVerifierExtensionTest extends CamelTestSupport {
+
+    // *************************************************
+    // Tests (parameters)
+    // *************************************************
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        Component component = context().getComponent("aws-sns");
+
+        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("topicNameOrArn", "bucket1");
+
+        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-sns");
+        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("topicNameOrArn", "test12");
+
+        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>.