You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2019/01/18 23:08:48 UTC
svn commit: r1851656 [14/28] - in /xmlbeans/trunk: ./ external/ lib/
resources/ resources/typeimpl/ resources/typeimpl/org/
resources/typeimpl/org/apache/ resources/typeimpl/org/apache/xmlbeans/
resources/typeimpl/org/apache/xmlbeans/impl/ resources/ty...
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/CopyXmlContentsTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/CopyXmlContentsTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/CopyXmlContentsTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/CopyXmlContentsTest.java Fri Jan 18 23:08:44 2019
@@ -20,156 +20,134 @@ package xmlcursor.checkin;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlCursor.TokenType;
import org.apache.xmlbeans.XmlObject;
+import org.junit.Ignore;
+import org.junit.Test;
import xmlcursor.common.BasicCursorTestCase;
import xmlcursor.common.Common;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.*;
-/**
- *
- *
- */
public class CopyXmlContentsTest extends BasicCursorTestCase {
- public CopyXmlContentsTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(CopyXmlContentsTest.class);
- }
-
- public void testCopyToNull() throws Exception {
-
- m_xc = XmlObject.Factory.parse(Common.XML_FOO_DIGITS).newCursor();
- toNextTokenOfType(m_xc, TokenType.TEXT);
- try {
- m_xc.copyXmlContents(null);
- fail("Expected IllegalArgumentException. Can't copy to foreign document");
- } catch (IllegalArgumentException ise) {
- }
- }
- public void testCopyDifferentStoresLoadedByParseInvalidDest() throws Exception {
- String sDoc1=Common.XML_FOO_DIGITS;
- String sDoc2=Common.XML_FOO_2ATTR_TEXT;
- m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
- XmlCursor xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
- toNextTokenOfType(m_xc, TokenType.START);
- toNextTokenOfType(xc1, TokenType.START);
- try{
- xc1.dispose();
- m_xc.copyXmlContents(xc1);
- fail("Expected IllegalStateException. Destination cursor was disposed ");
- } catch (IllegalStateException ise) {
- }
- }
- public void testCopyDifferentStoresLoadedByParse() throws Exception {
- String sDoc1=Common.XML_FOO_DIGITS;
- String sDoc2=Common.XML_FOO_2ATTR_TEXT;
- m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
- XmlCursor xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
- toNextTokenOfType(m_xc, TokenType.START);
- toNextTokenOfType(xc1, TokenType.TEXT);
- m_xc.copyXmlContents(xc1);
- xc1.toParent();
- // verify xc1
- assertEquals("01234text", xc1.getTextValue());
- xc1.dispose();
-
- System.out.println("test "+m_xc.xmlText());
- // verify m_xc
- toNextTokenOfType(m_xc, TokenType.TEXT); //get to the text
- assertEquals("01234", m_xc.getChars());
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testCopyToNull() throws Exception {
+ m_xc = XmlObject.Factory.parse(Common.XML_FOO_DIGITS).newCursor();
+ toNextTokenOfType(m_xc, TokenType.TEXT);
+ m_xc.copyXmlContents(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testCopyDifferentStoresLoadedByParseInvalidDest() throws Exception {
+ String sDoc1 = Common.XML_FOO_DIGITS;
+ String sDoc2 = Common.XML_FOO_2ATTR_TEXT;
+ m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
+ XmlCursor xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
+ toNextTokenOfType(m_xc, TokenType.START);
+ toNextTokenOfType(xc1, TokenType.START);
+ xc1.dispose();
+ m_xc.copyXmlContents(xc1);
+ }
+
+ @Test
+ public void testCopyDifferentStoresLoadedByParse() throws Exception {
+ String sDoc1 = Common.XML_FOO_DIGITS;
+ String sDoc2 = Common.XML_FOO_2ATTR_TEXT;
+ m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
+ XmlCursor xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
+ toNextTokenOfType(m_xc, TokenType.START);
+ toNextTokenOfType(xc1, TokenType.TEXT);
+ m_xc.copyXmlContents(xc1);
+ xc1.toParent();
+ // verify xc1
+ assertEquals("01234text", xc1.getTextValue());
+ xc1.dispose();
+
+ // verify m_xc
+ toNextTokenOfType(m_xc, TokenType.TEXT); //get to the text
+ assertEquals("01234", m_xc.getChars());
+ }
/* the source is not a container*/
- public void testCopyDifferentStoresLoadedByParseInvalidSrc() throws Exception {
- String sDoc1=Common.XML_FOO_DIGITS;
- String sDoc2=Common.XML_FOO_2ATTR_TEXT;
- m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
- XmlCursor xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
- toNextTokenOfType(m_xc, TokenType.TEXT);
- toNextTokenOfType(xc1, TokenType.START);
- boolean result=m_xc.copyXmlContents(xc1);
- assertEquals(false, result);
-
- }
-
- /*public void testCopyOntoItself() throws Exception {
- String sDoc1=Common.XML_FOO_DIGITS;
- m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
- toNextTokenOfType(m_xc, TokenType.TEXT);
- String sExpectedXml=m_xc.xmlText();
- boolean result=m_xc.copyXmlContents(m_xc);
-
- //cursor is left immediately before copied material
- assertEquals(sExpectedXml,m_xc.getTextValue());
-
- }
- */
- public void testCopySelf() throws Exception {
- String sDoc1=Common.XML_FOO_DIGITS;
- m_xo = XmlObject.Factory.parse(sDoc1);
- m_xc=m_xo.newCursor();
-
- toNextTokenOfType(m_xc, TokenType.START);
- String sExpectedXml="<xml-fragment>01234<foo attr0=\"val0\" xmlns=\"http://www.foo.org\">01234</foo></xml-fragment>";
- boolean result=m_xc.copyXmlContents(m_xc);
-
- //cursor is left immediately before copied material
- m_xc.toStartDoc();
- //assertEquals(sExpectedXml.length(),m_xc.xmlText().length());
- assertEquals(sExpectedXml,m_xc.xmlText());
- }
+ @Test
+ public void testCopyDifferentStoresLoadedByParseInvalidSrc() throws Exception {
+ String sDoc1 = Common.XML_FOO_DIGITS;
+ String sDoc2 = Common.XML_FOO_2ATTR_TEXT;
+ m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
+ XmlCursor xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
+ toNextTokenOfType(m_xc, TokenType.TEXT);
+ toNextTokenOfType(xc1, TokenType.START);
+ boolean result = m_xc.copyXmlContents(xc1);
+ assertFalse(result);
+ }
+
+ @Test
+ @Ignore
+ public void testCopyOntoItself() throws Exception {
+ String sDoc1 = Common.XML_FOO_DIGITS;
+ m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
+ toNextTokenOfType(m_xc, TokenType.TEXT);
+ String sExpectedXml = m_xc.xmlText();
+ boolean result = m_xc.copyXmlContents(m_xc);
+
+ //cursor is left immediately before copied material
+ assertEquals(sExpectedXml, m_xc.getTextValue());
+ }
+
+ @Test
+ public void testCopySelf() throws Exception {
+ String sDoc1 = Common.XML_FOO_DIGITS;
+ m_xo = XmlObject.Factory.parse(sDoc1);
+ m_xc = m_xo.newCursor();
+
+ toNextTokenOfType(m_xc, TokenType.START);
+ String sExpectedXml = "<xml-fragment>01234<foo attr0=\"val0\" xmlns=\"http://www.foo.org\">01234</foo></xml-fragment>";
+ boolean result = m_xc.copyXmlContents(m_xc);
+
+ //cursor is left immediately before copied material
+ m_xc.toStartDoc();
+ //assertEquals(sExpectedXml.length(),m_xc.xmlText().length());
+ assertEquals(sExpectedXml, m_xc.xmlText());
+ }
/**
Can't really copy the whole doc, so copy all the contents
into a false root */
- public void testCopyWholeDoc() throws Exception {
- String sDoc1=Common.XML_FOO_BAR_WS_TEXT;
- String sDoc2="<root></root>";
- m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
- XmlCursor xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
- xc1.toFirstChild();
- String sExpectedXml=m_xc.xmlText();
- boolean result=m_xc.copyXmlContents(xc1);
- toPrevTokenOfType(xc1,TokenType.STARTDOC);
- toNextTokenOfType(xc1,TokenType.START);
- assertEquals(sExpectedXml,xc1.xmlText());
-
- //namespaces are not copied
- sDoc1=Common.XML_FOO_NS_PREFIX;
- sDoc2="<root></root>";
- m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
- xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
- sExpectedXml=m_xc.xmlText();
- xc1.toFirstChild();
-
- result=m_xc.copyXmlContents(xc1);
- toPrevTokenOfType(xc1,TokenType.STARTDOC);
- assertEquals(false,sExpectedXml.equals(xc1.xmlText()));
-
- //attributes are not copied
- sDoc1=Common.XML_FOO_2ATTR;
- sDoc2="<root></root>";
- m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
- xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
- sExpectedXml=m_xc.xmlText();
- xc1.toFirstChild();
-
- result=m_xc.copyXmlContents(xc1);
- toPrevTokenOfType(xc1,TokenType.STARTDOC);
- assertEquals(false,sExpectedXml.equals(xc1.xmlText()));
-
- }
-
- public static void main(String[] rgs){
- try{
- // (new CopyXmlContentsTest("")).testCopyOntoItself();
- (new CopyXmlContentsTest("")).testCopyWholeDoc();
- }catch(Exception e){System.err.println(e.getMessage());}
- }
-
+ @Test
+ public void testCopyWholeDoc() throws Exception {
+ String sDoc1 = Common.XML_FOO_BAR_WS_TEXT;
+ String sDoc2 = "<root></root>";
+ m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
+ XmlCursor xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
+ xc1.toFirstChild();
+ String sExpectedXml = m_xc.xmlText();
+ boolean result = m_xc.copyXmlContents(xc1);
+ toPrevTokenOfType(xc1, TokenType.STARTDOC);
+ toNextTokenOfType(xc1, TokenType.START);
+ assertEquals(sExpectedXml, xc1.xmlText());
+
+ //namespaces are not copied
+ sDoc1 = Common.XML_FOO_NS_PREFIX;
+ sDoc2 = "<root></root>";
+ m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
+ xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
+ sExpectedXml = m_xc.xmlText();
+ xc1.toFirstChild();
+
+ result = m_xc.copyXmlContents(xc1);
+ toPrevTokenOfType(xc1, TokenType.STARTDOC);
+ assertNotEquals(sExpectedXml, xc1.xmlText());
+
+ //attributes are not copied
+ sDoc1 = Common.XML_FOO_2ATTR;
+ sDoc2 = "<root></root>";
+ m_xc = XmlObject.Factory.parse(sDoc1).newCursor();
+ xc1 = XmlObject.Factory.parse(sDoc2).newCursor();
+ sExpectedXml = m_xc.xmlText();
+ xc1.toFirstChild();
+
+ result = m_xc.copyXmlContents(xc1);
+ toPrevTokenOfType(xc1, TokenType.STARTDOC);
+ assertNotEquals(sExpectedXml, xc1.xmlText());
+ }
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/CurrentTokenTypeTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/CurrentTokenTypeTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/CurrentTokenTypeTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/CurrentTokenTypeTest.java Fri Jan 18 23:08:44 2019
@@ -19,28 +19,17 @@ package xmlcursor.checkin;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
import xmlcursor.common.BasicCursorTestCase;
import xmlcursor.common.Common;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
-/**
- *
- *
- */
public class CurrentTokenTypeTest extends BasicCursorTestCase {
String sInputDoc;
- public CurrentTokenTypeTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(CurrentTokenTypeTest.class);
- }
/**
ATTR
COMMENT
@@ -54,82 +43,70 @@ public class CurrentTokenTypeTest extend
TEXT
*/
+ @Test
public void testAttrType() throws XmlException{
- sInputDoc=Common.XML_FOO_2ATTR_TEXT;
- m_xc= XmlObject.Factory.parse(sInputDoc).newCursor();
- assertEquals(m_xc.currentTokenType(),XmlCursor.TokenType.STARTDOC);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.START);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.ATTR);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.ATTR);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.TEXT);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.END);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.ENDDOC);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.NONE);
- }
- public void testCommentType()throws XmlException{
- sInputDoc=Common.XML_FOO_COMMENT;
- m_xc= XmlObject.Factory.parse(sInputDoc).newCursor();
- assertEquals(m_xc.currentTokenType(),XmlCursor.TokenType.STARTDOC);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.COMMENT);
- }
- public void testEndType(){
- //tested by testAttrType
- }
- public void testEndDocType(){
- //tested by testAttrType
+ sInputDoc = Common.XML_FOO_2ATTR_TEXT;
+ m_xc = XmlObject.Factory.parse(sInputDoc).newCursor();
+ assertEquals(m_xc.currentTokenType(), XmlCursor.TokenType.STARTDOC);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.START);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.ATTR);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.ATTR);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.TEXT);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.END);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.ENDDOC);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.NONE);
+ }
+
+ @Test
+ public void testCommentType() throws XmlException {
+ sInputDoc = Common.XML_FOO_COMMENT;
+ m_xc = XmlObject.Factory.parse(sInputDoc).newCursor();
+ assertEquals(m_xc.currentTokenType(), XmlCursor.TokenType.STARTDOC);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.COMMENT);
}
- public void testNamespaceType()throws XmlException{
- sInputDoc=Common.XML_FOO_NS_PREFIX ;
- m_xc= XmlObject.Factory.parse(sInputDoc).newCursor();
- assertEquals(m_xc.currentTokenType(),XmlCursor.TokenType.STARTDOC);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.START);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.NAMESPACE);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.COMMENT);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.TEXT);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.START);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.ATTR);
+ @Test
+ public void testNamespaceType()throws XmlException{
+ sInputDoc = Common.XML_FOO_NS_PREFIX;
+ m_xc = XmlObject.Factory.parse(sInputDoc).newCursor();
+ assertEquals(m_xc.currentTokenType(), XmlCursor.TokenType.STARTDOC);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.START);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.NAMESPACE);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.COMMENT);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.TEXT);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.START);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.ATTR);
}
+
+ @Test
public void testNoneType()throws XmlException{
- sInputDoc="<a/>";
- m_xc= XmlObject.Factory.parse(sInputDoc).newCursor();
- m_xc.toEndDoc();
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.NONE);
+ sInputDoc = "<a/>";
+ m_xc = XmlObject.Factory.parse(sInputDoc).newCursor();
+ m_xc.toEndDoc();
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.NONE);
}
+
+ @Test
public void testProcinstType()throws XmlException{
- sInputDoc=Common.XML_FOO_PROCINST;
- m_xc= XmlObject.Factory.parse(sInputDoc).newCursor();
- assertEquals(m_xc.currentTokenType(),XmlCursor.TokenType.STARTDOC);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.PROCINST);
+ sInputDoc = Common.XML_FOO_PROCINST;
+ m_xc = XmlObject.Factory.parse(sInputDoc).newCursor();
+ assertEquals(m_xc.currentTokenType(), XmlCursor.TokenType.STARTDOC);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.PROCINST);
+ }
- }
- public void testStartType(){
- //tested by testAttrType
- }
- public void testStartdocType(){
- //tested by testAttrType
- }
+ @Test
public void testTextType()throws XmlException{
- sInputDoc="<text>blah<test>test and some more test</test>"+"\u042F\u0436\n\r</text>";
- m_xc= XmlObject.Factory.parse(sInputDoc).newCursor();
- assertEquals(m_xc.currentTokenType(),XmlCursor.TokenType.STARTDOC);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.START);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.TEXT);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.START);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.TEXT);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.END);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.TEXT);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.END);
- assertEquals(m_xc.toNextToken(),XmlCursor.TokenType.ENDDOC);
-
- }
-
- public static void main(String[] rgs){
- try{
- (new CurrentTokenTypeTest("")).testAttrType();
- }catch (Exception e){
- System.err.println(e.getMessage());
- }
+ sInputDoc = "<text>blah<test>test and some more test</test>" + "\u042F\u0436\n\r</text>";
+ m_xc = XmlObject.Factory.parse(sInputDoc).newCursor();
+ assertEquals(m_xc.currentTokenType(), XmlCursor.TokenType.STARTDOC);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.START);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.TEXT);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.START);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.TEXT);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.END);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.TEXT);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.END);
+ assertEquals(m_xc.toNextToken(), XmlCursor.TokenType.ENDDOC);
}
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/DisposeTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/DisposeTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/DisposeTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/DisposeTest.java Fri Jan 18 23:08:44 2019
@@ -16,43 +16,20 @@
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 javax.xml.namespace.QName;
-
-import xmlcursor.common.*;
+import org.junit.Test;
+import xmlcursor.common.BasicCursorTestCase;
+import xmlcursor.common.Common;
-import java.net.URL;
-
-/**
- *
- *
- */
public class DisposeTest extends BasicCursorTestCase {
- public DisposeTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(DisposeTest.class);
- }
+ @Test
public void testMultipleDispose() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO);
m_xc = m_xo.newCursor();
m_xc.dispose();
m_xc.dispose();
- assertEquals(true, true);
}
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetAllBookmarkRefsTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetAllBookmarkRefsTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetAllBookmarkRefsTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetAllBookmarkRefsTest.java Fri Jan 18 23:08:44 2019
@@ -16,44 +16,23 @@
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 java.util.Vector;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-/**
- *
- *
- */
public class GetAllBookmarkRefsTest extends BasicCursorTestCase {
private Bookmark0 _theBookmark0 = new Bookmark0("value0");
private Bookmark1 _theBookmark1 = new Bookmark1("value1");
private Bookmark2 _theBookmark2 = new Bookmark2("value2");
- public GetAllBookmarkRefsTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetAllBookmarkRefsTest.class);
- }
-
+ @Test
public void testGetAll() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -69,6 +48,7 @@ public class GetAllBookmarkRefsTest exte
assertEquals("value2", ((Bookmark2) v.elementAt(2)).text);
}
+ @Test
public void testGetAllNullListToFill() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -82,7 +62,7 @@ public class GetAllBookmarkRefsTest exte
public class Bookmark0 extends XmlCursor.XmlBookmark {
public String text;
- public Bookmark0(String text) {
+ Bookmark0(String text) {
this.text = text;
}
}
@@ -90,7 +70,7 @@ public class GetAllBookmarkRefsTest exte
public class Bookmark1 extends XmlCursor.XmlBookmark {
public String text;
- public Bookmark1(String text) {
+ Bookmark1(String text) {
this.text = text;
}
}
@@ -98,11 +78,9 @@ public class GetAllBookmarkRefsTest exte
public class Bookmark2 extends XmlCursor.XmlBookmark {
public String text;
- public Bookmark2(String text) {
+ Bookmark2(String text) {
this.text = text;
}
}
-
-
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetAllNamespacesTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetAllNamespacesTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetAllNamespacesTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetAllNamespacesTest.java Fri Jan 18 23:08:44 2019
@@ -16,61 +16,30 @@
package xmlcursor.checkin;
-import junit.framework.*;
-
-import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlCursor;
-import xmlcursor.common.*;
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Before;
+import org.junit.Test;
+import xmlcursor.common.BasicCursorTestCase;
+import java.util.HashMap;
+import java.util.Map;
-import java.util.*;
+import static org.junit.Assert.assertEquals;
-/**
- *
- *
- */
public class GetAllNamespacesTest extends BasicCursorTestCase {
- static String sTestXml = "<bk:book xmlns:bk='urn:loc.gov:books'" +
- " xmlns:isbn='urn:ISBN:0-395-36341-6'>" +
- "<bk:title>Cheaper by the Dozen</bk:title>" +
- "<isbn:number>1568491379</isbn:number>" +
- "<nestedInfo xmlns:bk='urn:loc.gov:booksOverridden'>" +
- "nestedText</nestedInfo>" +
- "</bk:book>";
-
-
- public GetAllNamespacesTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetAllNamespacesTest.class);
- }
-
-
+ @Test(expected = Exception.class)
public void testCursorNotContainer() {
//lousy message
toNextTokenOfType(m_xc, XmlCursor.TokenType.TEXT);
Map myHash = new HashMap();
- try {
- m_xc.getAllNamespaces(myHash);
- fail("Cursor not on a container");
- }
- catch (Exception e) {
- System.err.println(e.getMessage());
- }
- /*
- Iterator it=myHash.values().iterator();
- while(it.hasNext()){
- System.out.println(it.next());
- }
- */
-
+ m_xc.getAllNamespaces(myHash);
}
+ @Test
public void testGetAllNamespaces() {
//parse in setUp
int nExpectedNamespaces = 2;//2 distinct namespaces but 3
@@ -84,6 +53,7 @@ public class GetAllNamespacesTest extend
"urn:ISBN:0-395-36341-6");
}
+ @Test
public void testGetAllNamespacesIllegalCursorPos() {
int nExpectedNamespaces = 0;
Map namespaceMap = new HashMap();
@@ -91,6 +61,7 @@ public class GetAllNamespacesTest extend
assertEquals(namespaceMap.entrySet().size(), nExpectedNamespaces);
}
+ @Test
public void testGetAllNamespacesNull() {
toNextTokenOfType(m_xc, XmlCursor.TokenType.START);
@@ -101,6 +72,7 @@ public class GetAllNamespacesTest extend
/**
* cursor is positioned below the namespace declaration but in its scope
*/
+ @Test
public void testGetAllNamespacesInternal() {
int nExpectedNamespaces = 2;
Map namespaceMap = new HashMap();
@@ -116,20 +88,15 @@ public class GetAllNamespacesTest extend
}
+ @Before
public void setUp() throws Exception {
+ String sTestXml = "<bk:book xmlns:bk='urn:loc.gov:books'" +
+ " xmlns:isbn='urn:ISBN:0-395-36341-6'>" +
+ "<bk:title>Cheaper by the Dozen</bk:title>" +
+ "<isbn:number>1568491379</isbn:number>" +
+ "<nestedInfo xmlns:bk='urn:loc.gov:booksOverridden'>" +
+ "nestedText</nestedInfo>" +
+ "</bk:book>";
m_xc = XmlObject.Factory.parse(sTestXml).newCursor();
}
-
- public static void main(String[] rgs) {
- try {
- GetAllNamespacesTest t = (new GetAllNamespacesTest(""));
- t.setUp();
- t.testGetAllNamespacesNull();
- }
- catch (Exception e) {
- System.err.println(e.getMessage());
- }
- }
-
-
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetAttributeTextTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetAttributeTextTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetAttributeTextTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetAttributeTextTest.java Fri Jan 18 23:08:44 2019
@@ -18,28 +18,19 @@ package xmlcursor.checkin;
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 junit.framework.Test;
-import junit.framework.TestSuite;
import javax.xml.namespace.QName;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
-/**
- *
- *
- */
-public class GetAttributeTextTest extends BasicCursorTestCase {
- public GetAttributeTextTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetAttributeTextTest.class);
- }
+public class GetAttributeTextTest extends BasicCursorTestCase {
+ @Test
public void testGetAttributeTextFromSTARTwith2ATTR() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
@@ -47,34 +38,37 @@ public class GetAttributeTextTest extend
assertEquals("val1", m_xc.getAttributeText(new QName("attr1")));
}
+ @Test
public void testGetAttributeTextFromSTARTwithInvalid() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
m_xc.toFirstChild();
- assertEquals(null, m_xc.getAttributeText(new QName("invalid")));
+ assertNull(m_xc.getAttributeText(new QName("invalid")));
}
+ @Test
public void testGetAttributeTextFromSTARTChildHasAttr() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
m_xc = m_xo.newCursor();
m_xc.selectPath("$this//items");
- assertEquals(null, m_xc.getAttributeText(new QName("partNum")));
+ assertNull(m_xc.getAttributeText(new QName("partNum")));
}
+ @Test
public void testGetAttributeTextFromSTARTDOCChildHasAttr() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
m_xc = m_xo.newCursor();
- assertEquals(null, m_xc.getAttributeText(new QName("partNum")));
+ assertNull(m_xc.getAttributeText(new QName("partNum")));
}
+ @Test
public void testGetAttributeTextFromATTR() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.ATTR);
- assertEquals(null, m_xc.getAttributeText(new QName("attr1")));
+ assertNull(m_xc.getAttributeText(new QName("attr1")));
}
-
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetBookmarkTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetBookmarkTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetBookmarkTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetBookmarkTest.java Fri Jan 18 23:08:44 2019
@@ -16,43 +16,24 @@
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 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.assertNull;
-/**
- *
- *
- */
public class GetBookmarkTest extends BasicCursorTestCase {
private Bookmark0 _theBookmark0 = new Bookmark0("value0");
private Bookmark1 _theBookmark1 = new Bookmark1("value1");
private Bookmark2 _theBookmark2 = new Bookmark2("value2");
- public GetBookmarkTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetBookmarkTest.class);
- }
+ @Test
public void testGetBookmarkIndependentKey() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -67,6 +48,7 @@ public class GetBookmarkTest extends Bas
assertEquals("value2", ann2.text);
}
+ @Test
public void testGetBookmarkNullKey() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -75,6 +57,7 @@ public class GetBookmarkTest extends Bas
assertNull(xa);
}
+ @Test
public void testGetBookmarkInvalidKey() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -83,6 +66,7 @@ public class GetBookmarkTest extends Bas
assertNull(xa);
}
+ @Test
public void testGetBookmarkNotAtCursor() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetCharsTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetCharsTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetCharsTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetCharsTest.java Fri Jan 18 23:08:44 2019
@@ -16,38 +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 GetCharsTest extends BasicCursorTestCase {
- public GetCharsTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetCharsTest.class);
- }
-
-
+ @Test
public void testGetCharFromTEXTOffset() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -56,6 +35,7 @@ public class GetCharsTest extends BasicC
assertEquals("1234", m_xc.getChars());
}
+ @Test
public void testGetCharFromATTR() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -63,6 +43,7 @@ public class GetCharsTest extends BasicC
assertEquals("", m_xc.getChars());
}
+ @Test
public void testGetCharFromCOMMENT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT);
m_xc = m_xo.newCursor();
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetCharsType2Test.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetCharsType2Test.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetCharsType2Test.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetCharsType2Test.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 GetCharsType2Test extends BasicCursorTestCase {
- public GetCharsType2Test(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetCharsType2Test.class);
- }
-
+ @Test
public void testGetCharsType2LessThanBufLength() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -57,6 +37,7 @@ public class GetCharsType2Test extends B
assertEquals("012\0\0", s);
}
+ @Test
public void testGetCharsType2GTBufLengthMinusOffset() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -70,6 +51,7 @@ public class GetCharsType2Test extends B
assertEquals('1', buf[4]);
}
+ @Test
public void testGetCharsType2FromATTR() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -78,6 +60,7 @@ public class GetCharsType2Test extends B
assertEquals(0, m_xc.getChars(buf, 3, 4));
}
+ @Test
public void testGetCharsType2FromSTART() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -86,6 +69,7 @@ public class GetCharsType2Test extends B
assertEquals(0, m_xc.getChars(buf, 3, 4));
}
+ @Test
public void testGetCharsType2FromSTARTDOC() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -93,6 +77,7 @@ public class GetCharsType2Test extends B
assertEquals(0, m_xc.getChars(buf, 3, 4));
}
+ @Test
public void testGetCharsType2FromNAMESPACE() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -101,6 +86,7 @@ public class GetCharsType2Test extends B
assertEquals(0, m_xc.getChars(buf, 3, 4));
}
+ @Test
public void testGetCharsType2FromPROCINST() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
m_xc = m_xo.newCursor();
@@ -109,6 +95,7 @@ public class GetCharsType2Test extends B
assertEquals(0, m_xc.getChars(buf, 3, 4));
}
+ @Test
public void testGetCharsType2FromEND() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -117,6 +104,7 @@ public class GetCharsType2Test extends B
assertEquals(0, m_xc.getChars(buf, 3, 4));
}
+ @Test
public void testGetCharsType2FromENDDOC() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -125,6 +113,7 @@ public class GetCharsType2Test extends B
assertEquals(0, m_xc.getChars(buf, 3, 4));
}
+ @Test
public void testGetCharsType2FromCOMMENT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT);
m_xc = m_xo.newCursor();
@@ -132,6 +121,5 @@ public class GetCharsType2Test extends B
char[] buf = new char[5];
assertEquals(0, m_xc.getChars(buf, 3, 4));
}
-
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetDocChangeStampTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetDocChangeStampTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetDocChangeStampTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetDocChangeStampTest.java Fri Jan 18 23:08:44 2019
@@ -18,26 +18,16 @@ package xmlcursor.checkin;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
import tools.util.JarUtil;
import xmlcursor.common.BasicCursorTestCase;
import xmlcursor.common.Common;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
-/**
- *
- *
- */
-public class GetDocChangeStampTest extends BasicCursorTestCase {
- public GetDocChangeStampTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetDocChangeStampTest.class);
- }
+public class GetDocChangeStampTest extends BasicCursorTestCase {
+ @Test
public void testGetDocChangeStampHasChanged() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
@@ -53,6 +43,7 @@ public class GetDocChangeStampTest exten
assertEquals(true, cs0.hasChanged());
}
+ @Test
public void testGetDocChangeStampNotChanged() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetNameTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetNameTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetNameTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetNameTest.java Fri Jan 18 23:08:44 2019
@@ -18,22 +18,17 @@ package xmlcursor.checkin;
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 junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
-public class GetNameTest extends BasicCursorTestCase {
- public GetNameTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetNameTest.class);
- }
+public class GetNameTest extends BasicCursorTestCase {
+ @Test
public void testGetNameFromSTARTDOC() throws Exception {
// String test="<?xml version=\"1.0\"?><purchaseOrder xmlns= \"http://www.bea.com/po\" orderDate=\"1999-10-20\"><shipTo country=\"US\"><name>Alice Smith</name><street>123 Maple Street</street><city>Mill Valley</city><state>CA</state><zip>90952</zip></shipTo><comment>Hurry, my lawn is going wild!</comment><!-- comment text --><items>2 <item partNum=\"872-AA\" partid=\"00A\"><productName>Lawnmower</productName> <quantity>10</quantity></item><item partNum=\"926-AA\" partid=\"00B\"><productName>Baby Monitor</productName><quantity>1</quantity></item></items></purchaseOrder>";
String test="<?xml version=\"1.0\"?>\n" +
@@ -73,9 +68,10 @@ public class GetNameTest extends BasicCu
Common.TRANXML_FILE_XMLCURSOR_PO));
*/
m_xc = m_xo.newCursor();
- assertEquals(null, m_xc.getName());
+ assertNull(m_xc.getName());
}
+ @Test
public void testGetNameFromPROCINST() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
m_xc = m_xo.newCursor();
@@ -83,6 +79,7 @@ public class GetNameTest extends BasicCu
assertEquals("xml-stylesheet", m_xc.getName().getLocalPart());
}
+ @Test
public void testGetNameFromSTART() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
@@ -94,14 +91,16 @@ public class GetNameTest extends BasicCu
assertEquals("city", m_xc.getName().getLocalPart());
}
+ @Test
public void testGetNameFromEND() throws Exception {
m_xo = XmlObject.Factory.parse("<foo><bar>text</bar></foo>");
m_xc = m_xo.newCursor();
m_xc.selectPath(".//bar");
toNextTokenOfType(m_xc, TokenType.END);
- assertEquals(null, m_xc.getName());
+ assertNull(m_xc.getName());
}
+ @Test
public void testGetNameFromATTR() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
@@ -114,13 +113,15 @@ public class GetNameTest extends BasicCu
assertEquals("country", m_xc.getName().getLocalPart());
}
+ @Test
public void testGetNameFromCOMMENT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.COMMENT);
- assertEquals(null, m_xc.getName());
+ assertNull(m_xc.getName());
}
+ @Test
public void testGetNameElementWithDefaultNamespace() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
@@ -131,6 +132,7 @@ public class GetNameTest extends BasicCu
assertEquals(Common.CLM_NS, m_xc.getName().getNamespaceURI());
}
+ @Test
public void testGetNameAttrWithDefaultNamespace() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_NS_PREFIX);
m_xc = m_xo.newCursor();
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/GetObjectTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/GetObjectTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/GetObjectTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/GetObjectTest.java Fri Jan 18 23:08:44 2019
@@ -19,108 +19,99 @@ package xmlcursor.checkin;
import org.apache.xmlbeans.XmlCursor.TokenType;
import org.apache.xmlbeans.XmlNMTOKEN;
import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
+import org.tranxml.tranXML.version40.CarLocationMessageDocument;
import tools.util.JarUtil;
import xmlcursor.common.BasicCursorTestCase;
import xmlcursor.common.Common;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.tranxml.tranXML.version40.CarLocationMessageDocument;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-/**
- *
- *
- */
-public class GetObjectTest extends BasicCursorTestCase {
- public GetObjectTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(GetObjectTest.class);
- }
-
- public void testClassPath() throws Exception {
- String sClassPath = System.getProperty("java.class.path");
- int i = sClassPath.indexOf(Common.CARLOCATIONMESSAGE_JAR);
- assertTrue(i >= 0);
- }
+public class GetObjectTest extends BasicCursorTestCase {
+ @Test
public void testGetObjectFromSTARTDOC() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
m_xc = m_xo.newCursor();
- assertEquals(true,
- m_xc.getObject() instanceof CarLocationMessageDocument);
+ assertTrue(m_xc.getObject() instanceof CarLocationMessageDocument);
}
+ @Test
public void testGetObjectFromSTART() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
m_xc = m_xo.newCursor();
m_xc.toFirstChild();
- assertEquals(true,
- m_xc.getObject() instanceof CarLocationMessageDocument.CarLocationMessage);
+ assertTrue(m_xc.getObject() instanceof CarLocationMessageDocument.CarLocationMessage);
}
+ @Test
public void testGetObjectFromATTR() throws Exception {
m_xo =
- XmlObject.Factory.parse(
- JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
+ 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 );
+ String sQuery =
+ "declare namespace po=\"http://xbean.test/xmlcursor/PurchaseOrder\"; " +
+ "$this//po:shipTo";
+ m_xc.selectPath(sQuery);
m_xc.toNextSelection();
m_xc.toFirstAttribute();
- assertEquals(true, m_xc.getObject() instanceof XmlNMTOKEN);
+ assertTrue(m_xc.getObject() instanceof XmlNMTOKEN);
}
+ @Test
public void testGetObjectFromEND() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.END);
- assertEquals(null, m_xc.getObject());
+ assertNull(m_xc.getObject());
}
+ @Test
public void testGetObjectFromENDDOC() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
m_xc = m_xo.newCursor();
m_xc.toEndDoc();
- assertEquals(null, m_xc.getObject());
+ assertNull(m_xc.getObject());
}
+ @Test
public void testGetObjectFromNAMESPACE() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.NAMESPACE);
- assertEquals(null, m_xc.getObject());
+ assertNull(m_xc.getObject());
}
+ @Test
public void testGetObjectFromPROCINST() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.PROCINST);
- assertEquals(null, m_xc.getObject());
+ assertNull(m_xc.getObject());
}
+ @Test
public void testGetObjectFromCOMMENT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_COMMENT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.COMMENT);
- assertEquals(null, m_xc.getObject());
+ assertNull(m_xc.getObject());
}
+ @Test
public void testGetObjectFromTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.TEXT);
- assertEquals(null, m_xc.getObject());
+ assertNull(m_xc.getObject());
}
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/InsertAttributeTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/InsertAttributeTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/InsertAttributeTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/InsertAttributeTest.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;
-/**
- *
- *
- */
public class InsertAttributeTest extends BasicCursorTestCase {
- public InsertAttributeTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(InsertAttributeTest.class);
- }
-
+ @Test
public void testInsertAttributeAtSTART() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -56,6 +38,7 @@ public class InsertAttributeTest extends
assertEquals("<foo uri:name=\"value\" xmlns:uri=\"uri\">text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertAttributeAtATTR() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
@@ -65,6 +48,7 @@ public class InsertAttributeTest extends
assertEquals("<foo name=\"value\" attr0=\"val0\" attr1=\"val1\">text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertAttributeAt2ndATTR() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
@@ -75,56 +59,41 @@ public class InsertAttributeTest extends
assertEquals("<foo attr0=\"val0\" name=\"value\" attr1=\"val1\">text</foo>", m_xc.xmlText());
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeAtPROCINST() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_PROCINST);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.PROCINST);
m_xc.toNextToken();
- try {
- m_xc.insertAttributeWithValue("name", null, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue("name", null, "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeAtSTARTwithEmptyStringName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.START);
- try {
- m_xc.insertAttributeWithValue("", "uri", "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue("", "uri", "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeAtSTARTwithNullName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.START);
- try {
- m_xc.insertAttributeWithValue(null, "uri", "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue(null, "uri", "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeWithNullQName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.START);
- try {
- QName name = new QName(null);
- m_xc.insertAttribute(name);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ QName name = new QName(null);
+ m_xc.insertAttribute(name);
}
+ @Test
public void testInsertAttributeAtSTARTwithEmptyStringUri() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -134,6 +103,7 @@ public class InsertAttributeTest extends
assertEquals("<foo name=\"value\">text</foo>", m_xc.xmlText());
}
+ @Test(expected = Exception.class)
public void testInsertAttributeAtSTARTwithNameXml() throws Exception {
/*
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
@@ -150,17 +120,12 @@ catch (IllegalArgumentException iae)
assertEquals(true,true);
*/
- try {
- m_xo = XmlObject.Factory.parse("<foo>text</foo>");
- m_xc = m_xo.newCursor();
- m_xc.insertAttributeWithValue("xml", null, "value");
- fail("Expected Exception");
- } catch (Exception e) {
- }
-
- assertTrue(true);
+ m_xo = XmlObject.Factory.parse("<foo>text</foo>");
+ m_xc = m_xo.newCursor();
+ m_xc.insertAttributeWithValue("xml", null, "value");
}
+ @Test
public void testInsertAttributeAtSTARTwithValueXml() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -170,18 +135,15 @@ assertEquals(true,true);
assertEquals("<foo name=\"xml\">text</foo>", m_xc.xmlText());
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeAtSTARTwithLTcharInName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.TEXT);
- try {
- m_xc.insertAttributeWithValue("<b", null, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue("<b", null, "value");
}
+ @Test
public void testInsertAttributeAtSTARTwithLTcharInValue() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -191,6 +153,7 @@ assertEquals(true,true);
assertEquals("<foo name=\"<value\">text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertAttributeAtSTARTwithAmpCharInValue() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -200,20 +163,16 @@ assertEquals(true,true);
assertEquals("<foo name=\"&value\">text</foo>", m_xc.xmlText());
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeAtSTARTwithAmpCharInName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.TEXT);
- try {
- m_xc.insertAttributeWithValue("&bar", null, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue("&bar", null, "value");
}
// tests below use the XMLName form of the parameter signature
-
+ @Test
public void testInsertAttributeType2AtATTR() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
@@ -224,6 +183,7 @@ assertEquals(true,true);
assertEquals("<foo name=\"value\" attr0=\"val0\" attr1=\"val1\">text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertAttributeType2AfterSTART() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
@@ -234,69 +194,49 @@ assertEquals(true,true);
assertEquals("<foo attr0=\"val0\" attr1=\"val1\" name=\"\">text</foo>", m_xc.xmlText());
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeType2WithXMLinName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.ATTR);
QName name = new QName("<xml>");
- try {
- m_xc.insertAttributeWithValue(name, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue(name, "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeType2WithLeadingSpaceinName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.ATTR);
QName name = new QName(" any");
- try {
- m_xc.insertAttributeWithValue(name, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue(name, "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeType2ContainingSpaceinName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.ATTR);
QName name = new QName("any any");
- try {
- m_xc.insertAttributeWithValue(name, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue(name, "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeType2WithTrailingSpaceinName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.ATTR);
QName name = new QName("any ");
- try {
- m_xc.insertAttributeWithValue(name, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue(name, "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertAttributeType2WithXMLinNameCase() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_2ATTR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.ATTR);
QName name = new QName("<xMlzorro>");
- try {
- m_xc.insertAttributeWithValue(name, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertAttributeWithValue(name, "value");
}
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/InsertCharsTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/InsertCharsTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/InsertCharsTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/InsertCharsTest.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 InsertCharsTest extends BasicCursorTestCase {
- public InsertCharsTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(InsertCharsTest.class);
- }
-
+ @Test
public void testInsertCharsAtSTART() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -58,6 +38,7 @@ public class InsertCharsTest extends Bas
assertEquals(" new chars ", m_xc.getChars());
}
+ @Test
public void testInsertCharsAtSTARTnonEmptyPriorTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_WS_ONLY);
m_xc = m_xo.newCursor();
@@ -69,6 +50,7 @@ public class InsertCharsTest extends Bas
assertEquals(" new chars ", m_xc.getChars());
}
+ @Test
public void testInsertCharsAtENDnonEmptyPriorTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_WS_ONLY);
m_xc = m_xo.newCursor();
@@ -79,6 +61,7 @@ public class InsertCharsTest extends Bas
assertEquals(" new chars ", m_xc.getChars());
}
+ @Test
public void testInsertCharsInMiddleOfTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -91,6 +74,7 @@ public class InsertCharsTest extends Bas
assertEquals("tenew chars xt", m_xc.getTextValue());
}
+ @Test
public void testInsertCharsNullInMiddleOfTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -103,6 +87,7 @@ public class InsertCharsTest extends Bas
assertEquals("text", m_xc.getTextValue());
}
+ @Test
public void testInsertCharsEmptyInMiddleOfTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -115,16 +100,12 @@ public class InsertCharsTest extends Bas
assertEquals("text", m_xc.getTextValue());
}
+ @Test(expected = IllegalStateException.class)
public void testInsertCharsInNAMESPACE() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_NS);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.NAMESPACE);
- try {
- m_xc.insertChars("fred");
- fail("Expected IllegalStateException");
- } catch (IllegalStateException e) {
- }
- assertEquals(true, true);
+ m_xc.insertChars("fred");
}
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/InsertCommentTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/InsertCommentTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/InsertCommentTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/InsertCommentTest.java Fri Jan 18 23:08:44 2019
@@ -16,37 +16,18 @@
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.fail;
-/**
- *
- *
- */
public class InsertCommentTest extends BasicCursorTestCase {
- public InsertCommentTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(InsertCommentTest.class);
- }
-
+ @Test
public void testInsertCommentAtSTART() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -57,6 +38,7 @@ public class InsertCommentTest extends B
assertEquals("<foo><!-- new comment --><bar>text</bar></foo>", m_xc.xmlText());
}
+ @Test
public void testInsertCommentInMiddleOfTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -68,6 +50,7 @@ public class InsertCommentTest extends B
assertEquals("<bar>te<!-- new comment -->xt</bar>", m_xc.xmlText());
}
+ @Test
public void testInsertCommentAtEND() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -77,6 +60,7 @@ public class InsertCommentTest extends B
assertEquals("<bar>text<!-- new comment --></bar>", m_xc.xmlText());
}
+ @Test
public void testInsertCommentWithLTChar() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -86,6 +70,7 @@ public class InsertCommentTest extends B
assertEquals("<foo><!--< new comment -->text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertCommentWithDoubleDash() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -95,6 +80,7 @@ public class InsertCommentTest extends B
assertEquals("<foo><!-- - -->text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertCommentWithDoubleDashNoWS() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -104,6 +90,7 @@ public class InsertCommentTest extends B
assertEquals("<foo><!--- -->text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertCommentWithEndDash() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -113,7 +100,7 @@ public class InsertCommentTest extends B
assertEquals("<foo><!-- -->text</foo>", m_xc.xmlText());
}
-
+ @Test
public void testInsertCommentWithEmptyString() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -123,6 +110,7 @@ public class InsertCommentTest extends B
assertEquals("<foo><!---->text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertCommentWithNull() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -132,6 +120,7 @@ public class InsertCommentTest extends B
assertEquals("<foo><!---->text</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertCommentAtSTARTDOC() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/InsertElementTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/InsertElementTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/InsertElementTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/InsertElementTest.java Fri Jan 18 23:08:44 2019
@@ -18,50 +18,31 @@ package xmlcursor.checkin;
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 junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
-/**
- *
- *
- */
public class InsertElementTest extends BasicCursorTestCase {
- public InsertElementTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(InsertElementTest.class);
- }
-
+ @Test(expected = IllegalArgumentException.class)
public void testInsertElementNullName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.START);
- try {
- m_xc.insertElementWithText(null, "uri", "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertElementWithText(null, "uri", "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertElementEmptyStringName() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.START);
- try {
- m_xc.insertElementWithText("", "uri", "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertElementWithText("", "uri", "value");
}
+ @Test
public void testInsertElementNullUri() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -71,6 +52,7 @@ public class InsertElementTest extends B
assertEquals("<name>value</name>", m_xc.xmlText());
}
+ @Test
public void testInsertElementNullText() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -80,6 +62,7 @@ public class InsertElementTest extends B
assertEquals("<uri:name xmlns:uri=\"uri\"/>", m_xc.xmlText());
}
+ @Test
public void testInsertElementEmptyStringText() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_DIGITS);
m_xc = m_xo.newCursor();
@@ -89,6 +72,7 @@ public class InsertElementTest extends B
assertEquals("<name/>", m_xc.xmlText());
}
+ @Test
public void testInsertElementInMiddleOfTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -100,6 +84,7 @@ public class InsertElementTest extends B
assertEquals("<foo>te<name>value</name>xt</foo>", m_xc.xmlText());
}
+ @Test
public void testInsertElementAtEND() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -109,17 +94,14 @@ public class InsertElementTest extends B
assertEquals("<foo>text<name>value</name></foo>", m_xc.xmlText());
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertElementAtSTARTDOC() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
- try {
- m_xc.insertElementWithText("name", null, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- assertEquals(true, true);
+ m_xc.insertElementWithText("name", null, "value");
}
+ @Test
public void testInsertElementAtENDDOC() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_TEXT);
m_xc = m_xo.newCursor();
@@ -129,6 +111,7 @@ public class InsertElementTest extends B
assertEquals(Common.wrapInXmlFrag("<foo>text</foo><name>value</name>"), m_xc.xmlText());
}
+ @Test
public void testInsertElementInStoreWithNamespace() throws Exception {
m_xo = XmlObject.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/InsertProcInstTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/InsertProcInstTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/InsertProcInstTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/InsertProcInstTest.java Fri Jan 18 23:08:44 2019
@@ -16,78 +16,42 @@
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 java.net.URL;
-
-import org.apache.xmlbeans.XmlOptions;
-import xmlcursor.common.*;
-
-import java.util.HashMap;
+import static org.junit.Assert.assertEquals;
-/**
- *
- *
- */
public class InsertProcInstTest extends BasicCursorTestCase {
- public InsertProcInstTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(InsertProcInstTest.class);
- }
-
+ @Test(expected = IllegalArgumentException.class)
public void testInsertProcInstWithNullTarget() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.TEXT);
- try {
- m_xc.insertProcInst(null, "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertProcInst(null, "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertProcInstWithEmptyStringTarget() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.TEXT);
- try {
- m_xc.insertProcInst("", "value");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertEquals(true, true);
+ m_xc.insertProcInst("", "value");
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertProcInstWithLTcharInTarget() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
m_xc.selectPath("$this//bar");
m_xc.toNextSelection();
- try {
- m_xc.insertProcInst("<target", " value ");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- assertTrue(true);
+ m_xc.insertProcInst("<target", " value ");
}
+ @Test
public void testInsertProcInstWithNullText() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -99,6 +63,7 @@ public class InsertProcInstTest extends
assertEquals("<bar>te<?target?>xt</bar>", m_xc.xmlText());
}
+ @Test
public void testInsertProcInstWithEmptyStringText() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -110,6 +75,7 @@ public class InsertProcInstTest extends
assertEquals("<bar>te<?target?>xt</bar>", m_xc.xmlText());
}
+ @Test
public void testInsertProcInstWithLTcharInText() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -120,6 +86,7 @@ public class InsertProcInstTest extends
assertEquals("<foo><?target < value ?><bar>text</bar></foo>", m_xc.xmlText());
}
+ @Test
public void testInsertProcInstInMiddleOfTEXT() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -131,6 +98,7 @@ public class InsertProcInstTest extends
assertEquals("<bar>te<?target value ?>xt</bar>", m_xc.xmlText());
}
+ @Test
public void testInsertProcInstAfterSTART() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_TEXT);
m_xc = m_xo.newCursor();
@@ -141,6 +109,7 @@ public class InsertProcInstTest extends
assertEquals("<foo><?target value ?><bar>text</bar></foo>", m_xc.xmlText());
}
+ @Test
public void testInsertProcInstAtEND() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_NS);
m_xc = m_xo.newCursor();
@@ -150,16 +119,12 @@ public class InsertProcInstTest extends
assertEquals("<foo xmlns=\"http://www.foo.org\"><?target value ?></foo>", m_xc.xmlText());
}
+ @Test(expected = IllegalArgumentException.class)
public void testInsertProcInstBeforeATTR() throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT);
m_xc = m_xo.newCursor();
toNextTokenOfType(m_xc, TokenType.ATTR);
- try {
- m_xc.insertProcInst("target", " value ");
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException ise) {
- }
- assertEquals(true, true);
+ m_xc.insertProcInst("target", " value ");
}
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/IsAtSamePositionAsTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/IsAtSamePositionAsTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/IsAtSamePositionAsTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/IsAtSamePositionAsTest.java Fri Jan 18 23:08:44 2019
@@ -16,93 +16,59 @@
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 org.apache.xmlbeans.XmlObject;
+import org.junit.Before;
+import org.junit.Test;
+import xmlcursor.common.BasicCursorTestCase;
+import xmlcursor.common.Common;
+
+import static org.junit.Assert.*;
-import javax.xml.namespace.QName;
-import xmlcursor.common.*;
+public class IsAtSamePositionAsTest extends BasicCursorTestCase{
-import java.net.URL;
+ private static String sDoc=Common.XML_FOO_DIGITS;
+ @Test
+ public void testNormalCase() {
+ XmlCursor m_xc1 = m_xo.newCursor();
+ m_xc.toFirstChild();
+ m_xc1.toFirstChild();
+ assertTrue(m_xc.isAtSamePositionAs(m_xc1));
+ }
-/**
- *
- *
- */
+ @Test(expected = IllegalArgumentException.class)
+ public void testSamePosDiffDoc() throws Exception {
+ XmlCursor m_xc1 = XmlObject.Factory.parse(sDoc).newCursor();
+ m_xc.toFirstChild();
+ m_xc1.toFirstChild();
+ m_xc.isAtSamePositionAs(m_xc1);
+ }
-public class IsAtSamePositionAsTest extends BasicCursorTestCase{
+ @Test
+ public void testDiffPosSameDoc() throws Exception {
+ XmlCursor m_xc1 = m_xo.newCursor();
+ m_xc.toFirstChild();
+ m_xc1.toFirstChild();
+ m_xc1.toFirstAttribute();
+ assertFalse(m_xc.isAtSamePositionAs(m_xc1));
+ }
- static String sDoc=Common.XML_FOO_DIGITS;
+ @Test(expected = Exception.class)
+ public void testNull() {
+ m_xc.isAtSamePositionAs(null);
+ }
- public IsAtSamePositionAsTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(IsAtSamePositionAsTest.class);
- }
- public void testNormalCase(){
- XmlCursor m_xc1=m_xo.newCursor();; //parse
- m_xc.toFirstChild();
- m_xc1.toFirstChild();
- assertEquals(true,m_xc.isAtSamePositionAs(m_xc1));
- }
-
- public void testSamePosDiffDoc()throws Exception{
- XmlCursor m_xc1=XmlObject.Factory.parse(sDoc).newCursor();
- m_xc.toFirstChild();
- m_xc1.toFirstChild();
- try{
- assertEquals(false,m_xc.isAtSamePositionAs(m_xc1));
- fail("Cursors are in different docs");
- }catch (IllegalArgumentException e){}
- }
- public void testDiffPosSameDoc()throws Exception{
- XmlCursor m_xc1=m_xo.newCursor();
- m_xc.toFirstChild();
- m_xc1.toFirstChild();
- m_xc1.toFirstAttribute();
- assertEquals(false,m_xc.isAtSamePositionAs(m_xc1));
- }
-
- public void testNull(){
- try {
- assertEquals(false,m_xc.isAtSamePositionAs(null));
- fail("Other cursor is Null");
- }catch(Exception e){
- }
- }
-
- public void testSelf(){
- m_xc.toFirstChild();
- assertEquals(true,m_xc.isAtSamePositionAs(m_xc));
- }
-
- public void setUp()throws Exception{
- m_xo=XmlObject.Factory.parse(sDoc);
- m_xc=m_xo.newCursor();
- }
-
- public static void main(String[] rgs){
- try{
- IsAtSamePositionAsTest t=new IsAtSamePositionAsTest("");
- t.setUp();
- t.testNormalCase();
- }catch (Exception e){
- System.err.println("Error "+e.getMessage());
- e.printStackTrace();
+ @Test
+ public void testSelf() {
+ m_xc.toFirstChild();
+ assertEquals(true, m_xc.isAtSamePositionAs(m_xc));
}
- }
+ @Before
+ public void setUp() throws Exception {
+ m_xo = XmlObject.Factory.parse(sDoc);
+ m_xc = m_xo.newCursor();
+ }
}
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/IsInSameDocumentTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/checkin/IsInSameDocumentTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/IsInSameDocumentTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/IsInSameDocumentTest.java Fri Jan 18 23:08:44 2019
@@ -16,71 +16,66 @@
package xmlcursor.checkin;
-import junit.framework.Test;
-import junit.framework.TestSuite;
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 xmlcursor.common.Common;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
-/**
- *
- *
- */
-public class IsInSameDocumentTest extends BasicCursorTestCase {
- public IsInSameDocumentTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(IsInSameDocumentTest.class);
- }
+public class IsInSameDocumentTest extends BasicCursorTestCase {
+ @Test
public void testSameDocSTARTDOCandENDDOC() throws Exception {
m_xc = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
XmlCursor xc0 = m_xc.newCursor();
xc0.toEndDoc();
try {
- assertEquals(true, m_xc.isInSameDocument(xc0));
- assertEquals(true, xc0.isInSameDocument(m_xc));
+ assertTrue(m_xc.isInSameDocument(xc0));
+ assertTrue(xc0.isInSameDocument(m_xc));
} finally {
xc0.dispose();
}
}
+ @Test
public void testSameDocNAMESPACEandATTR() throws Exception {
m_xc = XmlObject.Factory.parse(Common.XML_FOO_DIGITS).newCursor();
XmlCursor xc0 = m_xc.newCursor();
try {
toNextTokenOfType(m_xc, TokenType.NAMESPACE);
toNextTokenOfType(xc0, TokenType.ATTR);
- assertEquals(true, m_xc.isInSameDocument(xc0));
- assertEquals(true, xc0.isInSameDocument(m_xc));
+ assertTrue(m_xc.isInSameDocument(xc0));
+ assertTrue(xc0.isInSameDocument(m_xc));
} finally {
xc0.dispose();
}
}
+ @Test
public void testSameDocNull() throws Exception {
m_xc = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
- assertEquals(false, m_xc.isInSameDocument(null));
+ assertFalse(m_xc.isInSameDocument(null));
}
+ @Test
public void testSameDocDifferentDocs() throws Exception {
m_xc = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
XmlCursor xc0 = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
toNextTokenOfType(m_xc, TokenType.TEXT);
toNextTokenOfType(xc0, TokenType.TEXT);
try {
- assertEquals(false, m_xc.isInSameDocument(xc0));
- assertEquals(false, xc0.isInSameDocument(m_xc));
+ assertFalse(m_xc.isInSameDocument(xc0));
+ assertFalse(xc0.isInSameDocument(m_xc));
} finally {
xc0.dispose();
}
}
+ @Test
public void testSameDocTEXTpositional() throws Exception {
m_xc = XmlObject.Factory.parse(Common.XML_FOO_1ATTR_TEXT).newCursor();
XmlCursor xc0 = m_xc.newCursor();
@@ -88,12 +83,10 @@ public class IsInSameDocumentTest extend
toNextTokenOfType(xc0, TokenType.TEXT);
xc0.toNextChar(2);
try {
- assertEquals(true, m_xc.isInSameDocument(xc0));
- assertEquals(true, xc0.isInSameDocument(m_xc));
+ assertTrue(m_xc.isInSameDocument(xc0));
+ assertTrue(xc0.isInSameDocument(m_xc));
} finally {
xc0.dispose();
}
}
-
}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org