aldettinger commented on a change in pull request #2190: URL: https://github.com/apache/camel-quarkus/pull/2190#discussion_r568680713
########## File path: integration-tests/oaipmh/src/test/java/org/apache/camel/quarkus/component/oaipmh/it/OaipmhTestServer.java ########## @@ -0,0 +1,149 @@ +/* + * 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.oaipmh.it; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.IOUtils; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.HttpConfiguration; +import org.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.server.SecureRequestCustomizer; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class OaipmhTestServer { + + private static final Logger LOG = LoggerFactory.getLogger(OaipmhTestServer.class); + private static final String PASSWORD = "changeit"; + private static Map<String, String> RESPONSE_CACHE; + + private String context; + private boolean useHttps; + private int port; + private Server server; + + public OaipmhTestServer(String context, int port) { + this(context, port, false); + } + + public OaipmhTestServer(String context, int port, boolean useHttps) { + this.context = context; + this.useHttps = useHttps; + this.port = port; + } + + private static synchronized Map<String, String> getResponseCache() throws IOException { + if (RESPONSE_CACHE == null) { + HashMap<String, String> responseCache = new HashMap<String, String>(); + + ZipInputStream zis = new ZipInputStream(OaipmhTestServer.class.getResourceAsStream("/data.zip")); + + ZipEntry entry = zis.getNextEntry(); + while (entry != null) { + if (!entry.isDirectory()) { + responseCache.put(entry.getName(), IOUtils.toString(zis, StandardCharsets.UTF_8)); + } + entry = zis.getNextEntry(); + } + RESPONSE_CACHE = Collections.unmodifiableMap(responseCache); + } + return RESPONSE_CACHE; + } + + public void startServer() { + server = new Server(port); + + if (useHttps) { + HttpConfiguration https = new HttpConfiguration(); + https.addCustomizer(new SecureRequestCustomizer()); + SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); + + String keyStorePath = OaipmhTestServer.class.getResource("/jettyKS/localhost.p12").toExternalForm(); + sslContextFactory.setKeyStorePath(keyStorePath); Review comment: I expect this to work on platform too. ########## File path: pom.xml ########## @@ -84,6 +84,7 @@ <java.xml.ws.version>2.3.1</java.xml.ws.version> <jcodings.version>1.0.55</jcodings.version><!-- used by hbase --> <joni.version>2.1.31</joni.version><!-- used by json-validator --> + <jsoup.version>1.12.1</jsoup.version><!-- used by oaipmh --> Review comment: camel-oaipmh brought 1.13.1 in compile scope while quarkus-junit5 brought 1.12.1 in test scope. So I aligned on quarkus version with compile scope. ########## File path: extensions/oaipmh/deployment/src/main/java/org/apache/camel/quarkus/component/oaipmh/deployment/OaipmhProcessor.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.oaipmh.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceDirectoryBuildItem; + +class OaipmhProcessor { + + private static final String FEATURE = "camel-oaipmh"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(FEATURE); + } + + @BuildStep + NativeImageResourceDirectoryBuildItem registerNativeResources() { + return new NativeImageResourceDirectoryBuildItem("org/joda/time/tz/data"); Review comment: Filed https://github.com/apache/camel-quarkus/issues/2191. ########## File path: integration-tests/oaipmh/pom.xml ########## @@ -0,0 +1,200 @@ +<?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.7.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-oaipmh</artifactId> + <name>Camel Quarkus :: Integration Tests :: OAI-PMH</name> + <description>Integration tests for Camel Quarkus OAI-PMH 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>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mock</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-oaipmh</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-xpath</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.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-test-support</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bean-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mock-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> Review comment: I've regenerated that part and it looks cleaner. I don't think the cq-plugin is broken, but maybe I misled it as I have added/removed/changed order of dependencies. ########## File path: integration-tests/oaipmh/src/test/java/org/apache/camel/quarkus/component/oaipmh/it/OaipmhTestServer.java ########## @@ -0,0 +1,149 @@ +/* + * 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.oaipmh.it; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.IOUtils; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.HttpConfiguration; +import org.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.server.SecureRequestCustomizer; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class OaipmhTestServer { + + private static final Logger LOG = LoggerFactory.getLogger(OaipmhTestServer.class); + private static final String PASSWORD = "changeit"; + private static Map<String, String> RESPONSE_CACHE; + + private String context; + private boolean useHttps; + private int port; + private Server server; + + public OaipmhTestServer(String context, int port) { + this(context, port, false); + } + + public OaipmhTestServer(String context, int port, boolean useHttps) { + this.context = context; + this.useHttps = useHttps; + this.port = port; + } + + private static synchronized Map<String, String> getResponseCache() throws IOException { + if (RESPONSE_CACHE == null) { + HashMap<String, String> responseCache = new HashMap<String, String>(); + + ZipInputStream zis = new ZipInputStream(OaipmhTestServer.class.getResourceAsStream("/data.zip")); + + ZipEntry entry = zis.getNextEntry(); + while (entry != null) { + if (!entry.isDirectory()) { + responseCache.put(entry.getName(), IOUtils.toString(zis, StandardCharsets.UTF_8)); + } + entry = zis.getNextEntry(); + } + RESPONSE_CACHE = Collections.unmodifiableMap(responseCache); + } + return RESPONSE_CACHE; + } + + public void startServer() { + server = new Server(port); Review comment: Indeed, let's have a look at this in https://github.com/apache/camel-quarkus/issues/2192 to check if I can achieved to find a solution that is clear and could be applied to main Camel too. To be clear, the idea you mentioned would be to implement a test resource launching a route that consume from camel-http ? ########## File path: integration-tests/oaipmh/src/test/java/org/apache/camel/quarkus/component/oaipmh/it/OaipmhTestServer.java ########## @@ -0,0 +1,149 @@ +/* + * 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.oaipmh.it; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.IOUtils; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.HttpConfiguration; +import org.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.server.SecureRequestCustomizer; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class OaipmhTestServer { + + private static final Logger LOG = LoggerFactory.getLogger(OaipmhTestServer.class); + private static final String PASSWORD = "changeit"; + private static Map<String, String> RESPONSE_CACHE; + + private String context; + private boolean useHttps; + private int port; + private Server server; + + public OaipmhTestServer(String context, int port) { + this(context, port, false); + } + + public OaipmhTestServer(String context, int port, boolean useHttps) { + this.context = context; + this.useHttps = useHttps; + this.port = port; + } + + private static synchronized Map<String, String> getResponseCache() throws IOException { + if (RESPONSE_CACHE == null) { + HashMap<String, String> responseCache = new HashMap<String, String>(); + + ZipInputStream zis = new ZipInputStream(OaipmhTestServer.class.getResourceAsStream("/data.zip")); + + ZipEntry entry = zis.getNextEntry(); + while (entry != null) { + if (!entry.isDirectory()) { + responseCache.put(entry.getName(), IOUtils.toString(zis, StandardCharsets.UTF_8)); + } + entry = zis.getNextEntry(); + } + RESPONSE_CACHE = Collections.unmodifiableMap(responseCache); + } + return RESPONSE_CACHE; + } + + public void startServer() { + server = new Server(port); Review comment: Ok I see, thanks for sharing ideas :+1: ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org