You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2011/01/10 16:40:02 UTC

svn commit: r1057243 - in /ode/branches/ode-1.3.5.x/bpel-compiler/src: main/java/org/apache/ode/bpel/compiler/ test/java/org/apache/ode/bpel/compiler_2_0/ test/resources/xslt/

Author: vanto
Date: Mon Jan 10 15:40:02 2011
New Revision: 1057243

URL: http://svn.apache.org/viewvc?rev=1057243&view=rev
Log:
fixing ODE-472, compiler part.

Added:
    ode/branches/ode-1.3.5.x/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/XslTest.java
    ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/
    ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-iso.xslt
    ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-utf8.xslt
    ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test1.wsdl
    ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-iso.bpel
    ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-utf8.bpel
Modified:
    ode/branches/ode-1.3.5.x/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java

Modified: ode/branches/ode-1.3.5.x/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
URL: http://svn.apache.org/viewvc/ode/branches/ode-1.3.5.x/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java?rev=1057243&r1=1057242&r2=1057243&view=diff
==============================================================================
--- ode/branches/ode-1.3.5.x/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java (original)
+++ ode/branches/ode-1.3.5.x/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java Mon Jan 10 15:40:02 2011
@@ -110,6 +110,7 @@ import org.apache.ode.bpel.o.OTerminatio
 import org.apache.ode.bpel.o.OVarType;
 import org.apache.ode.bpel.o.OXsdTypeVarType;
 import org.apache.ode.bpel.o.OXslSheet;
+import org.apache.ode.utils.DOMUtils;
 import org.apache.ode.utils.GUID;
 import org.apache.ode.utils.NSContext;
 import org.apache.ode.utils.Namespaces;
@@ -1608,8 +1609,10 @@ public abstract class BpelCompiler imple
             return null;
 
         try {
-            return new String(StreamUtils.read(is));
-        } catch (IOException e) {
+            // verify that sheet is well-formed and preserve encoding.
+            Document doc = DOMUtils.parse(is);
+            return DOMUtils.domToString(doc);
+        } catch (Exception e) {
             __log.debug("IO error", e);
             // todo: this should produce a message
             return null;

Added: ode/branches/ode-1.3.5.x/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/XslTest.java
URL: http://svn.apache.org/viewvc/ode/branches/ode-1.3.5.x/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/XslTest.java?rev=1057243&view=auto
==============================================================================
--- ode/branches/ode-1.3.5.x/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/XslTest.java (added)
+++ ode/branches/ode-1.3.5.x/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/XslTest.java Mon Jan 10 15:40:02 2011
@@ -0,0 +1,90 @@
+/*
+ * 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.ode.bpel.compiler_2_0;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.compiler.BpelCompiler20;
+import org.apache.ode.bpel.compiler.DefaultResourceFinder;
+import org.apache.ode.bpel.compiler.ResourceFinder;
+import org.apache.ode.bpel.compiler.bom.BpelObjectFactory;
+import org.apache.ode.bpel.o.OProcess;
+import org.apache.ode.bpel.o.OXslSheet;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.StreamUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+
+public class XslTest {
+
+    private final Log __log = LogFactory.getLog(getClass());
+    private BpelCompiler20 _compiler;
+    private ResourceFinder _resfinder;
+
+    @Before
+    public void setUp() throws Exception {
+        _compiler = new BpelCompiler20();
+        File dir = new File(getClass().getResource(".").toURI());
+        _resfinder = new DefaultResourceFinder(dir, dir);
+        _compiler.setResourceFinder(_resfinder);
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        _compiler = null;
+    }
+    
+    @Test
+    public void testUTFEncoding() throws Exception {
+        Document original = DOMUtils.parse(getClass().getResourceAsStream("/xslt/test-utf8.xslt"));
+        OProcess op = compile("xsl-utf8");
+        OXslSheet sheet = op.xslSheets.get(URI.create("test-utf8.xslt"));
+        Assert.assertNotNull(sheet);
+        Assert.assertEquals(DOMUtils.domToString(original), sheet.sheetBody);        
+    }
+
+    @Test
+    public void testISOEncoding() throws Exception {
+        Document original = DOMUtils.parse(getClass().getResourceAsStream("/xslt/test-iso.xslt"));
+        OProcess op = compile("xsl-iso");
+        OXslSheet sheet = op.xslSheets.get(URI.create("test-iso.xslt"));
+        Assert.assertNotNull(sheet);
+        Assert.assertEquals(DOMUtils.domToString(original), sheet.sheetBody);
+    }
+
+    private OProcess compile(String bpelFile) throws Exception {
+        URL bpelURL = getClass().getResource("/xslt/" + bpelFile + ".bpel");
+
+        InputSource isrc = new InputSource(bpelURL.openStream());
+        isrc.setSystemId(bpelURL.toExternalForm());
+
+        org.apache.ode.bpel.compiler.bom.Process process = BpelObjectFactory.getInstance().parse(isrc, bpelURL.toURI());
+
+        return _compiler.compile(process, _resfinder, 0);
+    }
+}

Added: ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-iso.xslt
URL: http://svn.apache.org/viewvc/ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-iso.xslt?rev=1057243&view=auto
==============================================================================
--- ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-iso.xslt (added)
+++ ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-iso.xslt Mon Jan 10 15:40:02 2011
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:fn="http://www.w3.org/2005/xpath-functions"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:tns="http://example.org/test"
+	>
+	<xsl:output method="xml" indent="no" />
+
+	<xsl:template match="/">
+		<tns:testxslt>
+			<tns:from-xslt>
+				<xsl:value-of select="'Prova lettere accentate: à è ì ò ù'"/>
+			</tns:from-xslt>
+			<tns:from-document>
+				<xsl:value-of select="document('test.xml')"/>
+			</tns:from-document>
+		</tns:testxslt>
+	</xsl:template>
+
+	<xsl:template match="text()|@*"/>
+
+</xsl:stylesheet>

Added: ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-utf8.xslt
URL: http://svn.apache.org/viewvc/ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-utf8.xslt?rev=1057243&view=auto
==============================================================================
--- ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-utf8.xslt (added)
+++ ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test-utf8.xslt Mon Jan 10 15:40:02 2011
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:fn="http://www.w3.org/2005/xpath-functions"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:tns="http://example.org/test"
+	>
+	<xsl:output method="xml" indent="no" />
+
+	<xsl:template match="/">
+		<tns:testxslt>
+			<tns:from-xslt>
+				<xsl:value-of select="'Prova lettere accentate: à è ì ò ù'"/>
+			</tns:from-xslt>
+			<tns:from-document>
+				<xsl:value-of select="document('test.xml')"/>
+			</tns:from-document>
+		</tns:testxslt>
+	</xsl:template>
+
+	<xsl:template match="text()|@*"/>
+
+</xsl:stylesheet>

Added: ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test1.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test1.wsdl?rev=1057243&view=auto
==============================================================================
--- ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test1.wsdl (added)
+++ ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/test1.wsdl Mon Jan 10 15:40:02 2011
@@ -0,0 +1,88 @@
+<?xml version="1.0"?>
+<definitions name="test1"
+        targetNamespace="http://example.org/test1"
+        xmlns:tns="http://example.org/test1"
+        xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
+        xmlns="http://schemas.xmlsoap.org/wsdl/"
+        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     TYPE DEFINITION - List of types participating in this BPEL process 
+     The BPEL Designer will generate default request and response types
+     but you can define or import any XML Schema type and use them as part 
+     of the message types.
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
+    <types>
+        <schema attributeFormDefault="unqualified" elementFormDefault="qualified" 
+                targetNamespace="http://example.org/test1" 
+                xmlns="http://www.w3.org/2001/XMLSchema">
+
+            <element name="test1">
+                <complexType>
+                    <sequence>
+                        <element name="action" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+
+            <element name="test1Response">
+                <complexType>
+                    <sequence>
+                        <any namespace="##any" processContents="lax"/>
+                    </sequence>
+                </complexType>
+            </element>
+        </schema>
+    </types>
+
+
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     MESSAGE TYPE DEFINITION - Definition of the message types used as 
+     part of the port type defintions
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
+    <message name="test1RequestMessage">
+        <part name="payload" element="tns:test1"/>
+    </message>
+    <message name="test1ResponseMessage">
+        <part name="payload" element="tns:test1Response"/>
+    </message>
+
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     PORT TYPE DEFINITION - A port type groups a set of operations into
+     a logical service unit.
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
+
+    <!-- portType implemented by the test1 BPEL process -->
+    <portType name="test1">
+        <operation name="test1">
+            <input  message="tns:test1RequestMessage" />
+            <output message="tns:test1ResponseMessage"/>
+        </operation>
+    </portType>
+  
+    <binding name="test1" type="tns:test1">
+    	<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
+    	<operation name="test1">
+    		<soap:operation soapAction="http://example.org/test1/test1"></soap:operation>
+    		<input>
+    			<soap:body use="literal"></soap:body>
+    		</input>
+    		<output>
+    			<soap:body use="literal"></soap:body>
+    		</output>
+    	</operation>
+    </binding>
+
+    <service name="test1">
+		<port binding="tns:test1" name="test1">
+			<soap:address location="http://FILLED_BY_SERVER/ode/processes/test1" />
+		</port>
+	</service>
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     PARTNER LINK TYPE DEFINITION
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
+    <plnk:partnerLinkType name="test1">
+        <plnk:role name="test1Provider" portType="tns:test1"/>
+    </plnk:partnerLinkType>
+    
+</definitions>

Added: ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-iso.bpel
URL: http://svn.apache.org/viewvc/ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-iso.bpel?rev=1057243&view=auto
==============================================================================
--- ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-iso.bpel (added)
+++ ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-iso.bpel Mon Jan 10 15:40:02 2011
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpws:process exitOnStandardFault="yes" name="test1"
+    suppressJoinFailure="yes" targetNamespace="http://example.org/test1"
+    xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+    xmlns:tns="http://example.org/test1">
+    <bpws:import importType="http://schemas.xmlsoap.org/wsdl/"
+        location="test1.wsdl" namespace="http://example.org/test1"/>
+    <bpws:partnerLinks>
+        <bpws:partnerLink myRole="test1Provider" name="client" partnerLinkType="tns:test1"/>
+    </bpws:partnerLinks>
+    <bpws:variables>
+        <bpws:variable messageType="tns:test1RequestMessage" name="input"/>
+        <bpws:variable messageType="tns:test1ResponseMessage" name="output"/>
+    </bpws:variables>
+    <bpws:sequence name="main">
+        <bpws:receive createInstance="yes" name="receiveInput"
+            operation="test1" partnerLink="client" portType="tns:test1" variable="input"/>
+        <bpws:assign name="prepareResponse" validate="no">
+            <bpws:copy>
+                <bpws:from>
+                    <bpws:literal>
+                        <test1Response xmlns="http://example.org/test1">
+                            <testxslt xmlns="http://example.org/test"/>
+                        </test1Response>
+                    </bpws:literal>
+                </bpws:from>
+                <bpws:to part="payload" variable="output"/>
+            </bpws:copy>
+            <bpws:copy>
+                <bpws:from><![CDATA[bpws:doXslTransform("test-iso.xslt", $input.payload)]]></bpws:from>
+                <bpws:to><![CDATA[$output.payload/*[1]]]></bpws:to>
+            </bpws:copy>
+        </bpws:assign>
+        <bpws:reply name="replyOutput" operation="test1"
+            partnerLink="client" portType="tns:test1" variable="output"/>
+    </bpws:sequence>
+</bpws:process>

Added: ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-utf8.bpel
URL: http://svn.apache.org/viewvc/ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-utf8.bpel?rev=1057243&view=auto
==============================================================================
--- ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-utf8.bpel (added)
+++ ode/branches/ode-1.3.5.x/bpel-compiler/src/test/resources/xslt/xsl-utf8.bpel Mon Jan 10 15:40:02 2011
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpws:process exitOnStandardFault="yes" name="test1"
+    suppressJoinFailure="yes" targetNamespace="http://example.org/test1"
+    xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+    xmlns:tns="http://example.org/test1">
+    <bpws:import importType="http://schemas.xmlsoap.org/wsdl/"
+        location="test1.wsdl" namespace="http://example.org/test1"/>
+    <bpws:partnerLinks>
+        <bpws:partnerLink myRole="test1Provider" name="client" partnerLinkType="tns:test1"/>
+    </bpws:partnerLinks>
+    <bpws:variables>
+        <bpws:variable messageType="tns:test1RequestMessage" name="input"/>
+        <bpws:variable messageType="tns:test1ResponseMessage" name="output"/>
+    </bpws:variables>
+    <bpws:sequence name="main">
+        <bpws:receive createInstance="yes" name="receiveInput"
+            operation="test1" partnerLink="client" portType="tns:test1" variable="input"/>
+        <bpws:assign name="prepareResponse" validate="no">
+            <bpws:copy>
+                <bpws:from>
+                    <bpws:literal>
+                        <test1Response xmlns="http://example.org/test1">
+                            <testxslt xmlns="http://example.org/test"/>
+                        </test1Response>
+                    </bpws:literal>
+                </bpws:from>
+                <bpws:to part="payload" variable="output"/>
+            </bpws:copy>
+            <bpws:copy>
+                <bpws:from><![CDATA[bpws:doXslTransform("test-utf8.xslt", $input.payload)]]></bpws:from>
+                <bpws:to><![CDATA[$output.payload/*[1]]]></bpws:to>
+            </bpws:copy>
+        </bpws:assign>
+        <bpws:reply name="replyOutput" operation="test1"
+            partnerLink="client" portType="tns:test1" variable="output"/>
+    </bpws:sequence>
+</bpws:process>