You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zh...@apache.org on 2022/11/14 09:58:09 UTC

[camel-quarkus] branch main updated: Fix #4258 make xml integration tests working in Quarkus Platform (#4275)

This is an automated email from the ASF dual-hosted git repository.

zhfeng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 6f90fec14e Fix #4258 make xml integration tests working in Quarkus Platform (#4275)
6f90fec14e is described below

commit 6f90fec14e9f31ba168524aabcc7f871794c66b3
Author: Zheng Feng <zh...@gmail.com>
AuthorDate: Mon Nov 14 17:58:03 2022 +0800

    Fix #4258 make xml integration tests working in Quarkus Platform (#4275)
    
    * Copy xslt files to tmp directory
    * Send the xml contents to a aggregate route directly
---
 integration-tests/xml/pom.xml                        |  4 ----
 .../camel/quarkus/component/xml/it/XmlResource.java  | 17 ++++++++++++++---
 .../quarkus/component/xml/it/XmlRouteBuilder.java    |  5 ++---
 integration-tests/xml/src/test/resources/data1.xml   | 20 --------------------
 integration-tests/xml/src/test/resources/data2.xml   | 20 --------------------
 integration-tests/xml/src/test/resources/data3.xml   | 20 --------------------
 6 files changed, 16 insertions(+), 70 deletions(-)

diff --git a/integration-tests/xml/pom.xml b/integration-tests/xml/pom.xml
index 42785c5575..a76ed6105c 100644
--- a/integration-tests/xml/pom.xml
+++ b/integration-tests/xml/pom.xml
@@ -55,10 +55,6 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-direct</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-file</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-mock</artifactId>
diff --git a/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlResource.java b/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlResource.java
index cb70629924..21b9da6b3d 100644
--- a/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlResource.java
+++ b/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlResource.java
@@ -16,6 +16,10 @@
  */
 package org.apache.camel.quarkus.component.xml.it;
 
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.util.StringJoiner;
 
 import javax.enterprise.context.ApplicationScoped;
@@ -111,8 +115,12 @@ public class XmlResource {
     @Path("/xslt-file")
     @POST
     @Produces(MediaType.TEXT_PLAIN)
-    public String xsltFile(String body) {
-        return producerTemplate.requestBody("xslt:file:src/main/resources/xslt/classpath-transform.xsl", body, String.class);
+    public String xsltFile(String body) throws Exception {
+        try (InputStream in = getClass().getClassLoader().getResourceAsStream("xslt/classpath-transform.xsl")) {
+            File file = File.createTempFile("xslt", ".xsl");
+            Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
+            return producerTemplate.requestBody("xslt:file:" + file, body, String.class);
+        }
     }
 
     @Path("/xslt-http")
@@ -131,7 +139,10 @@ public class XmlResource {
     public String aggregate() throws Exception {
         MockEndpoint mock = camelContext.getEndpoint("mock:transformed", MockEndpoint.class);
         mock.expectedMessageCount(1);
-        camelContext.getRouteController().startRoute("aggregate");
+
+        producerTemplate.sendBody("direct:aggregate", "<item>A</item>");
+        producerTemplate.sendBody("direct:aggregate", "<item>B</item>");
+        producerTemplate.sendBody("direct:aggregate", "<item>C</item>");
 
         mock.assertIsSatisfied();
         return mock.getExchanges().get(0).getIn().getBody(String.class);
diff --git a/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlRouteBuilder.java b/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlRouteBuilder.java
index 160efcc5cb..b018598291 100644
--- a/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlRouteBuilder.java
+++ b/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlRouteBuilder.java
@@ -58,11 +58,10 @@ public class XmlRouteBuilder extends RouteBuilder {
                 .xtokenize("//C:child", new Namespaces("C", "urn:c"))
                 .to("seda:xtokenize-result");
 
-        from("file:src/test/resources?noop=true&sortBy=file:name&antInclude=*.xml")
-                .routeId("aggregate").noAutoStartup()
+        from("direct:aggregate")
                 .aggregate(new XsltSaxonAggregationStrategy("xslt/aggregate.xsl"))
                 .constant(true)
-                .completionFromBatchConsumer()
+                .completionSize(3)
                 .log("after aggregate body: ${body}")
                 .to("mock:transformed");
     }
diff --git a/integration-tests/xml/src/test/resources/data1.xml b/integration-tests/xml/src/test/resources/data1.xml
deleted file mode 100644
index ab271eff66..0000000000
--- a/integration-tests/xml/src/test/resources/data1.xml
+++ /dev/null
@@ -1,20 +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.
-
--->
-<item>A</item>
\ No newline at end of file
diff --git a/integration-tests/xml/src/test/resources/data2.xml b/integration-tests/xml/src/test/resources/data2.xml
deleted file mode 100644
index ff5eca1e90..0000000000
--- a/integration-tests/xml/src/test/resources/data2.xml
+++ /dev/null
@@ -1,20 +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.
-
--->
-<item>B</item>
diff --git a/integration-tests/xml/src/test/resources/data3.xml b/integration-tests/xml/src/test/resources/data3.xml
deleted file mode 100644
index b447fb9edd..0000000000
--- a/integration-tests/xml/src/test/resources/data3.xml
+++ /dev/null
@@ -1,20 +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.
-
--->
-<item>C</item>