This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1aa37960cbf7d09dc7f9f108431f97a2036845eb Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Fri May 9 11:34:09 2025 +0200 CAMEL-22013 - camel-api - Remove all usage of component.extension and the component.extension package content itself - Solr Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../apache/camel/component/solr/SolrComponent.java | 1 - .../solr/SolrComponentVerifierExtension.java | 90 ---------------------- .../solr/SolrComponentVerifierExtensionTest.java | 63 --------------- 3 files changed, 154 deletions(-) diff --git a/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java b/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java index 76ffd94f069..3339b5cd4c2 100644 --- a/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java +++ b/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java @@ -56,7 +56,6 @@ public class SolrComponent extends DefaultComponent { public SolrComponent(CamelContext context) { super(context); - registerExtension(new SolrComponentVerifierExtension()); } @Override diff --git a/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponentVerifierExtension.java b/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponentVerifierExtension.java deleted file mode 100644 index 9378da38d3e..00000000000 --- a/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponentVerifierExtension.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.solr; - -import java.io.IOException; -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 org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.impl.HttpJdkSolrClient; - -public class SolrComponentVerifierExtension extends DefaultComponentVerifierExtension { - - public SolrComponentVerifierExtension() { - this("solr"); - } - - public SolrComponentVerifierExtension(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(parameters, "host")); - // 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 { - SolrConfiguration configuration = setProperties(new SolrConfiguration(), parameters); - if (configuration.getSolrClient() != null) { - configuration.getSolrClient().ping(); - } else { - try (SolrClient client = getDefaultSolrClientBuilder(configuration).build()) { - client.ping(); - } - } - } catch (IOException e) { - ResultErrorBuilder errorBuilder - = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage()) - .detail("solr_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(); - } - - private static HttpJdkSolrClient.Builder getDefaultSolrClientBuilder(SolrConfiguration configuration) { - HttpJdkSolrClient.Builder builder = new HttpJdkSolrClient.Builder(configuration.getSolrBaseUrl()); - builder.withDefaultCollection(configuration.getCollection()); - return builder; - } -} diff --git a/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentVerifierExtensionTest.java b/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentVerifierExtensionTest.java deleted file mode 100644 index 3246b76627c..00000000000 --- a/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentVerifierExtensionTest.java +++ /dev/null @@ -1,63 +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.solr; - -import java.net.ConnectException; -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; - -class SolrComponentVerifierExtensionTest extends CamelTestSupport { - - @Test - void testParameters() { - Component component = context().getComponent("solr"); - - ComponentVerifierExtension verifier - = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new); - - Map<String, Object> parameters = new HashMap<>(); - parameters.put("host", "localhost"); - - ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - - assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); - } - - @Test - void testConnectivity() { - Component component = context().getComponent("solr"); - ComponentVerifierExtension verifier - = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new); - - Map<String, Object> parameters = new HashMap<>(); - parameters.put("host", "localhost"); - - ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - - assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - assertEquals(ConnectException.class.getCanonicalName(), result.getErrors().get(0) - .getDetail(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_CLASS)); - } - -}