This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new 9217ba9 Solr native support fixes #1703 9217ba9 is described below commit 9217ba9476c61cd175c3399ed1bf1f1022828fe6 Author: Zineb Bendhiba <bendhiba.zi...@gmail.com> AuthorDate: Thu Nov 12 17:23:04 2020 +0100 Solr native support fixes #1703 --- .../ROOT/pages/reference/extensions/solr.adoc | 14 +- .../ROOT/partials/reference/components/solr.adoc | 6 +- extensions-jvm/pom.xml | 1 - extensions-jvm/solr/integration-test/pom.xml | 83 ------- .../quarkus/component/solr/it/SolrResource.java | 77 ------ extensions/pom.xml | 1 + .../solr/deployment/pom.xml | 12 + .../component/solr/deployment/SolrProcessor.java | 16 +- {extensions-jvm => extensions}/solr/pom.xml | 1 - .../solr/runtime/pom.xml | 13 + .../main/resources/META-INF/quarkus-extension.yaml | 3 +- integration-tests/pom.xml | 1 + integration-tests/solr/pom.xml | 167 +++++++++++++ .../component/solr/it/SolrCloudResource.java | 43 ++++ .../component/solr/it/SolrCommonResource.java | 176 +++++++++++++ .../quarkus/component/solr/it/SolrSslResource.java | 43 ++++ .../component/solr/it/SolrStandaloneResource.java | 42 ++++ .../camel/quarkus/component/solr/it/bean/Item.java | 45 ++-- .../camel/quarkus/component/solr/it/SolrIT.java | 33 +-- .../camel/quarkus/component/solr/it/SolrTest.java | 272 +++++++++++++++++++++ .../component/solr/it/SolrTestResource.java | 120 +++++++++ .../src/test/resources/ssl/solr-ssl.keystore.jks | Bin 0 -> 2659 bytes .../src/test/resources/ssl/solr-ssl.keystore.p12 | Bin 0 -> 2659 bytes .../solr/src/test/resources/ssl/solr-ssl.pem | 63 +++++ poms/bom-test/pom.xml | 5 + poms/bom/pom.xml | 6 + tooling/scripts/test-categories.yaml | 1 + 27 files changed, 1007 insertions(+), 237 deletions(-) diff --git a/docs/modules/ROOT/pages/reference/extensions/solr.adoc b/docs/modules/ROOT/pages/reference/extensions/solr.adoc index 5c73915..0090367 100644 --- a/docs/modules/ROOT/pages/reference/extensions/solr.adoc +++ b/docs/modules/ROOT/pages/reference/extensions/solr.adoc @@ -2,15 +2,15 @@ // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page = Solr :cq-artifact-id: camel-quarkus-solr -:cq-native-supported: false -:cq-status: Preview +:cq-native-supported: true +:cq-status: Stable :cq-description: Perform operations against Apache Lucene Solr. :cq-deprecated: false :cq-jvm-since: 1.1.0 -:cq-native-since: n/a +:cq-native-since: 1.5.0 [.badges] -[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported## +[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.5.0## Perform operations against Apache Lucene Solr. @@ -33,3 +33,9 @@ Please refer to the above links for usage and configuration details. ---- Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. + +== SSL in native mode + +This extension auto-enables SSL support in native mode. Hence you do not need to add +`quarkus.ssl.native=true` to your `application.properties` yourself. See also +https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide]. diff --git a/docs/modules/ROOT/partials/reference/components/solr.adoc b/docs/modules/ROOT/partials/reference/components/solr.adoc index bb1dc1b..b89e814 100644 --- a/docs/modules/ROOT/partials/reference/components/solr.adoc +++ b/docs/modules/ROOT/partials/reference/components/solr.adoc @@ -2,11 +2,11 @@ // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page :cq-artifact-id: camel-quarkus-solr :cq-artifact-id-base: solr -:cq-native-supported: false -:cq-status: Preview +:cq-native-supported: true +:cq-status: Stable :cq-deprecated: false :cq-jvm-since: 1.1.0 -:cq-native-since: n/a +:cq-native-since: 1.5.0 :cq-camel-part-name: solr :cq-camel-part-title: Solr :cq-camel-part-description: Perform operations against Apache Lucene Solr. diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index dbb2244..4eef5cb 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -119,7 +119,6 @@ <module>sip</module> <module>smpp</module> <module>snmp</module> - <module>solr</module> <module>soroush</module> <module>spark</module> <module>splunk</module> diff --git a/extensions-jvm/solr/integration-test/pom.xml b/extensions-jvm/solr/integration-test/pom.xml deleted file mode 100644 index 700792a..0000000 --- a/extensions-jvm/solr/integration-test/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-build-parent-it</artifactId> - <version>1.5.0-SNAPSHOT</version> - <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> - </parent> - - <artifactId>camel-quarkus-solr-integration-test</artifactId> - <name>Camel Quarkus :: Solr :: Integration Test</name> - <description>Integration tests for Camel Quarkus Solr extension</description> - - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom-test</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-solr</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> - - <!-- test dependencies --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-junit5</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>io.rest-assured</groupId> - <artifactId>rest-assured</artifactId> - <scope>test</scope> - </dependency> - - <!-- The following dependencies guarantee that this module is built after them. You can update them by runing `mvn process-resources -Pformat -N` from the source tree root directory --> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-solr-deployment</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - -</project> diff --git a/extensions-jvm/solr/integration-test/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrResource.java b/extensions-jvm/solr/integration-test/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrResource.java deleted file mode 100644 index e03d6e3..0000000 --- a/extensions-jvm/solr/integration-test/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrResource.java +++ /dev/null @@ -1,77 +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.quarkus.component.solr.it; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.camel.CamelContext; -import org.jboss.logging.Logger; - -@Path("/solr") -@ApplicationScoped -public class SolrResource { - - private static final Logger LOG = Logger.getLogger(SolrResource.class); - - private static final String COMPONENT_SOLR = "solr"; - private static final String COMPONENT_SOLRCLOUD = "solrCloud"; - private static final String COMPONENT_SOLRS = "solrs"; - @Inject - CamelContext context; - - @Path("/load/component/solr") - @GET - @Produces(MediaType.TEXT_PLAIN) - public Response loadComponentSolr() throws Exception { - /* This is an autogenerated test */ - if (context.getComponent(COMPONENT_SOLR) != null) { - return Response.ok().build(); - } - LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_SOLR); - return Response.status(500, COMPONENT_SOLR + " could not be loaded from the Camel context").build(); - } - - @Path("/load/component/solrcloud") - @GET - @Produces(MediaType.TEXT_PLAIN) - public Response loadComponentSolrCloud() throws Exception { - /* This is an autogenerated test */ - if (context.getComponent(COMPONENT_SOLRCLOUD) != null) { - return Response.ok().build(); - } - LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_SOLRCLOUD); - return Response.status(500, COMPONENT_SOLRCLOUD + " could not be loaded from the Camel context").build(); - } - - @Path("/load/component/solrs") - @GET - @Produces(MediaType.TEXT_PLAIN) - public Response loadComponentSolrs() throws Exception { - /* This is an autogenerated test */ - if (context.getComponent(COMPONENT_SOLRS) != null) { - return Response.ok().build(); - } - LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_SOLRS); - return Response.status(500, COMPONENT_SOLRS + " could not be loaded from the Camel context").build(); - } -} diff --git a/extensions/pom.xml b/extensions/pom.xml index 9728c0f..c853c44 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -194,6 +194,7 @@ <module>smallrye-reactive-messaging</module> <module>snakeyaml</module> <module>soap</module> + <module>solr</module> <module>sql</module> <module>ssh</module> <module>stream</module> diff --git a/extensions-jvm/solr/deployment/pom.xml b/extensions/solr/deployment/pom.xml similarity index 82% rename from extensions-jvm/solr/deployment/pom.xml rename to extensions/solr/deployment/pom.xml index 5a568c2..0fbb986 100644 --- a/extensions-jvm/solr/deployment/pom.xml +++ b/extensions/solr/deployment/pom.xml @@ -38,6 +38,18 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-solr</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-httpclient-deployment</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-netty-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-commons-logging-deployment</artifactId> + </dependency> </dependencies> <build> diff --git a/extensions-jvm/solr/deployment/src/main/java/org/apache/camel/quarkus/component/solr/deployment/SolrProcessor.java b/extensions/solr/deployment/src/main/java/org/apache/camel/quarkus/component/solr/deployment/SolrProcessor.java similarity index 68% rename from extensions-jvm/solr/deployment/src/main/java/org/apache/camel/quarkus/component/solr/deployment/SolrProcessor.java rename to extensions/solr/deployment/src/main/java/org/apache/camel/quarkus/component/solr/deployment/SolrProcessor.java index b8561d0..403ee2e 100644 --- a/extensions-jvm/solr/deployment/src/main/java/org/apache/camel/quarkus/component/solr/deployment/SolrProcessor.java +++ b/extensions/solr/deployment/src/main/java/org/apache/camel/quarkus/component/solr/deployment/SolrProcessor.java @@ -17,11 +17,8 @@ package org.apache.camel.quarkus.component.solr.deployment; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.ExecutionTime; -import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.pkg.steps.NativeBuild; -import org.apache.camel.quarkus.core.JvmOnlyRecorder; import org.jboss.logging.Logger; class SolrProcessor { @@ -34,13 +31,8 @@ class SolrProcessor { return new FeatureBuildItem(FEATURE); } - /** - * Remove this once this extension starts supporting the native mode. - */ - @BuildStep(onlyIf = NativeBuild.class) - @Record(value = ExecutionTime.RUNTIME_INIT) - void warnJvmInNative(JvmOnlyRecorder recorder) { - JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time - recorder.warnJvmInNative(FEATURE); // warn at runtime + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(FEATURE); } } diff --git a/extensions-jvm/solr/pom.xml b/extensions/solr/pom.xml similarity index 97% rename from extensions-jvm/solr/pom.xml rename to extensions/solr/pom.xml index 2a65894..9d75df8 100644 --- a/extensions-jvm/solr/pom.xml +++ b/extensions/solr/pom.xml @@ -33,6 +33,5 @@ <modules> <module>deployment</module> <module>runtime</module> - <module>integration-test</module> </modules> </project> diff --git a/extensions-jvm/solr/runtime/pom.xml b/extensions/solr/runtime/pom.xml similarity index 88% rename from extensions-jvm/solr/runtime/pom.xml rename to extensions/solr/runtime/pom.xml index 7386066..d783281 100644 --- a/extensions-jvm/solr/runtime/pom.xml +++ b/extensions/solr/runtime/pom.xml @@ -32,6 +32,7 @@ <properties> <camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>1.5.0</camel.quarkus.nativeSince> </properties> <dependencyManagement> @@ -55,6 +56,18 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-solr</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-httpclient</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-netty</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-commons-logging</artifactId> + </dependency> </dependencies> <build> diff --git a/extensions-jvm/solr/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/solr/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 97% rename from extensions-jvm/solr/runtime/src/main/resources/META-INF/quarkus-extension.yaml rename to extensions/solr/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 9091cce..470b36b 100644 --- a/extensions-jvm/solr/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/solr/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -24,9 +24,8 @@ name: "Camel Solr" description: "Perform operations against Apache Lucene Solr" metadata: - unlisted: true guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/solr.html" categories: - "integration" status: - - "preview" + - "stable" diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index a508405..c5ce2ed 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -163,6 +163,7 @@ <module>slack</module> <module>smallrye-reactive-messaging</module> <module>soap</module> + <module>solr</module> <module>sql</module> <module>ssh</module> <module>stringtemplate</module> diff --git a/integration-tests/solr/pom.xml b/integration-tests/solr/pom.xml new file mode 100644 index 0000000..ad090a9 --- /dev/null +++ b/integration-tests/solr/pom.xml @@ -0,0 +1,167 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests</artifactId> + <version>1.5.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-quarkus-integration-test-solr</artifactId> + <name>Camel Quarkus :: Integration Tests :: Solr</name> + <description>Integration tests for Camel Quarkus Solr extension</description> + + <properties> + <solr.trust-store>${project.basedir}/src/test/resources/ssl/solr-ssl.keystore.jks</solr.trust-store> + <solr.trust-store-password>secret</solr.trust-store-password> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-test</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jackson-deployment</artifactId> + <version>${quarkus.version}</version> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson-deployment</artifactId> + <version>${quarkus.version}</version> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-solr</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-testcontainers-support</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>solr</artifactId> + <scope>test</scope> + </dependency> + <!-- this dependency is added so that all artifacts quarkus-resteasy-jackson-deployment and quarkus-jackson-deployment are downloaded before tests, otherwise it will fail after setting the javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword properties --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jackson-deployment</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson-deployment</artifactId> + </dependency> + + <!-- The following dependencies guarantee that this module is built after them. You can update them by runing `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-solr-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <javax.net.ssl.trustStore>${solr.trust-store}</javax.net.ssl.trustStore> + <javax.net.ssl.trustStorePassword>${solr.trust-store-password}</javax.net.ssl.trustStorePassword> + </systemPropertyVariables> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + <quarkus.native.additional-build-args>-H:IncludeResources=.*ssl/.*,-J-Djavax.net.ssl.trustStore=${solr.trust-store}, + -J-Djavax.net.ssl.trustStorePassword=${solr.trust-store-password}</quarkus.native.additional-build-args> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + + </profiles> + +</project> diff --git a/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrCloudResource.java b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrCloudResource.java new file mode 100644 index 0000000..4509ab0 --- /dev/null +++ b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrCloudResource.java @@ -0,0 +1,43 @@ +/* + * 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.quarkus.component.solr.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import io.quarkus.runtime.StartupEvent; +import org.apache.solr.client.solrj.impl.HttpSolrClient; +import org.eclipse.microprofile.config.inject.ConfigProperty; + +@ApplicationScoped +@Path("/solr/cloud") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class SolrCloudResource extends SolrCommonResource { + + @ConfigProperty(name = "solr.cloud.url", defaultValue = "localhost:8981/solr/collection1") + String solrUrl; + + public void init(@Observes StartupEvent startupEvent) { + solrComponentURI = String.format("solrCloud://%s", solrUrl); + solrClient = new HttpSolrClient.Builder(String.format("http://%s", solrUrl)).build(); + } +} diff --git a/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrCommonResource.java b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrCommonResource.java new file mode 100644 index 0000000..ef4a1b0 --- /dev/null +++ b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrCommonResource.java @@ -0,0 +1,176 @@ +/* + * 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.quarkus.component.solr.it; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +import io.quarkus.runtime.StartupEvent; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.solr.SolrConstants; +import org.apache.camel.quarkus.component.solr.it.bean.Item; +import org.apache.solr.client.solrj.SolrQuery; +import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.client.solrj.impl.HttpSolrClient; +import org.apache.solr.client.solrj.request.QueryRequest; +import org.apache.solr.client.solrj.response.QueryResponse; +import org.apache.solr.client.solrj.util.ClientUtils; +import org.apache.solr.common.SolrInputDocument; + +public abstract class SolrCommonResource { + + @Inject + ProducerTemplate producerTemplate; + + /** + * solr camel component URI + */ + String solrComponentURI; + + /** + * used to check data + */ + HttpSolrClient solrClient; + + /** + * inits the params solrComponentURI and solrClient + * + * @param startupEvent + */ + public abstract void init(StartupEvent startupEvent); + + @PUT + @Path("bean") + public Response addBean(Item bean) { + producerTemplate.sendBodyAndHeader(solrComponentURI, bean, SolrConstants.OPERATION, SolrConstants.OPERATION_ADD_BEAN); + solrCommit(); + return Response.accepted().build(); + } + + @PUT + @Path("beans") + public Response addBeans(List<Item> beans) { + producerTemplate.sendBodyAndHeader(solrComponentURI, beans, SolrConstants.OPERATION, SolrConstants.OPERATION_ADD_BEANS); + solrCommit(); + return Response.accepted().build(); + } + + @DELETE + @Path("bean") + public Response deleteBeanById(String id) { + producerTemplate.sendBodyAndHeader(solrComponentURI, id, SolrConstants.OPERATION, SolrConstants.OPERATION_DELETE_BY_ID); + solrCommit(); + return Response.accepted().build(); + } + + @DELETE + @Path("beans") + public Response deleteByIdPrefix(String idPrefix) { + producerTemplate.sendBodyAndHeader(solrComponentURI, String.format("id:%s*", idPrefix), SolrConstants.OPERATION, + SolrConstants.OPERATION_DELETE_BY_QUERY); + solrCommit(); + return Response.accepted().build(); + } + + @PUT + @Path("document/commit") + public Response insertAndCommit(Map<String, Object> fields) { + solrInsert(fields); + solrCommit(); + return Response.accepted().build(); + } + + @PUT + @Path("document") + public Response insertDocument(Map<String, Object> fields) { + solrInsert(fields); + return Response.accepted().build(); + } + + private void solrInsert(Map<String, Object> fields) { + String docAsXml = createDocument(fields); + producerTemplate.sendBodyAndHeader(solrComponentURI, docAsXml, SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT); + } + + private String createDocument(Map<String, Object> fields) { + SolrInputDocument doc = new SolrInputDocument(); + fields.forEach((key, value) -> doc.addField(key, value)); + return ClientUtils.toXML(doc); + } + + @GET + @Path("optimize") + public Response optimize() { + producerTemplate.sendBodyAndHeader(solrComponentURI, null, SolrConstants.OPERATION, SolrConstants.OPERATION_OPTIMIZE); + return Response.accepted().build(); + } + + @GET + @Path("rollback") + public Response rollback() { + producerTemplate.sendBodyAndHeader(solrComponentURI, null, SolrConstants.OPERATION, SolrConstants.OPERATION_ROLLBACK); + return Response.accepted().build(); + } + + @GET + @Path("commit") + public Response commit() { + solrCommit(); + return Response.accepted().build(); + } + + @GET + @Path("softcommit") + public Response softcommit() { + producerTemplate.sendBodyAndHeader(solrComponentURI, null, SolrConstants.OPERATION, + SolrConstants.OPERATION_SOFT_COMMIT); + return Response.accepted().build(); + } + + @PUT + @Path("streaming") + public Response insertStreaming(Map<String, Object> fields) { + String docAsXml = createDocument(fields); + producerTemplate.sendBodyAndHeader(solrComponentURI, docAsXml, SolrConstants.OPERATION, + SolrConstants.OPERATION_INSERT_STREAMING); + return Response.accepted().build(); + } + + private void solrCommit() { + producerTemplate.sendBodyAndHeader(solrComponentURI, null, SolrConstants.OPERATION, SolrConstants.OPERATION_COMMIT); + } + + @GET + @Path("bean/{id}") + public Item getBeanById(@PathParam("id") String id) throws IOException, SolrServerException { + SolrQuery solrQuery = new SolrQuery(); + solrQuery.set("q", "id:" + id); + QueryRequest queryRequest = new QueryRequest(solrQuery); + QueryResponse response = queryRequest.process(solrClient); + List<Item> responses = response.getBeans(Item.class); + return responses.size() != 0 ? responses.get(0) : new Item(); + } +} diff --git a/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrSslResource.java b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrSslResource.java new file mode 100644 index 0000000..b85721a --- /dev/null +++ b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrSslResource.java @@ -0,0 +1,43 @@ +/* + * 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.quarkus.component.solr.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import io.quarkus.runtime.StartupEvent; +import org.apache.solr.client.solrj.impl.HttpSolrClient; +import org.eclipse.microprofile.config.inject.ConfigProperty; + +@Path("/solr/ssl") +@ApplicationScoped +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class SolrSslResource extends SolrCommonResource { + @ConfigProperty(name = "solr.ssl.url", defaultValue = "localhost:8984/solr/collection1") + String solrUrl; + + public void init(@Observes StartupEvent startupEvent) { + solrComponentURI = String.format("solrs://%s", solrUrl); + solrClient = new HttpSolrClient.Builder(String.format("https://%s", solrUrl)).build(); + } + +} diff --git a/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrStandaloneResource.java b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrStandaloneResource.java new file mode 100644 index 0000000..a615c19 --- /dev/null +++ b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/SolrStandaloneResource.java @@ -0,0 +1,42 @@ +/* + * 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.quarkus.component.solr.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import io.quarkus.runtime.StartupEvent; +import org.apache.solr.client.solrj.impl.HttpSolrClient; +import org.eclipse.microprofile.config.inject.ConfigProperty; + +@Path("/solr/standalone") +@ApplicationScoped +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class SolrStandaloneResource extends SolrCommonResource { + @ConfigProperty(name = "solr.standalone.url", defaultValue = "localhost:8983/solr/collection1") + String solrUrl; + + public void init(@Observes StartupEvent startupEvent) { + solrComponentURI = String.format("solr://%s", solrUrl); + solrClient = new HttpSolrClient.Builder(String.format("http://%s", solrUrl)).build(); + } +} diff --git a/extensions-jvm/solr/integration-test/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/bean/Item.java similarity index 50% copy from extensions-jvm/solr/integration-test/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java copy to integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/bean/Item.java index ba90279..80103cb 100644 --- a/extensions-jvm/solr/integration-test/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java +++ b/integration-tests/solr/src/main/java/org/apache/camel/quarkus/component/solr/it/bean/Item.java @@ -14,37 +14,34 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.solr.it; +package org.apache.camel.quarkus.component.solr.it.bean; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; +import org.apache.solr.client.solrj.beans.Field; -@QuarkusTest -class SolrTest { +public class Item { - @Test - public void loadComponentSolr() { - /* A simple autogenerated test */ - RestAssured.get("/solr/load/component/solr") - .then() - .statusCode(200); + @Field + String id; + + @Field("cat") + String[] categories; + + public Item() { } - @Test - public void loadComponentSolrCloud() { - /* A simple autogenerated test */ - RestAssured.get("/solr/load/component/solrcloud") - .then() - .statusCode(200); + public String getId() { + return id; } - @Test - public void loadComponentSolrs() { - /* A simple autogenerated test */ - RestAssured.get("/solr/load/component/solrs") - .then() - .statusCode(200); + public void setId(String id) { + this.id = id; } + public String[] getCategories() { + return categories; + } + + public void setCategories(String[] categories) { + this.categories = categories; + } } diff --git a/extensions-jvm/solr/integration-test/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java b/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrIT.java similarity index 52% rename from extensions-jvm/solr/integration-test/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java rename to integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrIT.java index ba90279..854dbd8 100644 --- a/extensions-jvm/solr/integration-test/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java +++ b/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrIT.java @@ -16,35 +16,8 @@ */ package org.apache.camel.quarkus.component.solr.it; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; - -@QuarkusTest -class SolrTest { - - @Test - public void loadComponentSolr() { - /* A simple autogenerated test */ - RestAssured.get("/solr/load/component/solr") - .then() - .statusCode(200); - } - - @Test - public void loadComponentSolrCloud() { - /* A simple autogenerated test */ - RestAssured.get("/solr/load/component/solrcloud") - .then() - .statusCode(200); - } - - @Test - public void loadComponentSolrs() { - /* A simple autogenerated test */ - RestAssured.get("/solr/load/component/solrs") - .then() - .statusCode(200); - } +import io.quarkus.test.junit.NativeImageTest; +@NativeImageTest +public class SolrIT extends SolrTest { } diff --git a/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java b/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java new file mode 100644 index 0000000..e267eea --- /dev/null +++ b/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTest.java @@ -0,0 +1,272 @@ +/* + * 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.quarkus.component.solr.it; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.http.ContentType; +import org.apache.camel.quarkus.component.solr.it.bean.Item; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.emptyOrNullString; +import static org.hamcrest.Matchers.equalTo; + +@QuarkusTest +@QuarkusTestResource(SolrTestResource.class) +public class SolrTest { + /** + * Quarkus resources to test + * + * @return + */ + private static Stream<String> resources() { + return Stream.of("/solr/standalone", "/solr/ssl", "/solr/cloud"); + } + + @ParameterizedTest + @MethodSource("resources") + public void testSingleBean(String resource) { + // create a bean item + Item item = createItem("test1"); + given() + .contentType(ContentType.JSON) + .body(item) + .put(resource + "/bean") + .then() + .statusCode(202); + // verify existing bean + given() + .get(resource + "/bean/test1") + .then() + .body("id", equalTo("test1")); + + // delete bean by id + given() + .contentType(ContentType.JSON) + .body("test1") + .delete(resource + "/bean") + .then() + .statusCode(202); + // verify non existing bean + given() + .get(resource + "/bean/test1") + .then() + .body("id", emptyOrNullString()); + } + + @ParameterizedTest + @MethodSource("resources") + public void testMultipleBeans(String resource) { + // create list of beans + List<Item> beans = new ArrayList<>(); + beans.add(createItem("bean1")); + beans.add(createItem("bean2")); + + // add beans with camel + given() + .contentType(ContentType.JSON) + .body(beans) + .put(resource + "/beans") + .then() + .statusCode(202); + + // verify existing beans + given() + .get(resource + "/bean/bean1") + .then() + .body("id", equalTo("bean1")); + given() + .get(resource + "/bean/bean2") + .then() + .body("id", equalTo("bean2")); + + // delete all beans that has id begins with bean + given() + .contentType(ContentType.JSON) + .body("bean") + .delete(resource + "/beans") + .then() + .statusCode(202); + + // verify non existing beans + given() + .get(resource + "/bean/bean1") + .then() + .body("id", emptyOrNullString()); + given() + .get(resource + "/bean/bean2") + .then() + .body("id", emptyOrNullString()); + } + + @ParameterizedTest + @MethodSource("resources") + public void testInsertId(String resource) { + Map<String, Object> fields = new HashMap<>(); + fields.put("id", "id1"); + + //insert and commit document + given() + .contentType(ContentType.JSON) + .body(fields) + .put(resource + "/document/commit") + .then() + .statusCode(202); + + // verify existing document + given() + .get(resource + "/bean/id1") + .then() + .body("id", equalTo("id1")); + + } + + @ParameterizedTest + @MethodSource("resources") + public void testOptimize(String resource) { + Map<String, Object> fields = new HashMap<>(); + fields.put("id", "opt1"); + // insert without commit + given() + .contentType(ContentType.JSON) + .body(fields) + .put(resource + "/document") + .then() + .statusCode(202); + // verify non existing document + given() + .get(resource + "/bean/opt1") + .then() + .body("id", emptyOrNullString()); + // optimize + given() + .get(resource + "/optimize") + .then() + .statusCode(202); + // verify existing document + given() + .get(resource + "/bean/opt1") + .then() + .body("id", equalTo("opt1")); + + } + + // Rollback is currently not supported in SolrCloud mode (SOLR-4895). So limiting this test to standalone and standalone with SSL modes + @ParameterizedTest + @ValueSource(strings = { "/solr/standalone", "/solr/ssl" }) + public void testRollback(String resource) { + Map<String, Object> fields = new HashMap<>(); + fields.put("id", "roll1"); + // insert without commit + given() + .contentType(ContentType.JSON) + .body(fields) + .put(resource + "/document") + .then() + .statusCode(202); + // verify non existing document + given() + .get(resource + "/bean/roll1") + .then() + .body("id", emptyOrNullString()); + // rollback + given() + .get(resource + "/rollback") + .then() + .statusCode(202); + //then commit + given() + .get(resource + "/commit") + .then() + .statusCode(202); + // verify non existing document + given() + .get(resource + "/bean/roll1") + .then() + .body("id", emptyOrNullString()); + } + + @ParameterizedTest + @MethodSource("resources") + public void testSoftCommit(String resource) { + Map<String, Object> fields = new HashMap<>(); + fields.put("id", "com1"); + // insert without commit + given() + .contentType(ContentType.JSON) + .body(fields) + .put(resource + "/document") + .then() + .statusCode(202); + // verify non existing document + given() + .get(resource + "/bean/com1") + .then() + .body("id", emptyOrNullString()); + // soft commit + given() + .get(resource + "/softcommit") + .then() + .statusCode(202); + // verify existing document + given() + .get(resource + "/bean/com1") + .then() + .body("id", equalTo("com1")); + } + + @ParameterizedTest + @MethodSource("resources") + public void testInsertStreaming(String resource) throws InterruptedException { + Map<String, Object> fields = new HashMap<>(); + fields.put("id", "stream1"); + // insert with streaming mode + given() + .contentType(ContentType.JSON) + .body(fields) + .put(resource + "/streaming") + .then() + .statusCode(202); + // wait before commit + Thread.sleep(500); + given() + .get(resource + "/commit") + .then() + .statusCode(202); + // verify existing document + given() + .get(resource + "/bean/stream1") + .then() + .body("id", equalTo("stream1")); + } + + private Item createItem(String id) { + Item item = new Item(); + item.setId(id); + item.setCategories(new String[] { "aaa", "bbb", "ccc" }); + return item; + } +} diff --git a/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTestResource.java b/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTestResource.java new file mode 100644 index 0000000..7fef3cc --- /dev/null +++ b/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTestResource.java @@ -0,0 +1,120 @@ +/* + * 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.quarkus.component.solr.it; + +import java.util.Map; + +import org.apache.camel.quarkus.testcontainers.ContainerResourceLifecycleManager; +import org.apache.camel.util.CollectionHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.BindMode; +import org.testcontainers.containers.SolrContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.utility.DockerImageName; + +public class SolrTestResource implements ContainerResourceLifecycleManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(SolrTestResource.class); + + private static final DockerImageName SOLR_IMAGE = DockerImageName.parse("solr:8.7.0"); + private static final String COLLECTION_NAME = "collection1"; + private static final String URL_FORMAT = "localhost:%s/solr/collection1"; + + private SolrContainer standaloneContainer; + private SolrContainer sslContainer; + private SolrContainer cloudContainer; + + @Override + public Map<String, String> start() { + // creates 3 containers for 3 different modes of using SOLR + createContainers(); + // start containers + startContainers(standaloneContainer, sslContainer, cloudContainer); + // return custom URLs + return CollectionHelper.mapOf("solr.standalone.url", String.format(URL_FORMAT, standaloneContainer.getSolrPort()), + "solr.ssl.url", String.format(URL_FORMAT, sslContainer.getSolrPort()), + "solr.cloud.url", String.format(URL_FORMAT, cloudContainer.getSolrPort())); + } + + private void createContainers() { + createStandaloneContainer(); + createSslContainer(); + createCloudContainer(); + } + + private void startContainers(SolrContainer... containers) { + for (SolrContainer container : containers) { + container.start(); + } + } + + /** + * creates a standalone container + */ + private void createStandaloneContainer() { + standaloneContainer = new SolrContainer(SOLR_IMAGE) + .withCollection(COLLECTION_NAME) + .withZookeeper(false) + .withLogConsumer(new Slf4jLogConsumer(LOGGER)); + } + + /** + * creates a standalone container with SSL + */ + private void createSslContainer() { + sslContainer = new SolrContainer(SOLR_IMAGE) + .withCollection(COLLECTION_NAME) + .withZookeeper(false) + .withClasspathResourceMapping("ssl", "/ssl", BindMode.READ_ONLY) + .withEnv("SOLR_SSL_ENABLED", "true") + .withEnv("SOLR_SSL_KEY_STORE", "/ssl/solr-ssl.keystore.jks") + .withEnv("SOLR_SSL_KEY_STORE_PASSWORD", "secret") + .withEnv("SOLR_SSL_TRUST_STORE", "/ssl/solr-ssl.keystore.jks") + .withEnv("SOLR_SSL_TRUST_STORE_PASSWORD", "secret") + .withEnv("SOLR_SSL_NEED_CLIENT_AUTH", "false") + .withEnv("SOLR_SSL_WANT_CLIENT_AUTH", "false") + .withEnv("SOLR_SSL_CHECK_PEER_NAME", "true") + .withEnv("SOLR_SSL_KEY_STORE_TYPE", "JKS") + .withEnv("SOLR_SSL_TRUST_STORE_TYPE", "JKS") + .withLogConsumer(new Slf4jLogConsumer(LOGGER)); + + } + + /** + * creates a cloud container with zookeeper + */ + private void createCloudContainer() { + cloudContainer = new SolrContainer(SOLR_IMAGE) + .withZookeeper(true) + .withCollection(COLLECTION_NAME) + .withLogConsumer(new Slf4jLogConsumer(LOGGER)); + } + + @Override + public void stop() { + stopContainers(standaloneContainer, sslContainer, cloudContainer); + } + + private void stopContainers(SolrContainer... containers) { + for (SolrContainer container : containers) { + if (container != null) { + container.stop(); + } + } + } +} diff --git a/integration-tests/solr/src/test/resources/ssl/solr-ssl.keystore.jks b/integration-tests/solr/src/test/resources/ssl/solr-ssl.keystore.jks new file mode 100644 index 0000000..2cbbee5 Binary files /dev/null and b/integration-tests/solr/src/test/resources/ssl/solr-ssl.keystore.jks differ diff --git a/integration-tests/solr/src/test/resources/ssl/solr-ssl.keystore.p12 b/integration-tests/solr/src/test/resources/ssl/solr-ssl.keystore.p12 new file mode 100644 index 0000000..f83bff9 Binary files /dev/null and b/integration-tests/solr/src/test/resources/ssl/solr-ssl.keystore.p12 differ diff --git a/integration-tests/solr/src/test/resources/ssl/solr-ssl.pem b/integration-tests/solr/src/test/resources/ssl/solr-ssl.pem new file mode 100644 index 0000000..404b5a3 --- /dev/null +++ b/integration-tests/solr/src/test/resources/ssl/solr-ssl.pem @@ -0,0 +1,63 @@ +Bag Attributes + friendlyName: solr-ssl + localKeyID: 54 69 6D 65 20 31 36 30 35 37 30 37 38 34 34 38 32 36 +Key Attributes: <No Attributes> +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQI8hUTfU2CykECAggA +MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECIheXQFdGg7wBIIEyNjpbmVwwtyk ++R5nKN/Ln1VvtGV70j6gYEw8z2Ovk1Dt1a2Ppxmd1rPJtaIJ8GiOaYJWSA1ASDXg +mYWXqP4jaqGEzCs3yGpLL/EjmfOVQTN2ffoPQJ10NRFqm7RH/D1YLu3J4SfPOaEz +vBF8h6OrgDWSYf+QstDU3vdeYSqLjZ7Q/2mnSoiwz33VV21+Qo50+b2ewAb/p8LE +1U1M1rs/nZI5iJEjIJ26WawY6Pdi6XKWV4tbG/X0P4sTZIfVZv7tePd+qSj9vKOb +qp34NuC1pWwFzk0PIcLQp0Cs+ikb0jDnfuDwv/1u3XPpzRql2QkH5u6SaXPnLXRK +2tPNA7oEw6YGIfeGea02jw6ZKB0m1ieKJaXQx0OXiEk4iZV10+aA/fx6ToW3aVri +GBN1FvoZ/ZLNKq6/XvDS3GaKo37GmunNjk8bQsu2B3WhD1TcLwtIUo0wIhHzIFnh +3Y1qBDX5m2sidyoDoDYC14Ric9N5cmE+NDehy4nU92hsMfp5gtm9BnK4+7PqMWFz +gMuKOD6SbZvU6bR17VQNM4RkajtJHMlhpDxE+CDWVrz872GYJT7FyM8mfMbLPwCc +TSITWIIJ2auCBtd6um1NBpzh4JEokjr/WfzWLwiXEA0JcCwMVOI5QJN9JlRGIqgr +NbhY+12ll3lkAKI8TJbdtNacK9LurUJDvDhx4ZC0Zz2GPB8n2isuQyu+iZgzStaU +ssD8J7EDuHO22Wos1IGv8Y2EtVadHyfMhIRvrm+C7a/sOu2bVutkUjvvemg+ztnr +5CIffgE4zK2iSLOyLxx3aE4kYPC0oRqYwhbTNlbWsVJJUGw9x7qAgmlnIMrh3CcE +9yFtnrhD2K4geceHbd5jLD5HlPIFuJZwtwDhjIei1iJ3LUCzlya/nv0EDEZyi/6f +J5vtUPpPMai07EWI0WI42Ax2XosSCgKB4+0IL7Pxs4pDBD6AvwsRSd9LhdzrXRhz +hwuvHwlCan0c6tF0WNq8T+GSz8vUnZIf1pX9NzskNv31mbVmovfTjKmSLS1xX81x +nhlCnbKTKaw7mvLVLJ2c3UUCu8ZYa9qUvEzxmWTjIIN8dWbzu1MXEn4s6WUNZaEr ++7lQoE/7DJ7oS0D6piOCbV6pTrbIS/Tfyu7LenWIlXOI8GD2YN21K7hIR/5XbGyU +RRuEJbkunUeJvKS+Mvkk43VF6xGga/ChbQ32t2GX6lj8bOfdpXkKdGbPm8kB+LtY +dwc+UfJqIzHP5OtcqzmL9HvcjpEGJF1WgBgfwowD3kYsCZq1N6MCTCm2WEDz7Q5Y +ylsi/sFMyoiNUtXIj+T2w9HfM82NOAzAHGGZVAhVPtHtfU/m5Yo8rFMkdmbwxeJZ +NwVoWOyJzefCMNXMosHxOCTef7FB24UGa+vi+e7WC6mLVny1FjTxCpxkb8Bw3+e1 +OHetZZisp0PK8gQGA4XiyMaAOKCpKGNoIYPwaNzB0S6qB9OM4ohyiBiOYglnQtv8 +JrLWJVjV2mBZRREfjc+Ik9iKGFbF95xAKvW66T3zBpJQjkjPQ6exsQKv3tGaL9mX +VW5ySdJ9IXAm5tiqfakE2BYvozsyGRD5m+Z1v71zA9ovY1utlIf0iBuSnQvgxcTp +KJyiBtXkAPrRLz1tD3wrXA== +-----END ENCRYPTED PRIVATE KEY----- +Bag Attributes + friendlyName: solr-ssl + localKeyID: 54 69 6D 65 20 31 36 30 35 37 30 37 38 34 34 38 32 36 +subject=C = Country, ST = State, L = Location, O = Organization, OU = Organizational Unit, CN = localhost + +issuer=C = Country, ST = State, L = Location, O = Organization, OU = Organizational Unit, CN = localhost + +-----BEGIN CERTIFICATE----- +MIIDtzCCAp+gAwIBAgIEM3jJlzANBgkqhkiG9w0BAQsFADB+MRAwDgYDVQQGEwdD +b3VudHJ5MQ4wDAYDVQQIEwVTdGF0ZTERMA8GA1UEBxMITG9jYXRpb24xFTATBgNV +BAoTDE9yZ2FuaXphdGlvbjEcMBoGA1UECxMTT3JnYW5pemF0aW9uYWwgVW5pdDES +MBAGA1UEAxMJbG9jYWxob3N0MB4XDTIwMTExODEzNTcxMFoXDTQ4MDQwNDEzNTcx +MFowfjEQMA4GA1UEBhMHQ291bnRyeTEOMAwGA1UECBMFU3RhdGUxETAPBgNVBAcT +CExvY2F0aW9uMRUwEwYDVQQKEwxPcmdhbml6YXRpb24xHDAaBgNVBAsTE09yZ2Fu +aXphdGlvbmFsIFVuaXQxEjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBAOwmcDqlyOwC8vv3j7NrC1Y24sBmgAyfuLy0Y4KF +yakZIVJQSWLm2NyjmK3a3ZN2gjsv8dcLdg+8KJvvwUDhMxMeS+xXS4UjHX27crL2 +AouKI/ueAC+thhfvdPIgR/opnrLXueK6kRgLiHOq4Ao18QJ0VCYhpfQx73ZXAMPN +g4XdktmdZURCx96noYB6oG5SQ/SL2LT+g5GDPbJHGDIvMSe6j1no5Sqn11Q46Azf +DZfhP6+OzT7zWOGCvi/Tn7qPQ6hX27esin93zlKA9fY/hIbq2o5u6ARS0SV3xNhd +8MlHC7s4ML0SD7ecZMbK6Xb4ECFvVkiNa0SScEpJ21eEL5sCAwEAAaM9MDswHQYD +VR0OBBYEFBNQ3LdaHZHA44JakfiUWV9pm7RbMBoGA1UdEQQTMBGCCWxvY2FsaG9z +dIcEfwAAATANBgkqhkiG9w0BAQsFAAOCAQEAHTGU1JEjwDOongGlRC+e+zJVLymJ +6x+npvmrIwjpGL/FoSfEtk8UH4TU02hzXPrq+mKlYIXVgvh2Ip7LSPSBNH1dPksi +qhKXxNsnqdED9svQ8wjoIC/4PNJ1+cRUwOeC5rmEZlJaBmL7qgAmf/UsgPs5/zM9 +a+OEOyCoiA+I8hQYBhrbeDoJGhLsIxePMQVTPjoKHk10j+o7h7MpOmeCe4Sy3pT4 +yN+Z3esa9wlJoRiJVqlYoYq2ZI4NedTWksVu+B2sdNb8jWMT4V6gCF8Se/rNKifr +kR0KR/InP19Ioz6t7IMYFyVDaoUsRK8DmUlTwXiWV+5sCiJZYYUOLGIbTg== +-----END CERTIFICATE----- diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml index eded524..8b970d4 100644 --- a/poms/bom-test/pom.xml +++ b/poms/bom-test/pom.xml @@ -164,6 +164,11 @@ <version>${testcontainers.version}</version> </dependency> <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>solr</artifactId> + <version>${testcontainers.version}</version> + </dependency> + <dependency> <groupId>org.jvnet.mock-javamail</groupId> <artifactId>mock-javamail</artifactId> <version>${mock-javamail.version}</version> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index b95dcec..b39fb92 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1778,6 +1778,12 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-solr</artifactId> <version>${camel.version}</version> + <exclusions> + <exclusion> + <artifactId>commons-logging</artifactId> + <groupId>commons-logging</groupId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.apache.camel</groupId> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 3977600..1c57d37 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -33,6 +33,7 @@ cloud: - grpc - protobuf - smallrye-reactive-messaging + - solr core-main-validation: - core - core-discovery-disabled