Test validate() EIP DSL method #2628
diff --git a/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlIoResource.java b/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlIoResource.java
index a9ea868..5446e06 100644
--- a/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlIoResource.java
+++ b/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlIoResource.java
@@ -16,6 +16,11 @@
  */
 package org.apache.camel.quarkus.main;
 
+import java.util.AbstractMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Inject;
 import javax.json.Json;
@@ -25,8 +30,11 @@
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.ProducerTemplate;
@@ -34,16 +42,16 @@
 import org.apache.camel.dsl.xml.io.XmlRoutesBuilderLoader;
 import org.apache.camel.spi.RoutesBuilderLoader;
 
-@Path("/test")
+@Path("/xml-io")
 @ApplicationScoped
 public class CoreMainXmlIoResource {
     @Inject
     CamelMain main;
 
     @Inject
-    ProducerTemplate template;
+    ProducerTemplate producerTemplate;
 
-    @Path("/main/describe")
+    @Path("/describe")
     @GET
     @Produces(MediaType.APPLICATION_JSON)
     public JsonObject describeMain() {
@@ -76,12 +84,14 @@
                 .build();
     }
 
-    @Path("/xml-io/namespace-aware")
+    @Path("/route/{route}")
     @POST
+    @Consumes(MediaType.TEXT_PLAIN)
     @Produces(MediaType.TEXT_PLAIN)
-    @Consumes(MediaType.APPLICATION_XML)
-    public String namespaceAware(String body) {
-        return template.requestBody("direct:namespace-aware", body, String.class);
+    public String route(String statement, @PathParam("route") String route, @Context UriInfo uriInfo) {
+        final Map<String, Object> headers = uriInfo.getQueryParameters().entrySet().stream()
+                .map(e -> new AbstractMap.SimpleImmutableEntry<String, Object>(e.getKey(), e.getValue().get(0)))
+                .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+        return producerTemplate.requestBodyAndHeaders("direct:" + route, statement, headers, String.class);
     }
-
 }
diff --git a/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/XmlIoRoutes.java b/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/XmlIoRoutes.java
new file mode 100644
index 0000000..ae4cc16
--- /dev/null
+++ b/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/XmlIoRoutes.java
@@ -0,0 +1,30 @@
+/*
+ * 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.main;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class XmlIoRoutes extends RouteBuilder {
+
+    @Override
+    public void configure() {
+
+        from("direct:validate")
+                .validate(body().regex("^K.*"))
+                .setBody(e -> "Hello " + e.getMessage().getBody() + " you were validated");
+    }
+}
diff --git a/integration-tests/main-xml-io/src/test/java/org/apache/camel/quarkus/main/CoreMainXmlIoTest.java b/integration-tests/main-xml-io/src/test/java/org/apache/camel/quarkus/main/CoreMainXmlIoTest.java
index 1956ad0..e3fa0cb 100644
--- a/integration-tests/main-xml-io/src/test/java/org/apache/camel/quarkus/main/CoreMainXmlIoTest.java
+++ b/integration-tests/main-xml-io/src/test/java/org/apache/camel/quarkus/main/CoreMainXmlIoTest.java
@@ -28,6 +28,7 @@
 import org.apache.camel.quarkus.core.DisabledModelJAXBContextFactory;
 import org.apache.camel.quarkus.core.DisabledModelToXMLDumper;
 import org.apache.camel.quarkus.core.DisabledXMLRoutesDefinitionLoader;
+import org.hamcrest.Matchers;
 import org.junit.jupiter.api.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -39,7 +40,7 @@
     public void testMainInstanceWithXmlRoutes() {
         JsonPath p = RestAssured.given()
                 .accept(MediaType.APPLICATION_JSON)
-                .get("/test/main/describe")
+                .get("/xml-io/describe")
                 .then()
                 .statusCode(200)
                 .extract()
@@ -55,7 +56,7 @@
                 .isEqualTo(XmlRoutesBuilderLoader.class.getName());
 
         assertThat(p.getList("routeBuilders", String.class))
-                .isEmpty();
+                .contains("org.apache.camel.quarkus.main.XmlIoRoutes");
 
         List<String> routes = p.getList("routes", String.class);
         assertThat(routes)
@@ -72,13 +73,32 @@
                 + "<foo:foo-text xmlns:foo=\"http://camel.apache.org/foo\">bar</foo:foo-text>";
 
         RestAssured.given()
-                .contentType(ContentType.XML)
+                .contentType(ContentType.TEXT)
                 .body(message)
-                .post("/test/xml-io/namespace-aware")
+                .post("/xml-io/route/namespace-aware")
                 .then()
                 .statusCode(200)
                 .body(is("bar"));
 
     }
 
+    @Test
+    public void validate() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("Kermit")
+                .post("/xml-io/route/validate")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("Hello Kermit you were validated"));
+
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("Cookie Monster") // does not match ^K.*
+                .post("/xml-io/route/validate")
+                .then()
+                .statusCode(500);
+
+    }
+
 }