Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/GetNameTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/GetNameTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/GetNameTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/GetNameTest.java Sun Feb  6 
01:51:55 2022
@@ -16,133 +16,125 @@
 
 package xmlcursor.checkin;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
-import tools.util.JarUtil;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-
-public class GetNameTest extends BasicCursorTestCase {
-    @Test
-    public void testGetNameFromSTARTDOC() throws Exception {
-       // String test="<?xml version=\"1.0\"?><purchaseOrder xmlns= 
\"http://www.bea.com/po\"; orderDate=\"1999-10-20\"><shipTo 
country=\"US\"><name>Alice Smith</name><street>123 Maple 
Street</street><city>Mill 
Valley</city><state>CA</state><zip>90952</zip></shipTo><comment>Hurry, my lawn 
is going wild!</comment><!-- comment text --><items>2 <item partNum=\"872-AA\" 
partid=\"00A\"><productName>Lawnmower</productName> 
<quantity>10</quantity></item><item partNum=\"926-AA\" 
partid=\"00B\"><productName>Baby 
Monitor</productName><quantity>1</quantity></item></items></purchaseOrder>";
-        String test="<?xml version=\"1.0\"?>\n" +
-                "<po:purchaseOrder 
xmlns:po=\"http://xbean.test/xmlcursor/PurchaseOrder\"; 
orderDate=\"1999-10-20\">\n" +
-                "    <po:shipTo country=\"US\">\n" +
-                "        <po:name>Alice Smith</po:name>\n" +
-                "        <po:street>123 Maple Street</po:street>\n" +
-                "        <po:city>Mill Valley</po:city>\n" +
-                "        <po:state>CA</po:state>\n" +
-                "        <po:zip>90952</po:zip>\n" +
-                "    </po:shipTo>\n" +
-                "    <po:billTo country=\"US\">\n" +
-                "        <po:name>Robert Smith</po:name>\n" +
-                "        <po:street>8 Oak Avenue</po:street>\n" +
-                "        <po:city>Old Town</po:city>\n" +
-                "        <po:state>PA</po:state>\n" +
-                "        <po:zip>95819</po:zip>\n" +
-                "    </po:billTo>\n" +
-                "    <po:comment>Hurry, my lawn is going wild!</po:comment>\n" 
+
-                "    <po:items>\n" +
-                "        <po:item partNum=\"872-AA\">\n" +
-                "            <po:productName>Lawnmower</po:productName>\n" +
-                "            <po:quantity>1</po:quantity>\n" +
-                "            <po:USPrice>148.95</po:USPrice>\n" +
-                "            <po:comment>Confirm this is 
electric</po:comment>\n" +
-                "        </po:item>\n" +
-                "        <po:item partNum=\"926-AA\">\n" +
-                "            <po:productName>Baby Monitor</po:productName>\n" +
-                "            <po:quantity>1</po:quantity>\n" +
-                "            <po:USPrice>39.98</po:USPrice>\n" +
-                "            <po:shipDate>1999-05-21</po:shipDate>\n" +
-                "        </po:item>\n" +
-                "    </po:items>\n" +
-                "</po:purchaseOrder>";
-                m_xo = XmlObject.Factory.parse(test);
-               /*   JarUtil.getResourceFromJar(Common.XMLCASES_JAR,
-                        Common.TRANXML_FILE_XMLCURSOR_PO));
-                        */
-        m_xc = m_xo.newCursor();
-        assertNull(m_xc.getName());
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static xmlcursor.common.BasicCursorTestCase.*;
+
+
+public class GetNameTest {
+    private static final String STARTDOC_XML =
+        "<?xml version=\"1.0\"?>\n" +
+        "<po:purchaseOrder 
xmlns:po=\"http://xbean.test/xmlcursor/PurchaseOrder\"; 
orderDate=\"1999-10-20\">\n" +
+        "    <po:shipTo country=\"US\">\n" +
+        "        <po:name>Alice Smith</po:name>\n" +
+        "        <po:street>123 Maple Street</po:street>\n" +
+        "        <po:city>Mill Valley</po:city>\n" +
+        "        <po:state>CA</po:state>\n" +
+        "        <po:zip>90952</po:zip>\n" +
+        "    </po:shipTo>\n" +
+        "    <po:billTo country=\"US\">\n" +
+        "        <po:name>Robert Smith</po:name>\n" +
+        "        <po:street>8 Oak Avenue</po:street>\n" +
+        "        <po:city>Old Town</po:city>\n" +
+        "        <po:state>PA</po:state>\n" +
+        "        <po:zip>95819</po:zip>\n" +
+        "    </po:billTo>\n" +
+        "    <po:comment>Hurry, my lawn is going wild!</po:comment>\n" +
+        "    <po:items>\n" +
+        "        <po:item partNum=\"872-AA\">\n" +
+        "            <po:productName>Lawnmower</po:productName>\n" +
+        "            <po:quantity>1</po:quantity>\n" +
+        "            <po:USPrice>148.95</po:USPrice>\n" +
+        "            <po:comment>Confirm this is electric</po:comment>\n" +
+        "        </po:item>\n" +
+        "        <po:item partNum=\"926-AA\">\n" +
+        "            <po:productName>Baby Monitor</po:productName>\n" +
+        "            <po:quantity>1</po:quantity>\n" +
+        "            <po:USPrice>39.98</po:USPrice>\n" +
+        "            <po:shipDate>1999-05-21</po:shipDate>\n" +
+        "        </po:item>\n" +
+        "    </po:items>\n" +
+        "</po:purchaseOrder>";
+
+    @Test
+    void testGetNameFromSTARTDOC() throws Exception {
+        try (XmlCursor m_xc = cur(STARTDOC_XML)) {
+            assertNull(m_xc.getName());
+        }
     }
 
     @Test
-    public void testGetNameFromPROCINST() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.PROCINST);
-        assertEquals("xml-stylesheet", m_xc.getName().getLocalPart());
+    void testGetNameFromPROCINST() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_PROCINST)) {
+            toNextTokenOfType(m_xc, TokenType.PROCINST);
+            assertEquals("xml-stylesheet", m_xc.getName().getLocalPart());
+        }
     }
 
     @Test
-    public void testGetNameFromSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                  
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
+    void testGetNameFromSTART() throws Exception {
         String ns="declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";; ";
-
-        m_xc.selectPath(ns+" .//po:shipTo/po:city");
-        m_xc.toNextSelection();
-        assertEquals("city", m_xc.getName().getLocalPart());
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            m_xc.selectPath(ns + " .//po:shipTo/po:city");
+            m_xc.toNextSelection();
+            assertEquals("city", m_xc.getName().getLocalPart());
+        }
     }
 
     @Test
-    public void testGetNameFromEND() throws Exception {
-        m_xo = XmlObject.Factory.parse("<foo><bar>text</bar></foo>");
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath(".//bar");
-        toNextTokenOfType(m_xc, TokenType.END);
-        assertNull(m_xc.getName());
+    void testGetNameFromEND() throws Exception {
+        try (XmlCursor m_xc = cur("<foo><bar>text</bar></foo>")) {
+            m_xc.selectPath(".//bar");
+            toNextTokenOfType(m_xc, TokenType.END);
+            assertNull(m_xc.getName());
+        }
     }
 
     @Test
-    public void testGetNameFromATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                  
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
+    void testGetNameFromATTR() throws Exception {
         String ns="declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";; ";
-
-        m_xc.selectPath(ns+" .//po:shipTo");
-        m_xc.toNextSelection();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        assertEquals("country", m_xc.getName().getLocalPart());
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            m_xc.selectPath(ns + " .//po:shipTo");
+            m_xc.toNextSelection();
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            assertEquals("country", m_xc.getName().getLocalPart());
+        }
     }
 
     @Test
-    public void testGetNameFromCOMMENT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.COMMENT);
-        assertNull(m_xc.getName());
+    void testGetNameFromCOMMENT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_COMMENT)) {
+            toNextTokenOfType(m_xc, TokenType.COMMENT);
+            assertNull(m_xc.getName());
+        }
     }
 
     @Test
-    public void testGetNameElementWithDefaultNamespace() throws Exception {
-        m_xo =  XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath(Common.CLM_NS_XQUERY_DEFAULT + ".//ETA");
-        m_xc.toNextSelection();
-        assertEquals("ETA", m_xc.getName().getLocalPart());
-        assertEquals(Common.CLM_NS, m_xc.getName().getNamespaceURI());
+    void testGetNameElementWithDefaultNamespace() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            m_xc.selectPath(Common.CLM_NS_XQUERY_DEFAULT + ".//ETA");
+            m_xc.toNextSelection();
+            assertEquals("ETA", m_xc.getName().getLocalPart());
+            assertEquals(Common.CLM_NS, m_xc.getName().getNamespaceURI());
+        }
     }
 
     @Test
-    public void testGetNameAttrWithDefaultNamespace() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_NS_PREFIX);
-        m_xc = m_xo.newCursor();
-        String sDefaultElemNS = "declare default element namespace 
\"http://ecommerce.org/schema\";; ";
-        m_xc.selectPath(sDefaultElemNS + ".//price");
-        m_xc.toNextSelection();
-        m_xc.toFirstAttribute();
-        assertEquals("units", m_xc.getName().getLocalPart());
-        // note: default namespace does not apply to attribute names, hence 
should be null
-        assertEquals("", m_xc.getName().getNamespaceURI());
+    void testGetNameAttrWithDefaultNamespace() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_NS_PREFIX)) {
+            String sDefaultElemNS = "declare default element namespace 
\"http://ecommerce.org/schema\";; ";
+            m_xc.selectPath(sDefaultElemNS + ".//price");
+            m_xc.toNextSelection();
+            m_xc.toFirstAttribute();
+            assertEquals("units", m_xc.getName().getLocalPart());
+            // note: default namespace does not apply to attribute names, 
hence should be null
+            assertEquals("", m_xc.getName().getNamespaceURI());
+        }
     }
 }
 

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/GetObjectTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/GetObjectTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/GetObjectTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/GetObjectTest.java Sun Feb  
6 01:51:55 2022
@@ -16,102 +16,92 @@
 
 package xmlcursor.checkin;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
 import org.apache.xmlbeans.XmlNMTOKEN;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.tranxml.tranXML.version40.CarLocationMessageDocument;
-import tools.util.JarUtil;
-import xmlcursor.common.BasicCursorTestCase;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
 
-public class GetObjectTest extends BasicCursorTestCase {
+public class GetObjectTest {
+
     @Test
-    public void testGetObjectFromSTARTDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        assertTrue(m_xc.getObject() instanceof CarLocationMessageDocument);
+    void testGetObjectFromSTARTDOC() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            assertTrue(m_xc.getObject() instanceof CarLocationMessageDocument);
+        }
     }
 
     @Test
-    public void testGetObjectFromSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        m_xc.toFirstChild();
-        assertTrue(m_xc.getObject() instanceof 
CarLocationMessageDocument.CarLocationMessage);
+    void testGetObjectFromSTART() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            m_xc.toFirstChild();
+            assertTrue(m_xc.getObject() instanceof 
CarLocationMessageDocument.CarLocationMessage);
+        }
     }
 
     @Test
-    public void testGetObjectFromATTR() throws Exception {
-        m_xo =
-            XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
-        m_xc = m_xo.newCursor();
-        String sQuery =
-            "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";;  " +
-                "$this//po:shipTo";
-        m_xc.selectPath(sQuery);
-        m_xc.toNextSelection();
-        m_xc.toFirstAttribute();
-        assertTrue(m_xc.getObject() instanceof XmlNMTOKEN);
+    void testGetObjectFromATTR() throws Exception {
+        String sQuery = "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";;  $this//po:shipTo";
+        try (XmlCursor m_xc = jcur("xbean/xmlcursor/po.xml")) {
+            m_xc.selectPath(sQuery);
+            m_xc.toNextSelection();
+            m_xc.toFirstAttribute();
+            assertTrue(m_xc.getObject() instanceof XmlNMTOKEN);
+        }
     }
 
     @Test
-    public void testGetObjectFromEND() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.END);
-        assertNull(m_xc.getObject());
+    void testGetObjectFromEND() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            toNextTokenOfType(m_xc, TokenType.END);
+            assertNull(m_xc.getObject());
+        }
     }
 
     @Test
-    public void testGetObjectFromENDDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        m_xc.toEndDoc();
-        assertNull(m_xc.getObject());
+    void testGetObjectFromENDDOC() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            m_xc.toEndDoc();
+            assertNull(m_xc.getObject());
+        }
     }
 
     @Test
-    public void testGetObjectFromNAMESPACE() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.NAMESPACE);
-        assertNull(m_xc.getObject());
+    void testGetObjectFromNAMESPACE() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            toNextTokenOfType(m_xc, TokenType.NAMESPACE);
+            assertNull(m_xc.getObject());
+        }
     }
 
     @Test
-    public void testGetObjectFromPROCINST() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.PROCINST);
-        assertNull(m_xc.getObject());
+    void testGetObjectFromPROCINST() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_PROCINST)) {
+            toNextTokenOfType(m_xc, TokenType.PROCINST);
+            assertNull(m_xc.getObject());
+        }
     }
 
     @Test
-    public void testGetObjectFromCOMMENT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.COMMENT);
-        assertNull(m_xc.getObject());
+    void testGetObjectFromCOMMENT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_COMMENT)) {
+            toNextTokenOfType(m_xc, TokenType.COMMENT);
+            assertNull(m_xc.getObject());
+        }
     }
 
     @Test
-    public void testGetObjectFromTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        assertNull(m_xc.getObject());
+    void testGetObjectFromTEXT() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertNull(m_xc.getObject());
+        }
     }
 }
 

Modified: 
xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertAttributeTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertAttributeTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertAttributeTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertAttributeTest.java Sun 
Feb  6 01:51:55 2022
@@ -16,227 +16,193 @@
 
 package xmlcursor.checkin;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 import xmlcursor.common.Common;
 
 import javax.xml.namespace.QName;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static xmlcursor.common.BasicCursorTestCase.cur;
+import static xmlcursor.common.BasicCursorTestCase.toNextTokenOfType;
 
 
-public class InsertAttributeTest extends BasicCursorTestCase {
+public class InsertAttributeTest {
+
     @Test
-    public void testInsertAttributeAtSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertAttributeWithValue("name", "uri", "value");
-        m_xc.toStartDoc();
-        assertEquals("<foo uri:name=\"value\" xmlns:uri=\"uri\">text</foo>", 
m_xc.xmlText());
-    }
-
-    @Test
-    public void testInsertAttributeAtATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        m_xc.insertAttributeWithValue("name", null, "value");
-        m_xc.toStartDoc();
-        assertEquals("<foo name=\"value\" attr0=\"val0\" 
attr1=\"val1\">text</foo>", m_xc.xmlText());
-    }
-
-    @Test
-    public void testInsertAttributeAt2ndATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        m_xc.insertAttributeWithValue("name", null, "value");
-        m_xc.toStartDoc();
-        assertEquals("<foo attr0=\"val0\" name=\"value\" 
attr1=\"val1\">text</foo>", m_xc.xmlText());
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeAtPROCINST() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.PROCINST);
-        m_xc.toNextToken();
-        m_xc.insertAttributeWithValue("name", null, "value");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeAtSTARTwithEmptyStringName() throws 
Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        m_xc.insertAttributeWithValue("", "uri", "value");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeAtSTARTwithNullName() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        m_xc.insertAttributeWithValue(null, "uri", "value");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeWithNullQName() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        QName name = new QName(null);
-        m_xc.insertAttribute(name);
-    }
-
-    @Test
-    public void testInsertAttributeAtSTARTwithEmptyStringUri() throws 
Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertAttributeWithValue("name", "", "value");
-        m_xc.toStartDoc();
-        assertEquals("<foo name=\"value\">text</foo>", m_xc.xmlText());
-    }
-
-    @Test(expected = Exception.class)
-    public void testInsertAttributeAtSTARTwithNameXml() throws Exception {
-        /*
-m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-m_xc = m_xo.newCursor();
-toNextTokenOfType(m_xc, TokenType.TEXT);
-try
-{
-m_xc.insertAttributeWithValue("xml", null, "value");
-fail("Expected IllegalArgumentException");
-}
-catch (IllegalArgumentException iae)
-{
-}
-assertEquals(true,true);
-        */
+    void testInsertAttributeAtSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertAttributeWithValue("name", "uri", "value");
+            m_xc.toStartDoc();
+            assertEquals("<foo uri:name=\"value\" 
xmlns:uri=\"uri\">text</foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testInsertAttributeAtATTR() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            m_xc.insertAttributeWithValue("name", null, "value");
+            m_xc.toStartDoc();
+            assertEquals("<foo name=\"value\" attr0=\"val0\" 
attr1=\"val1\">text</foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testInsertAttributeAt2ndATTR() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            m_xc.insertAttributeWithValue("name", null, "value");
+            m_xc.toStartDoc();
+            assertEquals("<foo attr0=\"val0\" name=\"value\" 
attr1=\"val1\">text</foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testInsertAttributeAtPROCINST() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_PROCINST)) {
+            toNextTokenOfType(m_xc, TokenType.PROCINST);
+            m_xc.toNextToken();
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertAttributeWithValue("name", null, "value"));
+        }
+    }
 
-        m_xo = XmlObject.Factory.parse("<foo>text</foo>");
-        m_xc = m_xo.newCursor();
-        m_xc.insertAttributeWithValue("xml", null, "value");
+    @Test
+    void testInsertAttributeAtSTARTwithEmptyStringName() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertAttributeWithValue("", "uri", "value"));
+        }
     }
 
     @Test
-    public void testInsertAttributeAtSTARTwithValueXml() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertAttributeWithValue("name", null, "xml");
-        m_xc.toStartDoc();
-        assertEquals("<foo name=\"xml\">text</foo>", m_xc.xmlText());
+    void testInsertAttributeAtSTARTwithNullName() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertAttributeWithValue(null, "uri", "value"));
+        }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeAtSTARTwithLTcharInName() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertAttributeWithValue("<b", null, "value");
+    @Test
+    void testInsertAttributeWithNullQName() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertAttribute((QName)null));
+        }
     }
 
     @Test
-    public void testInsertAttributeAtSTARTwithLTcharInValue() throws Exception 
{
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertAttributeWithValue("name", null, "<value");
-        m_xc.toStartDoc();
-        assertEquals("<foo name=\"&lt;value\">text</foo>", m_xc.xmlText());
+    void testInsertAttributeAtSTARTwithEmptyStringUri() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertAttributeWithValue("name", "", "value");
+            m_xc.toStartDoc();
+            assertEquals("<foo name=\"value\">text</foo>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertAttributeAtSTARTwithAmpCharInValue() throws 
Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertAttributeWithValue("name", null, "&value");
-        m_xc.toStartDoc();
-        assertEquals("<foo name=\"&amp;value\">text</foo>", m_xc.xmlText());
+    void testInsertAttributeAtSTARTwithNameXml() throws Exception {
+        try (XmlCursor m_xc = cur("<foo>text</foo>")) {
+            assertThrows(Exception.class, () ->
+                m_xc.insertAttributeWithValue("xml", null, "value"));
+        }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeAtSTARTwithAmpCharInName() throws Exception 
{
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertAttributeWithValue("&bar", null, "value");
+    @Test
+    void testInsertAttributeAtSTARTwithValueXml() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertAttributeWithValue("name", null, "xml");
+            m_xc.toStartDoc();
+            assertEquals("<foo name=\"xml\">text</foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testInsertAttributeAtSTARTwithLTcharInName() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertAttributeWithValue("<b", null, "value"));
+        }
+    }
+
+    @Test
+    void testInsertAttributeAtSTARTwithLTcharInValue() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertAttributeWithValue("name", null, "<value");
+            m_xc.toStartDoc();
+            assertEquals("<foo name=\"&lt;value\">text</foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testInsertAttributeAtSTARTwithAmpCharInValue() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertAttributeWithValue("name", null, "&value");
+            m_xc.toStartDoc();
+            assertEquals("<foo name=\"&amp;value\">text</foo>", 
m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testInsertAttributeAtSTARTwithAmpCharInName() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertAttributeWithValue("&bar", null, "value"));
+        }
     }
 
     // tests below use the XMLName form of the parameter signature
     @Test
-    public void testInsertAttributeType2AtATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        QName name = new QName("name");
-        m_xc.insertAttributeWithValue(name, "value");
-        m_xc.toStartDoc();
-        assertEquals("<foo name=\"value\" attr0=\"val0\" 
attr1=\"val1\">text</foo>", m_xc.xmlText());
-    }
-
-    @Test
-    public void testInsertAttributeType2AfterSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        QName name = new QName("name");
-        m_xc.insertAttributeWithValue(name, null);
-        m_xc.toStartDoc();
-        assertEquals("<foo attr0=\"val0\" attr1=\"val1\" 
name=\"\">text</foo>", m_xc.xmlText());
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeType2WithXMLinName() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        QName name = new QName("<xml>");
-        m_xc.insertAttributeWithValue(name, "value");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeType2WithLeadingSpaceinName() throws 
Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        QName name = new QName(" any");
-        m_xc.insertAttributeWithValue(name, "value");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeType2ContainingSpaceinName() throws 
Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        QName name = new QName("any any");
-        m_xc.insertAttributeWithValue(name, "value");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeType2WithTrailingSpaceinName() throws 
Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        QName name = new QName("any ");
-        m_xc.insertAttributeWithValue(name, "value");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertAttributeType2WithXMLinNameCase() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        QName name = new QName("<xMlzorro>");
-        m_xc.insertAttributeWithValue(name, "value");
+    void testInsertAttributeType2AtATTR() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            QName name = new QName("name");
+            m_xc.insertAttributeWithValue(name, "value");
+            m_xc.toStartDoc();
+            assertEquals("<foo name=\"value\" attr0=\"val0\" 
attr1=\"val1\">text</foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testInsertAttributeType2AfterSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            QName name = new QName("name");
+            m_xc.insertAttributeWithValue(name, null);
+            m_xc.toStartDoc();
+            assertEquals("<foo attr0=\"val0\" attr1=\"val1\" 
name=\"\">text</foo>", m_xc.xmlText());
+        }
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {
+        // WithXMLinName
+        "<xml>",
+        // WithLeadingSpaceinName
+        " any",
+        // ContainingSpaceinName
+        "any any",
+        // WithTrailingSpaceinName
+        "any ",
+        // WithXMLinNameCase
+        "<xMlzorro>"
+    })
+    void testInsertAttributeTypeInvalid(String localPart) throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            QName name = new QName(localPart);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertAttributeWithValue(name, "value"));
+        }
     }
 }
 

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertCharsTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertCharsTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertCharsTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertCharsTest.java Sun Feb 
 6 01:51:55 2022
@@ -16,96 +16,97 @@
 
 package xmlcursor.checkin;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static xmlcursor.common.BasicCursorTestCase.cur;
+import static xmlcursor.common.BasicCursorTestCase.toNextTokenOfType;
 
 
-public class InsertCharsTest extends BasicCursorTestCase {
+public class InsertCharsTest {
+
+    @Test
+    void testInsertCharsAtSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            m_xc.selectPath("$this//bar");
+            m_xc.toNextSelection();
+            m_xc.insertChars(" new chars ");
+            m_xc.toPrevToken();
+            assertEquals(" new chars ", m_xc.getChars());
+        }
+    }
+
+    @Test
+    void testInsertCharsAtSTARTnonEmptyPriorTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_WS_ONLY)) {
+            m_xc.selectPath("$this//bar");
+            m_xc.toNextSelection();
+            m_xc.insertChars("new chars ");
+            m_xc.toPrevToken();
+            assertEquals(" new chars ", m_xc.getChars());
+        }
+    }
+
+    @Test
+    void testInsertCharsAtENDnonEmptyPriorTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_WS_ONLY)) {
+            m_xc.selectPath("$this//bar");
+            toNextTokenOfType(m_xc, TokenType.END);
+            m_xc.insertChars("new chars ");
+            m_xc.toPrevToken();
+            assertEquals(" new chars ", m_xc.getChars());
+        }
+    }
+
+    @Test
+    void testInsertCharsInMiddleOfTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.insertChars("new chars ");
+            assertEquals("xt", m_xc.getChars());
+            m_xc.toPrevToken();
+            assertEquals("tenew chars xt", m_xc.getTextValue());
+        }
+    }
+
+    @Test
+    void testInsertCharsNullInMiddleOfTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.insertChars(null);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.toPrevToken();
+            assertEquals("text", m_xc.getTextValue());
+        }
+    }
+
+    @Test
+    void testInsertCharsEmptyInMiddleOfTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.insertChars("");
+            assertEquals("xt", m_xc.getChars());
+            m_xc.toPrevToken();
+            assertEquals("text", m_xc.getTextValue());
+        }
+    }
+
     @Test
-    public void testInsertCharsAtSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath("$this//bar");
-        m_xc.toNextSelection();
-        m_xc.insertChars(" new chars ");
-        m_xc.toPrevToken();
-        System.out.println(m_xc.currentTokenType());
-        assertEquals(" new chars ", m_xc.getChars());
-    }
-
-    @Test
-    public void testInsertCharsAtSTARTnonEmptyPriorTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_WS_ONLY);
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath("$this//bar");
-        m_xc.toNextSelection();
-        m_xc.insertChars("new chars ");
-        m_xc.toPrevToken();
-        System.out.println(m_xc.currentTokenType());
-        assertEquals(" new chars ", m_xc.getChars());
-    }
-
-    @Test
-    public void testInsertCharsAtENDnonEmptyPriorTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_WS_ONLY);
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath("$this//bar");
-        toNextTokenOfType(m_xc, TokenType.END);
-        m_xc.insertChars("new chars ");
-        m_xc.toPrevToken();
-        assertEquals(" new chars ", m_xc.getChars());
-    }
-
-    @Test
-    public void testInsertCharsInMiddleOfTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.insertChars("new chars ");
-        assertEquals("xt", m_xc.getChars());
-        m_xc.toPrevToken();
-        assertEquals("tenew chars xt", m_xc.getTextValue());
-    }
-
-    @Test
-    public void testInsertCharsNullInMiddleOfTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.insertChars(null);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.toPrevToken();
-        assertEquals("text", m_xc.getTextValue());
-    }
-
-    @Test
-    public void testInsertCharsEmptyInMiddleOfTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.insertChars("");
-        assertEquals("xt", m_xc.getChars());
-        m_xc.toPrevToken();
-        assertEquals("text", m_xc.getTextValue());
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void testInsertCharsInNAMESPACE() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_NS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.NAMESPACE);
-        m_xc.insertChars("fred");
+    void testInsertCharsInNAMESPACE() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_NS)) {
+            toNextTokenOfType(m_xc, TokenType.NAMESPACE);
+            assertThrows(IllegalStateException.class, () -> 
m_xc.insertChars("fred"));
+        }
     }
 
 }

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertCommentTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertCommentTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertCommentTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertCommentTest.java Sun 
Feb  6 01:51:55 2022
@@ -16,120 +16,116 @@
 
 package xmlcursor.checkin;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
 
-public class InsertCommentTest extends BasicCursorTestCase {
+public class InsertCommentTest {
+
     @Test
-    public void testInsertCommentAtSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath("$this//bar");
-        m_xc.toNextSelection();
-        m_xc.insertComment(" new comment ");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<foo><!-- new comment --><bar>text</bar></foo>", 
m_xc.xmlText());
+    void testInsertCommentAtSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            m_xc.selectPath("$this//bar");
+            m_xc.toNextSelection();
+            m_xc.insertComment(" new comment ");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<foo><!-- new comment --><bar>text</bar></foo>", 
m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentInMiddleOfTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.insertComment(" new comment ");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<bar>te<!-- new comment -->xt</bar>", m_xc.xmlText());
+    void testInsertCommentInMiddleOfTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.insertComment(" new comment ");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<bar>te<!-- new comment -->xt</bar>", 
m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentAtEND() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.END);
-        m_xc.insertComment(" new comment ");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<bar>text<!-- new comment --></bar>", m_xc.xmlText());
+    void testInsertCommentAtEND() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.END);
+            m_xc.insertComment(" new comment ");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<bar>text<!-- new comment --></bar>", 
m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentWithLTChar() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertComment("< new comment ");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<foo><!--< new comment -->text</foo>", m_xc.xmlText());
+    void testInsertCommentWithLTChar() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertComment("< new comment ");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<foo><!--< new comment -->text</foo>", 
m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentWithDoubleDash() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertComment(" -- ");
-        m_xc.toStartDoc();
-        assertEquals("<foo><!-- -  -->text</foo>", m_xc.xmlText());
+    void testInsertCommentWithDoubleDash() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertComment(" -- ");
+            m_xc.toStartDoc();
+            assertEquals("<foo><!-- -  -->text</foo>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentWithDoubleDashNoWS() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertComment("--");
-        m_xc.toStartDoc();
-        assertEquals("<foo><!--- -->text</foo>", m_xc.xmlText());
+    void testInsertCommentWithDoubleDashNoWS() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertComment("--");
+            m_xc.toStartDoc();
+            assertEquals("<foo><!--- -->text</foo>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentWithEndDash() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertComment(" -");
-        m_xc.toStartDoc();
-        assertEquals("<foo><!--  -->text</foo>", m_xc.xmlText());
+    void testInsertCommentWithEndDash() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertComment(" -");
+            m_xc.toStartDoc();
+            assertEquals("<foo><!--  -->text</foo>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentWithEmptyString() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertComment("");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<foo><!---->text</foo>", m_xc.xmlText());
+    void testInsertCommentWithEmptyString() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertComment("");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<foo><!---->text</foo>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentWithNull() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertComment(null);
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<foo><!---->text</foo>", m_xc.xmlText());
+    void testInsertCommentWithNull() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.insertComment(null);
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<foo><!---->text</foo>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertCommentAtSTARTDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        try {
-            m_xc.insertComment("should fail");
-            fail("Expected IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
+    void testInsertCommentAtSTARTDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertComment("should fail"));
         }
-        assertEquals(true, true);
     }
 }
 

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertElementTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertElementTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertElementTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertElementTest.java Sun 
Feb  6 01:51:55 2022
@@ -16,115 +16,114 @@
 
 package xmlcursor.checkin;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
-import tools.util.JarUtil;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
-public class InsertElementTest extends BasicCursorTestCase {
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertElementNullName() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        m_xc.insertElementWithText(null, "uri", "value");
+public class InsertElementTest {
+
+    @Test
+    void testInsertElementNullName() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertElementWithText(null, "uri", "value"));
+        }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertElementEmptyStringName() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        m_xc.insertElementWithText("", "uri", "value");
+    @Test
+    void testInsertElementEmptyStringName() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertElementWithText("", "uri", "value"));
+        }
     }
 
     @Test
-    public void testInsertElementNullUri() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        m_xc.insertElementWithText("name", null, "value");
-        m_xc.toPrevSibling();
-        assertEquals("<name>value</name>", m_xc.xmlText());
+    void testInsertElementNullUri() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            m_xc.insertElementWithText("name", null, "value");
+            m_xc.toPrevSibling();
+            assertEquals("<name>value</name>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertElementNullText() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        m_xc.insertElementWithText("name", "uri", null);
-        m_xc.toPrevSibling();
-        assertEquals("<uri:name xmlns:uri=\"uri\"/>", m_xc.xmlText());
+    void testInsertElementNullText() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            m_xc.insertElementWithText("name", "uri", null);
+            m_xc.toPrevSibling();
+            assertEquals("<uri:name xmlns:uri=\"uri\"/>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertElementEmptyStringText() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        m_xc.insertElementWithText("name", null, "");
-        m_xc.toPrevSibling();
-        assertEquals("<name/>", m_xc.xmlText());
+    void testInsertElementEmptyStringText() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            m_xc.insertElementWithText("name", null, "");
+            m_xc.toPrevSibling();
+            assertEquals("<name/>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertElementInMiddleOfTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.insertElementWithText("name", null, "value");
-        m_xc.toStartDoc();
-        assertEquals("<foo>te<name>value</name>xt</foo>", m_xc.xmlText());
+    void testInsertElementInMiddleOfTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.insertElementWithText("name", null, "value");
+            m_xc.toStartDoc();
+            assertEquals("<foo>te<name>value</name>xt</foo>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertElementAtEND() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.END);
-        m_xc.insertElementWithText("name", null, "value");
-        m_xc.toStartDoc();
-        assertEquals("<foo>text<name>value</name></foo>", m_xc.xmlText());
+    void testInsertElementAtEND() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.END);
+            m_xc.insertElementWithText("name", null, "value");
+            m_xc.toStartDoc();
+            assertEquals("<foo>text<name>value</name></foo>", m_xc.xmlText());
+        }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertElementAtSTARTDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.insertElementWithText("name", null, "value");
+    @Test
+    void testInsertElementAtSTARTDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertElementWithText("name", null, "value"));
+        }
     }
 
     @Test
-    public void testInsertElementAtENDDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ENDDOC);
-        m_xc.insertElementWithText("name", null, "value");
-        m_xc.toStartDoc();
-        
assertEquals(Common.wrapInXmlFrag("<foo>text</foo><name>value</name>"), 
m_xc.xmlText());
+    void testInsertElementAtENDDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.ENDDOC);
+            m_xc.insertElementWithText("name", null, "value");
+            m_xc.toStartDoc();
+            
assertEquals(Common.wrapInXmlFrag("<foo>text</foo><name>value</name>"), 
m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertElementInStoreWithNamespace() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath(Common.CLM_NS_XQUERY_DEFAULT +
-                        ".//FleetID");
-        m_xc.toNextSelection();
-        m_xc.insertElementWithText("name", "uri", "value");
-        m_xc.toPrevSibling();
-        assertEquals("<uri:name xmlns=\"" +
-                     Common.CLM_NS + "\" " +
-                     Common.CLM_XSI_NS + " " +
-                     "xmlns:uri=\"uri\">value</uri:name>", m_xc.xmlText());
+    void testInsertElementInStoreWithNamespace() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            m_xc.selectPath(Common.CLM_NS_XQUERY_DEFAULT + ".//FleetID");
+            m_xc.toNextSelection();
+            m_xc.insertElementWithText("name", "uri", "value");
+            m_xc.toPrevSibling();
+            assertEquals("<uri:name xmlns=\"" +
+                                    Common.CLM_NS + "\" " +
+                                    Common.CLM_XSI_NS + " " +
+                                    "xmlns:uri=\"uri\">value</uri:name>", 
m_xc.xmlText());
+        }
     }
 }
 

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertProcInstTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertProcInstTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertProcInstTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/InsertProcInstTest.java Sun 
Feb  6 01:51:55 2022
@@ -16,115 +16,117 @@
 
 package xmlcursor.checkin;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
 
-public class InsertProcInstTest extends BasicCursorTestCase {
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertProcInstWithNullTarget() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertProcInst(null, "value");
+public class InsertProcInstTest {
+
+    @Test
+    void testInsertProcInstWithNullTarget() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertProcInst(null, "value"));
+        }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertProcInstWithEmptyStringTarget() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.insertProcInst("", "value");
+    @Test
+    void testInsertProcInstWithEmptyStringTarget() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertProcInst("", "value"));
+        }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertProcInstWithLTcharInTarget() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath("$this//bar");
-        m_xc.toNextSelection();
-        m_xc.insertProcInst("<target", " value ");
+    @Test
+    void testInsertProcInstWithLTcharInTarget() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            m_xc.selectPath("$this//bar");
+            m_xc.toNextSelection();
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertProcInst("<target", " value "));
+        }
     }
 
     @Test
-    public void testInsertProcInstWithNullText() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.insertProcInst("target", null);
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<bar>te<?target?>xt</bar>", m_xc.xmlText());
+    void testInsertProcInstWithNullText() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.insertProcInst("target", null);
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<bar>te<?target?>xt</bar>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertProcInstWithEmptyStringText() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.insertProcInst("target", "");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<bar>te<?target?>xt</bar>", m_xc.xmlText());
+    void testInsertProcInstWithEmptyStringText() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.insertProcInst("target", "");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<bar>te<?target?>xt</bar>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertProcInstWithLTcharInText() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath("$this//bar");
-        m_xc.toNextSelection();
-        m_xc.insertProcInst("target", "< value ");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<foo><?target < value ?><bar>text</bar></foo>", 
m_xc.xmlText());
+    void testInsertProcInstWithLTcharInText() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            m_xc.selectPath("$this//bar");
+            m_xc.toNextSelection();
+            m_xc.insertProcInst("target", "< value ");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<foo><?target < value ?><bar>text</bar></foo>", 
m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertProcInstInMiddleOfTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("xt", m_xc.getChars());
-        m_xc.insertProcInst("target", " value ");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<bar>te<?target  value ?>xt</bar>", m_xc.xmlText());
+    void testInsertProcInstInMiddleOfTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("xt", m_xc.getChars());
+            m_xc.insertProcInst("target", " value ");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<bar>te<?target  value ?>xt</bar>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertProcInstAfterSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath("$this//bar");
-        m_xc.toNextSelection();
-        m_xc.insertProcInst("target", " value ");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<foo><?target  value ?><bar>text</bar></foo>", 
m_xc.xmlText());
+    void testInsertProcInstAfterSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            m_xc.selectPath("$this//bar");
+            m_xc.toNextSelection();
+            m_xc.insertProcInst("target", " value ");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<foo><?target  value ?><bar>text</bar></foo>", 
m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testInsertProcInstAtEND() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_NS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.END);
-        m_xc.insertProcInst("target", " value ");
-        toPrevTokenOfType(m_xc, TokenType.START);
-        assertEquals("<foo xmlns=\"http://www.foo.org\";><?target  value 
?></foo>", m_xc.xmlText());
+    void testInsertProcInstAtEND() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_NS)) {
+            toNextTokenOfType(m_xc, TokenType.END);
+            m_xc.insertProcInst("target", " value ");
+            toPrevTokenOfType(m_xc, TokenType.START);
+            assertEquals("<foo xmlns=\"http://www.foo.org\";><?target  value 
?></foo>", m_xc.xmlText());
+        }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testInsertProcInstBeforeATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        m_xc.insertProcInst("target", " value ");
+    @Test
+    void testInsertProcInstBeforeATTR() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_1ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.insertProcInst("target", " value "));
+        }
     }
 }
 

Modified: 
xmlbeans/trunk/src/test/java/xmlcursor/checkin/IsAtSamePositionAsTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/IsAtSamePositionAsTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/IsAtSamePositionAsTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/IsAtSamePositionAsTest.java 
Sun Feb  6 01:51:55 2022
@@ -17,40 +17,44 @@
 package xmlcursor.checkin;
 
 import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.junit.Before;
-import org.junit.Test;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+import static xmlcursor.common.BasicCursorTestCase.cur;
+import static xmlcursor.common.BasicCursorTestCase.obj;
 
 
-public class IsAtSamePositionAsTest extends BasicCursorTestCase{
-
-    private static String sDoc=Common.XML_FOO_DIGITS;
+public class IsAtSamePositionAsTest {
 
        @Test
-       public void testNormalCase() {
-           try (XmlCursor m_xc1 = m_xo.newCursor()) {
+       void testNormalCase() throws XmlException {
+               XmlObject m_xo = obj(Common.XML_FOO_DIGITS);
+           try (XmlCursor m_xc = m_xo.newCursor();
+                       XmlCursor m_xc1 = m_xo.newCursor()) {
                m_xc.toFirstChild();
                m_xc1.toFirstChild();
                assertTrue(m_xc.isAtSamePositionAs(m_xc1));
            }
        }
 
-       @Test(expected = IllegalArgumentException.class)
-       public void testSamePosDiffDoc() throws Exception {
-           try (XmlCursor m_xc1 = XmlObject.Factory.parse(sDoc).newCursor()) {
+       @Test
+       void testSamePosDiffDoc() throws Exception {
+           try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS);
+                       XmlCursor m_xc1 = cur(Common.XML_FOO_DIGITS)) {
                m_xc.toFirstChild();
                m_xc1.toFirstChild();
-               m_xc.isAtSamePositionAs(m_xc1);
+               assertThrows(IllegalArgumentException.class, () -> 
m_xc.isAtSamePositionAs(m_xc1));
            }
        }
 
        @Test
-       public void testDiffPosSameDoc() throws Exception {
-           try (XmlCursor m_xc1 = m_xo.newCursor()) {
+       void testDiffPosSameDoc() throws Exception {
+               XmlObject m_xo = obj(Common.XML_FOO_DIGITS);
+           try (XmlCursor m_xc = m_xo.newCursor();
+                        XmlCursor m_xc1 = m_xo.newCursor()) {
                m_xc.toFirstChild();
                m_xc1.toFirstChild();
                m_xc1.toFirstAttribute();
@@ -58,20 +62,18 @@ public class IsAtSamePositionAsTest exte
            }
        }
 
-       @Test(expected = Exception.class)
-       public void testNull() {
-               m_xc.isAtSamePositionAs(null);
-       }
-
        @Test
-       public void testSelf() {
-               m_xc.toFirstChild();
-               assertEquals(true, m_xc.isAtSamePositionAs(m_xc));
+       void testNull() throws XmlException {
+               try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+                       assertThrows(Exception.class, () -> 
m_xc.isAtSamePositionAs(null));
+               }
        }
 
-       @Before
-       public void setUp() throws Exception {
-               m_xo = XmlObject.Factory.parse(sDoc);
-               m_xc = m_xo.newCursor();
+       @Test
+       void testSelf() throws XmlException {
+               try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+                       m_xc.toFirstChild();
+                       assertTrue(m_xc.isAtSamePositionAs(m_xc));
+               }
        }
 }

Modified: 
xmlbeans/trunk/src/test/java/xmlcursor/checkin/IsInSameDocumentTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/IsInSameDocumentTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/IsInSameDocumentTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/IsInSameDocumentTest.java 
Sun Feb  6 01:51:55 2022
@@ -18,20 +18,21 @@ package xmlcursor.checkin;
 
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static xmlcursor.common.BasicCursorTestCase.cur;
+import static xmlcursor.common.BasicCursorTestCase.toNextTokenOfType;
 
 
-public class IsInSameDocumentTest extends BasicCursorTestCase {
+public class IsInSameDocumentTest {
+
     @Test
-    public void testSameDocSTARTDOCandENDDOC() throws Exception {
-        m_xc = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
-        try (XmlCursor xc0 = m_xc.newCursor()) {
+    void testSameDocSTARTDOCandENDDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_1ATTR_TEXT);
+            XmlCursor xc0 = m_xc.newCursor()) {
             xc0.toEndDoc();
             assertTrue(m_xc.isInSameDocument(xc0));
             assertTrue(xc0.isInSameDocument(m_xc));
@@ -39,9 +40,9 @@ public class IsInSameDocumentTest extend
     }
 
     @Test
-    public void testSameDocNAMESPACEandATTR() throws Exception {
-        m_xc = XmlObject.Factory.parse(Common.XML_FOO_DIGITS).newCursor();
-        try (XmlCursor xc0 = m_xc.newCursor()) {
+    void testSameDocNAMESPACEandATTR() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS);
+             XmlCursor xc0 = m_xc.newCursor()) {
             toNextTokenOfType(m_xc, TokenType.NAMESPACE);
             toNextTokenOfType(xc0, TokenType.ATTR);
             assertTrue(m_xc.isInSameDocument(xc0));
@@ -50,15 +51,16 @@ public class IsInSameDocumentTest extend
     }
 
     @Test
-    public void testSameDocNull() throws Exception {
-        m_xc = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
-        assertFalse(m_xc.isInSameDocument(null));
+    void testSameDocNull() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_1ATTR_TEXT)) {
+            assertFalse(m_xc.isInSameDocument(null));
+        }
     }
 
     @Test
-    public void testSameDocDifferentDocs() throws Exception {
-        m_xc = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
-        try (XmlCursor xc0 = 
XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor()) {
+    void testSameDocDifferentDocs() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_1ATTR_TEXT);
+             XmlCursor xc0 = cur(Common.XML_FOO_1ATTR_TEXT)) {
             toNextTokenOfType(m_xc, TokenType.TEXT);
             toNextTokenOfType(xc0, TokenType.TEXT);
 
@@ -68,9 +70,9 @@ public class IsInSameDocumentTest extend
     }
 
     @Test
-    public void testSameDocTEXTpositional() throws Exception {
-        m_xc = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
-        try (XmlCursor xc0 = m_xc.newCursor()) {
+    void testSameDocTEXTpositional() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_1ATTR_TEXT);
+             XmlCursor xc0 = m_xc.newCursor()) {
             toNextTokenOfType(m_xc, TokenType.TEXT);
             toNextTokenOfType(xc0, TokenType.TEXT);
             xc0.toNextChar(2);

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/MoveCharsTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/MoveCharsTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/MoveCharsTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/MoveCharsTest.java Sun Feb  
6 01:51:55 2022
@@ -19,21 +19,21 @@ package xmlcursor.checkin;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
 import org.apache.xmlbeans.XmlObject;
-import org.junit.Test;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Test;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.*;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
 
-public class MoveCharsTest extends BasicCursorTestCase {
+public class MoveCharsTest {
+
     @Test
-    public void testMoveCharsOverlap() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        try (XmlCursor xc1 = m_xo.newCursor()) {
+    void testMoveCharsOverlap() throws Exception {
+        XmlObject m_xo = obj(Common.XML_FOO_DIGITS);
+        try (XmlCursor m_xc = m_xo.newCursor();
+             XmlCursor xc1 = m_xo.newCursor()) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
             toNextTokenOfType(xc1, TokenType.TEXT);
             xc1.toNextChar(2);
             assertEquals("234", xc1.getChars());
@@ -44,12 +44,13 @@ public class MoveCharsTest extends Basic
     }
 
     @Test
-    public void testMoveCharsNoOverlap() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        try (XmlCursor xc1 = m_xo.newCursor();
+    void testMoveCharsNoOverlap() throws Exception {
+        XmlObject m_xo = obj(Common.XML_FOO_DIGITS);
+        try (XmlCursor m_xc = m_xo.newCursor();
+            XmlCursor xc1 = m_xo.newCursor();
             XmlCursor xc2 = m_xo.newCursor()) {
+
+            toNextTokenOfType(m_xc, TokenType.TEXT);
             xc1.toCursor(m_xc);
             xc2.toCursor(m_xc);
             xc1.toNextChar(3);
@@ -64,54 +65,49 @@ public class MoveCharsTest extends Basic
         }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testMoveCharsToNull() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.moveChars(4, null);
+    @Test
+    void testMoveCharsToNull() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.moveChars(4, null));
+        }
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void testMoveCharsSibling() throws Exception {
-        m_xo = 
XmlObject.Factory.parse("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
-        m_xc = m_xo.newCursor();
-        try (XmlCursor xc0 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT);
-            XmlCursor xc1 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT)) {
+    @Test
+    void testMoveCharsSibling() throws Exception {
+        try (XmlCursor m_xc = cur("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
+             XmlCursor xc0 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT);
+             XmlCursor xc1 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT)) {
             assertFalse(xc0.isAtSamePositionAs(xc1));
             assertEquals(4, xc1.moveChars(4, xc0));
             assertEquals("0123", xc0.getChars());
             xc0.toPrevToken();
             assertEquals("WXYZ0123", xc0.getTextValue());
-            System.out.println("we are here");
             assertEquals(TokenType.END, xc1.currentTokenType());
-
-            xc1.getTextValue();
+            assertThrows(IllegalStateException.class, xc1::getTextValue);
         }
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void testMoveCharsNegative() throws Exception {
-        m_xo = 
XmlObject.Factory.parse("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
-        m_xc = m_xo.newCursor();
-        try (XmlCursor xc0 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT);
-            XmlCursor xc1 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT)) {
+    @Test
+    void testMoveCharsNegative() throws Exception {
+        try (XmlCursor m_xc = cur("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
+             XmlCursor xc0 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT);
+             XmlCursor xc1 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT)) {
             assertFalse(xc0.isAtSamePositionAs(xc1));
             assertEquals(4, xc1.moveChars(-1, xc0));
             assertEquals("0123", xc0.getChars());
             xc0.toPrevToken();
             assertEquals("WXYZ0123", xc0.getTextValue());
             assertEquals(TokenType.END, xc1.currentTokenType());
-            xc1.getTextValue();
+            assertThrows(IllegalStateException.class, xc1::getTextValue);
         }
     }
 
     @Test
-    public void testMoveCharsZero() throws Exception {
-        m_xo = 
XmlObject.Factory.parse("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
-        m_xc = m_xo.newCursor();
-        try (XmlCursor xc0 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT);
-            XmlCursor xc1 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT)) {
+    void testMoveCharsZero() throws Exception {
+        try (XmlCursor m_xc = cur("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
+             XmlCursor xc0 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT);
+             XmlCursor xc1 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT)) {
             assertFalse(xc0.isAtSamePositionAs(xc1));
             assertEquals(0, xc1.moveChars(0, xc0));
             assertEquals("0123", xc0.getChars());
@@ -122,22 +118,22 @@ public class MoveCharsTest extends Basic
         }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testMoveCharsToSTARTDOC() throws Exception {
-        m_xo = 
XmlObject.Factory.parse("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        try (XmlCursor xc0 = m_xo.newCursor()) {
-            m_xc.moveChars(4, xc0);
+    @Test
+    void testMoveCharsToSTARTDOC() throws Exception {
+        XmlObject m_xo = obj("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
+        try (XmlCursor m_xc = m_xo.newCursor();
+             XmlCursor xc0 = m_xo.newCursor()) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.moveChars(4, xc0));
         }
     }
 
     @Test
-    public void testMoveCharsToPROCINST() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        try (XmlCursor xc0 = m_xo.newCursor()) {
+    void testMoveCharsToPROCINST() throws Exception {
+        XmlObject m_xo = obj(Common.XML_FOO_PROCINST);
+        try (XmlCursor m_xc = m_xo.newCursor();
+             XmlCursor xc0 = m_xo.newCursor()) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
             toNextTokenOfType(xc0, TokenType.PROCINST);
             m_xc.moveChars(1, xc0);
             xc0.toPrevToken();
@@ -147,11 +143,12 @@ public class MoveCharsTest extends Basic
         }
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void testMoveCharsGTmax() throws Exception {
-        m_xo = 
XmlObject.Factory.parse("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
-        m_xc = m_xo.newCursor();
-        try (XmlCursor xc0 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT);
+    @Test
+    void testMoveCharsGTmax() throws Exception {
+        XmlObject m_xo = obj("<foo><bar>0123</bar><bar>WXYZ</bar></foo>");
+
+        try (XmlCursor m_xc = m_xo.newCursor();
+             XmlCursor xc0 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT);
             XmlCursor xc1 = toNextTokenOfTypeCursor(m_xc, TokenType.TEXT)) {
             assertFalse(xc0.isAtSamePositionAs(xc1));
             assertEquals(4, xc1.moveChars(1000, xc0));
@@ -161,25 +158,23 @@ public class MoveCharsTest extends Basic
 
             assertEquals(TokenType.END, xc1.currentTokenType());
 
-            xc1.getTextValue();
+            assertThrows(IllegalStateException.class, xc1::getTextValue);
         }
     }
 
     @Test
-    public void testMoveCharsToNewDocument() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        XmlObject xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        try (XmlCursor xc1 = xo.newCursor()) {
+    void testMoveCharsToNewDocument() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS);
+             XmlCursor xc1 = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
             toNextTokenOfType(xc1, TokenType.TEXT);
             assertEquals(5, m_xc.moveChars(5, xc1));
             xc1.toParent();
             // verify xc1
             assertEquals("01234text", xc1.getTextValue());
+            // verify m_xc
+            assertEquals(TokenType.END, m_xc.currentTokenType());
         }
-        // verify m_xc
-        assertEquals(TokenType.END, m_xc.currentTokenType());
     }
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to