Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/MoveCharsTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/MoveCharsTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/MoveCharsTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/MoveCharsTest.java Fri Jan 18 23:08:44 2019 @@ -16,37 +16,19 @@ package xmlcursor.checkin; -import org.apache.xmlbeans.XmlOptions; -import junit.framework.*; -import junit.framework.Assert.*; - -import java.io.*; - -import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlCursor.TokenType; +import org.apache.xmlbeans.XmlObject; +import org.junit.Test; +import xmlcursor.common.BasicCursorTestCase; +import xmlcursor.common.Common; -import javax.xml.namespace.QName; - -import xmlcursor.common.*; - -import java.net.URL; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; -/** - * - * - */ public class MoveCharsTest extends BasicCursorTestCase { - public MoveCharsTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(MoveCharsTest.class); - } - + @Test public void testMoveCharsOverlap() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS); m_xc = m_xo.newCursor(); @@ -64,6 +46,7 @@ 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(); @@ -87,18 +70,15 @@ 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); - try { - m_xc.moveChars(4, null); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException ise) { - } - assertEquals(true, true); + 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(); @@ -107,7 +87,7 @@ public class MoveCharsTest extends Basic toNextTokenOfType(m_xc, TokenType.TEXT); XmlCursor xc1 = m_xc.newCursor(); try { - assertEquals(false, xc0.isAtSamePositionAs(xc1)); + assertFalse(xc0.isAtSamePositionAs(xc1)); assertEquals(4, xc1.moveChars(4, xc0)); assertEquals("0123", xc0.getChars()); xc0.toPrevToken(); @@ -115,18 +95,14 @@ public class MoveCharsTest extends Basic System.out.println("we are here"); assertEquals(TokenType.END, xc1.currentTokenType()); - - try { - xc1.getTextValue(); - fail("Expected IllegalStateException"); - } catch (IllegalStateException e) { - } + xc1.getTextValue(); } finally { xc0.dispose(); xc1.dispose(); } } + @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(); @@ -135,24 +111,20 @@ public class MoveCharsTest extends Basic toNextTokenOfType(m_xc, TokenType.TEXT); XmlCursor xc1 = m_xc.newCursor(); try { - assertEquals(false, xc0.isAtSamePositionAs(xc1)); + 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()); - try { - xc1.getTextValue(); - fail("Expected IllegalStateException"); - } catch (IllegalStateException e) { - } - + xc1.getTextValue(); } finally { xc0.dispose(); xc1.dispose(); } } + @Test public void testMoveCharsZero() throws Exception { m_xo = XmlObject.Factory.parse("<foo><bar>0123</bar><bar>WXYZ</bar></foo>"); m_xc = m_xo.newCursor(); @@ -161,35 +133,33 @@ public class MoveCharsTest extends Basic toNextTokenOfType(m_xc, TokenType.TEXT); XmlCursor xc1 = m_xc.newCursor(); try { - assertEquals(false, xc0.isAtSamePositionAs(xc1)); + assertFalse(xc0.isAtSamePositionAs(xc1)); assertEquals(0, xc1.moveChars(0, xc0)); assertEquals("0123", xc0.getChars()); xc0.toPrevToken(); assertEquals("0123", xc0.getTextValue()); assertEquals(TokenType.TEXT, xc1.currentTokenType()); assertEquals("WXYZ", xc1.getChars()); - - } finally { xc0.dispose(); xc1.dispose(); } } + @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(); XmlCursor xc0 = m_xo.newCursor(); toNextTokenOfType(m_xc, TokenType.TEXT); - try { + try{ m_xc.moveChars(4, xc0); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException ise) { } finally { xc0.dispose(); } } + @Test public void testMoveCharsToPROCINST() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST); m_xc = m_xo.newCursor(); @@ -206,6 +176,7 @@ 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(); @@ -214,7 +185,7 @@ public class MoveCharsTest extends Basic toNextTokenOfType(m_xc, TokenType.TEXT); XmlCursor xc1 = m_xc.newCursor(); try { - assertEquals(false, xc0.isAtSamePositionAs(xc1)); + assertFalse(xc0.isAtSamePositionAs(xc1)); assertEquals(4, xc1.moveChars(1000, xc0)); assertEquals("0123", xc0.getChars()); xc0.toPrevToken(); @@ -222,17 +193,14 @@ public class MoveCharsTest extends Basic assertEquals(TokenType.END, xc1.currentTokenType()); - try { - xc1.getTextValue(); - fail("Expected IllegalStateException"); - } catch (IllegalStateException e) { - } + xc1.getTextValue(); } finally { xc0.dispose(); xc1.dispose(); } } + @Test public void testMoveCharsToNewDocument() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS); m_xc = m_xo.newCursor();
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/MoveTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/MoveTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/MoveTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/MoveTest.java Fri Jan 18 23:08:44 2019 @@ -16,47 +16,30 @@ package xmlcursor.checkin; -import junit.framework.*; - -import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlCursor.TokenType; - -import javax.xml.namespace.QName; - -import xmlcursor.common.*; - - +import org.apache.xmlbeans.XmlObject; +import org.junit.Test; import tools.util.JarUtil; import tools.util.Util; +import xmlcursor.common.BasicCursorTestCase; +import xmlcursor.common.Common; +import javax.xml.namespace.QName; -/** - * - * - */ -public class MoveTest extends BasicCursorTestCase { - public MoveTest(String sName) { - super(sName); - } +import static org.junit.Assert.*; - public static Test suite() { - return new TestSuite(MoveTest.class); - } +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); - try { - m_xc.moveXml(null); - fail( - "Expected IllegalArgumentException. Can't move to foreign document"); - } - catch (IllegalArgumentException e) { - } + m_xc.moveXml(null); } + @Test public void testMoveDifferentStoresLoadedByParse() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS); m_xc = m_xo.newCursor(); @@ -73,6 +56,7 @@ public class MoveTest extends BasicCurso assertEquals(TokenType.END, m_xc.currentTokenType()); } + @Test public void testMoveDifferentStoresLoadedFromFile() throws Exception { // load the documents and obtain a cursor XmlObject xobj0 = XmlObject.Factory.parse( @@ -113,6 +97,7 @@ 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(); @@ -124,6 +109,7 @@ public class MoveTest extends BasicCurso assertEquals("01234", m_xc.getChars()); } + @Test public void testMoveNewLocation() throws Exception { m_xo=XmlObject.Factory.parse( JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO)); @@ -148,6 +134,7 @@ public class MoveTest extends BasicCurso assertEquals("CA", m_xc.getTextValue()); } + @Test public void testMoveElementToMiddleOfTEXT() throws Exception { m_xo = XmlObject.Factory.parse( JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO)); @@ -182,11 +169,9 @@ public class MoveTest extends BasicCurso /** * Method testMoveFromSTARTDOC - * <p/> * Also used to verify radar bug 16160 - * - * @throws Exception */ + @Test(expected = IllegalArgumentException.class) public void testMoveFromSTARTDOC() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO); m_xc = m_xo.newCursor(); @@ -199,10 +184,8 @@ public class MoveTest extends BasicCurso String sTrace = Util.getStackTrace(e); int i = sTrace.indexOf("splay.bitch"); assertTrue(i < 0); + throw e; } - assertTrue(true); } - - } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/PrevTokenTypeTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/PrevTokenTypeTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/PrevTokenTypeTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/PrevTokenTypeTest.java Fri Jan 18 23:08:44 2019 @@ -16,113 +16,88 @@ package xmlcursor.checkin; -import org.apache.xmlbeans.XmlOptions; -import junit.framework.*; -import junit.framework.Assert.*; - -import java.io.*; - -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlCursor.TokenType; -import org.apache.xmlbeans.XmlDocumentProperties; -import org.apache.xmlbeans.XmlCursor.XmlBookmark; - -import javax.xml.namespace.QName; - - -import xmlcursor.common.*; +import org.apache.xmlbeans.XmlObject; +import org.junit.Before; +import xmlcursor.common.BasicCursorTestCase; -import java.net.URL; +import static org.junit.Assert.*; -/** - * - * - */ public class PrevTokenTypeTest extends BasicCursorTestCase { - 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>"; - - public PrevTokenTypeTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(PrevTokenTypeTest.class); - } - + @org.junit.Test public void testAllTokensTest(){ - m_xc.toEndDoc(); - assertEquals(true,m_xc.isEnddoc()); - assertEquals(true,m_xc.isFinish()); - assertEquals(TokenType.END,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isEnd()); - assertEquals(true,m_xc.isFinish()); - assertEquals(TokenType.END,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - - assertEquals(true,m_xc.isEnd()); - assertEquals(TokenType.TEXT,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isText()); - assertEquals(false,m_xc.isContainer()); - assertEquals(TokenType.ATTR,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isAttr()); - assertEquals(true,m_xc.isAnyAttr()); - assertEquals(TokenType.ATTR,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isAttr()); - assertEquals(true,m_xc.isAnyAttr()); - assertEquals(TokenType.START,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isStart()); - assertEquals(true,m_xc.isContainer()); - assertEquals(TokenType.TEXT,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isText()); - assertEquals(TokenType.COMMENT,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isComment()); - assertEquals(TokenType.PROCINST,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isProcinst()); - assertEquals(TokenType.NAMESPACE,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isNamespace()); - assertEquals(true,m_xc.isAnyAttr()); - assertEquals(false,m_xc.isAttr()); - assertEquals(TokenType.START,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isStart()); - assertEquals(true,m_xc.isContainer()); - assertEquals(TokenType.STARTDOC,m_xc.prevTokenType()); - m_xc.toPrevToken(); - - assertEquals(true,m_xc.isStartdoc()); - assertEquals(true,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()); + 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()); } - + @Before public void setUp() throws Exception{ - m_xc=XmlObject.Factory.parse(sDoc).newCursor(); + 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(); } } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveAttributeTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveAttributeTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveAttributeTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveAttributeTest.java Fri Jan 18 23:08:44 2019 @@ -16,89 +16,71 @@ package xmlcursor.checkin; -import org.apache.xmlbeans.XmlOptions; -import junit.framework.*; -import junit.framework.Assert.*; - -import java.io.*; - -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlCursor.TokenType; +import org.apache.xmlbeans.XmlObject; +import org.junit.Test; +import xmlcursor.common.BasicCursorTestCase; +import xmlcursor.common.Common; import javax.xml.namespace.QName; -import xmlcursor.common.*; - -import java.net.URL; +import static org.junit.Assert.*; -/** - * - * - */ public class RemoveAttributeTest extends BasicCursorTestCase { - public RemoveAttributeTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(RemoveAttributeTest.class); - } - + @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"); - assertEquals(true, m_xc.removeAttribute(name)); - assertEquals(null, m_xc.getAttributeText(name)); + 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"); - assertEquals(false, m_xc.removeAttribute(name)); + 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"); - try { - assertEquals(false, m_xc.removeAttribute(null)); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - } - assertTrue(true); + 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"); - assertEquals(false, m_xc.removeAttribute(name)); + 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"); - assertEquals(false, m_xc.removeAttribute(name)); + 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"); - assertEquals(false, m_xc.removeAttribute(name)); + assertFalse(m_xc.removeAttribute(name)); } } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveCharsTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveCharsTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveCharsTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveCharsTest.java Fri Jan 18 23:08:44 2019 @@ -16,37 +16,17 @@ package xmlcursor.checkin; -import org.apache.xmlbeans.XmlOptions; -import junit.framework.*; -import junit.framework.Assert.*; - -import java.io.*; - -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlCursor.TokenType; +import org.apache.xmlbeans.XmlObject; +import org.junit.Test; +import xmlcursor.common.BasicCursorTestCase; +import xmlcursor.common.Common; -import javax.xml.namespace.QName; - -import xmlcursor.common.*; - -import java.net.URL; +import static org.junit.Assert.assertEquals; -/** - * - * - */ public class RemoveCharsTest extends BasicCursorTestCase { - public RemoveCharsTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(RemoveCharsTest.class); - } - + @Test public void testRemoveCharsLTLengthFromTEXT() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS); m_xc = m_xo.newCursor(); @@ -55,6 +35,7 @@ public class RemoveCharsTest extends Bas 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(); @@ -63,6 +44,7 @@ public class RemoveCharsTest extends Bas 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(); @@ -71,6 +53,7 @@ public class RemoveCharsTest extends Bas 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(); @@ -79,6 +62,7 @@ public class RemoveCharsTest extends Bas 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(); @@ -86,13 +70,12 @@ public class RemoveCharsTest extends Bas 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)); } - - } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/RemoveTest.java Fri Jan 18 23:08:44 2019 @@ -17,42 +17,27 @@ package xmlcursor.checkin; -import junit.framework.*; - -import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlCursor.TokenType; - -import xmlcursor.common.*; - -import test.xbean.xmlcursor.purchaseOrder.USAddress; +import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.impl.values.XmlValueDisconnectedException; +import org.junit.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; -/** - * - * - */ public class RemoveTest extends BasicCursorTestCase { - public RemoveTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(RemoveTest.class); - } - + @Test(expected = IllegalStateException.class) public void testRemoveFromSTARTDOC() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS); m_xc = m_xo.newCursor(); - try { - m_xc.removeXml(); - fail("Expected IllegalStateException"); - } - catch (IllegalStateException e) { - } + m_xc.removeXml(); } + @Test public void testRemoveFromFirstChild() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS); m_xc = m_xo.newCursor(); @@ -61,6 +46,7 @@ public class RemoveTest extends BasicCur 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(); @@ -71,6 +57,7 @@ public class RemoveTest extends BasicCur 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(); @@ -83,6 +70,7 @@ public class RemoveTest extends BasicCur 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(); @@ -93,6 +81,7 @@ public class RemoveTest extends BasicCur 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)); @@ -108,17 +97,11 @@ public class RemoveTest extends BasicCur XmlObject xo = m_xc.getObject(); USAddress usa = (USAddress) xo; m_xc.removeXml(); - try { - usa.getCity(); - fail("Expected XmlValueDisconnectedException"); - } - catch (XmlValueDisconnectedException xvde) { - } - assertTrue(true); + 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")); @@ -132,13 +115,7 @@ public class RemoveTest extends BasicCur USAddress usa = (USAddress) xo; m_xc.removeXml(); assertNotNull("USAddress object expected non-null, but is null", usa); - try { - m_xc = usa.newCursor(); - fail("Expected XmlValueDisconnectedException"); - } - catch (XmlValueDisconnectedException npe) { - } - assertTrue(true); + m_xc = usa.newCursor(); } } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/SelectPathTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/SelectPathTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/SelectPathTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/SelectPathTest.java Fri Jan 18 23:08:44 2019 @@ -16,54 +16,46 @@ package xmlcursor.checkin; -import junit.framework.*; - +import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlCursor.TokenType; - -import xmlcursor.common.*; - +import org.junit.Ignore; +import org.junit.Test; import tools.util.JarUtil; +import xmlcursor.common.BasicCursorTestCase; +import xmlcursor.common.Common; +import static org.junit.Assert.assertEquals; -/** - * - * - */ -public class SelectPathTest extends BasicCursorTestCase { - public SelectPathTest(String sName) { - super(sName); - } - public static Test suite() { - return new TestSuite(SelectPathTest.class); - } - - /** - *$BUGBUG: Eric's engine doesn't send to Jaxen appropriately - * - public void testSelectPathFromEND() throws Exception { +public class SelectPathTest extends BasicCursorTestCase { + /** + * $BUGBUG: Eric's engine doesn't send to Jaxen appropriately + */ + @Test + @Ignore + public void testSelectPathFromEND() throws Exception { m_xo = XmlObject.Factory.parse( - JarUtil.getResourceFromJar(Common.XMLCASES_JAR, - Common.TRANXML_FILE_XMLCURSOR_PO)); - String ns="declare namespace po=\"http://xbean.test/xmlcursor/PurchaseOrder\""; + 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, TokenType.END); - m_xc.selectPath(ns+" $this//city"); + toNextTokenOfType(m_xc, XmlCursor.TokenType.END); + m_xc.selectPath(ns + " $this//city"); assertEquals(0, m_xc.getSelectionCount()); } + @Test + @Ignore public void testSelectPathFromENDDOC() throws Exception { m_xo = XmlObject.Factory.parse( - JarUtil.getResourceFromJar(Common.XMLCASES_JAR, - Common.TRANXML_FILE_XMLCURSOR_PO)); + 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, TokenType.ENDDOC); + toNextTokenOfType(m_xc, XmlCursor.TokenType.ENDDOC); m_xc.selectPath(ns+" .//po:city"); assertEquals(0, m_xc.getSelectionCount()); } - */ + + @Test public void testSelectPathNamespace() throws Exception { m_xo = XmlObject.Factory.parse( JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM)); @@ -76,6 +68,7 @@ public class SelectPathTest extends Basi assertEquals(1, m_xc.getSelectionCount()); } + @Test public void testSelectPathCaseSensitive() throws Exception { m_xo = XmlObject.Factory.parse( JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO)); @@ -87,6 +80,7 @@ public class SelectPathTest extends Basi assertEquals(2, m_xc.getSelectionCount()); } + @Test public void testSelectPathReservedKeyword() throws Exception { m_xo = XmlObject.Factory.parse( JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO)); @@ -96,34 +90,25 @@ public class SelectPathTest extends Basi 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 - try { - m_xc.selectPath(null); - fail("Expected RuntimeException"); - } catch (RuntimeException re) { - } - assertTrue(true); + 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 - try { - m_xc.selectPath("&GARBAGE"); - assertEquals(0,m_xc.getSelectionCount()); - fail("Expected RuntimeException"); - } catch (RuntimeException re) { - } - assertTrue(true); + m_xc.selectPath("&GARBAGE"); + m_xc.getSelectionCount(); } - } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/SetAttributeTextTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/SetAttributeTextTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/SetAttributeTextTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/SetAttributeTextTest.java Fri Jan 18 23:08:44 2019 @@ -16,75 +16,58 @@ package xmlcursor.checkin; -import org.apache.xmlbeans.XmlOptions; -import junit.framework.*; -import junit.framework.Assert.*; - -import java.io.*; - -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlCursor.TokenType; +import org.apache.xmlbeans.XmlObject; +import org.junit.Test; +import tools.util.JarUtil; +import xmlcursor.common.BasicCursorTestCase; +import xmlcursor.common.Common; import javax.xml.namespace.QName; -import xmlcursor.common.*; -import tools.util.JarUtil; - -import java.net.URL; +import static org.junit.Assert.*; -/** - * - * - */ public class SetAttributeTextTest extends BasicCursorTestCase { - public SetAttributeTextTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(SetAttributeTextTest.class); - } - + @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"); - assertEquals(true, m_xc.setAttributeText(name, "newval2")); + 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"); - assertEquals(true, m_xc.setAttributeText(name, "newval2")); + 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"); - assertEquals(true, m_xc.setAttributeText(name, "Finland")); + 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"); - assertEquals(false, m_xc.setAttributeText(name, "2003-01-10")); + assertFalse(m_xc.setAttributeText(name, "2003-01-10")); } - - } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/SetBookmarkTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/SetBookmarkTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/SetBookmarkTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/SetBookmarkTest.java Fri Jan 18 23:08:44 2019 @@ -16,42 +16,22 @@ package xmlcursor.checkin; -import org.apache.xmlbeans.XmlOptions; -import junit.framework.*; -import junit.framework.Assert.*; - -import java.io.*; - -import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlCursor.TokenType; -import org.apache.xmlbeans.XmlDocumentProperties; -import org.apache.xmlbeans.XmlCursor.XmlBookmark; - -import javax.xml.namespace.QName; - -import xmlcursor.common.*; +import org.apache.xmlbeans.XmlObject; +import org.junit.Test; +import xmlcursor.common.BasicCursorTestCase; +import xmlcursor.common.Common; -import java.net.URL; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; -/** - * - * - */ public class SetBookmarkTest extends BasicCursorTestCase { private SimpleBookmark _theBookmark = new SimpleBookmark("value"); private SimpleBookmark _theBookmark1 = new SimpleBookmark("value1"); - public SetBookmarkTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(SetBookmarkTest.class); - } - + @Test public void testSetBookmarkAtSTARTDOC() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT); m_xc = m_xo.newCursor(); @@ -60,6 +40,7 @@ public class SetBookmarkTest extends Bas assertEquals("value", sa.text); } + @Test public void testSetBookmarkDuplicateKey() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT); m_xc = m_xo.newCursor(); @@ -70,6 +51,7 @@ public class SetBookmarkTest extends Bas assertEquals("value1", sa.text); } + @Test public void testSetBookmarkDuplicateKeyDifferentLocation() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT); m_xc = m_xo.newCursor(); @@ -83,6 +65,7 @@ public class SetBookmarkTest extends Bas assertEquals("value", sa.text); } + @Test public void testSetBookmarkAtSTART() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT); m_xc = m_xo.newCursor(); @@ -92,6 +75,7 @@ public class SetBookmarkTest extends Bas assertEquals("value", sa.text); } + @Test public void testSetBookmarkAtATTR() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR); m_xc = m_xo.newCursor(); @@ -101,6 +85,7 @@ public class SetBookmarkTest extends Bas assertEquals("value", sa.text); } + @Test public void testSetBookmarkAtPROCINST() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST); m_xc = m_xo.newCursor(); @@ -110,6 +95,7 @@ public class SetBookmarkTest extends Bas assertEquals("value", sa.text); } + @Test public void testSetBookmarkInMiddleOfTEXT() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT); m_xc = m_xo.newCursor(); @@ -120,6 +106,7 @@ public class SetBookmarkTest extends Bas assertEquals("value", sa.text); } + @Test public void testSetBookmarkAtENDDOC() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR); m_xc = m_xo.newCursor(); @@ -129,6 +116,7 @@ public class SetBookmarkTest extends Bas assertEquals("value", sa.text); } + @Test public void testSetBookmarkNull() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR); m_xc = m_xo.newCursor(); @@ -138,6 +126,7 @@ public class SetBookmarkTest extends Bas assertNull(sa); } + @Test public void testXmlDocumentProperties() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR); m_xo.documentProperties().put("fredkey", "fredvalue"); @@ -149,7 +138,7 @@ public class SetBookmarkTest extends Bas public class SimpleBookmark extends XmlCursor.XmlBookmark { public String text; - public SimpleBookmark(String text) { + SimpleBookmark(String text) { this.text = text; } } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/SetNameTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/SetNameTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/SetNameTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/SetNameTest.java Fri Jan 18 23:08:44 2019 @@ -16,99 +16,64 @@ package xmlcursor.checkin; -import org.apache.xmlbeans.XmlOptions; -import junit.framework.*; -import junit.framework.Assert.*; - -import java.io.*; - import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlBeans; -import org.apache.xmlbeans.XmlCursor.TokenType; +import org.junit.Before; +import org.junit.Test; +import xmlcursor.common.BasicCursorTestCase; import javax.xml.namespace.QName; -import xmlcursor.common.*; - -import java.net.URL; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; -/** - * - * - */ - public class SetNameTest extends BasicCursorTestCase{ - String sTestXml="<bk:book at0=\"value0\" xmlns:bk=\"urn:loc.gov:books\">text0<author at0=\"v0\" at1=\"value1\"/></bk:book>"; - - public SetNameTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(SetNameTest.class); - } - - - 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); + @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); } + @Test public void testNoUri(){ - m_xc.toFirstChild(); - QName newName=new QName(null,"newBook"); - m_xc.setName(newName); - assertEquals(m_xc.getName().getLocalPart(),"newBook"); - } - - public void testNull(){ - m_xc.toFirstChild(); - try{ - m_xc.setName(null); - fail("QName null"); - }catch(Exception e){ - System.err.println(e.getMessage()); + 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()); + } } + @Before public void setUp()throws Exception{ - m_xc=XmlObject.Factory.parse(sTestXml).newCursor(); - } - - - public static void main(String[]rgs){ - try{ - SetNameTest myTest=new SetNameTest(""); - myTest.setUp(); - myTest.testNormalCase(); - myTest.setUp(); - myTest.testNoUri(); - myTest.setUp(); - myTest.testNull(); - - }catch(Exception e){ - System.err.println(e.getMessage()); - } + 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(); } } Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/SetTextTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/SetTextTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/xmlcursor/checkin/SetTextTest.java (original) +++ xmlbeans/trunk/test/src/xmlcursor/checkin/SetTextTest.java Fri Jan 18 23:08:44 2019 @@ -16,37 +16,16 @@ package xmlcursor.checkin; -import org.apache.xmlbeans.XmlOptions; -import junit.framework.*; -import junit.framework.Assert.*; - -import java.io.*; - -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlCursor.TokenType; +import org.apache.xmlbeans.XmlObject; +import org.junit.Test; +import xmlcursor.common.BasicCursorTestCase; +import xmlcursor.common.Common; -import javax.xml.namespace.QName; - -import xmlcursor.common.*; - -import java.net.URL; - +import static org.junit.Assert.assertEquals; -/** - * - * - */ public class SetTextTest extends BasicCursorTestCase { - public SetTextTest(String sName) { - super(sName); - } - - public static Test suite() { - return new TestSuite(SetTextTest.class); - } - + @Test public void testSetTextFromCOMMENT() throws Exception { m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT); m_xc = m_xo.newCursor(); @@ -55,6 +34,7 @@ public class SetTextTest extends BasicCu 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(); @@ -63,6 +43,7 @@ public class SetTextTest extends BasicCu 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(); @@ -71,55 +52,42 @@ public class SetTextTest extends BasicCu 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); - try { - m_xc.setTextValue("fred"); - fail("Expected IllegalStateException"); - } catch (IllegalStateException e) { - } + 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(); - try { - m_xc.setTextValue("fred"); - fail("Expected IllegalStateException"); - } catch (IllegalStateException e) { - } + 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()); - try { - m_xc.setTextValue("new text"); - fail("Expected IllegalStateException"); - } catch (IllegalStateException e) { - } - assertEquals(true, true); + 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()); - try { - m_xc.setTextValue("new text"); - fail("Expected IllegalStateException"); - } catch (IllegalStateException e) { - } - assertEquals(true, true); + 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(); @@ -129,6 +97,7 @@ public class SetTextTest extends BasicCu 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(); @@ -138,6 +107,7 @@ public class SetTextTest extends BasicCu 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(); @@ -147,6 +117,7 @@ public class SetTextTest extends BasicCu 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(); @@ -156,6 +127,7 @@ public class SetTextTest extends BasicCu 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(); @@ -165,6 +137,7 @@ public class SetTextTest extends BasicCu 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(); @@ -172,7 +145,5 @@ public class SetTextTest extends BasicCu 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]
