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 2019/01/18 23:08:48 UTC

svn commit: r1851656 [25/28] - in /xmlbeans/trunk: ./ external/ lib/ resources/ resources/typeimpl/ resources/typeimpl/org/ resources/typeimpl/org/apache/ resources/typeimpl/org/apache/xmlbeans/ resources/typeimpl/org/apache/xmlbeans/impl/ resources/ty...

Modified: xmlbeans/trunk/test/src/xmlobject/checkin/NameworldTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/checkin/NameworldTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/checkin/NameworldTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/checkin/NameworldTest.java Fri Jan 18 23:08:44 2019
@@ -15,43 +15,29 @@
 
 package xmlobject.checkin;
 
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
+import org.openuri.nameworld.Loc;
 import org.openuri.nameworld.NameworldDocument;
 import org.openuri.nameworld.NameworldDocument.Nameworld;
-import org.openuri.nameworld.Loc;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlObject;
-
-import java.io.File;
+import tools.util.JarUtil;
 
 import javax.xml.namespace.QName;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-
-import tools.util.*;
-
+import static org.junit.Assert.assertEquals;
 
-public class NameworldTest extends TestCase
-{
-    public NameworldTest(String name) { super(name); }
-    public static Test suite() { return new TestSuite(NameworldTest.class); }
 
-    public static void testWorld1() throws Exception
-    {
+public class NameworldTest {
+    @Test
+    public void testWorld1() throws Exception {
         NameworldDocument doc = (NameworldDocument)
-                    XmlObject.Factory.parse(
-                                    JarUtil.getResourceFromJarasFile(
-                                            "xbean/xmlobject/nameworld.xml"));
+            XmlObject.Factory.parse(
+                JarUtil.getResourceFromJarasFile(
+                    "xbean/xmlobject/nameworld.xml"));
 
-        Assert.assertEquals(new QName("http://openuri.org/nameworld", "nameworld"), doc.schemaType().getDocumentElementName());
+        assertEquals(new QName("http://openuri.org/nameworld", "nameworld"), doc.schemaType().getDocumentElementName());
 
-        QName[] contents = new QName[]
-        {
+        QName[] contents = {
             new QName("http://bar.com/", "barcity"),
             new QName("http://foo.com/", "footown"),
             new QName("http://bar.com/", "barvillage"),
@@ -69,50 +55,14 @@ public class NameworldTest extends TestC
 
         Nameworld world = doc.getNameworld();
         Nameworld.Island[] islands = world.getIslandArray();
-        for (int i = 0; i < islands.length; i++)
-        {
+        for (int i = 0; i < islands.length; i++) {
             Loc[] locs = islands[i].getLocationArray();
-            for (int j = 0; j < locs.length; j++)
-            {
+            for (int j = 0; j < locs.length; j++) {
                 Loc.Reference[] refs = locs[j].getReferenceArray();
-                for (int k = 0; k < refs.length; k++)
-                {
-                    Assert.assertEquals(contents[t++], refs[k].getTo());
+                for (int k = 0; k < refs.length; k++) {
+                    assertEquals(contents[t++], refs[k].getTo());
                 }
             }
         }
     }
-
-    /*
-    public static void testAccessByName() throws Exception
-    {
-        NameworldDocument doc = (NameworldDocument)
-                    XmlLoader.Factory.parse(TestEnv.xbeanCase("xbean/xmlobject/nameworld.xml"),
-                    NameworldDocument.type);
-        String[] contents = new String[]
-        {
-            "http://foo.com/",
-            "foocity",
-            "footown",
-            "foovillage",
-            "http://bar.com/",
-            "barcity",
-            "bartown",
-            "barvillage",
-        };
-        int t = 0;
-        Nameworld world = (Nameworld)doc.elementByName(new Name("http://openuri.org/nameworld", "nameworld"), 0);
-        for (int i = 0; i < world.countOfElementByName(new Name("http://openuri.org/nameworld", "island")); i++)
-        {
-            Nameworld.Island island = (Nameworld.Island)world.elementByName(new Name("http://openuri.org/nameworld", "island"), i);
-            Assert.assertEquals(contents[t++], ((SimpleValue)island.attributeByName(new Name("targetNamespace"))).stringValue());
-            for (int j = 0; j < island.countOfElementByName(new Name( "http://openuri.org/nameworld", "location")); j++)
-            {
-                Loc loc = (Loc)island.elementByName(new Name("http://openuri.org/nameworld", "location"), j);
-                Assert.assertEquals(contents[t++], ((SimpleValue)loc.attributeByName(new Name("name"))).stringValue());
-            }
-        }
-    }
-    */
-
 }

Modified: xmlbeans/trunk/test/src/xmlobject/checkin/RedefineTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/checkin/RedefineTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/checkin/RedefineTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/checkin/RedefineTest.java Fri Jan 18 23:08:44 2019
@@ -14,104 +14,55 @@
  */
 package xmlobject.checkin;
 
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.Assert;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.XmlObject;
-
 import org.example.prod.NewSizeDocument;
+import org.junit.Test;
 import org.openuri.versionstest.ElementDocument;
 import org.openuri.versionstest.Type;
 import org.openuri.versionstest.TypeX;
 
-import java.util.List;
 import java.util.ArrayList;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-public class RedefineTest extends TestCase
-{
-    public RedefineTest(String name) { super(name); }
-    public static Test suite() { return new TestSuite(RedefineTest.class); }
-
-    public void testRedefine()
-    {
-        try
-        {
-            String xml = "<newSize xmlns='http://example.org/prod'>7</newSize>";
-            NewSizeDocument nsDoc = NewSizeDocument.Factory.parse(xml);
-
-            boolean valid = nsDoc.validate();
-
-            if (!valid)
-                print(nsDoc);
-
-            Assert.assertTrue(valid);
-
-            Assert.assertTrue(nsDoc.getNewSize()==7);
-
-            nsDoc.setNewSize(20);
+import java.util.List;
 
-            List errors = new ArrayList();
-            XmlOptions options = new XmlOptions();
-            options.setErrorListener(errors);
+import static org.junit.Assert.*;
 
-            valid = nsDoc.validate(options);
+public class RedefineTest {
+    @Test
+    public void testRedefine() throws XmlException {
+        String xml = "<newSize xmlns='http://example.org/prod'>7</newSize>";
+        NewSizeDocument nsDoc = NewSizeDocument.Factory.parse(xml);
 
-            if (valid || errors.size()!=1)
-                print(nsDoc);
+        boolean valid = nsDoc.validate();
 
-            Assert.assertTrue(!valid);
+        assertTrue(valid);
 
-            Assert.assertTrue(errors.size()==1);
-        }
-        catch (XmlException e)
-        {
-            StringWriter w = new StringWriter();
-            e.printStackTrace(new PrintWriter(w));
-            Assert.fail(w.toString());
-        }
-    }
+        assertEquals(7, nsDoc.getNewSize());
 
-    public void testMultipleRedefine()
-    {
-        try
-        {
-            String xml = "<v:element xmlns:v='http://openuri.org/versionstest'>" +
-                "<aa>AA</aa><a>A</a><b>B</b><c>C</c>" + "</v:element>";
-            ElementDocument doc = ElementDocument.Factory.parse(xml);
-            TypeX tx = doc.getElement();
-
-            Assert.assertTrue(tx.validate());
-            Assert.assertEquals("A", tx.getA());
-            Assert.assertEquals("B", tx.getB());
-            Assert.assertEquals("C", tx.getC());
-            Assert.assertEquals("AA", ((Type) tx).getAa());
-        }
-        catch (XmlException e)
-        {
-            StringWriter w = new StringWriter();
-            e.printStackTrace(new PrintWriter(w));
-            Assert.fail(w.toString());
-        }
-    }
+        nsDoc.setNewSize(20);
 
-    private static void print(XmlObject xo)
-    {
         List errors = new ArrayList();
         XmlOptions options = new XmlOptions();
         options.setErrorListener(errors);
 
-        System.out.println("Doc:\n" + xo + "\nValid: " + xo.validate(options));
+        valid = nsDoc.validate(options);
+
+        assertFalse(valid);
+
+        assertEquals(1, errors.size());
+    }
 
-        for (int i = 0; i < errors.size(); i++)
-        {
-            XmlError xmlError = (XmlError) errors.get(i);
-            System.out.println(xmlError);
-        }
+    @Test
+    public void testMultipleRedefine() throws XmlException {
+        String xml = "<v:element xmlns:v='http://openuri.org/versionstest'>" +
+            "<aa>AA</aa><a>A</a><b>B</b><c>C</c>" + "</v:element>";
+        ElementDocument doc = ElementDocument.Factory.parse(xml);
+        TypeX tx = doc.getElement();
+
+        assertTrue(tx.validate());
+        assertEquals("A", tx.getA());
+        assertEquals("B", tx.getB());
+        assertEquals("C", tx.getC());
+        assertEquals("AA", ((Type) tx).getAa());
     }
 }

Modified: xmlbeans/trunk/test/src/xmlobject/checkin/SelectChldAttTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/checkin/SelectChldAttTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/checkin/SelectChldAttTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/checkin/SelectChldAttTests.java Fri Jan 18 23:08:44 2019
@@ -15,32 +15,23 @@
 
 package xmlobject.checkin;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.TestCase;
-import junit.framework.Assert;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.QNameSet;
-import org.apache.xmlbeans.QNameSetBuilder;
 import org.apache.xml.test.selectChldAtt.DocDocument;
 import org.apache.xml.test.selectChldAtt.TypeExtendedC;
+import org.apache.xmlbeans.*;
+import org.junit.Test;
 
 import javax.xml.namespace.QName;
-import java.util.Collection;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 
-public class SelectChldAttTests extends TestCase
-{
-    public SelectChldAttTests(String name) { super(name); }
-    public static Test suite() { return new TestSuite(SelectChldAttTests.class); }
+import static org.junit.Assert.assertTrue;
 
-    private static final String XSI_URI="http://www.w3.org/2001/XMLSchema-instance";
+public class SelectChldAttTests {
+    private static final String XSI_URI = "http://www.w3.org/2001/XMLSchema-instance";
 
-    public void testSelect() throws XmlException
-    {
+    @Test
+    public void testSelect() throws XmlException {
         String uri = "http://xml.apache.org/test/selectChldAtt";
 
         String xml = "<doc xmlns='" + uri + "'>\n" +
@@ -72,7 +63,7 @@ public class SelectChldAttTests extends
         DocDocument document = DocDocument.Factory.parse(xml);
         DocDocument.Doc doc = document.getDoc();
         Collection errors = new ArrayList();
-        Assert.assertTrue("Valid instance", doc.validate(new XmlOptions().setErrorListener(errors)));
+        assertTrue("Valid instance", doc.validate(new XmlOptions().setErrorListener(errors)));
         printErrors(errors);
 
         XmlObject xo;
@@ -81,31 +72,31 @@ public class SelectChldAttTests extends
         // select a known element
         xos = doc.selectChildren(new QName(uri, "int"));
         //print("1 selectChildren 'int' : ", xos);
-        Assert.assertTrue("1 selectChildren 'int' : ", verifyResult(xos, new String[]{"<xml-fragment>7</xml-fragment>"}));
+        assertTrue("1 selectChildren 'int' : ", verifyResult(xos, new String[]{"<xml-fragment>7</xml-fragment>"}));
 
         xos = doc.selectChildren(uri, "string");
         //print("2 selectChildren 'string' : ", xos);
-        Assert.assertTrue("2 selectChildren 'string' : ", verifyResult(xos, new String[]{"<xml-fragment>... some text ...</xml-fragment>"}));
+        assertTrue("2 selectChildren 'string' : ", verifyResult(xos, new String[]{"<xml-fragment>... some text ...</xml-fragment>"}));
 
         // elemA
         xos = doc.selectChildren(new QName(uri, "elemA"));
         //print("3 selectChildren 'elemA' : ", xos);
-        Assert.assertTrue("3 selectChildren 'elemA' : ",
-            verifyResult(xos, new String[]{"<xml-fragment price=\"4.321\" xmlns:sel=\"" + uri +"\">\n" +
-            "  <sel:topLevelElement>this is wildcard bucket</sel:topLevelElement>\n" +
-            "</xml-fragment>"}));
+        assertTrue("3 selectChildren 'elemA' : ",
+            verifyResult(xos, new String[]{"<xml-fragment price=\"4.321\" xmlns:sel=\"" + uri + "\">\n" +
+                "  <sel:topLevelElement>this is wildcard bucket</sel:topLevelElement>\n" +
+                "</xml-fragment>"}));
 
         // select a known attribute
         xo = xos[0].selectAttribute(new QName("", "price"));
         //print("4     selectAttribute 'price' : ", xo);
-        Assert.assertTrue("4     selectAttribute 'price' : ",
+        assertTrue("4     selectAttribute 'price' : ",
             verifyResult(xo, "<xml-fragment>4.321</xml-fragment>"));
 
         // select all attributes
         QNameSet qns = QNameSet.forWildcardNamespaceString("##any", uri);
         xos = xos[0].selectAttributes(qns);
         //print("5     selectAttributes set'##any' :", xos);
-        Assert.assertTrue("5     selectAttributes set'##any' :",
+        assertTrue("5     selectAttributes set'##any' :",
             verifyResult(xos, new String[]{"<xml-fragment>4.321</xml-fragment>"}));
 
         // elemB
@@ -113,23 +104,23 @@ public class SelectChldAttTests extends
         //print("6 selectChildren 'elemB' : ", xos);
 
         //print("7     selectChildren set'##other' : " , xos[0].selectChildren(QNameSet.forWildcardNamespaceString("##other", uri)));
-        Assert.assertTrue("7     selectChildren set'##other' : ",
-            verifyResult( xos[0].selectChildren(QNameSet.forWildcardNamespaceString("##other", uri))
-            , new String[]{"<xml-fragment xmlns:p=\"uri:other_namespace\">element in #other namespace</xml-fragment>"}));
+        assertTrue("7     selectChildren set'##other' : ",
+            verifyResult(xos[0].selectChildren(QNameSet.forWildcardNamespaceString("##other", uri))
+                , new String[]{"<xml-fragment xmlns:p=\"uri:other_namespace\">element in #other namespace</xml-fragment>"}));
         //print("8     selectAttributes set'##other' : ", xos[0].selectAttributes(QNameSet.forWildcardNamespaceString("##other", uri)));
-        Assert.assertTrue("8     selectAttributes set'##other' : ",
+        assertTrue("8     selectAttributes set'##other' : ",
             verifyResult(xos[0].selectAttributes(QNameSet.forWildcardNamespaceString("##other", uri)),
-            new String[]{"<xml-fragment xmlns:p=\"uri:other_namespace\">attribute in #other namespace</xml-fragment>"}));
+                new String[]{"<xml-fragment xmlns:p=\"uri:other_namespace\">attribute in #other namespace</xml-fragment>"}));
 
         // elemC
         xos = doc.selectChildren(new QName(uri, "elemC"));
         //print("9 selectChildren 'elemC' : ", xos);
         //print("10    selectChildren set'##any' : " , xos[0].selectChildren(QNameSet.forWildcardNamespaceString("##any", uri)));
-        Assert.assertTrue("10    selectChildren set'##any' : ",
+        assertTrue("10    selectChildren set'##any' : ",
             verifyResult(xos[0].selectChildren(QNameSet.forWildcardNamespaceString("##any", uri))
-            , new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element from typeC</xml-fragment>",
-            "<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element in the 'any' bucket for typeExtendedC</xml-fragment>",
-            "<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element from typeExtendedC</xml-fragment>"}));
+                , new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element from typeC</xml-fragment>",
+                    "<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element in the 'any' bucket for typeExtendedC</xml-fragment>",
+                    "<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element from typeExtendedC</xml-fragment>"}));
 
         // select elements in the any bucket by excluding the the known elements
         QNameSetBuilder qnsb = new QNameSetBuilder();
@@ -138,14 +129,14 @@ public class SelectChldAttTests extends
         qnsb.invert();
 
         //print("11a    selectChildren in the any bucket for typeExtendedC: " , xos[0].selectChildren(qnsb.toQNameSet()));
-        Assert.assertTrue("11a    selectChildren in the any bucket for typeExtendedC: ",
+        assertTrue("11a    selectChildren in the any bucket for typeExtendedC: ",
             verifyResult(xos[0].selectChildren(qnsb.toQNameSet()),
-            new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element in the 'any' bucket for typeExtendedC</xml-fragment>"}));
+                new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element in the 'any' bucket for typeExtendedC</xml-fragment>"}));
 
         //print("11b    selectChildren in the any bucket for typeExtendedC: " , xos[0].selectChildren(TypeExtendedC.type.qnameSetForWildcardElements()));
-        Assert.assertTrue("11b    selectChildren in the any bucket for typeExtendedC: ",
+        assertTrue("11b    selectChildren in the any bucket for typeExtendedC: ",
             verifyResult(xos[0].selectChildren(TypeExtendedC.type.qnameSetForWildcardElements()),
-            new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element in the 'any' bucket for typeExtendedC</xml-fragment>"}));
+                new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">element in the 'any' bucket for typeExtendedC</xml-fragment>"}));
 
         // select attributes in the any bucket by excluding the the known attributes
         qnsb = new QNameSetBuilder();
@@ -155,54 +146,35 @@ public class SelectChldAttTests extends
         qnsb.invert();
 
         //print("12a    selectChildren in the any bucket for typeExtendedC: " , xos[0].selectAttributes(qnsb.toQNameSet()));
-        Assert.assertTrue("12a    selectChildren in the any bucket for typeExtendedC: ",
+        assertTrue("12a    selectChildren in the any bucket for typeExtendedC: ",
             verifyResult(xos[0].selectAttributes(qnsb.toQNameSet()),
-            new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">attribute in any bucket</xml-fragment>"}));
+                new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">attribute in any bucket</xml-fragment>"}));
         //print("12b    selectChildren in the any bucket for typeExtendedC: " , xos[0].selectAttributes(TypeExtendedC.type.qnameSetForWildcardAttributes()));
-        Assert.assertTrue("12b    selectChildren in the any bucket for typeExtendedC: ",
+        assertTrue("12b    selectChildren in the any bucket for typeExtendedC: ",
             verifyResult(xos[0].selectAttributes(TypeExtendedC.type.qnameSetForWildcardAttributes()),
-            new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">typeExtendedC</xml-fragment>",
-            "<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">attribute in any bucket</xml-fragment>"}));
-    }
-
-    private static void print(String msg, XmlObject[] xos)
-    {
-        System.out.println(msg + "   " + xos.length);
-        for (int i=0; i<xos.length; i++)
-        {
-            System.out.println("      " + i + " :" + xos[i]);
-        }
+                new String[]{"<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">typeExtendedC</xml-fragment>",
+                    "<xml-fragment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"uri_other_namespace\">attribute in any bucket</xml-fragment>"}));
     }
 
-    private static void print(String msg, XmlObject xo)
-    {
-        System.out.println(msg + "   " + xo);
-    }
-
-    private static void printErrors(Collection errors)
-    {
-        for (Iterator i = errors.iterator(); i.hasNext();)
-        {
+    private static void printErrors(Collection errors) {
+        for (Iterator i = errors.iterator(); i.hasNext(); ) {
             System.out.println("ERROR: " + i.next());
         }
     }
 
-    private static boolean verifyResult(XmlObject[] xos, String[] expected)
-    {
-        if (xos==null && expected==null)
+    private static boolean verifyResult(XmlObject[] xos, String[] expected) {
+        if (xos == null && expected == null)
             return true;
 
-        if (xos==null || expected==null)
+        if (xos == null || expected == null)
             return false;
 
         if (xos.length != expected.length)
             return false;
 
-        for (int i = 0; i < xos.length; i++)
-        {
+        for (int i = 0; i < xos.length; i++) {
             XmlObject xo = xos[i];
-            if (!equalsIgnoreNewLine(xo.toString(),expected[i]))
-            {
+            if (!equalsIgnoreNewLine(xo.toString(), expected[i])) {
                 System.out.println("ERROR:\n    Actual:\n" + xo.toString() + "\n   Expected:\n" + expected[i]);
                 return false;
             }
@@ -210,56 +182,46 @@ public class SelectChldAttTests extends
         return true;
     }
 
-    private static boolean verifyResult(XmlObject xo, String expected)
-    {
-        if (xo==null && expected==null)
+    private static boolean verifyResult(XmlObject xo, String expected) {
+        if (xo == null && expected == null)
             return true;
 
-        if (xo==null || expected==null)
+        if (xo == null || expected == null)
             return false;
 
-        if (!xo.toString().equals(expected))
-        {
+        if (!xo.toString().equals(expected)) {
             System.out.println("ERROR:\n    Actual:\n" + xo.toString() + "\n   Expected:\n" + expected);
             return false;
-        }
-        else
+        } else
             return true;
     }
 
-    private static boolean equalsIgnoreNewLine(String s1, String s2)
-    {
-        if (s1==null && s2==null)
+    private static boolean equalsIgnoreNewLine(String s1, String s2) {
+        if (s1 == null && s2 == null)
             return true;
 
-        if (s1==null || s2==null)
+        if (s1 == null || s2 == null)
             return false;
 
         int i1 = 0, i2 = 0;
-        while (i1<s1.length() || i2<s2.length())
-        {
-            if (s1.charAt(i1)=='\n' || s1.charAt(i1)=='\r')
-            {
+        while (i1 < s1.length() || i2 < s2.length()) {
+            if (s1.charAt(i1) == '\n' || s1.charAt(i1) == '\r') {
                 i1++;
                 continue;
             }
 
-            if (s2.charAt(i2)=='\n' || s2.charAt(i2)=='\r')
-            {
+            if (s2.charAt(i2) == '\n' || s2.charAt(i2) == '\r') {
                 i2++;
                 continue;
             }
 
-            if (s1.charAt(i1)!=s2.charAt(i2))
+            if (s1.charAt(i1) != s2.charAt(i2))
                 return false;
 
             i1++;
             i2++;
         }
 
-        if ( (i1 == s1.length()) && (i2 == s2.length()))
-            return true;
-        else
-            return false;
+        return (i1 == s1.length()) && (i2 == s2.length());
     }
 }

Modified: xmlbeans/trunk/test/src/xmlobject/checkin/SerializationTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/checkin/SerializationTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/checkin/SerializationTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/checkin/SerializationTests.java Fri Jan 18 23:08:44 2019
@@ -16,46 +16,33 @@
 
 package xmlobject.checkin;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.TestCase;
-import junit.framework.Assert;
-import com.easypo.XmlPurchaseOrderDocumentBean.PurchaseOrder;
 import com.easypo.XmlLineItemBean;
-import com.easypo.XmlShipperBean;
 import com.easypo.XmlPurchaseOrderDocumentBean;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.SchemaTypeLoader;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlOptions;
+import com.easypo.XmlPurchaseOrderDocumentBean.PurchaseOrder;
+import com.easypo.XmlShipperBean;
+import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+import org.junit.Test;
 import org.xml.sax.InputSource;
+import tools.util.JarUtil;
 
+import java.io.*;
 import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
-import java.io.File;
-import java.io.Reader;
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
-import tools.util.JarUtil;
-
-public class SerializationTests extends TestCase
-{
-    public SerializationTests (String name) { super(name); }
-    public static Test suite() { return new TestSuite(SerializationTests.class); }
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-    public void testXmlObjectSerialization() throws Exception
-    {
+public class SerializationTests {
+    @Test
+    public void testXmlObjectSerialization() throws Exception {
         String simpleDocument = "<simpleDoc><nestedTag attr=\"sample\">43</nestedTag></simpleDoc>";
         XmlObject doc = XmlObject.Factory.parse(simpleDocument);
 
         // baseline test
-        Assert.assertEquals(simpleDocument, doc.xmlText());
+        assertEquals(simpleDocument, doc.xmlText());
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(out);
@@ -65,14 +52,14 @@ public class SerializationTests extends
         byte[] byteArray = out.toByteArray();
         ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
         ObjectInputStream ois = new ObjectInputStream(in);
-        XmlObject newdoc = (XmlObject)ois.readObject();
+        XmlObject newdoc = (XmlObject) ois.readObject();
         ois.close();
 
-        Assert.assertEquals(simpleDocument, newdoc.xmlText());
+        assertEquals(simpleDocument, newdoc.xmlText());
     }
 
-    public void testXBeanSerialization() throws Exception
-    {
+    @Test
+    public void testXBeanSerialization() throws Exception {
         XmlPurchaseOrderDocumentBean doc = XmlPurchaseOrderDocumentBean.Factory.newInstance();
         PurchaseOrder order = doc.addNewPurchaseOrder();
         order.addNewCustomer().setName("David Bau");
@@ -107,66 +94,59 @@ public class SerializationTests extends
         byte[] byteArray = out.toByteArray();
         ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
         ObjectInputStream ois = new ObjectInputStream(in);
-        XmlLineItemBean newli1 = (XmlLineItemBean)ois.readObject();
-        XmlPurchaseOrderDocumentBean newdoc = (XmlPurchaseOrderDocumentBean)ois.readObject();
-        XmlLineItemBean newli2 = (XmlLineItemBean)ois.readObject();
+        XmlLineItemBean newli1 = (XmlLineItemBean) ois.readObject();
+        XmlPurchaseOrderDocumentBean newdoc = (XmlPurchaseOrderDocumentBean) ois.readObject();
+        XmlLineItemBean newli2 = (XmlLineItemBean) ois.readObject();
         ois.close();
 
         PurchaseOrder neworder = newdoc.getPurchaseOrder();
 
-        Assert.assertEquals(newli1, neworder.getLineItemArray(1));
-        Assert.assertEquals(newli2, neworder.getLineItemArray(2));
+        assertEquals(newli1, neworder.getLineItemArray(1));
+        assertEquals(newli2, neworder.getLineItemArray(2));
 
-        Assert.assertEquals("David Bau", neworder.getCustomer().getName());
-        Assert.assertEquals("Gladwyne, PA", neworder.getCustomer().getAddress());
-        Assert.assertEquals(3, neworder.sizeOfLineItemArray());
-
-        Assert.assertEquals("Burnham's Celestial Handbook, Vol 1", neworder.getLineItemArray(0).getDescription());
-        Assert.assertEquals(new BigDecimal("21.79"), neworder.getLineItemArray(0).getPrice());
-        Assert.assertEquals(new BigInteger("2"), neworder.getLineItemArray(0).getQuantity());
-        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(0).getPerUnitOunces());
-
-        Assert.assertEquals("Burnham's Celestial Handbook, Vol 2", neworder.getLineItemArray(1).getDescription());
-        Assert.assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(1).getPrice());
-        Assert.assertEquals(new BigInteger("2"), neworder.getLineItemArray(1).getQuantity());
-        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(1).getPerUnitOunces());
-
-        Assert.assertEquals("Burnham's Celestial Handbook, Vol 3", neworder.getLineItemArray(2).getDescription());
-        Assert.assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(2).getPrice());
-        Assert.assertEquals(new BigInteger("1"), neworder.getLineItemArray(2).getQuantity());
-        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(2).getPerUnitOunces());
-
-        Assert.assertEquals(true, neworder.isSetShipper());
-        Assert.assertEquals("UPS", neworder.getShipper().getName());
-        Assert.assertEquals(new BigDecimal("0.74"), neworder.getShipper().getPerOunceRate());
+        assertEquals("David Bau", neworder.getCustomer().getName());
+        assertEquals("Gladwyne, PA", neworder.getCustomer().getAddress());
+        assertEquals(3, neworder.sizeOfLineItemArray());
+
+        assertEquals("Burnham's Celestial Handbook, Vol 1", neworder.getLineItemArray(0).getDescription());
+        assertEquals(new BigDecimal("21.79"), neworder.getLineItemArray(0).getPrice());
+        assertEquals(new BigInteger("2"), neworder.getLineItemArray(0).getQuantity());
+        assertEquals(new BigDecimal("5"), neworder.getLineItemArray(0).getPerUnitOunces());
+
+        assertEquals("Burnham's Celestial Handbook, Vol 2", neworder.getLineItemArray(1).getDescription());
+        assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(1).getPrice());
+        assertEquals(new BigInteger("2"), neworder.getLineItemArray(1).getQuantity());
+        assertEquals(new BigDecimal("5"), neworder.getLineItemArray(1).getPerUnitOunces());
+
+        assertEquals("Burnham's Celestial Handbook, Vol 3", neworder.getLineItemArray(2).getDescription());
+        assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(2).getPrice());
+        assertEquals(new BigInteger("1"), neworder.getLineItemArray(2).getQuantity());
+        assertEquals(new BigDecimal("5"), neworder.getLineItemArray(2).getPerUnitOunces());
+
+        assertTrue(neworder.isSetShipper());
+        assertEquals("UPS", neworder.getShipper().getName());
+        assertEquals(new BigDecimal("0.74"), neworder.getShipper().getPerOunceRate());
     }
 
-    public void testWsdlSerialization()
-    {
+    @Test
+    public void testWsdlSerialization() throws IOException, XmlException {
         // test for TextSaver
-        try
-        {
-            File wsdlFile = JarUtil.getResourceFromJarasFile("xbean/xmlobject/wsdl.xml");
-
-            List loaders = new ArrayList();
-            loaders.add(SchemaDocument.type.getTypeSystem());
-            SchemaTypeLoader[] loadersArr = (SchemaTypeLoader[])loaders.toArray(new SchemaTypeLoader[1]);
-            SchemaTypeLoader loader = XmlBeans.typeLoaderUnion(loadersArr);
-
-            XmlOptions options = new XmlOptions();
-            options.setLoadLineNumbers();
-            XmlObject wsdlObj = (XmlObject) loader.parse(wsdlFile, XmlObject.type, options);
-
-            Reader reader = wsdlObj.newReader();
-            InputSource source = new InputSource(reader);
-            source.setSystemId("");
-
-
-            XmlObject wsdlDefinitions = XmlObject.Factory.parse(reader);
-        }
-        catch (Exception e)
-        {
-            throw new RuntimeException(e);
-        }
+        File wsdlFile = JarUtil.getResourceFromJarasFile("xbean/xmlobject/wsdl.xml");
+
+        List<SchemaTypeSystem> loaders = new ArrayList<SchemaTypeSystem>();
+        loaders.add(SchemaDocument.type.getTypeSystem());
+        SchemaTypeLoader[] loadersArr = (SchemaTypeLoader[]) loaders.toArray(new SchemaTypeLoader[1]);
+        SchemaTypeLoader loader = XmlBeans.typeLoaderUnion(loadersArr);
+
+        XmlOptions options = new XmlOptions();
+        options.setLoadLineNumbers();
+        XmlObject wsdlObj = (XmlObject) loader.parse(wsdlFile, XmlObject.type, options);
+
+        Reader reader = wsdlObj.newReader();
+        InputSource source = new InputSource(reader);
+        source.setSystemId("");
+
+
+        XmlObject.Factory.parse(reader);
     }
 }

Modified: xmlbeans/trunk/test/src/xmlobject/checkin/SetTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/checkin/SetTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/checkin/SetTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/checkin/SetTest.java Fri Jan 18 23:08:44 2019
@@ -14,46 +14,25 @@
  */
 package xmlobject.checkin;
 
-import java.util.*;
-
-import junit.framework.*;
-
-import xmlcursor.common.*;
-
-
-import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlCalendar;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlString;
 import org.apache.xmlbeans.XmlDate;
-import org.apache.xmlbeans.XmlCalendar;
-
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlString;
+import org.junit.Test;
 import test.xbean.xmlcursor.purchaseOrder.PurchaseOrderDocument;
 import test.xbean.xmlcursor.purchaseOrder.USAddress;
-
 import tools.util.JarUtil;
+import xmlcursor.common.BasicCursorTestCase;
+import xmlcursor.common.Common;
 
+import java.util.Calendar;
 
-/**
- *
- *
- */
-public class SetTest extends BasicCursorTestCase {
-    public SetTest(String sName) {
-        super(sName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(SetTest.class);
-    }
+import static org.junit.Assert.*;
 
-    public void testClassPath() throws Exception {
-        String sClassPath = System.getProperty("java.class.path");
-        int i = sClassPath.indexOf(Common.CARLOCATIONMESSAGE_JAR);
-        assertTrue(i >= 0);
-        i = sClassPath.indexOf(Common.XMLCURSOR_JAR);
-        assertTrue(i >= 0);
-    }
 
+public class SetTest extends BasicCursorTestCase {
+    @Test
     public void testSetFromSTART() throws Exception {
         m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT);
         m_xc = m_xo.newCursor();
@@ -63,6 +42,7 @@ public class SetTest extends BasicCursor
         assertEquals("newtext", m_xc.getTextValue());
     }
 
+    @Test
     public void testSetFromATTR() throws Exception {
         m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT);
         m_xc = m_xo.newCursor();
@@ -72,6 +52,7 @@ public class SetTest extends BasicCursor
         assertEquals(" new attr text ", m_xc.getTextValue());
     }
 
+    @Test
     public void testSetFromSTARTstronglyTyped() throws Exception {
        PurchaseOrderDocument pod = (PurchaseOrderDocument) XmlObject.Factory.parse(
                 JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
@@ -80,12 +61,13 @@ public class SetTest extends BasicCursor
         assertEquals("new comment text", pod.getPurchaseOrder().getComment());
     }
 
+    @Test
     public void testSetFromATTRstronglyTyped() throws Exception {
         PurchaseOrderDocument pod = (PurchaseOrderDocument) XmlObject.Factory.parse(
                 JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
         XmlDate xorderDate = pod.getPurchaseOrder().xgetOrderDate();
 
-        assertFalse(xorderDate==null);
+        assertNotNull(xorderDate);
 
         Calendar d = new XmlCalendar(new java.util.Date());
         xorderDate.setCalendarValue(d);
@@ -100,33 +82,34 @@ public class SetTest extends BasicCursor
                         Calendar.DAY_OF_MONTH));
     }
 
+    @Test
     public void testSetFromFixedATTR() throws Exception {
 
         PurchaseOrderDocument pod = (PurchaseOrderDocument) XmlObject.Factory.parse(
                 JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
         USAddress usa = pod.getPurchaseOrder().getShipTo();
-         assertFalse(usa==null);
+        assertNotNull(usa);
 
         XmlString xcountry = usa.xgetCountry();
 
         xcountry.setStringValue("UK");
 
-
-        assertEquals(false, pod.validate());
+        assertFalse(pod.validate());
     }
 
+    @Test
     public void testSetFromComplexType() throws Exception {
 
         PurchaseOrderDocument pod = (PurchaseOrderDocument) XmlObject.Factory.parse(
                 JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
         USAddress usa = pod.getPurchaseOrder().getShipTo();
-        assertFalse(usa==null);
+        assertNotNull(usa);
         usa.set(
                 USAddress.Factory.parse(
                         "<shipTo country=\"UK\"><name>Fred</name><street>paved</street><city>town</city><state>AK</state><zip>00000</zip></shipTo>"));
 
         // assertTrue(true);
-        assertEquals(false, pod.validate());
+        assertFalse(pod.validate());
     }
 }
 

Modified: xmlbeans/trunk/test/src/xmlobject/checkin/SubstGroupTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/checkin/SubstGroupTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/checkin/SubstGroupTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/checkin/SubstGroupTests.java Fri Jan 18 23:08:44 2019
@@ -15,26 +15,18 @@
 
 package xmlobject.checkin;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlNormalizedString;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlString;
-import org.apache.xmlbeans.XmlToken;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+import org.junit.Test;
 import org.openuri.sgs.ADocument;
 import org.openuri.sgs.BDocument;
 import org.openuri.sgs.CDocument;
 import org.openuri.sgs.RootDocument;
-import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
 
-public class SubstGroupTests extends TestCase
-{
-    public SubstGroupTests(String name) { super(name); }
-    public static Test suite() { return new TestSuite(SubstGroupTests.class); }
+import static org.junit.Assert.*;
 
+public class SubstGroupTests {
+    @Test
     public void test1() throws Exception {
         String xml1 = "<root xmlns='http://openuri.org/sgs'>" +
             "<A>\ta\ta\t</A>" +
@@ -48,15 +40,15 @@ public class SubstGroupTests extends Tes
         assertTrue(doc1.validate());
 
         XmlString a = root.xgetAArray(0);
-        assertTrue(a.schemaType().equals(XmlString.type));
+        assertEquals(a.schemaType(), XmlString.type);
         assertEquals("\ta\ta\t", a.getStringValue());
 
         XmlString b = root.xgetAArray(1);
-        assertTrue(b.schemaType().equals(XmlNormalizedString.type));
+        assertEquals(b.schemaType(), XmlNormalizedString.type);
         assertEquals(" b b ", b.getStringValue());
 
         XmlString c = root.xgetAArray(2);
-        assertTrue(c.schemaType().equals(XmlToken.type));
+        assertEquals(c.schemaType(), XmlToken.type);
         assertEquals("c c", c.getStringValue());
 
         root.insertA(2, "d d");
@@ -75,18 +67,19 @@ public class SubstGroupTests extends Tes
         // Test array setters
 
         // test m < n case
-        String[] smaller = new String[]{ "x", "y" };
+        String[] smaller = new String[]{"x", "y"};
         root.setAArray(smaller);
         assertEquals(2, root.sizeOfAArray());
         assertEquals("y", root.getAArray(1));
 
         // test m > n case
-        String[] larger = new String[] { "p", "q", "r", "s" };
+        String[] larger = new String[]{"p", "q", "r", "s"};
         root.setAArray(larger);
         assertEquals(4, root.sizeOfAArray());
         assertEquals("r", root.getAArray(2));
     }
 
+    @Test
     public void test2() throws Exception {
         String xml1 = "<A xmlns='http://openuri.org/sgs'>\ta\ta\t</A>";
         String xml2 = "<B xmlns='http://openuri.org/sgs'>\tb\tb\t</B>";
@@ -94,151 +87,143 @@ public class SubstGroupTests extends Tes
 
         ADocument d1 = ADocument.Factory.parse(xml1);
         XmlString a = d1.xgetA();
-        assertTrue(a.schemaType().equals(XmlString.type));
+        assertEquals(a.schemaType(), XmlString.type);
         assertEquals("\ta\ta\t", a.getStringValue());
 
         ADocument d2 = ADocument.Factory.parse(xml2);
         XmlString b = d2.xgetA();
-        assertTrue(d2.schemaType().equals(BDocument.type));
-        assertTrue(b.schemaType().equals(XmlNormalizedString.type));
+        assertEquals(d2.schemaType(), BDocument.type);
+        assertEquals(b.schemaType(), XmlNormalizedString.type);
         assertEquals(" b b ", b.getStringValue());
 
         ADocument d3 = ADocument.Factory.parse(xml3);
         XmlString c = d3.xgetA();
-        assertTrue(d3.schemaType().equals(CDocument.type));
-        assertTrue(c.schemaType().equals(XmlToken.type));
+        assertEquals(d3.schemaType(), CDocument.type);
+        assertEquals(c.schemaType(), XmlToken.type);
         assertEquals("c c", c.getStringValue());
     }
 
-    public static final String[] invalidSchemas = 
-    {
+    private static final String[] invalidSchemas = {
         "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
-        "  <xsd:element name='A' type='xsd:string'/> " +
-        "  <xsd:element name='B' type='xsd:int' substitutionGroup='A'/> " +
-        "</xsd:schema>",
-        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
-        "  <xsd:complexType name='foo'> " +
-        "    <xsd:sequence> " +
-        "      <xsd:element name='bar' substitutionGroup='A'/>" +
-        "    </xsd:sequence> " +
-        "  </xsd:complexType>" +
-        "</xsd:schema>",
-        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
-        "  <xsd:element name='A' type='xsd:string' final='#all'/> " +
-        "  <xsd:element name='B' type='xsd:string' substitutionGroup='A'/> " +
-        "</xsd:schema>",
-        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
-        "  <xsd:element name='A' type='xsd:string' final='restriction'/> " +
-        "  <xsd:element name='B' type='xsd:token' substitutionGroup='A'/> " +
-        "</xsd:schema>",
-        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
-        "  <xsd:element name='A' type='xsd:string' substitutionGroup='B'/> " +
-        "  <xsd:element name='B' type='xsd:string' substitutionGroup='C'/> " +
-        "  <xsd:element name='C' type='xsd:string' substitutionGroup='D'/> " +
-        "  <xsd:element name='D' type='xsd:string' substitutionGroup='E'/> " +
-        "  <xsd:element name='E' type='xsd:string' substitutionGroup='A'/> " +
-        "</xsd:schema>",
-        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
-        "  <xsd:element name='A' type='xsd:token' substitutionGroup='B'/> " +
-        "</xsd:schema>",
-        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
-        "  <xsd:element name='A' type='xsd:string'/> " +
-        "  <xsd:element name='B' type='xsd:string' substitutionGroup='A'/> " +
-        "  <xsd:element name='Complex'> " +
-        "    <xsd:complexType> " +
-        "      <xsd:choice> " +
-        "        <xsd:element ref='A'/>" +
-        "        <xsd:element ref='B'/>" +
-        "      </xsd:choice> " +
-        "    </xsd:complexType> " +
-        "  </xsd:element> " +
-        "</xsd:schema>",
+            "  <xsd:element name='A' type='xsd:string'/> " +
+            "  <xsd:element name='B' type='xsd:int' substitutionGroup='A'/> " +
+            "</xsd:schema>",
+        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
+            "  <xsd:complexType name='foo'> " +
+            "    <xsd:sequence> " +
+            "      <xsd:element name='bar' substitutionGroup='A'/>" +
+            "    </xsd:sequence> " +
+            "  </xsd:complexType>" +
+            "</xsd:schema>",
+        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
+            "  <xsd:element name='A' type='xsd:string' final='#all'/> " +
+            "  <xsd:element name='B' type='xsd:string' substitutionGroup='A'/> " +
+            "</xsd:schema>",
+        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
+            "  <xsd:element name='A' type='xsd:string' final='restriction'/> " +
+            "  <xsd:element name='B' type='xsd:token' substitutionGroup='A'/> " +
+            "</xsd:schema>",
+        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
+            "  <xsd:element name='A' type='xsd:string' substitutionGroup='B'/> " +
+            "  <xsd:element name='B' type='xsd:string' substitutionGroup='C'/> " +
+            "  <xsd:element name='C' type='xsd:string' substitutionGroup='D'/> " +
+            "  <xsd:element name='D' type='xsd:string' substitutionGroup='E'/> " +
+            "  <xsd:element name='E' type='xsd:string' substitutionGroup='A'/> " +
+            "</xsd:schema>",
+        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
+            "  <xsd:element name='A' type='xsd:token' substitutionGroup='B'/> " +
+            "</xsd:schema>",
+        "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> " +
+            "  <xsd:element name='A' type='xsd:string'/> " +
+            "  <xsd:element name='B' type='xsd:string' substitutionGroup='A'/> " +
+            "  <xsd:element name='Complex'> " +
+            "    <xsd:complexType> " +
+            "      <xsd:choice> " +
+            "        <xsd:element ref='A'/>" +
+            "        <xsd:element ref='B'/>" +
+            "      </xsd:choice> " +
+            "    </xsd:complexType> " +
+            "  </xsd:element> " +
+            "</xsd:schema>",
     };
 
-    public static final String[] validSchemas = 
-    {
+    public static final String[] validSchemas = {
         "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
-        "  <xsd:complexType name='base'>" +
-        "    <xsd:all>" +
-        "      <xsd:element ref='head'/>" +
-        "    </xsd:all>" +
-        "  </xsd:complexType>" +
-        "  <xsd:complexType name='restr'>" +
-        "    <xsd:complexContent>" +
-        "       <xsd:restriction base='base'>" +
-        "         <xsd:all>" +
-        "           <xsd:element ref='tail'/>" +
-        "         </xsd:all>" +
-        "       </xsd:restriction>" +
-        "    </xsd:complexContent>" +
-        "  </xsd:complexType>" +
-        "  <xsd:element name='head' type='xsd:string'/>" +
-        "  <xsd:element name='tail' substitutionGroup='head'/>" +
-        "</xsd:schema>",
+            "  <xsd:complexType name='base'>" +
+            "    <xsd:all>" +
+            "      <xsd:element ref='head'/>" +
+            "    </xsd:all>" +
+            "  </xsd:complexType>" +
+            "  <xsd:complexType name='restr'>" +
+            "    <xsd:complexContent>" +
+            "       <xsd:restriction base='base'>" +
+            "         <xsd:all>" +
+            "           <xsd:element ref='tail'/>" +
+            "         </xsd:all>" +
+            "       </xsd:restriction>" +
+            "    </xsd:complexContent>" +
+            "  </xsd:complexType>" +
+            "  <xsd:element name='head' type='xsd:string'/>" +
+            "  <xsd:element name='tail' substitutionGroup='head'/>" +
+            "</xsd:schema>",
     };
-        
+
+    @Test
     public void test3() throws Exception {
         SchemaDocument[] schemas = new SchemaDocument[invalidSchemas.length];
 
         // Parse the invalid schema files
-        for (int i = 0 ; i < invalidSchemas.length ; i++)
+        for (int i = 0; i < invalidSchemas.length; i++)
             schemas[i] = SchemaDocument.Factory.parse(invalidSchemas[i]);
 
         // Now compile the invalid schemas, test that they fail
-        for (int i = 0 ; i < schemas.length ; i++)
-        {
+        for (int i = 0; i < schemas.length; i++) {
             try {
-                XmlBeans.loadXsd(new XmlObject[] {schemas[i]});
+                XmlBeans.loadXsd(new XmlObject[]{schemas[i]});
                 fail("Schema should have failed to compile:\n" + invalidSchemas[i]);
-            }
-            catch (XmlException success) { /* System.out.println(success); */ }
+            } catch (XmlException success) { /* System.out.println(success); */ }
         }
 
 
         // Parse the valid schema files
         schemas = new SchemaDocument[validSchemas.length];
-        for (int i = 0 ; i < validSchemas.length ; i++)
+        for (int i = 0; i < validSchemas.length; i++)
             schemas[i] = SchemaDocument.Factory.parse(validSchemas[i]);
 
         // Now compile the valid schemas, test that they succeed
-        for (int i = 0 ; i < schemas.length ; i++)
-        {
+        for (int i = 0; i < schemas.length; i++) {
             try {
-                XmlBeans.loadXsd(new XmlObject[] {schemas[i]});
-            }
-            catch (XmlException fail)
-            {
-               fail("Failed to compile schema: " + schemas[i] + " with error: " + fail);
+                XmlBeans.loadXsd(new XmlObject[]{schemas[i]});
+            } catch (XmlException fail) {
+                fail("Failed to compile schema: " + schemas[i] + " with error: " + fail);
             }
         }
     }
 
-    public static String[] invalidDocs = 
-    {
-        "<abstractTest xmlns='http://openuri.org/sgs'>" +
-        "    <abstract>content</abstract> " +
-        "</abstractTest> ",
-    };
+    private static String[] invalidDocs =
+        {
+            "<abstractTest xmlns='http://openuri.org/sgs'>" +
+                "    <abstract>content</abstract> " +
+                "</abstractTest> ",
+        };
 
-    public static String[] validDocs = 
-    {
-        "<abstractTest xmlns='http://openuri.org/sgs'>" +
-        "    <concrete>content</concrete> " +
-        "</abstractTest> ",
-    };
+    private static String[] validDocs =
+        {
+            "<abstractTest xmlns='http://openuri.org/sgs'>" +
+                "    <concrete>content</concrete> " +
+                "</abstractTest> ",
+        };
 
-    public void test4() throws Exception 
-    {
+    @Test
+    public void test4() throws Exception {
 
-        for (int i = 0 ; i < invalidDocs.length ; i++)
-        {
+        for (int i = 0; i < invalidDocs.length; i++) {
             XmlObject xo = XmlObject.Factory.parse(invalidDocs[i]);
-            assertTrue("Doc was valid. Should be invalid: " + invalidDocs[i], 
-                ! xo.validate());
+            assertTrue("Doc was valid. Should be invalid: " + invalidDocs[i],
+                !xo.validate());
         }
 
-        for (int i = 0 ; i < validDocs.length ; i++)
-        {
+        for (int i = 0; i < validDocs.length; i++) {
             XmlObject xo = XmlObject.Factory.parse(validDocs[i]);
             assertTrue("Doc was invalid. Should be valid: " + validDocs[i],
                 xo.validate());

Modified: xmlbeans/trunk/test/src/xmlobject/checkin/ValidateTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/checkin/ValidateTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/checkin/ValidateTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/checkin/ValidateTest.java Fri Jan 18 23:08:44 2019
@@ -15,47 +15,28 @@
 
 package xmlobject.checkin;
 
-import junit.framework.*;
-
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
-
-import javax.xml.namespace.QName;
-
-import xmlcursor.common.*;
-
+import org.junit.Test;
 import test.xbean.xmlcursor.purchaseOrder.PurchaseOrderDocument;
 import tools.util.JarUtil;
+import xmlcursor.common.BasicCursorTestCase;
+import xmlcursor.common.Common;
 
+import javax.xml.namespace.QName;
 
-/**
- *
- *
- */
-public class ValidateTest extends BasicCursorTestCase {
-    public ValidateTest(String sName) {
-        super(sName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(ValidateTest.class);
-    }
-
-    public void testClassPath() throws Exception {
-        String sClassPath = System.getProperty("java.class.path");
-        int i = sClassPath.indexOf(Common.CARLOCATIONMESSAGE_JAR);
-        assertTrue(i >= 0);
-        i = sClassPath.indexOf(Common.XMLCURSOR_JAR);
-        assertTrue(i >= 0);
-    }
+import static org.junit.Assert.*;
 
+public class ValidateTest extends BasicCursorTestCase {
+    @Test
     public void testValidateTrue() throws Exception {
         //m_xo = XmlObject.Factory.parse(Common.XML_PURCHASEORDER);
          m_xo = XmlObject.Factory.parse(
                 JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
-        assertEquals(true, m_xo.validate());
+        assertTrue(m_xo.validate());
     }
 
+    @Test
     public void testValidateTrueWithOptionDiscardDocElement() throws Exception {
         XmlOptions map = new XmlOptions();
         map.put(XmlOptions.LOAD_REPLACE_DOCUMENT_ELEMENT, null);
@@ -63,9 +44,10 @@ public class ValidateTest extends BasicC
                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO)
                 , map);
 
-        assertEquals(false, m_xo.validate(map));
+        assertFalse(m_xo.validate(map));
     }
 
+    @Test
     public void testValidateFalseFixedAttr() throws Exception {
          m_xo = XmlObject.Factory.parse(
                 JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
@@ -80,11 +62,9 @@ public class ValidateTest extends BasicC
         assertEquals("UK", m_xc.getAttributeText(name));
         PurchaseOrderDocument pod = (PurchaseOrderDocument) m_xo;
 
-
-
-        assertEquals(false, xo.validate());
-        assertEquals(false, pod.validate());
-        assertEquals(false, m_xo.validate());
+        assertFalse(xo.validate());
+        assertFalse(pod.validate());
+        assertFalse(m_xo.validate());
 
         assertTrue(true);
     }

Modified: xmlbeans/trunk/test/src/xmlobject/checkin/XPathTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/checkin/XPathTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/checkin/XPathTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/checkin/XPathTest.java Fri Jan 18 23:08:44 2019
@@ -1,32 +1,23 @@
 package xmlobject.checkin;
 
-import junit.framework.TestCase;
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlCursor;
+import org.junit.Test;
 
-/**
- * Created by Cezar Andrei (cezar dot andrei at gmail dot com)
- * Date: Apr 10, 2008
- */
-public class XPathTest
-        extends TestCase
-{
-    public XPathTest(String name)
-    {
-        super(name);
-    }
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-    public void testPath()
-        throws XmlException
-    {
+public class XPathTest {
+    @Test
+    public void testPath() throws XmlException {
         final XmlObject obj = XmlObject.Factory.parse(
-                "<a>" +
-                  "<b>" +
-                    "<c>val1</c>" +
-                    "<d><c>val2</c></d>" +
-                  "</b>" +
-                  "<c>val3</c>" +
+            "<a>" +
+                "<b>" +
+                "<c>val1</c>" +
+                "<d><c>val2</c></d>" +
+                "</b>" +
+                "<c>val3</c>" +
                 "</a>");
         final XmlCursor c = obj.newCursor();
 
@@ -35,31 +26,28 @@ public class XPathTest
         int selCount = c.getSelectionCount();
         assertEquals("SelectionCount", 1, selCount);
 
-        while ( c.hasNextSelection() )
-        {
+        while (c.hasNextSelection()) {
             c.toNextSelection();
 
-            assertEquals("OnStartElement", true, c.isStart());
+            assertTrue("OnStartElement", c.isStart());
             assertEquals("TextValue", "val1", c.getTextValue());
-            System.out.println(" -> " + c.getObject() );
+            System.out.println(" -> " + c.getObject());
         }
         c.dispose();
     }
 
-
-    public void testPath2()
-        throws XmlException
-    {
+    @Test
+    public void testPath2() throws XmlException {
         final XmlObject obj = XmlObject.Factory.parse(
-                "<a>" +
-                  "<b>" +
-                    "<c>val1</c>" +
-                    "<d>" +
-                      "<c>val2</c>" +
-                      "<b><c>val3</c></b>" +
-                    "</d>" +
-                  "</b>" +
-                  "<c>val4</c>" +
+            "<a>" +
+                "<b>" +
+                "<c>val1</c>" +
+                "<d>" +
+                "<c>val2</c>" +
+                "<b><c>val3</c></b>" +
+                "</d>" +
+                "</b>" +
+                "<c>val4</c>" +
                 "</a>");
         final XmlCursor c = obj.newCursor();
 
@@ -68,42 +56,41 @@ public class XPathTest
         int selCount = c.getSelectionCount();
         assertEquals("SelectionCount", 2, selCount);
 
-        assertEquals("hasNextSelection", true, c.hasNextSelection() );
+        assertTrue("hasNextSelection", c.hasNextSelection());
         c.toNextSelection();
 
-        System.out.println(" -> " + c.getObject() );
-        assertEquals("OnStartElement", true, c.isStart());
+        System.out.println(" -> " + c.getObject());
+        assertTrue("OnStartElement", c.isStart());
         assertEquals("TextValue", "val1", c.getTextValue());
 
 
-        assertEquals("hasNextSelection2", true, c.hasNextSelection() );
+        assertTrue("hasNextSelection2", c.hasNextSelection());
         c.toNextSelection();
 
-        System.out.println(" -> " + c.getObject() );
-        assertEquals("OnStartElement2", true, c.isStart());
+        System.out.println(" -> " + c.getObject());
+        assertTrue("OnStartElement2", c.isStart());
         assertEquals("TextValue2", "val3", c.getTextValue());
 
         c.dispose();
     }
 
-    public void testPath3()
-        throws XmlException
-    {
+    @Test
+    public void testPath3() throws XmlException {
         final XmlObject obj = XmlObject.Factory.parse(
-                "<a>" +
-                  "<b>" +
-                    "<c>val1</c>" +
-                    "<d>" +
-                      "<c>val2</c>" +
-                      "<b>" +
-                        "<c>val3" +
-                          "<c>val5</c>" +
-                        "</c>" +
-                      "</b>" +
-                    "</d>" +
-                   "</b>" +
-                   "<c>val4</c>" +
-                 "</a>");
+            "<a>" +
+                "<b>" +
+                "<c>val1</c>" +
+                "<d>" +
+                "<c>val2</c>" +
+                "<b>" +
+                "<c>val3" +
+                "<c>val5</c>" +
+                "</c>" +
+                "</b>" +
+                "</d>" +
+                "</b>" +
+                "<c>val4</c>" +
+                "</a>");
         final XmlCursor c = obj.newCursor();
 
         c.selectPath(".//b/c//c");
@@ -111,12 +98,11 @@ public class XPathTest
         int selCount = c.getSelectionCount();
         assertEquals("SelectionCount", 1, selCount);
 
-        while ( c.hasNextSelection() )
-        {
+        while (c.hasNextSelection()) {
             c.toNextSelection();
 
-            System.out.println(" -> " + c.getObject() );
-            assertEquals("OnStartElement", true, c.isStart());
+            System.out.println(" -> " + c.getObject());
+            assertTrue("OnStartElement", c.isStart());
             assertEquals("TextValue", "val5", c.getTextValue());
         }
         c.dispose();

Modified: xmlbeans/trunk/test/src/xmlobject/common/SelectChildrenAttribCommon.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/common/SelectChildrenAttribCommon.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/common/SelectChildrenAttribCommon.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/common/SelectChildrenAttribCommon.java Fri Jan 18 23:08:44 2019
@@ -16,51 +16,39 @@ package xmlobject.common;
 
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
-
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import junit.framework.TestCase;
+import org.junit.Before;
 import tools.util.JarUtil;
 import tools.xml.XmlComparator;
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
-/**
- *
- *
- */
-public class SelectChildrenAttribCommon
-        extends TestCase
-{
-    public SelectChildrenAttribCommon(String name)
-    {
-        super(name);
-    }
-
-    public void setUp()
-    {
-        opts = new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(2);
-    }
+import static org.junit.Assert.*;
 
 
+public class SelectChildrenAttribCommon {
     // Common
     public XmlOptions opts;
 
 
+    @Before
+    public void setUp() {
+        opts = new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(2);
+    }
+
+
     //////////////////////////////////////////////////////////////////
     // Helper methods
-    public void validateTest(String testName, String[] exps, XmlObject[] act)
-        throws Exception
-    {
-        assertTrue(testName + ": Return array has more/less elements than expected: "
-                   + act.length, act.length == exps.length);
+    protected void validateTest(String testName, String[] exps, XmlObject[] act)
+        throws Exception {
+        assertEquals(testName + ": Return array has more/less elements than expected: "
+            + act.length, act.length, exps.length);
         boolean passed = true;
 
-        for (int i = 0; i < act.length; i++)
-        {
+        for (int i = 0; i < act.length; i++) {
             boolean res;
             res = XComp(convertFragToDoc(act[i].xmlText()), exps[i], true);
-            if (res == false)
-            {
+            if (!res) {
                 System.out.println("Expected value differs from actual: Index=" + i);
                 System.out.println("Expected: " + exps[i]);
                 System.out.println("Actual: " + act[i].xmlText());
@@ -71,23 +59,19 @@ public class SelectChildrenAttribCommon
     }
 
 
-    public void validateTest(String testName, String exp, XmlObject xml)
-        throws Exception
-    {
-        if (xml == null)
-            fail(testName + ": XmlObject Recevied is null");
+    protected void validateTest(String testName, String exp, XmlObject xml) throws Exception {
+        assertNotNull(testName + ": XmlObject Recevied is null", xml);
 
         boolean res = XComp(convertFragToDoc(xml.xmlText()), exp, true);
         assertTrue("Expected value differs from actual\n" +
-                   "Expected: " + exp + "\n" +
-                   "Actual: " + xml.xmlText(),
-                   res);
+                "Expected: " + exp + "\n" +
+                "Actual: " + xml.xmlText(),
+            res);
     }
 
 
-    public static String getXml(String file)
-        throws java.io.IOException
-    {
+    protected static String getXml(String file)
+        throws java.io.IOException {
         return JarUtil.getResourceFromJar(file);
     }
 
@@ -95,9 +79,8 @@ public class SelectChildrenAttribCommon
     /**
      * Just a thin wrapper around XmlComparator
      */
-    public static boolean XComp(String actual, String expected, boolean verbose)
-        throws org.apache.xmlbeans.XmlException
-    {
+    private static boolean XComp(String actual, String expected, boolean verbose)
+        throws org.apache.xmlbeans.XmlException {
         boolean same;
         XmlComparator.Diagnostic diag = new XmlComparator.Diagnostic();
         same = XmlComparator.lenientlyCompareTwoXmlStrings(actual, expected, diag);
@@ -114,10 +97,9 @@ public class SelectChildrenAttribCommon
      * this method will replace that with something like <xm> so that they look
      * like Xml Docs...
      */
-    public static String convertFragToDoc(String xmlFragment)
-    {
+    protected static String convertFragToDoc(String xmlFragment) {
         String startFragStr = "<xml-fragment";
-        String endFragStr   = "</xml-fragment>";
+        String endFragStr = "</xml-fragment>";
         String startReplacementStr = "<xm";
         String endReplacementStr = "</xm>";
 
@@ -133,6 +115,4 @@ public class SelectChildrenAttribCommon
 
         return xmlDoc;
     }
-
-
 }

Modified: xmlbeans/trunk/test/src/xmlobject/detailed/CompareToTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/detailed/CompareToTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/detailed/CompareToTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/detailed/CompareToTest.java Fri Jan 18 23:08:44 2019
@@ -16,147 +16,92 @@
 
 package xmlobject.detailed;
 
-import junit.framework.*;
-
-import java.math.BigDecimal;
-
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlCursor;
-
-//import xmlcursor.common.BasicCursorTestCase;
-import xmlcursor.common.Common;
-
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
 import org.tranxml.tranXML.version40.CarLocationMessageDocument;
-import org.tranxml.tranXML.version40.EventStatusDocument.EventStatus;
-import org.tranxml.tranXML.version40.GeographicLocationDocument.GeographicLocation;
 import org.tranxml.tranXML.version40.CityNameDocument.CityName;
 import org.tranxml.tranXML.version40.ETADocument.ETA;
-
+import org.tranxml.tranXML.version40.EventStatusDocument.EventStatus;
+import org.tranxml.tranXML.version40.GeographicLocationDocument.GeographicLocation;
 import test.xbean.xmlcursor.purchaseOrder.PurchaseOrderDocument;
 import tools.util.JarUtil;
+import xmlcursor.common.Common;
+
+import java.math.BigDecimal;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-/**
- *
- *
- */
-public class CompareToTest extends TestCase {
-    public CompareToTest(String sName) {
-        super(sName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(CompareToTest.class);
-    }
-
-    /*public void testClassPath() throws Exception {
-        String sClassPath = System.getProperty("java.class.path");
-        int i = sClassPath.indexOf(Common.CARLOCATIONMESSAGE_JAR);
-        assertTrue(i >= 0);
-        i = sClassPath.indexOf(Common.XMLCURSOR_JAR);
-        assertTrue(i >= 0);
-    }
-   */
+public class CompareToTest {
+    @Test(expected = ClassCastException.class)
     public void testCompareToEquals() throws Exception {
         CarLocationMessageDocument clmDoc = (CarLocationMessageDocument) XmlObject.Factory.parse(
-                   JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        EventStatus[] aEventStatus = clmDoc.getCarLocationMessage()
-                .getEventStatusArray();
-        if (aEventStatus.length < 1) {
-            fail(
-                    "Unexpected: Missing EventStatus element.  Test harness failure.");
-        } else {
-            GeographicLocation gl = aEventStatus[0].getGeographicLocation();
-            CityName cname0 = gl.getCityName();
-            ETA eta = aEventStatus[0].getETA();
-            CityName cname1 = eta.getGeographicLocation().getCityName();
-            assertTrue(cname0.valueEquals(cname1));
-            try {
-                assertTrue(XmlObject.EQUAL == cname0.compareTo(cname1));
-                fail("Expected ClassCastException.");
-            }
-            catch (ClassCastException e) {
-                assertTrue(true);
-            }
-        }
+            JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
+        EventStatus[] aEventStatus = clmDoc.getCarLocationMessage().getEventStatusArray();
+
+        assertTrue("Unexpected: Missing EventStatus element.  Test harness failure.", aEventStatus.length > 0);
+
+        GeographicLocation gl = aEventStatus[0].getGeographicLocation();
+        CityName cname0 = gl.getCityName();
+        ETA eta = aEventStatus[0].getETA();
+        CityName cname1 = eta.getGeographicLocation().getCityName();
+        assertTrue(cname0.valueEquals(cname1));
+        assertEquals(XmlObject.EQUAL, cname0.compareTo(cname1));
     }
 
+    @Test(expected = ClassCastException.class)
     public void testCompareToNull() throws Exception {
         m_xo = XmlObject.Factory.parse(
-                   JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        try {
-            assertEquals(XmlObject.NOT_EQUAL, m_xo.compareTo(null));
-            assertTrue(false);
-        }
-        catch (ClassCastException e) {
-            assertTrue(true);
-        }
+            JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
+        assertEquals(XmlObject.NOT_EQUAL, m_xo.compareTo(null));
     }
 
-
+    @Test
     public void testCompareToLessThan() throws Exception {
-//        PurchaseOrderDocument poDoc = (PurchaseOrderDocument) XmlObject.Factory.parse(
-   //             Common.XML_PURCHASEORDER);
-           PurchaseOrderDocument poDoc = (PurchaseOrderDocument) XmlObject.Factory.parse(
-              JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
-
-        try {
-            BigDecimal bdUSPrice0 = poDoc.getPurchaseOrder().getItems()
-                    .getItemArray(0)
-                    .getUSPrice();
-            BigDecimal bdUSPrice1 = poDoc.getPurchaseOrder().getItems()
-                    .getItemArray(1)
-                    .getUSPrice();
-            assertEquals(XmlObject.LESS_THAN, bdUSPrice1.compareTo(bdUSPrice0));
-        }
-        catch (NullPointerException npe) {
-            fail("Unexpected instance document.  Harness failure.");
-        }
+        PurchaseOrderDocument poDoc = (PurchaseOrderDocument) XmlObject.Factory.parse(
+            JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
+
+        BigDecimal bdUSPrice0 = poDoc.getPurchaseOrder().getItems()
+            .getItemArray(0)
+            .getUSPrice();
+        BigDecimal bdUSPrice1 = poDoc.getPurchaseOrder().getItems()
+            .getItemArray(1)
+            .getUSPrice();
+        assertEquals(XmlObject.LESS_THAN, bdUSPrice1.compareTo(bdUSPrice0));
     }
 
+    @Test
     public void testCompareToGreaterThan() throws Exception {
         PurchaseOrderDocument poDoc = (PurchaseOrderDocument)
-                XmlObject.Factory.parse(
+            XmlObject.Factory.parse(
                 JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
-        try {
-            BigDecimal bdUSPrice0 = poDoc.getPurchaseOrder().getItems()
-                    .getItemArray(0)
-                    .getUSPrice();
-            BigDecimal bdUSPrice1 = poDoc.getPurchaseOrder().getItems()
-                    .getItemArray(1)
-                    .getUSPrice();
-            assertEquals(XmlObject.GREATER_THAN,
-                    bdUSPrice0.compareTo(bdUSPrice1));
-        }
-        catch (NullPointerException npe) {
-            fail("Unexpected instance document.  Harness failure.");
-        }
+        BigDecimal bdUSPrice0 = poDoc.getPurchaseOrder().getItems()
+            .getItemArray(0)
+            .getUSPrice();
+        BigDecimal bdUSPrice1 = poDoc.getPurchaseOrder().getItems()
+            .getItemArray(1)
+            .getUSPrice();
+        assertEquals(XmlObject.GREATER_THAN, bdUSPrice0.compareTo(bdUSPrice1));
     }
 
-
+    @Test(expected = ClassCastException.class)
     public void testCompareToString() throws Exception {
         m_xo = XmlObject.Factory.parse(
-                   JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        try {
-            assertEquals(0, m_xo.compareTo(""));
-            fail("Expected ClassCastException");
-        }
-        catch (ClassCastException cce) {
-        }
-        assertTrue(true);
+            JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
+        assertEquals(0, m_xo.compareTo(""));
     }
 
+    @Test
     public void testCompareValue() throws Exception {
         m_xo = XmlObject.Factory.parse(
-                   JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
+            JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
+        XmlCursor m_xc = m_xo.newCursor();
         m_xc.toFirstChild();
         XmlObject xo = m_xc.getObject();
         assertEquals(XmlObject.NOT_EQUAL, m_xo.compareValue(xo));
     }
 
     private XmlObject m_xo;
-    private XmlCursor m_xc;
-
 }
 

Modified: xmlbeans/trunk/test/src/xmlobject/detailed/CopyTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/detailed/CopyTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/detailed/CopyTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/detailed/CopyTest.java Fri Jan 18 23:08:44 2019
@@ -14,51 +14,40 @@
  */
 package xmlobject.detailed;
 
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
 import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
 
-public class CopyTest extends TestCase
-{
-    public CopyTest(String sName) {
-        super(sName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(CopyTest.class);
-    }
+import static org.junit.Assert.assertEquals;
 
+public class CopyTest {
     // Test for a Document object being copied as DocFrag if the type of the
     // source of the copy is not a document type (as is the case with NO_TYPE).
-    public void testXobjTypeOnDomNodeCopy() throws Exception
-    {
+    @Test
+    public void testXobjTypeOnDomNodeCopy() throws Exception {
         XmlObject o = XmlObject.Factory.parse("<foo><a/></foo>");
         String xobjOrgClassName = "org.apache.xmlbeans.impl.store.Xobj$DocumentXobj";
-        assertEquals("Invalid Type!", o.getDomNode().getClass().getName(),xobjOrgClassName);
+        assertEquals("Invalid Type!", o.getDomNode().getClass().getName(), xobjOrgClassName);
 
         XmlObject o2 = o.copy();
         String xobjCopyClassName = o2.getDomNode().getClass().getName();
-        System.out.println ( "DocXobj:"+ xobjCopyClassName);
+        System.out.println("DocXobj:" + xobjCopyClassName);
 
         // check for the expected type
-        assertEquals("Invalid Type!", "org.apache.xmlbeans.impl.store.Xobj$DocumentXobj",xobjOrgClassName);
-        assertEquals("Invalid Type!", "org.apache.xmlbeans.impl.store.Xobj$DocumentXobj",xobjCopyClassName);
+        assertEquals("Invalid Type!", "org.apache.xmlbeans.impl.store.Xobj$DocumentXobj", xobjOrgClassName);
+        assertEquals("Invalid Type!", "org.apache.xmlbeans.impl.store.Xobj$DocumentXobj", xobjCopyClassName);
     }
 
     // Test the same for a simple untyped XmlObject copy
-    public void testXobjTypeOnCopy() throws Exception
-    {
+    @Test
+    public void testXobjTypeOnCopy() throws Exception {
         String untypedXobjClass = "org.apache.xmlbeans.impl.values.XmlAnyTypeImpl";
 
         XmlObject o = XmlObject.Factory.parse("<foo><a/></foo>");
-        assertEquals("Invalid Type!",untypedXobjClass,o.getClass().getName());
+        assertEquals("Invalid Type!", untypedXobjClass, o.getClass().getName());
 
         XmlObject o2 = o.copy();
         String xobjClass = o2.getClass().getName();
         // type should be unchanged after the copy
-        assertEquals("Invalid Type!",untypedXobjClass,o2.getClass().getName());
+        assertEquals("Invalid Type!", untypedXobjClass, o2.getClass().getName());
     }
-
-
 }

Modified: xmlbeans/trunk/test/src/xmlobject/detailed/IsImmutableTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/detailed/IsImmutableTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/detailed/IsImmutableTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/detailed/IsImmutableTest.java Fri Jan 18 23:08:44 2019
@@ -16,65 +16,27 @@
 
 package xmlobject.detailed;
 
-import junit.framework.*;
-import junit.framework.Assert.*;
-
-import java.io.*;
-
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.SchemaTypeSystem;
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaTypeLoader;
-import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlOptions;
-
-import java.util.*;
-import javax.xml.namespace.QName;
-
-import org.apache.xmlbeans.XmlAnySimpleType;
-
-import java.util.Vector;
-
-import xmlcursor.common.*;
-
-import java.net.URL;
-
-import org.apache.xmlbeans.xml.stream.XMLInputStream;
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
 import org.tranxml.tranXML.version40.CarLocationMessageDocument;
-import tools.util.Util;
 import tools.util.JarUtil;
+import xmlcursor.common.BasicCursorTestCase;
+import xmlcursor.common.Common;
 
+import static org.junit.Assert.*;
 
-/**
- *
- *
- */
-public class IsImmutableTest extends BasicCursorTestCase {
-    public IsImmutableTest(String sName) {
-        super(sName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(IsImmutableTest.class);
-    }
-
-    public void testClassPath() throws Exception {
-        String sClassPath = System.getProperty("java.class.path");
-        int i = sClassPath.indexOf(Common.CARLOCATIONMESSAGE_JAR);
-        assertTrue(i >= 0);
-        i = sClassPath.indexOf(Common.XMLCURSOR_JAR);
-        assertTrue(i >= 0);
-    }
 
+public class IsImmutableTest extends BasicCursorTestCase {
+    @Test
     public void testIsImmutableFalse() throws Exception {
         CarLocationMessageDocument clmDoc =
                 (CarLocationMessageDocument) XmlObject.Factory
                 .parse(   JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        assertEquals(false, clmDoc.isImmutable());
+        assertFalse(clmDoc.isImmutable());
     }
 
+    @Test
     public void testIsImmutableTrue() throws Exception {
         m_xo = XmlObject.Factory.parse(
                    JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
@@ -84,10 +46,8 @@ public class IsImmutableTest extends Bas
         m_xc.toNextSelection();
         SchemaType st = m_xc.getObject().schemaType();
         XmlObject xoNew = st.newValue("ZZZZ");
-        assertEquals(true, xoNew.isImmutable());
+        assertTrue(xoNew.isImmutable());
         // verify it's not in main store
         assertEquals("GATX", m_xc.getTextValue());
     }
-
 }
-

Modified: xmlbeans/trunk/test/src/xmlobject/detailed/NilTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/detailed/NilTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/detailed/NilTest.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/detailed/NilTest.java Fri Jan 18 23:08:44 2019
@@ -16,73 +16,53 @@
 
 package xmlobject.detailed;
 
-import junit.framework.*;
-
+import knextest.bug38361.TestDocument;
 import org.apache.xmlbeans.XmlObject;
-
-import xmlcursor.common.*;
-
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.values.XmlValueNotNillableException;
+import org.junit.Test;
 import org.tranxml.tranXML.version40.CarLocationMessageDocument;
 import org.tranxml.tranXML.version40.CarLocationMessageDocument.CarLocationMessage;
 import test.xbean.xmlcursor.purchaseOrder.PurchaseOrderDocument;
-import knextest.bug38361.TestDocument;
-
-
-import org.apache.xmlbeans.impl.values.XmlValueNotNillableException;
 import tools.util.JarUtil;
+import xmlcursor.common.BasicCursorTestCase;
+import xmlcursor.common.Common;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
-/**
- *
- *
- */
-public class NilTest extends BasicCursorTestCase {
-    public NilTest(String sName) {
-        super(sName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(NilTest.class);
-    }
-
-    public void testClassPath() throws Exception {
-        String sClassPath = System.getProperty("java.class.path");
-        int i = sClassPath.indexOf(Common.CARLOCATIONMESSAGE_JAR);
-        assertTrue(i >= 0);
-        i = sClassPath.indexOf(Common.XMLCURSOR_JAR);
-        assertTrue(i >= 0);
-    }
 
+public class NilTest extends BasicCursorTestCase {
+    @Test
     public void testIsNilFalse() throws Exception {
         CarLocationMessageDocument clmDoc = (CarLocationMessageDocument) XmlObject.Factory.parse(
                    JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
         CarLocationMessage clm = clmDoc.getCarLocationMessage();
-        assertEquals(false, clm.isNil());
+        assertFalse(clm.isNil());
     }
 
+    @Test
     public void testSetNilNillable() throws Exception {
         PurchaseOrderDocument pod = (PurchaseOrderDocument) XmlObject.Factory.parse(
                 JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
         m_xo = pod.getPurchaseOrder().getShipTo().xgetName();
         m_xo.setNil();
-        assertEquals(true, m_xo.isNil());
+        assertTrue(m_xo.isNil());
     }
 
+    @Test(expected = XmlValueNotNillableException.class)
     public void testSetNilNotNillable() throws Exception {
+        XmlOptions xo = new XmlOptions();
+        xo.setValidateOnSet();
         CarLocationMessageDocument clmDoc = (CarLocationMessageDocument) XmlObject.Factory.parse(
-                   JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        try {
-            clmDoc.setNil();
-            fail("Expected XmlValueNotNillableException");
-        }
-        catch (XmlValueNotNillableException xvnne) {
-        }
-        assertTrue(true);
+                   JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM), xo);
+        clmDoc.setNil();
     }
 
     /**
      * Test case for Radar bug: #38361
      */
+    @Test
     public void nillableTest() throws Exception {
         //Generates a xml document programatically
         TestDocument generated = TestDocument.Factory.newInstance();

Modified: xmlbeans/trunk/test/src/xmlobject/detailed/SelectAttributeTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/detailed/SelectAttributeTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/detailed/SelectAttributeTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/detailed/SelectAttributeTests.java Fri Jan 18 23:08:44 2019
@@ -15,51 +15,39 @@
 
 package xmlobject.detailed;
 
-import junit.framework.TestCase;
-import junit.framework.Assert;
-
-import org.openuri.test.selectChildren.*;
-import org.openuri.test.selectAttribute.*;
-
-import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
+import org.openuri.test.selectAttribute.DocDocument;
+import xmlobject.common.SelectChildrenAttribCommon;
 
 import javax.xml.namespace.QName;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
 
-import xmlobject.common.SelectChildrenAttribCommon;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
-/**
- *
- *
- */
-public class SelectAttributeTests
-            extends SelectChildrenAttribCommon
-{
-    public SelectAttributeTests(String name)
-    {
-        super(name);
-    }
+public class SelectAttributeTests extends SelectChildrenAttribCommon {
 
-    static String saUri = "http://openuri.org/test/selectAttribute";
-    static String saStartFrag = "<xm xmlns:sa=\"" + saUri + "\">";
+    private static String saUri = "http://openuri.org/test/selectAttribute";
+    private static String saStartFrag = "<xm xmlns:sa=\"" + saUri + "\">";
 
-    static String abcUri = "http://abc";
-    static String defUri = "http://def";
-    static String xyzUri = "http://xyz";
+    private static String abcUri = "http://abc";
+    private static String defUri = "http://def";
 
     static String anyStartFrag = "<xm xmlns:sa=\"" + saUri + "\"" +
-                                 " xmlns:abc=\"" + abcUri + "\"" +
-                                 " xmlns:def=\"" + defUri + "\"" + ">";
+        " xmlns:abc=\"" + abcUri + "\"" +
+        " xmlns:def=\"" + defUri + "\"" + ">";
 
-    static String endFrag = "</xm>";
+    private static String endFrag = "</xm>";
     // To speed up tests when running multiple test methods in the same run
-    DocDocument.Doc doc = null;
+    private DocDocument.Doc doc = null;
 
     ///////////////////////////////////////////////////////////////////
     // Tests for non-wildcard attributes
+    @Test
     public void testSelectWithQName()
-        throws Exception
-    {
+        throws Exception {
         if (doc == null)
             doc = (DocDocument.Doc) getTestObject();
         QName qn = new QName("", "att1");
@@ -69,13 +57,13 @@ public class SelectAttributeTests
         validateTest("testSelectWithQName", exp, x);
         // Check Select with QName that is not present.. should get null back.
         x = doc.getWithOther().selectAttribute(qn);
-        assertTrue(x == null);
+        assertNull(x);
     }
 
 
+    @Test
     public void testSelectWithURI()
-        throws Exception
-    {
+        throws Exception {
         if (doc == null)
             doc = (DocDocument.Doc) getTestObject();
 
@@ -85,15 +73,15 @@ public class SelectAttributeTests
         validateTest("testSelectWithURI", exp, x);
         // Check Select with QName that is not present.. should get null back.
         x = doc.getWithAny().selectAttribute("", "att2");
-        assertTrue(x == null);
+        assertNull(x);
 
     }
 
     ////////////////////////////////////////////////////////////////////
     // Test for wild-card attributes
+    @Test
     public void testSelectWithQNameForAny()
-        throws Exception
-    {
+        throws Exception {
         if (doc == null)
             doc = (DocDocument.Doc) getTestObject();
 
@@ -111,9 +99,8 @@ public class SelectAttributeTests
 
     ////////////////////////////////////////////////////////////////////
     // Helper
-    public XmlObject getTestObject()
-        throws Exception
-    {
+    private XmlObject getTestObject()
+        throws Exception {
         String xml = getXml("xbean/xmlobject/SelectAttribute-Doc.xml");
         DocDocument xmlObj = DocDocument.Factory.parse(xml);
         DocDocument.Doc doc = xmlObj.getDoc();
@@ -126,13 +113,4 @@ public class SelectAttributeTests
         assertTrue("Test Xml is not valid!!", valid);
         return doc;
     }
-
-    public void printXmlObj(XmlObject[] xobj)
-        throws Exception
-    {
-        for (int i = 0; i < xobj.length; i++)
-            System.out.println(convertFragToDoc(xobj[i].xmlText()));
-    }
-
-
 }



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