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 683a11682d5 CAMEL-18131 - Adding health check to test conectivity 
(#8244)
683a11682d5 is described below

commit 683a11682d561d6c48d796723ba2c224ff323468
Author: Rhuan Rocha <rhuan...@gmail.com>
AuthorDate: Wed Aug 31 01:26:21 2022 -0300

    CAMEL-18131 - Adding health check to test conectivity (#8244)
    
    * CAMEL-18131 - Adding health check to test conectivity
    
    Signed-off-by: Rhuan Rocha <rhuan...@gmail.com>
    
    * CAMEL-18131 - Adding health check to test conectivity
    
    Signed-off-by: Rhuan Rocha <rhuan...@gmail.com>
    
    * CAMEL-18131 - Fixing the AWS2S3Component
    
    Signed-off-by: Rhuan Rocha <rhuan...@gmail.com>
    
    Signed-off-by: Rhuan Rocha <rhuan...@gmail.com>
---
 components/camel-aws/camel-aws2-s3/pom.xml         |   4 +
 .../camel/health-check/camel-aws2-s3-repository    |   2 +
 .../camel/component/aws2/s3/AWS2S3Component.java   |   2 -
 .../aws2/s3/AWS2S3ComponentVerifierExtension.java  |  94 ------------------
 .../camel/component/aws2/s3/AWS2S3Consumer.java    |  20 ++++
 .../aws2/s3/AWS2S3ConsumerHealthCheck.java         |  77 +++++++++++++++
 .../aws2/s3/AWS2S3HealthCheckRepository.java       |  87 +++++++++++++++++
 .../aws2/s3/AWS2S3ConsumerHealthCheckTest.java     | 107 +++++++++++++++++++++
 .../aws2/s3/S3ComponentVerifierExtensionTest.java  |  90 -----------------
 9 files changed, 297 insertions(+), 186 deletions(-)

diff --git a/components/camel-aws/camel-aws2-s3/pom.xml 
b/components/camel-aws/camel-aws2-s3/pom.xml
index c39514654af..3d7366847b2 100644
--- a/components/camel-aws/camel-aws2-s3/pom.xml
+++ b/components/camel-aws/camel-aws2-s3/pom.xml
@@ -50,6 +50,10 @@
             <artifactId>apache-client</artifactId>
             <version>${aws-java-sdk2-version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-health</artifactId>
+        </dependency>
 
         <!-- for testing -->
         <dependency>
diff --git 
a/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-s3-repository
 
b/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-s3-repository
new file mode 100644
index 00000000000..2073257dbd0
--- /dev/null
+++ 
b/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-s3-repository
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.aws2.s3.AWS2S3HealthCheckRepository
diff --git 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
index 71e6fd197cd..b4bdbf59ee4 100644
--- 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
+++ 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
@@ -40,8 +40,6 @@ public class AWS2S3Component extends DefaultComponent {
 
     public AWS2S3Component(CamelContext context) {
         super(context);
-
-        registerExtension(new AWS2S3ComponentVerifierExtension());
     }
 
     @Override
diff --git 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3ComponentVerifierExtension.java
 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3ComponentVerifierExtension.java
deleted file mode 100644
index 30a0d1658c5..00000000000
--- 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3ComponentVerifierExtension.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.s3;
-
-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.s3.S3Client;
-import software.amazon.awssdk.services.s3.S3ClientBuilder;
-
-public class AWS2S3ComponentVerifierExtension extends 
DefaultComponentVerifierExtension {
-
-    public AWS2S3ComponentVerifierExtension() {
-        this("aws2-s3");
-    }
-
-    public AWS2S3ComponentVerifierExtension(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 {
-            AWS2S3Configuration configuration = setProperties(new 
AWS2S3Configuration(), parameters);
-            if 
(!S3Client.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());
-            S3ClientBuilder clientBuilder = S3Client.builder();
-            S3Client client = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred))
-                    .region(Region.of(configuration.getRegion())).build();
-            client.listBuckets();
-        } catch (SdkClientException e) {
-            ResultErrorBuilder errorBuilder
-                    = 
ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION,
 e.getMessage())
-                            .detail("aws_s3_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-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java
 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java
index ee54e12901b..faa2d33fda9 100644
--- 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java
+++ 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java
@@ -32,6 +32,7 @@ import org.apache.camel.ExtendedExchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.health.HealthCheckHelper;
 import org.apache.camel.spi.Synchronization;
 import org.apache.camel.support.ScheduledBatchPollingConsumer;
 import org.apache.camel.support.SynchronizationAdapter;
@@ -69,6 +70,8 @@ public class AWS2S3Consumer extends 
ScheduledBatchPollingConsumer {
 
     private String marker;
     private transient String s3ConsumerToString;
+    private AWS2S3HealthCheckRepository healthCheckRepository;
+    private AWS2S3ConsumerHealthCheck consumerHealthCheck;
 
     public AWS2S3Consumer(AWS2S3Endpoint endpoint, Processor processor) {
         super(endpoint, processor);
@@ -78,6 +81,14 @@ public class AWS2S3Consumer extends 
ScheduledBatchPollingConsumer {
     protected void doStart() throws Exception {
         super.doStart();
 
+        healthCheckRepository = 
HealthCheckHelper.getHealthCheckRepository(getEndpoint().getCamelContext(),
+                AWS2S3HealthCheckRepository.REPOSITORY_ID, 
AWS2S3HealthCheckRepository.class);
+
+        if (healthCheckRepository != null) {
+            consumerHealthCheck = new AWS2S3ConsumerHealthCheck(this, 
getRouteId());
+            healthCheckRepository.addHealthCheck(consumerHealthCheck);
+        }
+
         if (getConfiguration().isMoveAfterRead()) {
             try {
                 getAmazonS3Client()
@@ -440,4 +451,13 @@ public class AWS2S3Consumer extends 
ScheduledBatchPollingConsumer {
         }
         return s3ConsumerToString;
     }
+
+    @Override
+    protected void doStop() throws Exception {
+        if (healthCheckRepository != null && consumerHealthCheck != null) {
+            healthCheckRepository.removeHealthCheck(consumerHealthCheck);
+            consumerHealthCheck = null;
+        }
+        super.doStop();
+    }
 }
diff --git 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3ConsumerHealthCheck.java
 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3ConsumerHealthCheck.java
new file mode 100644
index 00000000000..d39331e621d
--- /dev/null
+++ 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3ConsumerHealthCheck.java
@@ -0,0 +1,77 @@
+/*
+ * 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.s3;
+
+import java.util.Map;
+
+import org.apache.camel.health.HealthCheckResultBuilder;
+import org.apache.camel.impl.health.AbstractHealthCheck;
+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.s3.S3Client;
+import software.amazon.awssdk.services.s3.S3ClientBuilder;
+
+public class AWS2S3ConsumerHealthCheck extends AbstractHealthCheck {
+
+    private final AWS2S3Consumer aws2S3Consumer;
+    private final String routeId;
+
+    public AWS2S3ConsumerHealthCheck(AWS2S3Consumer aws2S3Consumer, String 
routeId) {
+        super("camel", "aws2-s3-consumer-" + routeId);
+        this.aws2S3Consumer = aws2S3Consumer;
+        this.routeId = routeId;
+    }
+
+    @Override
+    public boolean isLiveness() {
+        // this health check is only readiness
+        return false;
+    }
+
+    @Override
+    protected void doCall(HealthCheckResultBuilder builder, Map<String, 
Object> options) {
+
+        try {
+            AWS2S3Configuration configuration = 
aws2S3Consumer.getConfiguration();
+            if 
(!S3Client.serviceMetadata().regions().contains(Region.of(configuration.getRegion())))
 {
+                builder.message("The service is not supported in this region");
+                builder.down();
+                return;
+            }
+            AwsBasicCredentials cred = 
AwsBasicCredentials.create(configuration.getAccessKey(), 
configuration.getSecretKey());
+            S3ClientBuilder clientBuilder = S3Client.builder();
+            S3Client client = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred))
+                    .region(Region.of(configuration.getRegion())).build();
+            client.listBuckets();
+        } catch (SdkClientException e) {
+            builder.message(e.getMessage());
+            builder.error(e);
+            builder.down();
+            return;
+
+        } catch (Exception e) {
+            builder.error(e);
+            builder.down();
+            return;
+        }
+
+        builder.up();
+
+    }
+}
diff --git 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3HealthCheckRepository.java
 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3HealthCheckRepository.java
new file mode 100644
index 00000000000..9c01730dce4
--- /dev/null
+++ 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3HealthCheckRepository.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.aws2.s3;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Stream;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.DeferredContextBinding;
+import org.apache.camel.NonManagedService;
+import org.apache.camel.StaticService;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckRepository;
+import org.apache.camel.support.service.ServiceSupport;
+
+/**
+ * Repository for camel-aws2-s3 {@link HealthCheck}s.
+ */
+@org.apache.camel.spi.annotations.HealthCheck("camel-aws2-s3-repository")
+@DeferredContextBinding
+public class AWS2S3HealthCheckRepository extends ServiceSupport
+        implements CamelContextAware, HealthCheckRepository, StaticService, 
NonManagedService {
+
+    public static final String REPOSITORY_ID = "camel-aws2-s3";
+
+    private final List<HealthCheck> checks = new CopyOnWriteArrayList<>();
+    private volatile CamelContext context;
+    private boolean enabled = true;
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        this.context = camelContext;
+    }
+
+    @Override
+    public String getId() {
+        return REPOSITORY_ID;
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        return context;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    @Override
+    public Stream<HealthCheck> stream() {
+        return this.context != null && enabled
+                ? checks.stream()
+                : Stream.empty();
+    }
+
+    public void addHealthCheck(HealthCheck healthCheck) {
+        CamelContextAware.trySetCamelContext(healthCheck, getCamelContext());
+        this.checks.add(healthCheck);
+    }
+
+    public void removeHealthCheck(HealthCheck healthCheck) {
+        this.checks.remove(healthCheck);
+    }
+
+}
diff --git 
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ConsumerHealthCheckTest.java
 
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ConsumerHealthCheckTest.java
new file mode 100644
index 00000000000..54bfd549c5c
--- /dev/null
+++ 
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ConsumerHealthCheckTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.s3;
+
+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.infra.aws.common.services.AWSService;
+import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
+import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
+
+public class AWS2S3ConsumerHealthCheckTest extends CamelTestSupport {
+
+    @RegisterExtension
+    public static AWSService service = AWSServiceFactory.createS3Service();
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(AWS2S3ConsumerHealthCheckTest.class);
+
+    CamelContext context;
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        context = super.createCamelContext();
+        context.getPropertiesComponent().setLocation("ref:prop");
+        AWS2S3Component component = new AWS2S3Component(context);
+        
component.getConfiguration().setAmazonS3Client(AWSSDKClientUtils.newS3Client());
+        component.init();
+        context.addComponent("aws2-s3", component);
+
+        // 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("aws2-s3://bucket1?moveAfterRead=true&region=l&secretKey=l&accessKey=k&destinationBucket=bucket1&autoCreateBucket=false")
+                        
.startupOrder(2).log("${body}").routeId("test-health-it");
+            }
+        };
+    }
+
+    @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 containsAws2S3HealthCheck = res2.stream()
+                    .filter(result -> 
result.getCheck().getId().startsWith("aws2-s3-consumer"))
+                    .findAny()
+                    .isPresent();
+            boolean hasRegionMessage = res2.stream()
+                    .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> 
msg.contains("region")));
+            Assertions.assertTrue(down, "liveness check");
+            Assertions.assertTrue(containsAws2S3HealthCheck, "aws2-s3 check");
+            Assertions.assertTrue(hasRegionMessage, "aws2-s3 check error 
message");
+        });
+
+    }
+}
diff --git 
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/S3ComponentVerifierExtensionTest.java
 
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/S3ComponentVerifierExtensionTest.java
deleted file mode 100644
index a1cac9ccfba..00000000000
--- 
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/S3ComponentVerifierExtensionTest.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.s3;
-
-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 S3ComponentVerifierExtensionTest extends CamelTestSupport {
-
-    // *************************************************
-    // Tests (parameters)
-    // *************************************************
-    @Override
-    public boolean isUseRouteBuilder() {
-        return false;
-    }
-
-    @Test
-    public void testParameters() {
-        Component component = context().getComponent("aws2-s3");
-
-        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("bucketNameOrArn", "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-s3");
-        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("bucketNameOrArn", "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-s3");
-        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("bucketNameOrArn", "test12");
-
-        ComponentVerifierExtension.Result result = 
verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
-
-        assertEquals(ComponentVerifierExtension.Result.Status.ERROR, 
result.getStatus());
-    }
-}

Reply via email to