You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/08/10 19:51:21 UTC

[camel] branch camel-3.7.x updated (3c458f6 -> 1d3a3b0)

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

davsclaus pushed a change to branch camel-3.7.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 3c458f6  Polish and cleanup documentation
     new eeea1d7  CAMEL-16853: fix resultHandlerFactory, add unit test (#5945)
     new 1d3a3b0  CAMEL-16853: Regen

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/camel/component/xslt/XsltEndpoint.java  |  8 ++--
 .../XsltResultHandlerTest.java}                    | 51 +++++++++++-----------
 2 files changed, 30 insertions(+), 29 deletions(-)
 copy core/camel-core/src/test/java/org/apache/camel/component/{log/LogListenerTest.java => xslt/XsltResultHandlerTest.java} (52%)

[camel] 02/02: CAMEL-16853: Regen

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.7.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1d3a3b07bdeb705b6bca330628169875b71482d6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Aug 10 21:46:54 2021 +0200

    CAMEL-16853: Regen
---
 .../java/org/apache/camel/component/xslt/XsltResultHandlerTest.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltResultHandlerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltResultHandlerTest.java
index ae3efa4..2a9465a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltResultHandlerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltResultHandlerTest.java
@@ -51,11 +51,11 @@ public class XsltResultHandlerTest extends TestSupport {
         assertEquals(factory, endpoint.getXslt().getResultHandlerFactory());
     }
 
-
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("direct:start").to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes&resultHandlerFactory=#factory");
+                from("direct:start")
+                        .to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes&resultHandlerFactory=#factory");
             }
         };
     }

[camel] 01/02: CAMEL-16853: fix resultHandlerFactory, add unit test (#5945)

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.7.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit eeea1d7d8f2df795f7bead68dd0b4ec396772ae6
Author: Rik van Ballegooijen <r....@codecast.nl>
AuthorDate: Tue Aug 10 21:45:42 2021 +0200

    CAMEL-16853: fix resultHandlerFactory, add unit test (#5945)
    
    * CAMEL-16853: fix resultHandlerFactory, add unit test
    
    * CAMEL-16853: Change unit test to DSL version, without depending on spring (note: still cyclic!)
    
    * CAMEL-16853: Fix cyclic dep: Moved unit test to camel-core, removed test dependencies from camel-xslt
    
    Co-authored-by: Rik van Ballegooijen <ri...@codecast.nl>
---
 .../apache/camel/component/xslt/XsltEndpoint.java  |  8 +--
 .../component/xslt/XsltResultHandlerTest.java      | 63 ++++++++++++++++++++++
 2 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
index bccd61f..9d3b897 100644
--- a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
+++ b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
@@ -386,9 +386,7 @@ public class XsltEndpoint extends ProcessorEndpoint {
             LOG.debug("Using TransformerFactory {}", factory);
             xslt.setTransformerFactory(factory);
         }
-        if (resultHandlerFactory != null) {
-            xslt.setResultHandlerFactory(resultHandlerFactory);
-        }
+
         if (errorListener != null) {
             xslt.errorListener(errorListener);
         }
@@ -400,6 +398,10 @@ public class XsltEndpoint extends ProcessorEndpoint {
 
         configureOutput(xslt, output.name());
 
+        if (resultHandlerFactory != null) {
+            xslt.setResultHandlerFactory(resultHandlerFactory);
+        }
+
         // any additional transformer parameters then make a copy to avoid side-effects
         if (parameters != null) {
             Map<String, Object> copy = new HashMap<>(parameters);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltResultHandlerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltResultHandlerTest.java
new file mode 100644
index 0000000..ae3efa4
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltResultHandlerTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.component.xslt;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.TestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class XsltResultHandlerTest extends TestSupport {
+
+    @Test
+    public void testResultHandlerFactory() throws Exception {
+        RouteBuilder builder = createRouteBuilder();
+        CamelContext context = new DefaultCamelContext();
+        ResultHandlerFactory factory = new DomResultHandlerFactory();
+        context.getRegistry().bind("factory", factory);
+        context.addRoutes(builder);
+        context.start();
+
+        XsltEndpoint endpoint = null;
+        for (Endpoint ep : context.getEndpoints()) {
+            if (ep instanceof XsltEndpoint) {
+                endpoint = (XsltEndpoint) ep;
+                break;
+            }
+        }
+
+        assertNotNull(endpoint);
+        assertEquals(DomResultHandlerFactory.class, factory.getClass());
+        assertEquals(factory, endpoint.getResultHandlerFactory());
+        assertEquals(factory, endpoint.getXslt().getResultHandlerFactory());
+    }
+
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:start").to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes&resultHandlerFactory=#factory");
+            }
+        };
+    }
+
+}