You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/12/08 05:22:07 UTC
[camel] branch main updated: CAMEL-18131 - aws2 sns health (#8867)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 25a31a809b6 CAMEL-18131 - aws2 sns health (#8867)
25a31a809b6 is described below
commit 25a31a809b6abf001f74e41e9fa8f56b6125fa70
Author: Rhuan Rocha <rh...@gmail.com>
AuthorDate: Thu Dec 8 02:22:00 2022 -0300
CAMEL-18131 - aws2 sns health (#8867)
* CAMEL-18131 - Adding health check to test conectivity
Signed-off-by: Rhuan Rocha <rh...@gmail.com>
* CAMEL-18131 - Adding health check to test conectivity
Signed-off-by: Rhuan Rocha <rh...@gmail.com>
* CAMEL-18131 - Adding health check to test conectivity
Signed-off-by: Rhuan Rocha <rh...@gmail.com>
Signed-off-by: Rhuan Rocha <rh...@gmail.com>
---
catalog/camel-allcomponents/pom.xml | 2 +-
components/camel-aws/camel-aws2-sns/pom.xml | 9 ++
.../camel/component/aws2/sns/Sns2Component.java | 1 -
.../aws2/sns/Sns2ComponentVerifierExtension.java | 94 ---------------------
.../camel/component/aws2/sns/Sns2Endpoint.java | 19 +++++
.../camel/component/aws2/sns/Sns2HealthCheck.java | 71 ++++++++++++++++
.../aws2/sns/Sns2HealthCheckProfileCredsTest.java | 96 ++++++++++++++++++++++
.../aws2/sns/Sns2HealthCheckStaticCredsTest.java | 96 ++++++++++++++++++++++
.../sns/SnsComponentVerifierExtensionTest.java | 90 --------------------
parent/pom.xml | 2 +-
10 files changed, 293 insertions(+), 187 deletions(-)
diff --git a/catalog/camel-allcomponents/pom.xml b/catalog/camel-allcomponents/pom.xml
index da2229d144d..40e2c4092fa 100644
--- a/catalog/camel-allcomponents/pom.xml
+++ b/catalog/camel-allcomponents/pom.xml
@@ -1990,4 +1990,4 @@
</dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
diff --git a/components/camel-aws/camel-aws2-sns/pom.xml b/components/camel-aws/camel-aws2-sns/pom.xml
index d53b82db70a..0ad0008e8fe 100644
--- a/components/camel-aws/camel-aws2-sns/pom.xml
+++ b/components/camel-aws/camel-aws2-sns/pom.xml
@@ -61,6 +61,10 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-health</artifactId>
+ </dependency>
<!-- test infra -->
<dependency>
@@ -77,6 +81,11 @@
<artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core-catalog</artifactId>
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
index 7b5d31dbc7a..944ecb1ac66 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
@@ -43,7 +43,6 @@ public class Sns2Component extends DefaultComponent {
public Sns2Component(CamelContext context) {
super(context);
- registerExtension(new Sns2ComponentVerifierExtension());
}
@Override
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2ComponentVerifierExtension.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2ComponentVerifierExtension.java
deleted file mode 100644
index f0b396a20ba..00000000000
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2ComponentVerifierExtension.java
+++ /dev/null
@@ -1,94 +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.aws2.sns;
-
-import java.util.Map;
-
-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;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.core.exception.SdkClientException;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.sns.SnsClient;
-import software.amazon.awssdk.services.sns.SnsClientBuilder;
-
-public class Sns2ComponentVerifierExtension extends DefaultComponentVerifierExtension {
-
- public Sns2ComponentVerifierExtension() {
- this("aws2-sns");
- }
-
- public Sns2ComponentVerifierExtension(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 {
- Sns2Configuration configuration = setProperties(new Sns2Configuration(), parameters);
- if (!SnsClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
- ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(
- VerificationError.StandardCode.ILLEGAL_PARAMETER, "The service is not supported in this region");
- return builder.error(errorBuilder.build()).build();
- }
- AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
- SnsClientBuilder clientBuilder = SnsClient.builder();
- SnsClient client = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred))
- .region(Region.of(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/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
index ad584ad67b0..e879f93f48a 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
@@ -27,6 +27,8 @@ import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.component.aws2.sns.client.Sns2ClientFactory;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.impl.health.ComponentsHealthCheckRepository;
import org.apache.camel.spi.HeaderFilterStrategy;
import org.apache.camel.spi.HeaderFilterStrategyAware;
import org.apache.camel.spi.Metadata;
@@ -60,6 +62,9 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg
private static final Logger LOG = LoggerFactory.getLogger(Sns2Endpoint.class);
+ private ComponentsHealthCheckRepository healthCheckRepository;
+ private Sns2HealthCheck clientHealthCheck;
+
private SnsClient snsClient;
@UriPath(description = "Topic name or ARN")
@@ -109,6 +114,15 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg
headerFilterStrategy = new Sns2HeaderFilterStrategy();
}
+ healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(getCamelContext(),
+ ComponentsHealthCheckRepository.REPOSITORY_ID, ComponentsHealthCheckRepository.class);
+
+ if (healthCheckRepository != null) {
+ clientHealthCheck = new Sns2HealthCheck(this, getId());
+ }
+
+ healthCheckRepository.addHealthCheck(clientHealthCheck);
+
if (configuration.getTopicArn() == null) {
try {
String nextToken = null;
@@ -193,6 +207,11 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg
snsClient.close();
}
}
+
+ if (healthCheckRepository != null && clientHealthCheck != null) {
+ healthCheckRepository.removeHealthCheck(clientHealthCheck);
+ clientHealthCheck = null;
+ }
super.doStop();
}
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HealthCheck.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HealthCheck.java
new file mode 100644
index 00000000000..540c5197ee6
--- /dev/null
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HealthCheck.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.aws2.sns;
+
+import java.util.Map;
+
+import org.apache.camel.component.aws2.sns.client.Sns2ClientFactory;
+import org.apache.camel.health.HealthCheckResultBuilder;
+import org.apache.camel.impl.health.AbstractHealthCheck;
+import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.sns.SnsClient;
+
+public class Sns2HealthCheck extends AbstractHealthCheck {
+
+ private final Sns2Endpoint sns2Endpoint;
+ private final String clientId;
+
+ public Sns2HealthCheck(Sns2Endpoint sns2Endpoint, String clientId) {
+ super("camel", "aws2-sns-client-" + clientId);
+ this.sns2Endpoint = sns2Endpoint;
+ this.clientId = clientId;
+ }
+
+ @Override
+ public boolean isLiveness() {
+ // this health check is only readiness
+ return false;
+ }
+
+ @Override
+ protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) {
+
+ try {
+ Sns2Configuration configuration = sns2Endpoint.getConfiguration();
+ if (!SnsClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
+ builder.message("The service is not supported in this region");
+ builder.down();
+ return;
+ }
+
+ SnsClient client = Sns2ClientFactory.getSnsClient(configuration).getSNSClient();
+ client.listSubscriptions();
+
+ } catch (AwsServiceException e) {
+ builder.message(e.getMessage());
+ builder.error(e);
+ builder.down();
+ } catch (Exception e) {
+ builder.error(e);
+ builder.down();
+ return;
+ }
+ builder.up();
+
+ }
+}
diff --git a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckProfileCredsTest.java
new file mode 100644
index 00000000000..d6b13ccb36b
--- /dev/null
+++ b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckProfileCredsTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.aws2.sns;
+
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
+
+public class Sns2HealthCheckProfileCredsTest extends CamelTestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Sns2HealthCheckProfileCredsTest.class);
+
+ CamelContext context;
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ context = super.createCamelContext();
+ context.getPropertiesComponent().setLocation("ref:prop");
+
+ // install health check manually (yes a bit cumbersome)
+ HealthCheckRegistry registry = new DefaultHealthCheckRegistry();
+ registry.setCamelContext(context);
+ Object hc = registry.resolveById("context");
+ registry.register(hc);
+ hc = registry.resolveById("routes");
+ registry.register(hc);
+ hc = registry.resolveById("consumers");
+ registry.register(hc);
+ context.setExtension(HealthCheckRegistry.class, registry);
+
+ return context;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() {
+ from("direct:testHealthCheck")
+ .to("aws2-sns://arn:aws:sns:us-east-1:account:MyTopic?region=l&useDefaultCredentialsProvider=true");
+ }
+ };
+ }
+
+ @Test
+ public void testConnectivity() {
+
+ Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
+ boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
+ Assertions.assertTrue(up, "liveness check");
+
+ // health-check readiness should be down
+ await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
+ Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
+ boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
+ boolean containsAws2AthenaHealthCheck = res2.stream()
+ .filter(result -> result.getCheck().getId().startsWith("aws2-sns-client"))
+ .findAny()
+ .isPresent();
+ boolean hasRegionMessage = res2.stream()
+ .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
+ Assertions.assertTrue(down, "liveness check");
+ Assertions.assertTrue(containsAws2AthenaHealthCheck, "aws2-sns check");
+ Assertions.assertTrue(hasRegionMessage, "aws2-sns check error message");
+ });
+
+ }
+}
diff --git a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckStaticCredsTest.java
new file mode 100644
index 00000000000..f11e5ef19ce
--- /dev/null
+++ b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckStaticCredsTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.aws2.sns;
+
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
+
+public class Sns2HealthCheckStaticCredsTest extends CamelTestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Sns2HealthCheckStaticCredsTest.class);
+
+ CamelContext context;
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ context = super.createCamelContext();
+ context.getPropertiesComponent().setLocation("ref:prop");
+
+ // install health check manually (yes a bit cumbersome)
+ HealthCheckRegistry registry = new DefaultHealthCheckRegistry();
+ registry.setCamelContext(context);
+ Object hc = registry.resolveById("context");
+ registry.register(hc);
+ hc = registry.resolveById("routes");
+ registry.register(hc);
+ hc = registry.resolveById("consumers");
+ registry.register(hc);
+ context.setExtension(HealthCheckRegistry.class, registry);
+
+ return context;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() {
+ from("direct:testHealthCheck")
+ .to("aws2-sns://arn:aws:sns:us-east-1:account:MyTopic?region=l&secretKey=l&accessKey=k");
+ }
+ };
+ }
+
+ @Test
+ public void testConnectivity() {
+
+ Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
+ boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
+ Assertions.assertTrue(up, "liveness check");
+
+ // health-check readiness should be down
+ await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
+ Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
+ boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
+ boolean containsAws2AthenaHealthCheck = res2.stream()
+ .filter(result -> result.getCheck().getId().startsWith("aws2-sns-client"))
+ .findAny()
+ .isPresent();
+ boolean hasRegionMessage = res2.stream()
+ .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
+ Assertions.assertTrue(down, "liveness check");
+ Assertions.assertTrue(containsAws2AthenaHealthCheck, "aws2-sns check");
+ Assertions.assertTrue(hasRegionMessage, "aws2-sns check error message");
+ });
+
+ }
+}
diff --git a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsComponentVerifierExtensionTest.java b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsComponentVerifierExtensionTest.java
deleted file mode 100644
index b0260c21fe2..00000000000
--- a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsComponentVerifierExtensionTest.java
+++ /dev/null
@@ -1,90 +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.aws2.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.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class SnsComponentVerifierExtensionTest extends CamelTestSupport {
-
- // *************************************************
- // Tests (parameters)
- // *************************************************
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @Test
- public void testParameters() {
- Component component = context().getComponent("aws2-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);
-
- assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus());
- }
-
- @Test
- public void testConnectivity() {
- Component component = context().getComponent("aws2-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);
-
- assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
- }
-
- @Test
- public void testConnectivityAndRegion() {
- Component component = context().getComponent("aws2-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", "test12");
-
- ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
-
- assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
- }
-}
diff --git a/parent/pom.xml b/parent/pom.xml
index c5e021f932d..a82380efe50 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -5026,4 +5026,4 @@
</build>
</profile>
</profiles>
-</project>
+</project>
\ No newline at end of file