You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/08/09 13:18:22 UTC

[GitHub] [camel-quarkus] svkcemk opened a new pull request, #3972: Improve/clean-up camel-quarkus-validator extension tests.

svkcemk opened a new pull request, #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972

   <!-- Uncomment and fill this section if your PR is not trivial
   [ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
   [ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
   [ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
   [ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
   -->


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] aldettinger commented on pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
aldettinger commented on PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#issuecomment-1210266627

   @svkcemk It's look good to me. Well done :+1: 
   
   Just one more thing. It's really nice to have separate commits during review. Before merging, it would be good to rebase all commits into a single one in order to help maintaining a clear git history.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] svkcemk commented on pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
svkcemk commented on PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#issuecomment-1210337581

   Thanks @aldettinger I was waiting for your review, now commits are squashed into one single commit.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] svkcemk commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
svkcemk commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r943346881


##########
integration-tests/validator/src/test/java/org/apache/camel/quarkus/component/validator/it/ValidatorTest.java:
##########
@@ -16,84 +16,40 @@
  */
 package org.apache.camel.quarkus.component.validator.it;
 
+import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 @QuarkusTest
+@QuarkusTestResource(ValidatorTestResource.class)
 class ValidatorTest {
 
-    @Test
-    public void validXMLFromClassPath() {
+    @ParameterizedTest
+    @ValueSource(strings = { "classpath", "filesystem", "http" })
+    public void validXML(String scheme) {
 
         RestAssured.given()
                 .contentType(ContentType.XML)
                 .body("<message><firstName>MyFirstname</firstName><lastName>MyLastname</lastName></message>")
-                .post("/validator/classpath")
+                .post("/validator/validate/" + scheme)
                 .then()
                 .statusCode(200);
 
     }
 
-    @Test
-    public void invalidXMLFromClassPath() {
+    @ParameterizedTest
+    @ValueSource(strings = { "classpath", "filesystem", "http" })
+    public void inValidXML(String scheme) {
 
         RestAssured.given()
                 .contentType(ContentType.XML)
                 .body("<message><firstName>MyFirstname</firstName></message>")
-                .post("/validator/classpath")
+                .post("/validator/validate/" + scheme)
                 .then()
                 .statusCode(500);

Review Comment:
   > The tests are failing. You might want to forward the exception message to the client in `ValidatorResource`. Something like
   > 
   > ```
   >     public javax.ws.rs.core.Response processOrderInXml(String statement, @PathParam("scheme") String scheme) {
   >         try {
   >             return javax.ws.rs.core.Response.ok().entity(producerTemplate.requestBody("direct:" + scheme, statement, String.class));
   >         } catch (Exception e) {
   >                 return javax.ws.rs.core.Response.serverError().entity(e.getMessage());
   >         }
   >             
   >     }
   > ```
   
   



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] ppalaga merged pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
ppalaga merged PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] svkcemk commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
svkcemk commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r942018891


##########
integration-tests/validator/src/main/java/org/apache/camel/quarkus/component/validator/it/ValidatorResource.java:
##########
@@ -32,28 +33,12 @@ public class ValidatorResource {
     @Inject
     ProducerTemplate producerTemplate;
 
-    @Path("/classpath")
+    @Path("/validate/{scheme}")
     @POST
     @Consumes(MediaType.APPLICATION_XML)
     @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromClassPath(String statement) {
-        return producerTemplate.requestBody("direct:classpath", statement, String.class);
-    }
-
-    @Path("/filesystem")
-    @POST
-    @Consumes(MediaType.APPLICATION_XML)
-    @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromFileSystem(String statement) {
-        return producerTemplate.requestBody("direct:filesystem", statement, String.class);
-    }
-
-    @Path("/http")
-    @POST
-    @Consumes(MediaType.APPLICATION_XML)
-    @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromHTTP(String statement) {
-        return producerTemplate.requestBody("direct:http", statement, String.class);
+    public String processOrderInXmlFromFileSystem(String statement, @PathParam("scheme") String scheme) {

Review Comment:
   Thanks just renamed to a generic one. 



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] ppalaga commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
ppalaga commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r942703154


##########
integration-tests/validator/src/test/java/org/apache/camel/quarkus/component/validator/it/ValidatorTest.java:
##########
@@ -16,84 +16,40 @@
  */
 package org.apache.camel.quarkus.component.validator.it;
 
+import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 @QuarkusTest
+@QuarkusTestResource(ValidatorTestResource.class)
 class ValidatorTest {
 
-    @Test
-    public void validXMLFromClassPath() {
+    @ParameterizedTest
+    @ValueSource(strings = { "classpath", "filesystem", "http" })
+    public void validXML(String scheme) {
 
         RestAssured.given()
                 .contentType(ContentType.XML)
                 .body("<message><firstName>MyFirstname</firstName><lastName>MyLastname</lastName></message>")
-                .post("/validator/classpath")
+                .post("/validator/validate/" + scheme)
                 .then()
                 .statusCode(200);
 
     }
 
-    @Test
-    public void invalidXMLFromClassPath() {
+    @ParameterizedTest
+    @ValueSource(strings = { "classpath", "filesystem", "http" })
+    public void inValidXML(String scheme) {
 
         RestAssured.given()
                 .contentType(ContentType.XML)
                 .body("<message><firstName>MyFirstname</firstName></message>")
-                .post("/validator/classpath")
+                .post("/validator/validate/" + scheme)
                 .then()
                 .statusCode(500);

Review Comment:
   The tests are failing. You might want to forward the exception message to the client in `ValidatorResource`. Something like 
   
   ```
       public javax.ws.rs.core.Response processOrderInXml(String statement, @PathParam("scheme") String scheme) {
           try {
               return javax.ws.rs.core.Response.ok().entity(producerTemplate.requestBody("direct:" + scheme, statement, String.class));
           } catch (Exception e) {
                   return javax.ws.rs.core.Response.serverError().entity(e.getMessage());
           }
               
       }
   ```



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r941464371


##########
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) {

Review Comment:
   Nice trick so that it works on platform also :+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.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] svkcemk commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
svkcemk commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r942322025


##########
integration-tests/validator/src/test/java/org/apache/camel/quarkus/component/validator/it/ValidatorTest.java:
##########
@@ -16,84 +16,40 @@
  */
 package org.apache.camel.quarkus.component.validator.it;
 
+import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 @QuarkusTest
+@QuarkusTestResource(ValidatorTestResource.class)
 class ValidatorTest {
 
-    @Test
-    public void validXMLFromClassPath() {
+    @ParameterizedTest
+    @ValueSource(strings = { "classpath", "filesystem", "http" })
+    public void validXML(String scheme) {
 
         RestAssured.given()
                 .contentType(ContentType.XML)
                 .body("<message><firstName>MyFirstname</firstName><lastName>MyLastname</lastName></message>")
-                .post("/validator/classpath")
+                .post("/validator/validate/" + scheme)
                 .then()
                 .statusCode(200);
 
     }
 
-    @Test
-    public void invalidXMLFromClassPath() {
+    @ParameterizedTest
+    @ValueSource(strings = { "classpath", "filesystem", "http" })
+    public void inValidXML(String scheme) {
 
         RestAssured.given()
                 .contentType(ContentType.XML)
                 .body("<message><firstName>MyFirstname</firstName></message>")
-                .post("/validator/classpath")
+                .post("/validator/validate/" + scheme)
                 .then()
                 .statusCode(500);

Review Comment:
   @ppalaga I have added some checks based on the body, I think it will make more sense now, Thanks for pointing out ! 



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r941462022


##########
integration-tests/validator/src/main/java/org/apache/camel/quarkus/component/validator/it/ValidatorResource.java:
##########
@@ -32,28 +33,12 @@ public class ValidatorResource {
     @Inject
     ProducerTemplate producerTemplate;
 
-    @Path("/classpath")
+    @Path("/validate/{scheme}")
     @POST
     @Consumes(MediaType.APPLICATION_XML)
     @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromClassPath(String statement) {
-        return producerTemplate.requestBody("direct:classpath", statement, String.class);
-    }
-
-    @Path("/filesystem")
-    @POST
-    @Consumes(MediaType.APPLICATION_XML)
-    @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromFileSystem(String statement) {
-        return producerTemplate.requestBody("direct:filesystem", statement, String.class);
-    }
-
-    @Path("/http")
-    @POST
-    @Consumes(MediaType.APPLICATION_XML)
-    @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromHTTP(String statement) {
-        return producerTemplate.requestBody("direct:http", statement, String.class);
+    public String processOrderInXmlFromFileSystem(String statement, @PathParam("scheme") String scheme) {

Review Comment:
   `processOrderInXmlFromFileSystem` => Don't we do more than file system ?



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] ppalaga commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
ppalaga commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r942212777


##########
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:
   ```suggestion
               throw new RuntimeException("Could not read "+ sourceXsd + " from classpath or copy it to " + tempXsd, e);
   ```
   
   The wrapped exception message does not say related to which file the operation failed. Adding the path to the wrapper exception will help future users to faster figure out where the problem is. 



##########
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);

Review Comment:
   ```suggestion
           try (InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(sourceXsd)) {
   ```
   
   Otherwise the stream is not closed. It may cause problems especially on Windows.



##########
integration-tests/validator/src/test/java/org/apache/camel/quarkus/component/validator/it/ValidatorTest.java:
##########
@@ -16,84 +16,40 @@
  */
 package org.apache.camel.quarkus.component.validator.it;
 
+import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 @QuarkusTest
+@QuarkusTestResource(ValidatorTestResource.class)
 class ValidatorTest {
 
-    @Test
-    public void validXMLFromClassPath() {
+    @ParameterizedTest
+    @ValueSource(strings = { "classpath", "filesystem", "http" })
+    public void validXML(String scheme) {
 
         RestAssured.given()
                 .contentType(ContentType.XML)
                 .body("<message><firstName>MyFirstname</firstName><lastName>MyLastname</lastName></message>")
-                .post("/validator/classpath")
+                .post("/validator/validate/" + scheme)
                 .then()
                 .statusCode(200);
 
     }
 
-    @Test
-    public void invalidXMLFromClassPath() {
+    @ParameterizedTest
+    @ValueSource(strings = { "classpath", "filesystem", "http" })
+    public void inValidXML(String scheme) {
 
         RestAssured.given()
                 .contentType(ContentType.XML)
                 .body("<message><firstName>MyFirstname</firstName></message>")
-                .post("/validator/classpath")
+                .post("/validator/validate/" + scheme)
                 .then()
                 .statusCode(500);

Review Comment:
   Here I wonder whether there is some body text (or any other way) from which we could see that what failed is really the XSD validation? 500 could mean a failure somewhere else in the stack, which we definitely would not want to accept as "test passed". 



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] svkcemk commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#discussion_r941462022


##########
integration-tests/validator/src/main/java/org/apache/camel/quarkus/component/validator/it/ValidatorResource.java:
##########
@@ -32,28 +33,12 @@ public class ValidatorResource {
     @Inject
     ProducerTemplate producerTemplate;
 
-    @Path("/classpath")
+    @Path("/validate/{scheme}")
     @POST
     @Consumes(MediaType.APPLICATION_XML)
     @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromClassPath(String statement) {
-        return producerTemplate.requestBody("direct:classpath", statement, String.class);
-    }
-
-    @Path("/filesystem")
-    @POST
-    @Consumes(MediaType.APPLICATION_XML)
-    @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromFileSystem(String statement) {
-        return producerTemplate.requestBody("direct:filesystem", statement, String.class);
-    }
-
-    @Path("/http")
-    @POST
-    @Consumes(MediaType.APPLICATION_XML)
-    @Produces(MediaType.TEXT_PLAIN)
-    public String processOrderInXmlFromHTTP(String statement) {
-        return producerTemplate.requestBody("direct:http", statement, String.class);
+    public String processOrderInXmlFromFileSystem(String statement, @PathParam("scheme") String scheme) {

Review Comment:
   `processOrderInXmlFromFileSystem` => Don't we do more than file system only ?
   
   Maybe `processOrderInXml()` is sufficient ?



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] ppalaga commented on pull request #3972: Improve/clean-up camel-quarkus-validator extension tests.

Posted by GitBox <gi...@apache.org>.
ppalaga commented on PR #3972:
URL: https://github.com/apache/camel-quarkus/pull/3972#issuecomment-1214771814

   Thanks @svkcemk !


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org