You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ve...@apache.org on 2008/06/23 11:41:17 UTC

svn commit: r670497 - in /synapse/trunk/java/modules/core/src/test: java/org/apache/synapse/mediators/transform/XSLTMediatorTest.java resources/org/apache/synapse/mediators/transform/cdata.xslt

Author: veithen
Date: Mon Jun 23 02:41:16 2008
New Revision: 670497

URL: http://svn.apache.org/viewvc?rev=670497&view=rev
Log:
XSLTMediator: added a unit test that checks that the mediator is able to handle CDATA sections in the source AXIOM tree.

Added:
    synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/mediators/transform/cdata.xslt
Modified:
    synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/transform/XSLTMediatorTest.java

Modified: synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/transform/XSLTMediatorTest.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/transform/XSLTMediatorTest.java?rev=670497&r1=670496&r2=670497&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/transform/XSLTMediatorTest.java (original)
+++ synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/transform/XSLTMediatorTest.java Mon Jun 23 02:41:16 2008
@@ -19,10 +19,14 @@
 
 package org.apache.synapse.mediators.transform;
 
+import javax.xml.namespace.QName;
+
 import junit.framework.TestCase;
 
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
 import org.apache.synapse.MessageContext;
 import org.apache.synapse.SynapseException;
@@ -256,4 +260,30 @@
             // this is what is expected
         }
     }
+    
+    /**
+     * Test that the XSLT mediator is able to handle CDATA sections in the
+     * source AXIOM tree.
+     * This tests for regression against WSCOMMONS-338. It should work with
+     * AXIOM versions above 1.2.7.
+     */
+    public void testWithCDATA() throws Exception {
+        transformMediator = new XSLTMediator();
+        transformMediator.setXsltKey("xslt-key");
+        
+        MessageContext mc = new TestMessageContextBuilder()
+            .addEntry("xslt-key", getClass().getResource("cdata.xslt"))
+            .build();
+        
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        OMElement in = factory.createOMElement(new QName(null, "in"));
+        factory.createOMText(in, "test", OMNode.CDATA_SECTION_NODE);
+        mc.getEnvelope().getBody().addChild(in);
+        
+        transformMediator.mediate(mc);
+        
+        OMElement out = mc.getEnvelope().getBody().getFirstElement();
+        assertEquals("out", out.getLocalName());
+        assertEquals("test", out.getText());
+    }
 }

Added: synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/mediators/transform/cdata.xslt
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/mediators/transform/cdata.xslt?rev=670497&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/mediators/transform/cdata.xslt (added)
+++ synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/mediators/transform/cdata.xslt Mon Jun 23 02:41:16 2008
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~  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.
+  -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:template match="/">
+        <out><xsl:value-of select="in"/></out>
+    </xsl:template>
+</xsl:stylesheet>