svkcemk commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r942320613
##########
integration-tests/validator/src/main/java/org/apache/camel/quarkus/component/validator/it/ValidatorRouteBuilder.java:
##########
@@ -16,19 +16,47 @@
*/
package org.apache.camel.quarkus.component.validator.it;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+
import org.apache.camel.builder.RouteBuilder;
+import org.eclipse.microprofile.config.ConfigProvider;
public class ValidatorRouteBuilder extends RouteBuilder {
+
@Override
public void configure() {
+ // validator from the classpath resource
from("direct:classpath")
.to("validator:message.xsd");
+ // validator from the filesytem
+ String xsdLocation = createTempXsd("message.xsd");
+
from("direct:filesystem")
- .to("validator:file:src/main/resources/message.xsd");
+ .to("validator:file:" + xsdLocation);
+ // validator from a http endpoint.
+ String serverURL = ConfigProvider.getConfig()
+ .getConfigValue("xsd.server-url")
+ .getRawValue();
from("direct:http")
-
.toD("validator:https://raw.githubusercontent.com/apache/camel-quarkus/main/integration-tests/validator/src/main/resources/message.xsd");
+ .toD("validator:" + serverURL + "/xsd");
}
+
+ public String createTempXsd(String sourceXsd) {
+ try {
+ InputStream resourceAsStream =
Thread.currentThread().getContextClassLoader().getResourceAsStream(sourceXsd);
+ Path tempXsd = Files.createTempFile("temp", ".xsd");
+ Files.copy(resourceAsStream, tempXsd,
StandardCopyOption.REPLACE_EXISTING);
+ return tempXsd.toAbsolutePath().toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
Review Comment:
Thanks @ppalaga added some changes.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]