You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2021/06/29 22:01:46 UTC

svn commit: r1891149 [3/3] - in /xmlbeans/trunk/src/test/java/compile/scomp/som: checkin/PartialSOMCheckinTest.java common/SomTestBase.java detailed/PartialSOMDetailedTest.java

Modified: xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java?rev=1891149&r1=1891148&r2=1891149&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java (original)
+++ xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java Tue Jun 29 22:01:46 2021
@@ -39,77 +39,54 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
 
-public class SomTestBase extends CompileTestBase
-{
-    public static String casesRootDir = XBEAN_CASE_ROOT+ P + "compile" + P + "som" + P;
-    public static String somOutputRootDir = OUTPUTROOT+ P + "som" + P;
+public class SomTestBase extends CompileTestBase {
+    public static String casesRootDir = XBEAN_CASE_ROOT + P + "compile" + P + "som" + P;
+    public static String somOutputRootDir = OUTPUTROOT + P + "som" + P;
     public static long runid;
-    public static PrintWriter outlog = null;
 
     public SchemaTypeSystem builtin;
-    public List errors;
+    public List<XmlError> errors;
     public XmlOptions options;
 
-    public static final String anySimpleType = "anySimpleType";
     public static final String anyType = "anyType";
 
     public static void inspectSOM(SchemaTypeSystem schematypesys,
                                   int expectedGlobalElems,
                                   int expectedGlobalAttrs,
                                   int expectedGlobalTypes,
-                                  int expectedAttrGroups)
-    {
+                                  int expectedAttrGroups) throws IOException {
         // System.outs written to a log file in the build\test\output\som directory, one file per run
         // ex. SOM_INSPECTION_RESULT_1107129259405.txt
 
         File outDir = new File(somOutputRootDir);
-        if (!outDir.exists())
-        {
-            outDir.mkdir();
-        }
+        assertTrue(outDir.exists() || outDir.mkdir());
 
         // check if file exists already
         String logFileName = somOutputRootDir + P + "SOM_INSPECTION_RESULT_" + runid + ".txt";
         File outfile = new File(logFileName);
-        PrintWriter out = null;
 
-        try
-        {
-            // if file exists for this run, append to it
-            if (outfile.exists())
-            {
-                out = new PrintWriter(new FileWriter(outfile, true));
-            }
-            else
-            {
-                if (outfile.createNewFile())
-                {
-                    out = new PrintWriter(new FileWriter(outfile));
-                }
-            }
+        try (PrintWriter out = new PrintWriter(new FileWriter(outfile, true))) {
 
             out.println("\n Call to inspectPSOM .. .. .. ..");
             out.println("\n\n =======================================================");
             out.println("Now Inspecting SOM for STS : " + schematypesys.getName());
             out.println("=======================================================");
             out.println("Input Params : #elems (" + expectedGlobalElems + "), #attr (" + expectedGlobalAttrs
-                    + "), #types (" + expectedGlobalTypes + "), #attr groups (" + expectedAttrGroups + ")");
+                        + "), #types (" + expectedGlobalTypes + "), #attr groups (" + expectedAttrGroups + ")");
             out.println("-------------------------------------------------------");
 
             out.println("New STUFF -------------------------------------------------------");
             schematypesys.resolve();
-            if (schematypesys.isNamespaceDefined("TestNameSpace"))
-            {
+            if (schematypesys.isNamespaceDefined("TestNameSpace")) {
                 out.println("Name Space 'TestNameSpace' for this STS is define ..");
-            }
-            else
-            {
+            } else {
                 out.println("No Name Space 'TestNameSpace' for this STS is NOT ndefine ..");
             }
             out.println("End New STUFF -------------------------------------------------------");
@@ -120,90 +97,75 @@ public class SomTestBase extends Compile
             // # of global attributes
             out.println("----- # Global Attributes :" + schematypesys.globalAttributes().length);
             assertEquals("Incorrect Number of Global Attributes in STS " + schematypesys.getName(), expectedGlobalAttrs, schematypesys.globalAttributes().length);
-            for (int i = 0; i < schematypesys.globalAttributes().length; i++)
-            {
-                out.println("\t------> Attr Name  :" + schematypesys.globalAttributes()[i].getName());
-                out.println("\t------> Attr Type  :" + schematypesys.globalAttributes()[i].getType());
+            for (SchemaGlobalAttribute sga : schematypesys.globalAttributes()) {
+                out.println("\t------> Attr Name  :" + sga.getName());
+                out.println("\t------> Attr Type  :" + sga.getType());
             }
 
             // # of global elements
             out.println("----- # Global Elements :" + schematypesys.globalElements().length);
             assertEquals("Incorrect Number of Global Elements in STS " + schematypesys.getName(), expectedGlobalElems, schematypesys.globalElements().length);
-            for (int i = 0; i < schematypesys.globalElements().length; i++)
-            {
-                out.println("\t------> Elem Name :" + schematypesys.globalElements()[i].getName());
-                out.println("\t------> Elem Type :" + schematypesys.globalElements()[i].getType());
+            for (SchemaGlobalElement sge : schematypesys.globalElements()) {
+                out.println("\t------> Elem Name :" + sge.getName());
+                out.println("\t------> Elem Type :" + sge.getType());
             }
 
             // # of global Types
             out.println("----- # Global Types :" + schematypesys.globalTypes().length);
             assertEquals("Incorrect Number of Global Types in STS " + schematypesys.getName(), expectedGlobalTypes, schematypesys.globalTypes().length);
-            for (int i = 0; i < schematypesys.globalTypes().length; i++)
-            {
-                out.println("\t------> TypeName:" + schematypesys.globalTypes()[i].getName());
+            for (SchemaType st : schematypesys.globalTypes()) {
+                out.println("\t------> TypeName:" + st.getName());
             }
 
             // # of attribute Groups
             out.println("----- # of Attribute Groups :" + schematypesys.attributeGroups().length);
             assertEquals("Incorrect Number of Attribute Groups in STS " + schematypesys.getName(), expectedAttrGroups, schematypesys.attributeGroups().length);
-            for (int i = 0; i < schematypesys.attributeGroups().length; i++)
-            {
-                out.println("\t------> Attr Group Name :" + schematypesys.attributeGroups()[i].getName());
-                out.println("\t------> Attr STS   :" + schematypesys.attributeGroups()[i].getTypeSystem());
+            for (SchemaAttributeGroup sag : schematypesys.attributeGroups()) {
+                out.println("\t------> Attr Group Name :" + sag.getName());
+                out.println("\t------> Attr STS   :" + sag.getTypeSystem());
             }
 
             out.println("----- # of Model Groups :" + schematypesys.modelGroups().length);
-            Assert.assertNotNull("Invalid Model Groups Collection returned in STS " + schematypesys.documentTypes());
-            for (int i = 0; i < schematypesys.modelGroups().length; i++)
-            {
-                out.println("\t------> Model Group Name:" + schematypesys.modelGroups()[i].getName());
-                out.println("\t------> Model Group STS :" + schematypesys.modelGroups()[i].getTypeSystem());
+            Assert.assertNotNull("Invalid Model Groups Collection returned in STS ", schematypesys.documentTypes());
+            for (SchemaModelGroup smg : schematypesys.modelGroups()) {
+                out.println("\t------> Model Group Name:" + smg.getName());
+                out.println("\t------> Model Group STS :" + smg.getTypeSystem());
             }
 
             out.println("----- # of Schema Annotations :" + schematypesys.annotations().length);
-            Assert.assertNotNull("Invalid Annotations Collection returned in STS " + schematypesys.annotations());
-            for (int i = 0; i < schematypesys.annotations().length; i++)
-            {
-                out.println("\t------> Annotation Application Info Array :" + schematypesys.annotations()[i].getApplicationInformation().toString());
-                out.println("\t------> Annotation User Info Array :" + schematypesys.annotations()[i].getUserInformation().toString());
+            Assert.assertNotNull("Invalid Annotations Collection returned in STS ", schematypesys.annotations());
+            for (SchemaAnnotation sa : schematypesys.annotations()) {
+                out.println("\t------> Annotation Application Info Array :" + Arrays.toString(sa.getApplicationInformation()));
+                out.println("\t------> Annotation User Info Array :" + Arrays.toString(sa.getUserInformation()));
             }
 
             out.println("----- # of Attribute Types :" + schematypesys.attributeTypes().length);
-            Assert.assertNotNull("Invalid Attribute Types Collection returned in STS " + schematypesys.attributeTypes());
+            Assert.assertNotNull("Invalid Attribute Types Collection returned in STS ", schematypesys.attributeTypes());
 
-            for (int i = 0; i < schematypesys.attributeTypes().length; i++)
-            {
-                out.println("\t------> Attr Type Name :" + schematypesys.attributeTypes()[i].getName());
-                out.println("\t------> Attr STS :" + schematypesys.attributeTypes()[i].getTypeSystem());
+            for (SchemaType st : schematypesys.attributeTypes()) {
+                out.println("\t------> Attr Type Name :" + st.getName());
+                out.println("\t------> Attr STS :" + st.getTypeSystem());
             }
 
             out.println("----- # of Document Types :" + schematypesys.documentTypes().length);
-            Assert.assertNotNull("Invalid Document Types Collection returned in STS " + schematypesys.documentTypes());
-            for (int i = 0; i < schematypesys.documentTypes().length; i++)
-            {
-                out.println("\t------> Doc Type Name :" + schematypesys.documentTypes()[i].getName());
-                out.println("\t------> Doc Type STS  :" + schematypesys.documentTypes()[i].getTypeSystem());
+            Assert.assertNotNull("Invalid Document Types Collection returned in STS ", schematypesys.documentTypes());
+            for (SchemaType st : schematypesys.documentTypes()) {
+                out.println("\t------> Doc Type Name :" + st.getName());
+                out.println("\t------> Doc Type STS  :" + st.getTypeSystem());
             }
 
             // walk through the Schema Types of this STS in detail
             out.println("\t=======================================================");
             out.println("\tWalking thro Global Schema TYpes for STS : " + schematypesys.getName());
             out.println("\t=======================================================");
-            SchemaType[] schematypes = schematypesys.globalTypes();
-            for (int i = 0; i < schematypes.length; i++)
-            {
-                SchemaType schema = schematypes[i];
-
+            for (SchemaType schema : schematypesys.globalTypes()) {
                 out.println("\n\t Schema Type :" + schema.getName());
                 out.println("\t=======================================================");
 
                 out.println("\t----Acessing New Schema Type ......");
-                if (schema.isCompiled())
-                {
+                if (schema.isCompiled()) {
                     out.println("\t----This Schema has been successfully compiled");
-                }
-                else
-                {
+                } else {
                     out.println("\t----This Schema has NOT compiled successfully yet");
                 }
 
@@ -221,18 +183,14 @@ public class SomTestBase extends Compile
                 out.println("\t Elements & Attributes for Schema Type :" + schema.getName());
                 out.println("\t=======================================================");
                 SchemaProperty[] spropsArr = schema.getProperties();
-                for (int j = 0; j < spropsArr.length; j++)
-                {
-                    SchemaProperty schemaProperty = spropsArr[j];
+                for (SchemaProperty schemaProperty : spropsArr) {
                     out.println("\t:::-> Each prop name : " + schemaProperty.getName());
                 }
                 out.println("\t=======================================================");
 
                 // other api's to look for
                 SchemaProperty[] sderviedpropArr = schema.getDerivedProperties();
-                for (int j = 0; j < sderviedpropArr.length; j++)
-                {
-                    SchemaProperty schemaProperty = sderviedpropArr[j];
+                for (SchemaProperty schemaProperty : sderviedpropArr) {
                     out.println("\t+++-> Each derived prop name : " + schemaProperty.getName());
                 }
 
@@ -243,76 +201,39 @@ public class SomTestBase extends Compile
             out.println("-------------------------------------------------------");
 
             out.println("Output for SchemaTypeSystem " + schematypesys.getName());
-            out.close();
-
-        } // end of try
-        catch (IOException ioe)
-        {
-            System.out.println(ioe.getMessage());
-            ioe.printStackTrace();
         }
-
-
     }
 
     public boolean lookForAttributeInSTS(SchemaTypeSystem tgtSTS,
-                                         String sAttrLocalName)
-    {
+                                         String sAttrLocalName) {
         // The QName for the find is constructed using the local name since the schemas have no namespace
         SchemaGlobalAttribute sga = tgtSTS.findAttribute(new QName(sAttrLocalName));
-        if (sga == null)
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
+        return sga != null;
     }
 
     public boolean lookForElemInSTS(SchemaTypeSystem tgtSTS,
-                                    String sElemLocalName)
-    {
+                                    String sElemLocalName) {
         // The QName for the find is constructed using the local name since the schemas have no namespace
         SchemaGlobalElement sge = tgtSTS.findElement(new QName(sElemLocalName));
 
-        if (sge == null)
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
+        return sge != null;
     }
 
     public boolean lookForIdentityConstraint(SchemaTypeSystem sts,
-                                             String ConstraintLocalName)
-    {
+                                             String ConstraintLocalName) {
 
         SchemaIdentityConstraint.Ref icref = sts.findIdentityConstraintRef(new QName(ConstraintLocalName));
-        if (icref == null)
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
+        return icref != null;
     }
 
-    public boolean checkPSOMSave(SchemaTypeSystem tgtSTS)
-    {
+    public boolean checkPSOMSave(SchemaTypeSystem tgtSTS) {
         String outDirName = tgtSTS.getName().split("org.apache.xmlbeans.metadata.system.")[1];
         String outDirNameWithPath = somOutputRootDir + P + runid + P + outDirName;
 
         // call the save
-        try
-        {
+        try {
             tgtSTS.saveToDirectory(new File(outDirNameWithPath));
-        }
-        catch (IllegalStateException ise)
-        {
+        } catch (IllegalStateException ise) {
             // uncomment to see the stack trace
             // ise.printStackTrace();
             return false;
@@ -321,126 +242,73 @@ public class SomTestBase extends Compile
 
     }
 
-    public boolean compareSavedSOMs(String outDirSchemaOne, String outDirSchemaTwo)
-    {
+    public boolean compareSavedSOMs(String outDirSchemaOne, String outDirSchemaTwo) {
         System.out.println("Comparing Schemas....");
 
         String runDir = somOutputRootDir + P + runid + P;
         File sts1 = new File(somOutputRootDir + P + runid + P + outDirSchemaOne);
-        if (!sts1.exists() && (!sts1.isDirectory()))
-        {
+        if (!sts1.exists() && (!sts1.isDirectory())) {
             System.out.println("Schema Type System save dir specified (" + runDir + outDirSchemaOne + ") does not exist!");
             return false;
         }
 
         File sts2 = new File(somOutputRootDir + P + runid + P + outDirSchemaTwo);
-        if (!sts2.exists() && (!sts2.isDirectory()))
-        {
+        if (!sts2.exists() && (!sts2.isDirectory())) {
             System.out.println("Schema Type System save dir specified (" + runDir + outDirSchemaTwo + ") does not exist!");
             return false;
         }
 
-        List diff = new ArrayList();
+        List<String> diff = new ArrayList<>();
         Diff.filesAsXsb(sts1, sts2, diff);
-        if (diff.isEmpty())
-        {
+        if (diff.isEmpty()) {
             return true;
-        }
-        else
-        {
-            for (Iterator itr = diff.iterator(); itr.hasNext();)
-            {
-                System.out.println("Difference found : " + itr.next());
+        } else {
+            for (Object o : diff) {
+                System.out.println("Difference found : " + o);
             }
             return false;
         }
     }
 
-    public boolean printRecoveredErrors()
-    {
+    public boolean printRecoveredErrors() {
         // check list of errors and print them
         boolean errFound = false;
-        if (!errors.isEmpty())
-        {
-            for (Iterator i = errors.iterator(); i.hasNext();)
-            {
-                XmlError eacherr = (XmlError) i.next();
-                int errSeverity = eacherr.getSeverity();
-                if (errSeverity == XmlError.SEVERITY_ERROR)
-                {
-                    System.out.println("Schema invalid: partial schema type system recovered");
-                    System.out.println("Err Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
-                    errFound = true;
-                }
-                else if (errSeverity == XmlError.SEVERITY_WARNING)
-                {
-                    System.out.println("Warning Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
-                }
-                else if (errSeverity == XmlError.SEVERITY_INFO)
-                {
-                    System.out.println("Info Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
-                }
+        for (XmlError eacherr : errors) {
+            int errSeverity = eacherr.getSeverity();
+            if (errSeverity == XmlError.SEVERITY_ERROR) {
+                System.out.println("Schema invalid: partial schema type system recovered");
+                System.out.println("Err Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
+                errFound = true;
+            } else if (errSeverity == XmlError.SEVERITY_WARNING) {
+                System.out.println("Warning Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
+            } else if (errSeverity == XmlError.SEVERITY_INFO) {
+                System.out.println("Info Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
             }
-            errors.clear();
         }
+        errors.clear();
         return errFound;
     }
 
-    public boolean validateInstance(File instancefile,
-                                    SchemaTypeSystem sts)
-    {
-        try
-        {
-            XmlObject instancedoc = sts.parse(instancefile, null, null);
-
-            XmlOptions instanceValOptions = new XmlOptions();
-            ArrayList errList = new ArrayList();
-            instanceValOptions.setErrorListener(errList);
-
-            if (!instancedoc.validate(instanceValOptions))
-            {
-                if (!errList.isEmpty())
-                {
-                    for (Iterator it = errList.iterator(); it.hasNext();)
-                    {
-                        System.out.println("Instance Validation Error(s) : " + it.next());
-                    }
-                }
-                //Assert.fail("Validation against instance failed");
-                return false;
-            }
-        }
-        catch (IOException ioe)
-        {
-            ioe.getMessage();
-            ioe.printStackTrace();
-            fail("IOException throw when accessing instance xml file " + instancefile.getAbsoluteFile());
-        }
-        catch (XmlException xme)
-        {
-            System.out.println("Instance Validation Errors .. .. ..");
-            if (xme.getErrors().isEmpty())
-            {
-                System.out.println(xme.getMessage());
-            }
-            else
-            {
-                for (Iterator itr = xme.getErrors().iterator(); itr.hasNext();)
-                {
-                    System.out.println(itr.next());
-                }
-            }
-            System.out.println("END Instance Validation Errors .. .. ..");
-            fail("Instance Validation - Xml Exception caught");
-        }
 
-        // validation successful
-        return true;
 
+    public boolean validateInstance(File instancefile, SchemaTypeSystem sts) throws IOException, XmlException {
+        return validateInstance(instancefile, sts, new ArrayList<>());
+    }
+
+    public boolean validateInstance(File instancefile, SchemaTypeSystem sts, List<XmlError> errList) throws IOException, XmlException {
+        XmlOptions loadOpt = new XmlOptions();
+        loadOpt.setLoadLineNumbers();
+        XmlObject instancedoc = sts.parse(instancefile, null, loadOpt);
+
+        errList.clear();
+        XmlOptions instanceValOptions = new XmlOptions();
+        instanceValOptions.setErrorListener(errList);
+        instanceValOptions.setLoadLineNumbers();
+
+        return instancedoc.validate(instanceValOptions);
     }
 
-    public File getTestCaseFile(String sFileName)
-    {
+    public File getTestCaseFile(String sFileName) {
         String sFileWithPath = casesRootDir + P + sFileName;
         //System.out.println("getTestCaseFile() Opening File : " + sFileWithPath);
         File schemaFile = new File(sFileWithPath);
@@ -450,145 +318,61 @@ public class SomTestBase extends Compile
 
     // returns the Local Part of the type QName for the specified Elem
     public String getElementType(SchemaTypeSystem sts,
-                                 String sElementLocalName)
-    {
+                                 String sElementLocalName) {
 
         SchemaGlobalElement elem = sts.findElement(new QName(sElementLocalName));
-        if (elem != null)
-        {
+        if (elem != null) {
             return elem.getType().getName().getLocalPart();
         }
         return "ElemNotFound";
     }
 
     public boolean getAttributeGroup(SchemaTypeSystem sts,
-                                     String sAttrGrpLocalName)
-    {
+                                     String sAttrGrpLocalName) {
         SchemaAttributeGroup attrGp = sts.findAttributeGroup(new QName(sAttrGrpLocalName));
-        if (attrGp == null)
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
+        return attrGp != null;
     }
 
     public boolean getModelGroup(SchemaTypeSystem sts,
-                                 String sModelGrpLocalName)
-    {
+                                 String sModelGrpLocalName) {
         SchemaModelGroup.Ref modelGp = sts.findModelGroupRef(new QName(sModelGrpLocalName));
-        if (modelGp == null)
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
+        return modelGp != null;
     }
 
     public SchemaTypeSystem createNewSTS(String xsdFileName,
                                          SchemaTypeSystem baseSchema,
-                                         String sSTSName, String sBaseSourceName)
-    {
-        SchemaTypeSystem returnSTS = null;
-        try
-        {
-            File xsdModified = getTestCaseFile(xsdFileName);
-            XmlObject xsdModifiedObj = XmlObject.Factory.parse(xsdModified);
-            System.out.println("Source Name for STS: " + xsdModifiedObj.documentProperties().getSourceName());
-
-            // If null is passed for the basename, the basename is not set. Modified for namespace testcases.
-            // If a source name is specified, deferencing of location for schemaLocation attribute gets messed up.
-            if(sBaseSourceName != null)
-            {
-                xsdModifiedObj.documentProperties().setSourceName(sBaseSourceName);
-            }
-            Assert.assertNotNull("Xml Object creation failed", xsdModifiedObj);
-            XmlObject[] xobjArr = new XmlObject[]{xsdModifiedObj};
-
-            returnSTS = XmlBeans.compileXmlBeans(sSTSName, baseSchema, xobjArr, null, builtin, null, options);
-            Assert.assertNotNull("Schema Type System created is Null.", returnSTS);
-
-            // validate the XmlObject created
-            Assert.assertTrue("Return Value for Validate()", xsdModifiedObj.validate());
-        }
-        catch (XmlException xme)
-        {
-            // even if using "COMPILE_PARTIAL_TYPESYSTEM", compilation will fail if
-            // there are any non-recoverable errors and an XmlException will be thrown
-            System.out.println("Schema invalid, XML Exception thrown : couldn't recover from errors");
-            if (errors.isEmpty())
-            {
-                System.out.println(xme.getMessage());
-            }
-            else
-            {
-                for (Iterator i = errors.iterator(); i.hasNext();)
-                {
-                    System.out.println(i.next());
-                }
-            }
-            fail("Schema invalid, XML Exception thrown : couldn't recover from errors");
-        }
-        catch (IOException ioe)
-        {
-            ioe.getMessage();
-            ioe.printStackTrace();
-        }
-        finally
-        {
-            //printRecoveredErrors();
-            return returnSTS;
-        }
+                                         String sSTSName, String sBaseSourceName) throws IOException, XmlException {
+        File xsdModified = getTestCaseFile(xsdFileName);
+        XmlObject xsdModifiedObj = XmlObject.Factory.parse(xsdModified);
+        System.out.println("Source Name for STS: " + xsdModifiedObj.documentProperties().getSourceName());
+
+        // If null is passed for the basename, the basename is not set. Modified for namespace testcases.
+        // If a source name is specified, deferencing of location for schemaLocation attribute gets messed up.
+        if (sBaseSourceName != null) {
+            xsdModifiedObj.documentProperties().setSourceName(sBaseSourceName);
+        }
+        Assert.assertNotNull("Xml Object creation failed", xsdModifiedObj);
+        XmlObject[] xobjArr = new XmlObject[]{xsdModifiedObj};
+
+        SchemaTypeSystem returnSTS = XmlBeans.compileXmlBeans(sSTSName, baseSchema, xobjArr, null, builtin, null, options);
+        Assert.assertNotNull("Schema Type System created is Null.", returnSTS);
+
+        // validate the XmlObject created
+        assertTrue("Return Value for Validate()", xsdModifiedObj.validate());
+        return returnSTS;
     }
 
     // deletes contents of specified directory, does not delete the specified directory
-    public void deleteDirRecursive(File dirToClean)
-    {
-        if (dirToClean.exists() && dirToClean.isDirectory())
-        {
-            File filesFound [] = dirToClean.listFiles();
-            for (int i = 0; i < filesFound.length; i++)
-            {
-                if (filesFound[i].isDirectory())
-                {
-                    deleteDirRecursive(filesFound[i]);
-                    Assert.assertTrue("Output Directory " + filesFound[i] + " Deletion Failed ", filesFound[i].delete());
-                }
-                else if (filesFound[i].isFile())
-                {
-                    Assert.assertTrue("Output File " + filesFound[i] + " Deletion Failed ", filesFound[i].delete());
+    public void deleteDirRecursive(File dirToClean) {
+        if (dirToClean.exists() && dirToClean.isDirectory()) {
+            for (File file : Objects.requireNonNull(dirToClean.listFiles())) {
+                if (file.isDirectory()) {
+                    deleteDirRecursive(file);
+                    assertTrue("Output Directory " + file + " Deletion Failed ", file.delete());
+                } else if (file.isFile()) {
+                    assertTrue("Output File " + file + " Deletion Failed ", file.delete());
                 }
             }
         }
-
-    }
-
-    public void createRunLogFile()
-    {
-        File logfile = new File(somOutputRootDir + P + "PartialSOMCheckinTest_Run_" + runid + ".log");
-
-
-        try
-        {
-            // if file exists for this run, append to it
-            if (logfile.exists())
-            {
-                outlog = new PrintWriter(new FileWriter(logfile, true));
-            }
-            else
-            {
-                outlog = new PrintWriter(new FileWriter(logfile));
-            }
-        }
-        catch (IOException ioe)
-        {
-            ioe.printStackTrace();
-        }
     }
-
-
 }

Modified: xmlbeans/trunk/src/test/java/compile/scomp/som/detailed/PartialSOMDetailedTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/som/detailed/PartialSOMDetailedTest.java?rev=1891149&r1=1891148&r2=1891149&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/compile/scomp/som/detailed/PartialSOMDetailedTest.java (original)
+++ xmlbeans/trunk/src/test/java/compile/scomp/som/detailed/PartialSOMDetailedTest.java Tue Jun 29 22:01:46 2021
@@ -17,6 +17,7 @@ package compile.scomp.som.detailed;
 import compile.scomp.som.common.SomTestBase;
 import org.apache.xmlbeans.SchemaTypeSystem;
 import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlOptions;
 import org.junit.After;
 import org.junit.Before;
@@ -24,6 +25,7 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 
@@ -40,7 +42,7 @@ public class PartialSOMDetailedTest exte
 
         // populate the XmlOptions
         if (errors == null) {
-            errors = new ArrayList();
+            errors = new ArrayList<>();
         }
         if (options == null) {
             options = (new XmlOptions()).setErrorListener(errors);
@@ -63,7 +65,7 @@ public class PartialSOMDetailedTest exte
     }
 
     @Test
-    public void testAddDataTypesList() {
+    public void testAddDataTypesList() throws IOException, XmlException {
         System.out.println("Inside test case testAddDataTypesList()");
 
         // Step 1 : create a PSOM from an incomplete/invalid xsd (datatypes.xsd) with unresolved references to various types
@@ -96,7 +98,7 @@ public class PartialSOMDetailedTest exte
     }
 
     @Test
-    public void testDeleteReusableGroups() {
+    public void testDeleteReusableGroups() throws IOException, XmlException {
         System.out.println("Inside test case testDeleteSubstitutionGroups()");
 
         // Step 1: read in a clean XSD groups_added.xsd
@@ -178,7 +180,7 @@ public class PartialSOMDetailedTest exte
     }
 
     @Test
-    public void testModifyDataTypesList() {
+    public void testModifyDataTypesList() throws IOException, XmlException {
         System.out.println("Inside test case testModifyDataTypes()");
 
         // 1. remove one of the constituent types for the union and test to see if union is anySimpleType
@@ -283,7 +285,7 @@ public class PartialSOMDetailedTest exte
     }
 
     @Test
-    public void testDeleteDerivedTypes() {
+    public void testDeleteDerivedTypes() throws IOException, XmlException {
         System.out.println("Inside test case testDeleteDerivedTypes()");
 
         // Step 1: read in a clean XSD derived_types_added.xsd with base and derived types to create a base schema with no unresolved components
@@ -344,7 +346,7 @@ public class PartialSOMDetailedTest exte
     }
 
     @Test
-    public void testModifyReusableGroups() {
+    public void testModifyReusableGroups() throws IOException, XmlException {
         System.out.println("Inside test case testModifyReusableGroups()");
 
         // Step 1: read in a clean XSD groups_added.xsd
@@ -432,7 +434,7 @@ public class PartialSOMDetailedTest exte
     }
 
     @Test
-    public void testModifyDerivedTypes() {
+    public void testModifyDerivedTypes() throws IOException, XmlException {
         System.out.println("Inside test case testModifyDerivedTypes()");
 
         // Step 1: read in a clean XSD derived_types_added.xsd
@@ -529,7 +531,7 @@ public class PartialSOMDetailedTest exte
     }
 
     @Test
-    public void testNameSpacesImportFile() {
+    public void testNameSpacesImportFile() throws IOException, XmlException {
         System.out.println("Inside test case testNameSpacesImportFile()");
 
         // Step 1: read in an xsd that imports from another xsd file providing file name only
@@ -550,7 +552,7 @@ public class PartialSOMDetailedTest exte
     }
 
     @Test
-    public void testNameSpacesWithInclude() {
+    public void testNameSpacesWithInclude() throws IOException, XmlException {
         System.out.println("Inside test case testNameSpacesWithInclude()");
 
         // Step 1: read in an xsd that includes another namespace in xsd file namespaces2.xsd
@@ -578,7 +580,7 @@ public class PartialSOMDetailedTest exte
 
     @Test
     @Ignore
-    public void testNameSpacesImportFileWithPath() {
+    public void testNameSpacesImportFileWithPath() throws IOException, XmlException {
         System.out.println("Inside test case testNameSpacesImportFileWithPath()");
 
         //Step 1: read in an xsd that does not have any imports



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