You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by dc...@apache.org on 2010/06/17 22:45:58 UTC

svn commit: r955735 - in /ode/trunk: bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/ utils/src/main/java/org/apache/ode/utils/xsd/

Author: dcarver
Date: Thu Jun 17 20:45:57 2010
New Revision: 955735

URL: http://svn.apache.org/viewvc?rev=955735&view=rev
Log:
ODE-850 fix infinite loop that can occur on WSDLs that import XSDs by schemaLocation.

Added:
    ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/AbstractCompileTestCase.java
Removed:
    ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTCase.java
Modified:
    ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
    ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
    ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java

Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java?rev=955735&r1=955734&r2=955735&view=diff
==============================================================================
--- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java (original)
+++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java Thu Jun 17 20:45:57 2010
@@ -134,19 +134,15 @@ class WSDLRegistry {
                 __log.info("WSDL at " + defuri + " is a duplicate import, your documents " +
                         "should all be in different namespaces (its's not nice but will still work).");
             }
-            boolean alreadyProcessed = false;
+            
             for (Definition4BPEL aDef : _definitions.get(def.getTargetNamespace())) {
                 if (aDef.getDocumentBaseURI().equals(def.getDocumentBaseURI())) {
-                    alreadyProcessed = true;
-                    break;
-                }
-            }
-            if (alreadyProcessed) {
-                if (__log.isInfoEnabled()) {
-                    __log.info("WSDL at " + defuri + " is already imported, this denotes a circular reference.");
-                    // no need to keep going: either return or throw an error
+                    if (__log.isInfoEnabled()) {
+                        __log.info("WSDL at " + defuri + " is already imported, this denotes a circular reference.");
+                        // no need to keep going: either return or throw an error
+                    }
+                    return;
                 }
-                return;
             }
         }
 
@@ -229,8 +225,13 @@ class WSDLRegistry {
                             Document doc = DOMUtils.parse(new InputSource(new ByteArrayInputStream(schema)));
                             String schemaTargetNS = doc.getDocumentElement().getAttribute("targetNamespace");
                             if (schemaTargetNS != null && schemaTargetNS.length() > 0) {
-                                _internalSchemas.put(new URI(schemaTargetNS), schema);
-                                _documentSchemas.put(new URI(schemaTargetNS), doc);
+                                URI schemaNamespace = new URI(schemaTargetNS);
+                                if (!_internalSchemas.containsKey(schemaNamespace)) {
+                                    _internalSchemas.put(schemaNamespace, schema);
+                                }
+                                if (!_documentSchemas.containsKey(schemaNamespace)) {
+                                    _documentSchemas.put(schemaNamespace, doc);
+                                }
                             }
                         } catch (Exception e) {
                             throw new RuntimeException("Couldn't parse schema in " + def.getTargetNamespace(), e);

Added: ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/AbstractCompileTestCase.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/AbstractCompileTestCase.java?rev=955735&view=auto
==============================================================================
--- ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/AbstractCompileTestCase.java (added)
+++ ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/AbstractCompileTestCase.java Thu Jun 17 20:45:57 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.util.ArrayList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.compiler.BpelC;
+import org.apache.ode.bpel.compiler.api.CompilationMessage;
+import org.apache.ode.bpel.compiler.api.CompileListener;
+import org.apache.ode.utils.StreamUtils;
+import org.junit.After;
+import org.junit.Before;
+
+public abstract class AbstractCompileTestCase implements CompileListener {
+
+    protected final Log __log = LogFactory.getLog(getClass());
+    protected BpelC _compiler;
+    protected ArrayList<CompilationMessage> _errors = new ArrayList<CompilationMessage>();
+
+    public void onCompilationMessage(CompilationMessage compilationMessage) {
+        _errors.add(compilationMessage);
+        __log.debug(compilationMessage.toString());
+    }
+    
+    public abstract void runTest(String bpel) throws Exception;
+    
+    @Before
+    public void setUp() throws Exception {
+        _compiler = BpelC.newBpelCompiler();
+        _compiler.setCompileListener(this);
+        _compiler.setOutputStream(new ByteArrayOutputStream(StreamUtils.DEFAULT_BUFFER_SIZE));
+        _errors.clear();
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        _compiler = null;
+        _errors.clear();
+    }
+    
+}

Modified: ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java?rev=955735&r1=955734&r2=955735&view=diff
==============================================================================
--- ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java (original)
+++ ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java Thu Jun 17 20:45:57 2010
@@ -16,67 +16,267 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.ode.bpel.compiler_2_0;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
 
-/**
- * A series of BPEL 2.0  compilation test.
- */
-public class GoodCompileTest extends TestCase {
+import org.apache.ode.bpel.compiler.api.CompileListener;
+import org.junit.Assert;
+import org.junit.Test;
 
-    public static Test suite() throws Exception {
-        TestSuite suite = new TestSuite();
-        suite.addTest(new GoodCompileTCase("/2.0/good/assign/Assign1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/assign/Assign2-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/assign/Assign3-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/assign/Assign5-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/assign/Assign6-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/assign/Assign7-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/assign/Assign8-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/assign/Assign9-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/AsyncProcess/AsyncProcess2.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/compensation/comp1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/compensation/comp2-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/flow/flow2-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/flow/flow3-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/flow/flow4-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/flow/flow5-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/flow/flow6-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/flow/flow7-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/if/If1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/if/If2-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/if/If3-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/pick/Pick3-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/pick/Pick4-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/pick/Pick5-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/pick/Pick6-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/rethrow/Rethrow1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/rethrow/Rethrow2-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/throw/Throw1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/throw/Throw2-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/throw/Throw3-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/throw/Throw4-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/throw/Throw5-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/throw/Throw6-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/throw/Throw7-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/wait/Wait1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/wait/Wait2-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/while/While1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath10-func/GetVariableData1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath10-func/GetVariableData2-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath10-func/GetVariableData3-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath10-func/GetVariableData4-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath10-func/GetVariableProperty1-2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath20-func/GetVariableData2-xp2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath20-func/GetVariableData3-xp2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath20-func/GetVariableData4-xp2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xpath20-func/GetVariableProperty1-xp2.0.bpel"));
-        suite.addTest(new GoodCompileTCase("/2.0/good/xsd-import/helloworld-Server.bpel"));
 
-        return suite;
+public class GoodCompileTest extends AbstractCompileTestCase implements CompileListener {
+           
+    public void runTest(String bpel) throws Exception {
+        try {
+            Class testClass = getClass();
+            URL url = testClass.getResource(bpel);
+            URI uri = url.toURI();
+            String path = uri.getPath();
+            File bpelFile = new File(path);
+            _compiler.compile(bpelFile, 0);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            Assert.fail("Compilation did not succeed.");
+        }
+    }
+    
+    @Test
+    public void testAssign1_BPEL20() throws Exception {
+        runTest("/2.0/good/assign/Assign1-2.0.bpel");
+    }
+
+    @Test
+    public void testAssign2_BPEL20() throws Exception {
+        runTest("/2.0/good/assign/Assign2-2.0.bpel");
+    }
+    
+    @Test
+    public void testAssign3_BPEL20() throws Exception {
+        runTest("/2.0/good/assign/Assign3-2.0.bpel");
+    }
+    
+    @Test
+    public void testAssign5_BPEL20() throws Exception {
+        runTest("/2.0/good/assign/Assign5-2.0.bpel");
     }
 
+    @Test
+    public void testAssign6_BPEL20() throws Exception {
+        runTest("/2.0/good/assign/Assign6-2.0.bpel");
+    }
+    
+    @Test
+    public void testAssign7_BPEL20() throws Exception {
+        runTest("/2.0/good/assign/Assign7-2.0.bpel");
+    }
+    
+    @Test
+    public void testAssign8_BPEL20() throws Exception {
+        runTest("/2.0/good/assign/Assign8-2.0.bpel");
+    }
+    
+    @Test
+    public void testAssign9_BPEL20() throws Exception {
+        runTest("/2.0/good/assign/Assign9-2.0.bpel");
+    }
+    
+    @Test
+    public void testAsyncProcess() throws Exception {
+        runTest("/2.0/good/AsyncProcess/AsyncProcess2.bpel");
+    }
+    
+    @Test
+    public void testCompensation1() throws Exception {
+        runTest("/2.0/good/compensation/comp1-2.0.bpel");
+    }
+    
+    @Test
+    public void testCompensation2() throws Exception {
+        runTest("/2.0/good/compensation/comp2-2.0.bpel");
+    }
+    
+    @Test
+    public void testFlow2() throws Exception {
+        runTest("/2.0/good/flow/flow2-2.0.bpel");
+    }
+    
+    @Test
+    public void testFlow3() throws Exception {
+        runTest("/2.0/good/flow/flow3-2.0.bpel");
+    }
+    
+    @Test
+    public void testFlow4() throws Exception {
+        runTest("/2.0/good/flow/flow4-2.0.bpel");
+    }
+    
+    @Test
+    public void testFlow5() throws Exception {
+        runTest("/2.0/good/flow/flow5-2.0.bpel");
+    }
+    
+    @Test
+    public void testFlow6() throws Exception {
+        runTest("/2.0/good/flow/flow6-2.0.bpel");
+    }
+    
+    @Test
+    public void testFlow7() throws Exception {
+        runTest("/2.0/good/flow/flow7-2.0.bpel");
+    }
+    
+    @Test
+    public void testIf1() throws Exception {
+        runTest("/2.0/good/if/If1-2.0.bpel");
+    }
+    
+    @Test
+    public void testIf2() throws Exception {
+        runTest("/2.0/good/if/If2-2.0.bpel");
+    }
+    
+    @Test
+    public void testIf3() throws Exception {
+        runTest("/2.0/good/if/If3-2.0.bpel");
+    }
+    
+    @Test
+    public void testPick3() throws Exception {
+        runTest("/2.0/good/pick/Pick3-2.0.bpel");
+    }
+    
+    @Test
+    public void testPick4() throws Exception {
+        runTest("/2.0/good/pick/Pick4-2.0.bpel");
+    }
+    
+    @Test
+    public void testPick5() throws Exception {
+        runTest("/2.0/good/pick/Pick5-2.0.bpel");
+    }
+    
+    @Test
+    public void testPick6() throws Exception {
+        runTest("/2.0/good/pick/Pick6-2.0.bpel");
+    }
+    
+    @Test
+    public void testRethrow1() throws Exception {
+        runTest("/2.0/good/rethrow/Rethrow1-2.0.bpel");
+    }
+    
+    @Test
+    public void testRethrow2() throws Exception {
+        runTest("/2.0/good/rethrow/Rethrow2-2.0.bpel");
+    }
+    
+    @Test
+    public void testThrow1() throws Exception {
+        runTest("/2.0/good/throw/Throw1-2.0.bpel");
+    }
+
+    @Test
+    public void testThrow2() throws Exception {
+        runTest("/2.0/good/throw/Throw2-2.0.bpel");
+    }
+    
+    @Test
+    public void testThrow3() throws Exception {
+        runTest("/2.0/good/throw/Throw3-2.0.bpel");
+    }
+    
+    @Test
+    public void testThrow4() throws Exception {
+        runTest("/2.0/good/throw/Throw4-2.0.bpel");
+    }
+    
+    @Test
+    public void testThrow5() throws Exception {
+        runTest("/2.0/good/throw/Throw5-2.0.bpel");
+    }
+    
+    @Test
+    public void testThrow6() throws Exception {
+        runTest("/2.0/good/throw/Throw6-2.0.bpel");
+    }
+    
+    @Test
+    public void testThrow7() throws Exception {
+        runTest("/2.0/good/throw/Throw7-2.0.bpel");
+    }
+    
+    @Test
+    public void testWait1() throws Exception {
+        runTest("/2.0/good/wait/Wait1-2.0.bpel");
+    }
+    
+    @Test
+    public void testWait2() throws Exception {
+        runTest("/2.0/good/wait/Wait2-2.0.bpel");
+    }
+    
+    @Test
+    public void testWhile() throws Exception {
+        runTest("/2.0/good/while/While1-2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath10GetVariableData1() throws Exception {
+        runTest("/2.0/good/xpath10-func/GetVariableData1-2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath10GetVariableData2() throws Exception {
+        runTest("/2.0/good/xpath10-func/GetVariableData2-2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath10GetVariableData3() throws Exception {
+        runTest("/2.0/good/xpath10-func/GetVariableData3-2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath10GetVariableData4() throws Exception {
+        runTest("/2.0/good/xpath10-func/GetVariableData4-2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath10GetVariableProperty1() throws Exception {
+        runTest("/2.0/good/xpath10-func/GetVariableProperty1-2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath20GetVariableData2() throws Exception {
+        runTest("/2.0/good/xpath20-func/GetVariableData2-xp2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath20GetVariableData3() throws Exception {
+        runTest("/2.0/good/xpath20-func/GetVariableData3-xp2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath20GetVariableData4() throws Exception {
+        runTest("/2.0/good/xpath20-func/GetVariableData4-xp2.0.bpel");
+    }
+    
+    @Test
+    public void testXPath20GetVariableProperty1() throws Exception {
+        runTest("/2.0/good/xpath20-func/GetVariableProperty1-xp2.0.bpel");
+    }
+    
+    @Test
+    public void testXSDImport() throws Exception {
+        runTest("/2.0/good/xsd-import/helloworld-Server.bpel");
+    }
+    
+    @Test
+    public void testCircularReference() throws Exception {
+        runTest("/2.0/good/circularReference/CircularReference.bpel");
+    }
+    
 }

Modified: ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java
URL: http://svn.apache.org/viewvc/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java?rev=955735&r1=955734&r2=955735&view=diff
==============================================================================
--- ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java (original)
+++ ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java Thu Jun 17 20:45:57 2010
@@ -85,9 +85,15 @@ public class CapturingXMLEntityResolver 
     }
 
     try {
-      URI systemId = new URI(
-          FileUtils.encodePath(resourceIdentifier.getLiteralSystemId() == null ? resourceIdentifier
-              .getNamespace() : resourceIdentifier.getLiteralSystemId()));
+
+      String identifier = null;
+      if (resourceIdentifier.getNamespace() == null) {
+          identifier = resourceIdentifier.getLiteralSystemId();
+      } else {
+          identifier = resourceIdentifier.getNamespace();
+      }
+      
+      URI systemId = new URI(FileUtils.encodePath(identifier));
 
       __log.debug("Captured: "+systemId);
       _capture.put(systemId, data);