Author: kiwiwings
Date: Tue Dec 28 20:17:27 2021
New Revision: 1896487

URL: http://svn.apache.org/viewvc?rev=1896487&view=rev
Log:
fix remaining failing tests

Modified:
    
xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/common/SystemCache.java
    
xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
    
xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltDefault.java
    
xmlbeans/branches/gradle-build/src/test/java/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java

Modified: 
xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/common/SystemCache.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/common/SystemCache.java?rev=1896487&r1=1896486&r2=1896487&view=diff
==============================================================================
--- 
xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/common/SystemCache.java
 (original)
+++ 
xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/common/SystemCache.java
 Tue Dec 28 20:17:27 2021
@@ -33,37 +33,7 @@ import java.lang.reflect.InvocationTarge
  * at any time, so use of static variables is discouraged to ensure proper 
cleanup.
  */
 public class SystemCache {
-    private static SystemCache INSTANCE = new SystemCache();
-
-    static {
-        String cacheClass = 
SystemProperties.getProperty("xmlbean.systemcacheimpl");
-        Object impl = null;
-        if (cacheClass != null) {
-            try {
-                impl = 
Class.forName(cacheClass).getDeclaredConstructor().newInstance();
-                if (!(impl instanceof SystemCache)) {
-                    throw new ClassCastException("Value for system property " +
-                                                 "\"xmlbean.systemcacheimpl\" 
points to a class (" + cacheClass +
-                                                 ") which does not derive from 
SystemCache");
-                }
-            } catch (ClassNotFoundException cnfe) {
-                throw new RuntimeException("Cache class " + cacheClass +
-                                           " specified by 
\"xmlbean.systemcacheimpl\" was not found.",
-                    cnfe);
-            } catch (InstantiationException | NoSuchMethodException | 
InvocationTargetException ie) {
-                throw new RuntimeException("Could not instantiate class " +
-                                           cacheClass + " as specified by 
\"xmlbean.systemcacheimpl\"." +
-                                           " An empty constructor may be 
missing.", ie);
-            } catch (IllegalAccessException iae) {
-                throw new RuntimeException("Could not instantiate class " +
-                                           cacheClass + " as specified by 
\"xmlbean.systemcacheimpl\"." +
-                                           " A public empty constructor may be 
missing.", iae);
-            }
-        }
-        if (impl != null) {
-            INSTANCE = (SystemCache) impl;
-        }
-    }
+    private static SystemCache INSTANCE = initCache();
 
     public static synchronized void set(SystemCache instance) {
         INSTANCE = instance;
@@ -82,6 +52,7 @@ public class SystemCache {
 
     private ThreadLocal<SoftReference> tl_saxLoaders = new ThreadLocal<>();
 
+
     public void clearThreadLocals() {
         tl_saxLoaders.remove();
     }
@@ -94,4 +65,24 @@ public class SystemCache {
     public void setSaxLoader(Object saxLoader) {
         tl_saxLoaders.set(new SoftReference(saxLoader));
     }
+
+
+    private static SystemCache initCache() {
+        String cacheClass = 
SystemProperties.getProperty("xmlbean.systemcacheimpl");
+        if (cacheClass == null) {
+            return new SystemCache();
+        }
+        String errPrefix = "Could not instantiate class " + cacheClass + " as 
specified by \"xmlbean.systemcacheimpl\". ";
+        try {
+            return (SystemCache) 
Class.forName(cacheClass).getDeclaredConstructor().newInstance();
+        } catch (ClassCastException cce) {
+            throw new ClassCastException(errPrefix + "Class does not derive 
from SystemCache.");
+        } catch (ClassNotFoundException cnfe) {
+            throw new RuntimeException(errPrefix + "Class was not found.", 
cnfe);
+        } catch (InstantiationException | NoSuchMethodException | 
InvocationTargetException ie) {
+            throw new RuntimeException(errPrefix + "An empty constructor may 
be missing.", ie);
+        } catch (IllegalAccessException iae) {
+            throw new RuntimeException(errPrefix + "A public empty constructor 
may be missing.", iae);
+        }
+    }
 }

Modified: 
xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java?rev=1896487&r1=1896486&r2=1896487&view=diff
==============================================================================
--- 
xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
 (original)
+++ 
xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
 Tue Dec 28 20:17:27 2021
@@ -1323,6 +1323,7 @@ public abstract class XmlObjectBase impl
             if (wasNilled) {
                 get_store().invalidate_nil();
             }
+            _flags &= ~(FLAGS_DATED);
         } else {
             _textsource = null;
         }

Modified: 
xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltDefault.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltDefault.java?rev=1896487&r1=1896486&r2=1896487&view=diff
==============================================================================
--- 
xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltDefault.java
 (original)
+++ 
xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltDefault.java
 Tue Dec 28 20:17:27 2021
@@ -49,10 +49,9 @@ public class GlobalEltDefault extends Ba
     //default value is used
     @Test
     public void testIntType() throws Throwable {
-        GlobalEltDefaultIntDocument testDoc
-            = GlobalEltDefaultIntDocument.Factory
-            .newInstance();
+        GlobalEltDefaultIntDocument testDoc = 
GlobalEltDefaultIntDocument.Factory.newInstance();
         assertEquals(0, testDoc.getGlobalEltDefaultInt());
+        testDoc.setGlobalEltDefaultInt(5);
         try {
             assertTrue(testDoc.validate(validateOptions));
         } catch (Throwable t) {

Modified: 
xmlbeans/branches/gradle-build/src/test/java/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java?rev=1896487&r1=1896486&r2=1896487&view=diff
==============================================================================
--- 
xmlbeans/branches/gradle-build/src/test/java/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java
 (original)
+++ 
xmlbeans/branches/gradle-build/src/test/java/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java
 Tue Dec 28 20:17:27 2021
@@ -17,7 +17,6 @@ package xmlcursor.xpath.complex.detailed
 
 import org.apache.xmlbeans.XmlObject;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import xmlcursor.xpath.common.XPathFunctionTest;
 
@@ -100,11 +99,10 @@ public class XPathFunctionTestImpl exten
     }
 
     @Test
-    @Ignore
     public void testExternalFunction() throws Exception {
         String query = "" +
-            "declare function local:toc($book-or-section as element()) as 
element()*;" +
-            " local:toc($book-or-section/section)";
+            "declare function local:toc($book-or-section as element()) as 
element()* { $book-or-section/section }; " +
+            "local:toc(book)";
         String input =
             "<book>\n" +
             "  <title>Data on the Web</title>\n" +
@@ -155,8 +153,7 @@ public class XPathFunctionTestImpl exten
             "  </section>\n" +
             "</book>";
         XmlObject o = XmlObject.Factory.parse(input);
-        XmlObject[] res = o.selectPath(query);
-        assertEquals(1, res.length);
-        assertEquals("", res[0].xmlText());
+        XmlObject[] res = o.execQuery(query);
+        assertEquals(2, res.length);
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to