Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/MoveTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/MoveTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/MoveTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/MoveTest.java Sun Feb  6 
01:51:55 2022
@@ -19,73 +19,64 @@ 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 org.junit.jupiter.api.Test;
 import tools.util.Util;
-import xmlcursor.common.BasicCursorTestCase;
 import xmlcursor.common.Common;
 
 import javax.xml.namespace.QName;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
 
-public class MoveTest extends BasicCursorTestCase {
-    @Test(expected = IllegalArgumentException.class)
-    public void testMoveToNull() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.moveXml(null);
+public class MoveTest {
+
+    @Test
+    void testMoveToNull() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.moveXml(null));
+        }
     }
 
     @Test
-    public void testMoveDifferentStoresLoadedByParse() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        XmlObject xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        try (XmlCursor xc1 = xo.newCursor()) {
+    void testMoveDifferentStoresLoadedByParse() 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);
             m_xc.moveXml(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());
     }
 
     @Test
-    public void testMoveDifferentStoresLoadedFromFile() throws Exception {
-        // load the documents and obtain a cursor
-        XmlObject xobj0 = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        XmlObject xobj1 = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
+    void testMoveDifferentStoresLoadedFromFile() throws Exception {
+        String sQuery = "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";; .//po:zip";
+        String sExpected = "<ver:Initial " +
+                           
"xmlns:po=\"http://xbean.test/xmlcursor/PurchaseOrder\"; " +
+                           
"xmlns:ver=\"http://www.tranxml.org/TranXML/Version4.0\";>" +
+                           "GATX</ver:Initial>";
 
-        try (XmlCursor xc0 = xobj0.newCursor();
-            XmlCursor xc1 = xobj1.newCursor()) {
+        // load the documents and obtain a cursor
+        try (XmlCursor xc0 = jcur(Common.TRANXML_FILE_CLM);
+             XmlCursor xc1 = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
             xc0.selectPath(Common.CLM_NS_XQUERY_DEFAULT + ".//Initial");
             xc0.toNextSelection();
 
-            String sQuery=
-                    "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";; "+
-                    ".//po:zip";
-            xc1.selectPath( sQuery );
-            assertTrue( 0 < xc1.getSelectionCount());
+            xc1.selectPath(sQuery);
+            assertTrue(0 < xc1.getSelectionCount());
             xc1.toNextSelection();
 
-
-            xc0.moveXml(xc1); // should move the <Initial>GATX</Initial> 
element plus the namespace
-
+            // should move the <Initial>GATX</Initial> element plus the 
namespace
+            xc0.moveXml(xc1);
 
             xc1.toPrevSibling();
             // verify xc1
-            String sExpected = "<ver:Initial " +
-                    "xmlns:po=\"http://xbean.test/xmlcursor/PurchaseOrder\"; " +
-                    "xmlns:ver=\"http://www.tranxml.org/TranXML/Version4.0\";>" 
+
-                    "GATX</ver:Initial>";
             assertEquals(sExpected, xc1.xmlText());
             // verify xc0
             xc0.toNextToken();  // skip the whitespace token
@@ -94,58 +85,55 @@ public class MoveTest extends BasicCurso
     }
 
     @Test
-    public void testMoveSameLocation() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        try (XmlCursor xc1 = m_xo.newCursor()) {
+    void testMoveSameLocation() throws Exception {
+        XmlObject m_xo = XmlObject.Factory.parse(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);
             m_xc.moveXml(xc1);
+            assertEquals("01234", m_xc.getChars());
         }
-        assertEquals("01234", m_xc.getChars());
     }
 
     @Test
-    public void testMoveNewLocation() throws Exception {
-       m_xo=XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        String ns="declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";; ";
-
-        m_xc = m_xo.newCursor();
-        try (XmlCursor xc1 = m_xo.newCursor()) {
-            m_xc.selectPath(ns+" .//po:shipTo/po:city");
+    void testMoveNewLocation() throws Exception {
+        String ns = "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";; ";
+        XmlObject m_xo = jobj(Common.TRANXML_FILE_XMLCURSOR_PO);
+
+        try (XmlCursor m_xc = m_xo.newCursor();
+             XmlCursor xc1 = m_xo.newCursor()) {
+            m_xc.selectPath(ns + " .//po:shipTo/po:city");
             m_xc.toNextSelection();
-            xc1.selectPath(ns +" .//po:billTo/po:city");
+            xc1.selectPath(ns + " .//po:billTo/po:city");
             xc1.toNextSelection();
             m_xc.moveXml(xc1);
             xc1.toPrevToken();
             xc1.toPrevToken();
-
             // verify xc1
             assertEquals("Mill Valley", xc1.getChars());
+            // verify m_xc
+            m_xc.toNextToken(); // skip the whitespace token
+            assertEquals("CA", m_xc.getTextValue());
         }
-
-        // verify m_xc
-        m_xc.toNextToken(); // skip the whitespace token
-
-        assertEquals("CA", m_xc.getTextValue());
     }
 
     @Test
-    public void testMoveElementToMiddleOfTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        String ns="declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";; ";
-
-        m_xc = m_xo.newCursor();
-        try (XmlCursor xc1 = m_xo.newCursor()) {
-            m_xc.selectPath(ns+" .//po:shipTo/po:city");
+    void testMoveElementToMiddleOfTEXT() throws Exception {
+        String ns = "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";; ";
+        XmlObject m_xo = jobj(Common.TRANXML_FILE_XMLCURSOR_PO);
+
+        try (XmlCursor m_xc = m_xo.newCursor();
+             XmlCursor xc1 = m_xo.newCursor()) {
+            m_xc.selectPath(ns + " .//po:shipTo/po:city");
             m_xc.toNextSelection();
-            xc1.selectPath(ns+" .//po:billTo/po:city");
+            xc1.selectPath(ns + " .//po:billTo/po:city");
             xc1.toNextSelection();
             xc1.toNextToken();
-            xc1.toNextChar(4);  // should be at 'T' in "Old Town"
-            m_xc.moveXml(xc1);     // should be "Old <city>Mill 
Valley</city>Town"
+            // should be at 'T' in "Old Town"
+            xc1.toNextChar(4);
+            // should be "Old <city>Mill Valley</city>Town"
+            m_xc.moveXml(xc1);
             // verify xc1
             xc1.toPrevToken();
             assertEquals(TokenType.END, xc1.currentTokenType());
@@ -153,36 +141,27 @@ public class MoveTest extends BasicCurso
             assertEquals("Mill Valley", xc1.getChars());
             xc1.toPrevToken();
             assertEquals(TokenType.START, xc1.currentTokenType());
-            assertEquals(new QName("city").getLocalPart(),
-                    xc1.getName().getLocalPart());
+            assertEquals(new QName("city").getLocalPart(), 
xc1.getName().getLocalPart());
             xc1.toPrevToken();
-
             assertEquals("Old ", xc1.getChars());
+            // verify m_xc
+            // skip the whitespace token
+            m_xc.toNextToken();
+            assertEquals("CA", m_xc.getTextValue());
         }
-        // verify m_xc
-        m_xc.toNextToken(); // skip the whitespace token
-
-        assertEquals("CA", m_xc.getTextValue());
     }
 
     /**
      * Method testMoveFromSTARTDOC
      * Also used to verify radar bug 16160
      */
-    @Test(expected = IllegalArgumentException.class)
-    public void testMoveFromSTARTDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO);
-        m_xc = m_xo.newCursor();
-        try {
-            m_xc.moveXml(m_xc);
-            fail("Expected IllegalArgumentException");
-        }
-        catch (IllegalArgumentException e) {
+    @Test
+    void testMoveFromSTARTDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO)) {
+            IllegalArgumentException e = 
assertThrows(IllegalArgumentException.class, () -> m_xc.moveXml(m_xc));
             // verify 16160
             String sTrace = Util.getStackTrace(e);
-            int i = sTrace.indexOf("splay.bitch");
-            assertTrue(i < 0);
-            throw e;
+            assertFalse(sTrace.contains("splay.bitch"));
         }
     }
 }

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/PrevTokenTypeTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/PrevTokenTypeTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/PrevTokenTypeTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/PrevTokenTypeTest.java Sun 
Feb  6 01:51:55 2022
@@ -16,88 +16,92 @@
 
 package xmlcursor.checkin;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Before;
-import xmlcursor.common.BasicCursorTestCase;
-
-import static org.junit.Assert.*;
-
-
-public class PrevTokenTypeTest extends BasicCursorTestCase {
-
-       @org.junit.Test
-    public void testAllTokensTest(){
-               m_xc.toEndDoc();
-               assertTrue(m_xc.isEnddoc());
-               assertTrue(m_xc.isFinish());
-               assertEquals(TokenType.END, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isEnd());
-               assertTrue(m_xc.isFinish());
-               assertEquals(TokenType.END, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-
-               assertTrue(m_xc.isEnd());
-               assertEquals(TokenType.TEXT, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isText());
-               assertFalse(m_xc.isContainer());
-               assertEquals(TokenType.ATTR, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isAttr());
-               assertTrue(m_xc.isAnyAttr());
-               assertEquals(TokenType.ATTR, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isAttr());
-               assertTrue(m_xc.isAnyAttr());
-               assertEquals(TokenType.START, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isStart());
-               assertTrue(m_xc.isContainer());
-               assertEquals(TokenType.TEXT, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isText());
-               assertEquals(TokenType.COMMENT, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isComment());
-               assertEquals(TokenType.PROCINST, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isProcinst());
-               assertEquals(TokenType.NAMESPACE, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isNamespace());
-               assertTrue(m_xc.isAnyAttr());
-               assertFalse(m_xc.isAttr());
-               assertEquals(TokenType.START, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isStart());
-               assertTrue(m_xc.isContainer());
-               assertEquals(TokenType.STARTDOC, m_xc.prevTokenType());
-               m_xc.toPrevToken();
-
-               assertTrue(m_xc.isStartdoc());
-               assertTrue(m_xc.isContainer());
-               assertEquals(TokenType.NONE, m_xc.prevTokenType());
-               //assert won't move further
-               assertEquals(TokenType.NONE, m_xc.toPrevToken());
-               assertEquals(true, m_xc.isStartdoc());
-    }
+import org.apache.xmlbeans.XmlException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static xmlcursor.common.BasicCursorTestCase.cur;
+
+
+public class PrevTokenTypeTest {
 
-       @Before
-    public void setUp() throws Exception{
-               String sDoc = "<foo 
xmlns:edi='http://ecommerce.org/schema'><?xml-stylesheet type=\"text/xsl\" 
xmlns=\"http://openuri.org/shipping/\";?><!-- the 'price' element's namespace is 
http://ecommerce.org/schema -->  <edi:price units='Euro' 
date='12-12-03'>32.18</edi:price></foo>";
-               m_xc = XmlObject.Factory.parse(sDoc).newCursor();
+       private static final String sDoc =
+               "<foo xmlns:edi='http://ecommerce.org/schema'>" +
+               "<?xml-stylesheet type=\"text/xsl\" 
xmlns=\"http://openuri.org/shipping/\";?>" +
+               "<!-- the 'price' element's namespace is 
http://ecommerce.org/schema -->  " +
+               "<edi:price units='Euro' 
date='12-12-03'>32.18</edi:price></foo>";
+
+       @Test
+    void testAllTokensTest() throws XmlException {
+               try (XmlCursor m_xc = cur(sDoc)) {
+
+                       m_xc.toEndDoc();
+                       assertTrue(m_xc.isEnddoc());
+                       assertTrue(m_xc.isFinish());
+                       assertEquals(TokenType.END, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isEnd());
+                       assertTrue(m_xc.isFinish());
+                       assertEquals(TokenType.END, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+
+                       assertTrue(m_xc.isEnd());
+                       assertEquals(TokenType.TEXT, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isText());
+                       assertFalse(m_xc.isContainer());
+                       assertEquals(TokenType.ATTR, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isAttr());
+                       assertTrue(m_xc.isAnyAttr());
+                       assertEquals(TokenType.ATTR, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isAttr());
+                       assertTrue(m_xc.isAnyAttr());
+                       assertEquals(TokenType.START, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isStart());
+                       assertTrue(m_xc.isContainer());
+                       assertEquals(TokenType.TEXT, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isText());
+                       assertEquals(TokenType.COMMENT, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isComment());
+                       assertEquals(TokenType.PROCINST, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isProcinst());
+                       assertEquals(TokenType.NAMESPACE, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isNamespace());
+                       assertTrue(m_xc.isAnyAttr());
+                       assertFalse(m_xc.isAttr());
+                       assertEquals(TokenType.START, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isStart());
+                       assertTrue(m_xc.isContainer());
+                       assertEquals(TokenType.STARTDOC, m_xc.prevTokenType());
+                       m_xc.toPrevToken();
+
+                       assertTrue(m_xc.isStartdoc());
+                       assertTrue(m_xc.isContainer());
+                       assertEquals(TokenType.NONE, m_xc.prevTokenType());
+                       //assert won't move further
+                       assertEquals(TokenType.NONE, m_xc.toPrevToken());
+                       assertTrue(m_xc.isStartdoc());
+               }
     }
 }

Modified: 
xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveAttributeTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveAttributeTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveAttributeTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveAttributeTest.java Sun 
Feb  6 01:51:55 2022
@@ -16,71 +16,72 @@
 
 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 javax.xml.namespace.QName;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+import static xmlcursor.common.BasicCursorTestCase.cur;
+import static xmlcursor.common.BasicCursorTestCase.toNextTokenOfType;
 
 
-public class RemoveAttributeTest extends BasicCursorTestCase {
+public class RemoveAttributeTest {
     @Test
-    public void testRemoveAttributeValidAttrFromSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        QName name = new QName("attr1");
-        assertTrue(m_xc.removeAttribute(name));
-        assertNull(m_xc.getAttributeText(name));
+    void testRemoveAttributeValidAttrFromSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            QName name = new QName("attr1");
+            assertTrue(m_xc.removeAttribute(name));
+            assertNull(m_xc.getAttributeText(name));
+        }
     }
 
     @Test
-    public void testRemoveAttributeInvalidAttrFromSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        QName name = new QName("invalid");
-        assertFalse(m_xc.removeAttribute(name));
+    void testRemoveAttributeInvalidAttrFromSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            QName name = new QName("invalid");
+            assertFalse(m_xc.removeAttribute(name));
+        }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testRemoveAttributeNullAttrFromSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        QName name = new QName("dummy");
-        m_xc.removeAttribute(null);
+    @Test
+    void testRemoveAttributeNullAttrFromSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            QName name = new QName("dummy");
+            assertThrows(IllegalArgumentException.class, () -> 
m_xc.removeAttribute(null));
+        }
     }
 
     @Test
-    public void testRemoveAttributeFromPROCINST() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.PROCINST);
-        QName name = new QName("type");
-        assertFalse(m_xc.removeAttribute(name));
+    void testRemoveAttributeFromPROCINST() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_PROCINST)) {
+            toNextTokenOfType(m_xc, TokenType.PROCINST);
+            QName name = new QName("type");
+            assertFalse(m_xc.removeAttribute(name));
+        }
     }
 
     @Test
-    public void testRemoveAttributeXMLNS() 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("xmlns");
-        assertFalse(m_xc.removeAttribute(name));
+    void testRemoveAttributeXMLNS() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            QName name = new QName("xmlns");
+            assertFalse(m_xc.removeAttribute(name));
+        }
     }
 
     @Test
-    public void testRemoveAttributeFromEND() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.END);
-        QName name = new QName("attr1");
-        assertFalse(m_xc.removeAttribute(name));
+    void testRemoveAttributeFromEND() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.END);
+            QName name = new QName("attr1");
+            assertFalse(m_xc.removeAttribute(name));
+        }
     }
 }
 

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveCharsTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveCharsTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveCharsTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveCharsTest.java Sun Feb 
 6 01:51:55 2022
@@ -16,66 +16,67 @@
 
 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 xmlcursor.common.BasicCursorTestCase.cur;
+import static xmlcursor.common.BasicCursorTestCase.toNextTokenOfType;
 
 
-public class RemoveCharsTest extends BasicCursorTestCase {
+public class RemoveCharsTest {
     @Test
-    public void testRemoveCharsLTLengthFromTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        assertEquals(3, m_xc.removeChars(3));
-        assertEquals("34", m_xc.getChars());
+    void testRemoveCharsLTLengthFromTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertEquals(3, m_xc.removeChars(3));
+            assertEquals("34", m_xc.getChars());
+        }
     }
 
     @Test
-    public void testRemoveCharsGTLengthFromTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        assertEquals(5, m_xc.removeChars(10));
-        assertEquals(TokenType.END, m_xc.currentTokenType());
+    void testRemoveCharsGTLengthFromTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertEquals(5, m_xc.removeChars(10));
+            assertEquals(TokenType.END, m_xc.currentTokenType());
+        }
     }
 
     @Test
-    public void testRemoveCharsNegativeFromTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        assertEquals(5, m_xc.removeChars(-1));
-        assertEquals(TokenType.END, m_xc.currentTokenType());
+    void testRemoveCharsNegativeFromTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertEquals(5, m_xc.removeChars(-1));
+            assertEquals(TokenType.END, m_xc.currentTokenType());
+        }
     }
 
     @Test
-    public void testRemoveCharsZeroFromTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        assertEquals(0, m_xc.removeChars(0));
-        assertEquals("01234", m_xc.getChars());
+    void testRemoveCharsZeroFromTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertEquals(0, m_xc.removeChars(0));
+            assertEquals("01234", m_xc.getChars());
+        }
     }
 
     @Test
-    public void testRemoveCharsFromPROCINST() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.PROCINST);
-        assertEquals(0, m_xc.removeChars(3));
+    void testRemoveCharsFromPROCINST() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_PROCINST)) {
+            toNextTokenOfType(m_xc, TokenType.PROCINST);
+            assertEquals(0, m_xc.removeChars(3));
+        }
     }
 
     @Test
-    public void testRemoveCharsFromNAMESPACE() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_NS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.NAMESPACE);
-        assertEquals(0, m_xc.removeChars(3));
+    void testRemoveCharsFromNAMESPACE() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_NS)) {
+            toNextTokenOfType(m_xc, TokenType.NAMESPACE);
+            assertEquals(0, m_xc.removeChars(3));
+        }
     }
 }
 

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/RemoveTest.java Sun Feb  6 
01:51:55 2022
@@ -17,105 +17,94 @@
 package xmlcursor.checkin;
 
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.values.XmlValueDisconnectedException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import test.xbean.xmlcursor.purchaseOrder.USAddress;
-import tools.util.JarUtil;
-import xmlcursor.common.BasicCursorTestCase;
 import xmlcursor.common.Common;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
-public class RemoveTest extends BasicCursorTestCase {
-    @Test(expected = IllegalStateException.class)
-    public void testRemoveFromSTARTDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        m_xc.removeXml();
-    }
-
-    @Test
-    public void testRemoveFromFirstChild() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        m_xc.toFirstChild();
-        m_xc.removeXml();
-        assertEquals(TokenType.ENDDOC, m_xc.currentTokenType());
-    }
-
-    @Test
-    public void testRemoveAllText() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.removeXml();
-        assertEquals(TokenType.END, m_xc.currentTokenType());
-        m_xc.toStartDoc();
-        assertEquals("<foo><bar/></foo>", m_xc.xmlText());
-    }
-
-    @Test
-    public void testRemovePartialText() 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.removeXml();
-        assertEquals(TokenType.END, m_xc.currentTokenType());
-        m_xc.toStartDoc();
-        assertEquals("<foo><bar>te</bar></foo>", m_xc.xmlText());
-    }
-
-    @Test
-    public void testRemoveFromATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        m_xc.removeXml();
-        assertEquals(TokenType.ATTR, m_xc.currentTokenType());
-        m_xc.toStartDoc();
-        assertEquals("<foo attr1=\"val1\">text</foo>", m_xc.xmlText());
-    }
-
-    @Test(expected = XmlValueDisconnectedException.class)
-    public void testRemoveAffectOnXmlObjectGetXXX() throws Exception {
-        //  m_xo =XmlObject.Factory.parse(JarUtil.getResourceFromJar(
-        //          Common.XMLCASES_JAR, Common.TRANXML_FILE_XMLCURSOR_PO));
-        //XmlObject.Factory.parse(Common.XML_PURCHASEORDER);
-        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();
-        XmlObject xo = m_xc.getObject();
-        USAddress usa = (USAddress) xo;
-        m_xc.removeXml();
-        usa.getCity();
-    }
-
-    @Test(expected = XmlValueDisconnectedException.class)
-    public void testRemoveAffectOnXmlObjectNewCursor() throws Exception {
-        // m_xo = XmlObject.Factory.parse(Common.XML_PURCHASEORDER);
-        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();
-        XmlObject xo = m_xc.getObject();
-        USAddress usa = (USAddress) xo;
-        m_xc.removeXml();
-        assertNotNull("USAddress object expected non-null, but is null", usa);
-        m_xc = usa.newCursor();
+public class RemoveTest {
+    @Test
+    void testRemoveFromSTARTDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            assertThrows(IllegalStateException.class,  m_xc::removeXml);
+        }
+    }
+
+    @Test
+    void testRemoveFromFirstChild() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            m_xc.toFirstChild();
+            m_xc.removeXml();
+            assertEquals(TokenType.ENDDOC, m_xc.currentTokenType());
+        }
+    }
+
+    @Test
+    void testRemoveAllText() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.removeXml();
+            assertEquals(TokenType.END, m_xc.currentTokenType());
+            m_xc.toStartDoc();
+            assertEquals("<foo><bar/></foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testRemovePartialText() 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.removeXml();
+            assertEquals(TokenType.END, m_xc.currentTokenType());
+            m_xc.toStartDoc();
+            assertEquals("<foo><bar>te</bar></foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testRemoveFromATTR() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            m_xc.removeXml();
+            assertEquals(TokenType.ATTR, m_xc.currentTokenType());
+            m_xc.toStartDoc();
+            assertEquals("<foo attr1=\"val1\">text</foo>", m_xc.xmlText());
+        }
+    }
+
+    @Test
+    void testRemoveAffectOnXmlObjectGetXXX() 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();
+            XmlObject xo = m_xc.getObject();
+            USAddress usa = (USAddress) xo;
+            m_xc.removeXml();
+            assertThrows(XmlValueDisconnectedException.class, usa::getCity);
+        }
+    }
+
+    @Test
+    void testRemoveAffectOnXmlObjectNewCursor() 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();
+            XmlObject xo = m_xc.getObject();
+            USAddress usa = (USAddress) xo;
+            m_xc.removeXml();
+            assertNotNull(usa, "USAddress object expected non-null, but is 
null");
+            assertThrows(XmlValueDisconnectedException.class, usa::newCursor);
+        }
     }
 }
 

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/SelectPathTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/SelectPathTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/SelectPathTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/SelectPathTest.java Sun Feb  
6 01:51:55 2022
@@ -17,98 +17,90 @@
 package xmlcursor.checkin;
 
 import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Ignore;
-import org.junit.Test;
-import tools.util.JarUtil;
-import xmlcursor.common.BasicCursorTestCase;
+import org.junit.jupiter.api.Disabled;
+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.jcur;
+import static xmlcursor.common.BasicCursorTestCase.toNextTokenOfType;
 
 
-public class SelectPathTest extends BasicCursorTestCase {
+public class SelectPathTest {
     /**
      * $BUGBUG: Eric's engine doesn't send to Jaxen appropriately
      */
     @Test
-    @Ignore
+    @Disabled
     public void testSelectPathFromEND() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-            JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
         String ns = "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\"";;
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, XmlCursor.TokenType.END);
-        m_xc.selectPath(ns + " $this//city");
-        assertEquals(0, m_xc.getSelectionCount());
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            toNextTokenOfType(m_xc, XmlCursor.TokenType.END);
+            m_xc.selectPath(ns + " $this//city");
+            assertEquals(0, m_xc.getSelectionCount());
+        }
     }
 
     @Test
-    @Ignore
+    @Disabled
     public void testSelectPathFromENDDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-            JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
-        String ns="declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\"";;
-        toNextTokenOfType(m_xc, XmlCursor.TokenType.ENDDOC);
-        m_xc.selectPath(ns+" .//po:city");
-        assertEquals(0, m_xc.getSelectionCount());
+        String ns = "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\"";;
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            toNextTokenOfType(m_xc, XmlCursor.TokenType.ENDDOC);
+            m_xc.selectPath(ns + " .//po:city");
+            assertEquals(0, m_xc.getSelectionCount());
+        }
+    }
+
+    @Test
+    void testSelectPathNamespace() throws Exception {
+        String sLocalPath = ".//FleetID";
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_CLM)) {
+            m_xc.selectPath(sLocalPath);
+            assertEquals(0, m_xc.getSelectionCount());
+            m_xc.selectPath(Common.CLM_NS_XQUERY_DEFAULT + sLocalPath);
+            assertEquals(1, m_xc.getSelectionCount());
+        }
+    }
+
+    @Test
+    void testSelectPathCaseSensitive() throws Exception {
+        String ns = "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";";;
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            m_xc.selectPath(ns + " .//po:ciTy");
+            assertEquals(0, m_xc.getSelectionCount());
+            m_xc.selectPath(ns + " .//po:city");
+            assertEquals(2, m_xc.getSelectionCount());
+        }
     }
 
     @Test
-    public void testSelectPathNamespace() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
-        m_xc = m_xo.newCursor();
-        String sLocalPath =".//FleetID";
-        m_xc.selectPath(sLocalPath);
-        assertEquals(0, m_xc.getSelectionCount());
-        m_xc.selectPath(Common.CLM_NS_XQUERY_DEFAULT +
-                        sLocalPath);
-        assertEquals(1, m_xc.getSelectionCount());
+    void testSelectPathReservedKeyword() throws Exception {
+        String ns = "declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";";;
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            m_xc.selectPath(ns + " .//po:item");
+            assertEquals(2, m_xc.getSelectionCount());
+        }
     }
 
     @Test
-    public void testSelectPathCaseSensitive() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
-        String ns="declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";";;
-        m_xc.selectPath(ns+" .//po:ciTy");
-        assertEquals(0, m_xc.getSelectionCount());
-        m_xc.selectPath(ns+" .//po:city");
-        assertEquals(2, m_xc.getSelectionCount());
+    void testSelectPathNull() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            // TODO: surround with appropriate t-c once ericvas creates the 
exception type
+            //  see bugs 18009 and/or 18718
+            assertThrows(RuntimeException.class, () -> m_xc.selectPath(null));
+        }
     }
 
     @Test
-    public void testSelectPathReservedKeyword() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
-        String ns="declare namespace 
po=\"http://xbean.test/xmlcursor/PurchaseOrder\";";;
-        m_xc.selectPath(ns+" .//po:item");
-        assertEquals(2, m_xc.getSelectionCount());
-    }
-
-    @Test(expected = RuntimeException.class)
-    public void testSelectPathNull() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
-        // TODO: surround with appropriate t-c once ericvas creates the 
exception type
-        // see bugs 18009 and/or 18718
-        m_xc.selectPath(null);
-    }
-
-    @Test(expected = RuntimeException.class)
-    public void testSelectPathInvalidXPath() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
-        // TODO: surround with appropriate t-c once ericvas creates the 
exception type
-        // see bugs 18009 and/or 18718
-        m_xc.selectPath("&GARBAGE");
-        m_xc.getSelectionCount();
+    void testSelectPathInvalidXPath() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            // TODO: surround with appropriate t-c once ericvas creates the 
exception type
+            // see bugs 18009 and/or 18718
+            m_xc.selectPath("&GARBAGE");
+            assertThrows(RuntimeException.class, m_xc::getSelectionCount);
+        }
     }
 }
 

Modified: 
xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetAttributeTextTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetAttributeTextTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetAttributeTextTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetAttributeTextTest.java 
Sun Feb  6 01:51:55 2022
@@ -16,58 +16,55 @@
 
 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 javax.xml.namespace.QName;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
 
-public class SetAttributeTextTest extends BasicCursorTestCase {
+public class SetAttributeTextTest {
     @Test
-    public void testSetAttributeTextFromSTARTOn2ndATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        QName name = new QName("attr2");
-        assertTrue(m_xc.setAttributeText(name, "newval2"));
-        assertEquals("newval2", m_xc.getAttributeText(name));
+    void testSetAttributeTextFromSTARTOn2ndATTR() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            QName name = new QName("attr2");
+            assertTrue(m_xc.setAttributeText(name, "newval2"));
+            assertEquals("newval2", m_xc.getAttributeText(name));
+        }
     }
 
     @Test
-    public void testSetAttributeTextNewName() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        QName name = new QName("newname");
-        assertTrue(m_xc.setAttributeText(name, "newval2"));
-        assertEquals("newval2", m_xc.getAttributeText(name));
+    void testSetAttributeTextNewName() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_2ATTR_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            QName name = new QName("newname");
+            assertTrue(m_xc.setAttributeText(name, "newval2"));
+            assertEquals("newval2", m_xc.getAttributeText(name));
+        }
     }
 
     @Test
-    public void testSetAttributeTextFromSTARTChildHasATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
-        m_xc.selectPath("$this//purchaseOrder");
-        QName name = new QName("country");
-        assertTrue(m_xc.setAttributeText(name, "Finland"));
-        assertEquals("Finland", m_xc.getAttributeText(name));
+    void testSetAttributeTextFromSTARTChildHasATTR() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            m_xc.selectPath("$this//purchaseOrder");
+            QName name = new QName("country");
+            assertTrue(m_xc.setAttributeText(name, "Finland"));
+            assertEquals("Finland", m_xc.getAttributeText(name));
+        }
     }
 
     @Test
-    public void testSetAttributeTextFromATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(
-                 JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        QName name = new QName("orderDate");
-        assertFalse(m_xc.setAttributeText(name, "2003-01-10"));
+    void testSetAttributeTextFromATTR() throws Exception {
+        try (XmlCursor m_xc = jcur(Common.TRANXML_FILE_XMLCURSOR_PO)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            QName name = new QName("orderDate");
+            assertFalse(m_xc.setAttributeText(name, "2003-01-10"));
+        }
     }
 }
 

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetBookmarkTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetBookmarkTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetBookmarkTest.java 
(original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetBookmarkTest.java Sun Feb 
 6 01:51:55 2022
@@ -19,123 +19,124 @@ 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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static xmlcursor.common.BasicCursorTestCase.*;
 
 
-public class SetBookmarkTest extends BasicCursorTestCase {
-    private SimpleBookmark _theBookmark = new SimpleBookmark("value");
-    private SimpleBookmark _theBookmark1 = new SimpleBookmark("value1");
+public class SetBookmarkTest {
+    private static final SimpleBookmark _theBookmark = new 
SimpleBookmark("value");
+    private static final SimpleBookmark _theBookmark1 = new 
SimpleBookmark("value1");
 
     @Test
-    public void testSetBookmarkAtSTARTDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.setBookmark(_theBookmark);
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value", sa.text);
+    void testSetBookmarkAtSTARTDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            m_xc.setBookmark(_theBookmark);
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value", sa.text);
+        }
     }
 
     @Test
-    public void testSetBookmarkDuplicateKey() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.setBookmark(_theBookmark);
-        m_xc.setBookmark(_theBookmark1);
-        // should overwrite the Bookmark of same key analogous to hashtable
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value1", sa.text);
+    void testSetBookmarkDuplicateKey() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            m_xc.setBookmark(_theBookmark);
+            m_xc.setBookmark(_theBookmark1);
+            // should overwrite the Bookmark of same key analogous to hashtable
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value1", sa.text);
+        }
     }
 
     @Test
-    public void testSetBookmarkDuplicateKeyDifferentLocation() throws 
Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        m_xc.setBookmark(_theBookmark);
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.setBookmark(_theBookmark1);
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value1", sa.text);
-        m_xc.toStartDoc();
-        sa = (SimpleBookmark) m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value", sa.text);
+    void testSetBookmarkDuplicateKeyDifferentLocation() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            m_xc.setBookmark(_theBookmark);
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.setBookmark(_theBookmark1);
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value1", sa.text);
+            m_xc.toStartDoc();
+            sa = (SimpleBookmark) m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value", sa.text);
+        }
     }
 
     @Test
-    public void testSetBookmarkAtSTART() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        m_xc.setBookmark(_theBookmark);
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value", sa.text);
+    void testSetBookmarkAtSTART() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            m_xc.setBookmark(_theBookmark);
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value", sa.text);
+        }
     }
 
     @Test
-    public void testSetBookmarkAtATTR() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        m_xc.setBookmark(_theBookmark);
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value", sa.text);
+    void testSetBookmarkAtATTR() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_1ATTR)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            m_xc.setBookmark(_theBookmark);
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value", sa.text);
+        }
     }
 
     @Test
-    public void testSetBookmarkAtPROCINST() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.PROCINST);
-        m_xc.setBookmark(_theBookmark);
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value", sa.text);
+    void testSetBookmarkAtPROCINST() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_PROCINST)) {
+            toNextTokenOfType(m_xc, TokenType.PROCINST);
+            m_xc.setBookmark(_theBookmark);
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value", sa.text);
+        }
     }
 
     @Test
-    public void testSetBookmarkInMiddleOfTEXT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(3);
-        m_xc.setBookmark(_theBookmark);
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value", sa.text);
+    void testSetBookmarkInMiddleOfTEXT() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_TEXT)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(3);
+            m_xc.setBookmark(_theBookmark);
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value", sa.text);
+        }
     }
 
     @Test
-    public void testSetBookmarkAtENDDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.END);
-        m_xc.setBookmark(_theBookmark);
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertEquals("value", sa.text);
+    void testSetBookmarkAtENDDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_1ATTR)) {
+            toNextTokenOfType(m_xc, TokenType.END);
+            m_xc.setBookmark(_theBookmark);
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertEquals("value", sa.text);
+        }
     }
 
     @Test
-    public void testSetBookmarkNull() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.END);
-        m_xc.setBookmark(null);
-        SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
-        assertNull(sa);
+    void testSetBookmarkNull() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_1ATTR)) {
+            toNextTokenOfType(m_xc, TokenType.END);
+            m_xc.setBookmark(null);
+            SimpleBookmark sa = (SimpleBookmark) 
m_xc.getBookmark(SimpleBookmark.class);
+            assertNull(sa);
+        }
     }
 
     @Test
-    public void testXmlDocumentProperties() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR);
+    void testXmlDocumentProperties() throws Exception {
+        XmlObject m_xo = obj(Common.XML_FOO_1ATTR);
         m_xo.documentProperties().put("fredkey", "fredvalue");
-        m_xc = m_xo.newCursor();
-        assertEquals("fredvalue", m_xo.documentProperties().get("fredkey"));
+        try (XmlCursor m_xc = m_xo.newCursor()) {
+            assertEquals("fredvalue", 
m_xo.documentProperties().get("fredkey"));
+        }
     }
 
 
-    public class SimpleBookmark extends XmlCursor.XmlBookmark {
+    private static class SimpleBookmark extends XmlCursor.XmlBookmark {
         public String text;
 
         SimpleBookmark(String text) {

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetNameTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetNameTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetNameTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetNameTest.java Sun Feb  6 
01:51:55 2022
@@ -16,64 +16,62 @@
 
 package xmlcursor.checkin;
 
-import org.apache.xmlbeans.XmlObject;
-import org.junit.Before;
-import org.junit.Test;
-import xmlcursor.common.BasicCursorTestCase;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
+import org.junit.jupiter.api.Test;
 
 import javax.xml.namespace.QName;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-
-public class SetNameTest extends BasicCursorTestCase{
-
-       @Test
-       public void testNormalCase(){
-               m_xc.toFirstChild();
-               QName newName = new QName("newBook");
-               m_xc.setName(newName);
-               assertEquals(m_xc.getName(), newName);
-
-               newName = new QName("uri:newUri", "newBook");
-               m_xc.setName(newName);
-               assertEquals(m_xc.getName(), newName);
-
-
-               newName = new QName("uri:newUri", "newBook", "prefix");
-               m_xc.setName(newName);
-               assertEquals(m_xc.getName(), newName);
-
-               //should work for attrs too...
-               m_xc.toFirstAttribute();
-               newName = new QName("uri:newUri", "newBook", "prefix");
-               m_xc.setName(newName);
-               assertEquals(m_xc.getName(), newName);
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static xmlcursor.common.BasicCursorTestCase.cur;
+
+
+public class SetNameTest {
+
+    private static final String XML =
+        "<bk:book at0=\"value0\" xmlns:bk=\"urn:loc.gov:books\">text0<author 
at0=\"v0\" at1=\"value1\"/></bk:book>";
+
+    @Test
+    void testNormalCase() throws XmlException {
+               try (XmlCursor m_xc = cur(XML)) {
+                       m_xc.toFirstChild();
+                       QName newName = new QName("newBook");
+                       m_xc.setName(newName);
+                       assertEquals(m_xc.getName(), newName);
+
+                       newName = new QName("uri:newUri", "newBook");
+                       m_xc.setName(newName);
+                       assertEquals(m_xc.getName(), newName);
+
+
+                       newName = new QName("uri:newUri", "newBook", "prefix");
+                       m_xc.setName(newName);
+                       assertEquals(m_xc.getName(), newName);
+
+                       //should work for attrs too...
+                       m_xc.toFirstAttribute();
+                       newName = new QName("uri:newUri", "newBook", "prefix");
+                       m_xc.setName(newName);
+                       assertEquals(m_xc.getName(), newName);
+               }
     }
 
-       @Test
-    public void testNoUri(){
-               m_xc.toFirstChild();
-               QName newName = new QName(null, "newBook");
-               m_xc.setName(newName);
-               assertEquals(m_xc.getName().getLocalPart(), "newBook");
-       }
-
-       @Test
-       public void testNull() {
-               m_xc.toFirstChild();
-               try {
-                       m_xc.setName(null);
-                       fail("QName null");
-               } catch (Exception e) {
-                       System.err.println(e.getMessage());
+    @Test
+    void testNoUri() throws XmlException {
+               try (XmlCursor m_xc = cur(XML)) {
+                       m_xc.toFirstChild();
+                       QName newName = new QName(null, "newBook");
+                       m_xc.setName(newName);
+                       assertEquals(m_xc.getName().getLocalPart(), "newBook");
                }
     }
 
-    @Before
-    public void setUp()throws Exception{
-               String sTestXml = "<bk:book at0=\"value0\" 
xmlns:bk=\"urn:loc.gov:books\">text0<author at0=\"v0\" 
at1=\"value1\"/></bk:book>";
-               m_xc=XmlObject.Factory.parse(sTestXml).newCursor();
+    @Test
+    void testNull() throws XmlException {
+               try (XmlCursor m_xc = cur(XML)) {
+                       m_xc.toFirstChild();
+                       assertThrows(Exception.class, () -> m_xc.setName(null), 
"QName null");
+               }
     }
 }

Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetTextTest.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetTextTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetTextTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/SetTextTest.java Sun Feb  6 
01:51:55 2022
@@ -16,134 +16,137 @@
 
 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 SetTextTest extends BasicCursorTestCase {
+public class SetTextTest {
     @Test
-    public void testSetTextFromCOMMENT() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.COMMENT);
-        m_xc.setTextValue("fred");
-        assertEquals("fred", m_xc.getTextValue());
+    void testSetTextFromCOMMENT() throws Exception {
+
+        try (XmlCursor m_xc = cur(Common.XML_FOO_COMMENT)) {
+            toNextTokenOfType(m_xc, TokenType.COMMENT);
+            m_xc.setTextValue("fred");
+            assertEquals("fred", m_xc.getTextValue());
+        }
     }
 
     @Test
-    public void testSetTextFromPROCINST() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.PROCINST);
-        m_xc.setTextValue("new procinst text");
-        assertEquals("new procinst text", m_xc.getTextValue());
+    void testSetTextFromPROCINST() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_PROCINST)) {
+            toNextTokenOfType(m_xc, TokenType.PROCINST);
+            m_xc.setTextValue("new procinst text");
+            assertEquals("new procinst text", m_xc.getTextValue());
+        }
     }
 
     @Test
-    public void testSetTextFromPROCINSTInputNull() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.PROCINST);
-        m_xc.setTextValue(null);
-        assertEquals("", m_xc.getTextValue());
+    void testSetTextFromPROCINSTInputNull() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_PROCINST)) {
+            toNextTokenOfType(m_xc, TokenType.PROCINST);
+            m_xc.setTextValue(null);
+            assertEquals("", m_xc.getTextValue());
+        }
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void testSetTextFromEND() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.END);
-        m_xc.setTextValue("fred");
+    @Test
+    void testSetTextFromEND() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_COMMENT)) {
+            toNextTokenOfType(m_xc, TokenType.END);
+            assertThrows(IllegalStateException.class, () -> 
m_xc.setTextValue("fred"));
+        }
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void testSetTextFromENDDOC() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_NS);
-        m_xc = m_xo.newCursor();
-        m_xc.toEndDoc();
-        m_xc.setTextValue("fred");
+    @Test
+    void testSetTextFromENDDOC() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_NS)) {
+            m_xc.toEndDoc();
+            assertThrows(IllegalStateException.class, () -> 
m_xc.setTextValue("fred"));
+        }
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void testSetTextFromTEXTbegin() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        assertEquals("01234", m_xc.getChars());
-        m_xc.setTextValue("new text");
+    @Test
+    void testSetTextFromTEXTbegin() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            assertEquals("01234", m_xc.getChars());
+            assertThrows(IllegalStateException.class, () -> 
m_xc.setTextValue("new text"));
+        }
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void testSetTextFromTEXTmiddle() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.TEXT);
-        m_xc.toNextChar(2);
-        assertEquals("234", m_xc.getChars());
-        m_xc.setTextValue("new text");
+    @Test
+    void testSetTextFromTEXTmiddle() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.TEXT);
+            m_xc.toNextChar(2);
+            assertEquals("234", m_xc.getChars());
+            assertThrows(IllegalStateException.class, () -> 
m_xc.setTextValue("new text"));
+        }
     }
 
     @Test
-    public void testSetTextFromSTARTnotNested() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        assertEquals("01234", m_xc.getTextValue());
-        m_xc.setTextValue("new text");
-        assertEquals("new text", m_xc.getTextValue());
+    void testSetTextFromSTARTnotNested() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertEquals("01234", m_xc.getTextValue());
+            m_xc.setTextValue("new text");
+            assertEquals("new text", m_xc.getTextValue());
+        }
     }
 
     @Test
-    public void testSetTextFromSTARTnotNestedInputNull() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        assertEquals("01234", m_xc.getTextValue());
-        m_xc.setTextValue(null);
-        assertEquals("", m_xc.getTextValue());
+    void testSetTextFromSTARTnotNestedInputNull() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_DIGITS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertEquals("01234", m_xc.getTextValue());
+            m_xc.setTextValue(null);
+            assertEquals("", m_xc.getTextValue());
+        }
     }
 
     @Test
-    public void testSetTextFromSTARTnested() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_NESTED_SIBLINGS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        assertEquals("text0nested0text1nested1", m_xc.getTextValue());
-        m_xc.setTextValue("new text");
-        assertEquals("<foo attr0=\"val0\">new text</foo>", m_xc.xmlText());
+    void testSetTextFromSTARTnested() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_NESTED_SIBLINGS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertEquals("text0nested0text1nested1", m_xc.getTextValue());
+            m_xc.setTextValue("new text");
+            assertEquals("<foo attr0=\"val0\">new text</foo>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testSetTextFromSTARTnestedInputNull() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_NESTED_SIBLINGS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.START);
-        assertEquals("text0nested0text1nested1", m_xc.getTextValue());
-        m_xc.setTextValue(null);
-        assertEquals("<foo attr0=\"val0\"/>", m_xc.xmlText());
+    void testSetTextFromSTARTnestedInputNull() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_NESTED_SIBLINGS)) {
+            toNextTokenOfType(m_xc, TokenType.START);
+            assertEquals("text0nested0text1nested1", m_xc.getTextValue());
+            m_xc.setTextValue(null);
+            assertEquals("<foo attr0=\"val0\"/>", m_xc.xmlText());
+        }
     }
 
     @Test
-    public void testSetTextFromATTRnested() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_NESTED_SIBLINGS);
-        m_xc = m_xo.newCursor();
-        toNextTokenOfType(m_xc, TokenType.ATTR);
-        assertEquals("val0", m_xc.getTextValue());
-        m_xc.setTextValue("new text");
-        assertEquals("new text", m_xc.getTextValue());
+    void testSetTextFromATTRnested() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_NESTED_SIBLINGS)) {
+            toNextTokenOfType(m_xc, TokenType.ATTR);
+            assertEquals("val0", m_xc.getTextValue());
+            m_xc.setTextValue("new text");
+            assertEquals("new text", m_xc.getTextValue());
+        }
     }
 
     @Test
-    public void testSetTextFromSTARTDOCnested() throws Exception {
-        m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_NESTED_SIBLINGS);
-        m_xc = m_xo.newCursor();
-        assertEquals("text0nested0text1nested1", m_xc.getTextValue());
-        m_xc.setTextValue("new text");
-        assertEquals(Common.wrapInXmlFrag("new text"), m_xc.xmlText());
+    void testSetTextFromSTARTDOCnested() throws Exception {
+        try (XmlCursor m_xc = cur(Common.XML_FOO_BAR_NESTED_SIBLINGS)) {
+            assertEquals("text0nested0text1nested1", m_xc.getTextValue());
+            m_xc.setTextValue("new text");
+            assertEquals(Common.wrapInXmlFrag("new text"), m_xc.xmlText());
+        }
     }
 }
 



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

Reply via email to