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 [21/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/xpath/common/XPathNodetestTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/common/XPathNodetestTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/common/XPathNodetestTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/common/XPathNodetestTest.java Fri Jan 18 23:08:44 2019
@@ -16,16 +16,13 @@
package xmlcursor.xpath.common;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlCursor.TokenType;
-
+import org.junit.Test;
import xmlcursor.common.BasicCursorTestCase;
-import xmlcursor.common.*;
+import xmlcursor.common.Common;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
@@ -33,18 +30,7 @@ import xmlcursor.common.*;
*/
public class XPathNodetestTest extends BasicCursorTestCase {
-
-
- public XPathNodetestTest(String sName) {
- super(sName);
- }
-
- public static Test suite() {
- return new TestSuite(XPathNodetestTest.class);
- }
-
-
- static String fixPath(String path){
+ private static String fixPath(String path){
return "."+path;
}
@@ -53,82 +39,85 @@ public class XPathNodetestTest extends B
//e.g //A/B/*: tested by Zvon
}
+ @Test
public void testComment()throws Exception {
- String sXml=Common.XML_FOO_NS_PREFIX;
- m_xc= XmlObject.Factory.parse(sXml).newCursor();
- String sExpected=Common.XMLFRAG_BEGINTAG+"<!-- the 'price' element's namespace is http://ecommerce.org/schema -->"+Common.XMLFRAG_ENDTAG;//the comment string
- String sXPath="//comment()";
- m_xc.selectPath(fixPath(sXPath));
- m_xc.toNextSelection();
- assertEquals(m_xc.xmlText(),sExpected );
- }
-
- public void testNode()throws Exception{
- String sInput="<foo> <node>foo</node>txt</foo>";
- m_xc= XmlObject.Factory.parse(sInput).newCursor();
- String sXPath="//foo/node()";
- String[] sExpected=new String[]{Common.XMLFRAG_BEGINTAG+" "+Common.XMLFRAG_ENDTAG,"<node>foo</node>",Common.XMLFRAG_BEGINTAG+"txt"+Common.XMLFRAG_ENDTAG};
- m_xc.selectPath(fixPath(sXPath));
- int i=0;
- if (m_xc.getSelectionCount()!=sExpected.length)
- fail("node() failed");
- while(m_xc.hasNextSelection()){
- m_xc.toNextSelection();
- assertEquals(m_xc.xmlText(),sExpected[i++]);
+ String sXml = Common.XML_FOO_NS_PREFIX;
+ m_xc = XmlObject.Factory.parse(sXml).newCursor();
+ String sExpected = "<xml-fragment xmlns:edi=\"http://ecommerce.org/schema\"><!-- the 'price' element's namespace is http://ecommerce.org/schema -->" + Common.XMLFRAG_ENDTAG;//the comment string
+ String sXPath = "//comment()";
+ m_xc.selectPath(fixPath(sXPath));
+ m_xc.toNextSelection();
+ assertEquals(m_xc.xmlText(), sExpected);
+ }
+
+ @Test
+ public void testNode() throws Exception {
+ String sInput = "<foo> <node>foo</node>txt</foo>";
+ m_xc = XmlObject.Factory.parse(sInput).newCursor();
+ String sXPath = "//foo/node()";
+ String[] sExpected = new String[]{Common.XMLFRAG_BEGINTAG + " " + Common.XMLFRAG_ENDTAG, "<node>foo</node>", Common.XMLFRAG_BEGINTAG + "txt" + Common.XMLFRAG_ENDTAG};
+ m_xc.selectPath(fixPath(sXPath));
+ int i = 0;
+ if (m_xc.getSelectionCount() != sExpected.length)
+ fail("node() failed");
+ while (m_xc.hasNextSelection()) {
+ m_xc.toNextSelection();
+ assertEquals(m_xc.xmlText(), sExpected[i++]);
+ }
}
- }
-
- public void testPI()throws Exception{
- String sInput=Common.XML_FOO_PROCINST;
- m_xc= XmlObject.Factory.parse(sInput).newCursor();
- String sXPath1="//processing-instruction()";
- String sXPath2="//processing-instruction(\"xml-stylesheet\")";
- String sXPath3="//processing-instruction(\"xsl\")";
- String sExpected1=Common.XMLFRAG_BEGINTAG+"<?xml-stylesheet type=\"text/xsl\" xmlns=\"http://openuri.org/shipping/\"?>"+Common.XMLFRAG_ENDTAG;
- String sExpected2="";
- m_xc.selectPath(fixPath(sXPath1));
- assertEquals(m_xc.getSelectionCount(),1);
- m_xc.toNextSelection();
- assertEquals(m_xc.xmlText(),sExpected1);
-
-
- m_xc.clearSelections();
- m_xc.selectPath(fixPath(sXPath2));
- assertEquals(m_xc.xmlText(),sExpected1);
-
- m_xc.clearSelections();
- //shouldn't select any nodes
- m_xc.selectPath(fixPath(sXPath3));
- assertEquals(m_xc.getSelectionCount(),0);
-
- }
+ @Test
+ public void testPI() throws Exception {
+ String sInput = Common.XML_FOO_PROCINST;
+ m_xc = XmlObject.Factory.parse(sInput).newCursor();
+ String sXPath1 = "//processing-instruction()";
+ String sXPath2 = "//processing-instruction(\"xml-stylesheet\")";
+ String sXPath3 = "//processing-instruction(\"xsl\")";
+ String sExpected1 = Common.XMLFRAG_BEGINTAG + "<?xml-stylesheet type=\"text/xsl\" xmlns=\"http://openuri.org/shipping/\"?>" + Common.XMLFRAG_ENDTAG;
+ String sExpected2 = "";
+ m_xc.selectPath(fixPath(sXPath1));
+ assertEquals(m_xc.getSelectionCount(), 1);
+ m_xc.toNextSelection();
+ assertEquals(m_xc.xmlText(), sExpected1);
+
+
+ m_xc.clearSelections();
+ m_xc.selectPath(fixPath(sXPath2));
+ assertEquals(m_xc.xmlText(), sExpected1);
+
+ m_xc.clearSelections();
+ //shouldn't select any nodes
+ m_xc.selectPath(fixPath(sXPath3));
+ assertEquals(m_xc.getSelectionCount(), 0);
+ }
- public void testText()throws Exception{
- String sInput="<?xml-stylesheet type=\"text/xsl\" xmlns=\"http://openuri.org/shipping/\"?><br>foo<foo>text</foo></br>";
- m_xc= XmlObject.Factory.parse(sInput).newCursor();
- String sXPath="//text()";
- String sExpected1=Common.XMLFRAG_BEGINTAG+"foo"+Common.XMLFRAG_ENDTAG;
- String sExpected2=Common.XMLFRAG_BEGINTAG+"text"+Common.XMLFRAG_ENDTAG;
- m_xc.selectPath(sXPath);
- assertEquals(m_xc.getSelectionCount(),2);
- m_xc.toNextSelection();
- assertEquals(m_xc.xmlText(),sExpected1);
- m_xc.toNextSelection();
- assertEquals(m_xc.xmlText(),sExpected2);
- }
+ @Test
+ public void testText() throws Exception {
+ String sInput = "<?xml-stylesheet type=\"text/xsl\" xmlns=\"http://openuri.org/shipping/\"?><br>foo<foo>text</foo></br>";
+ m_xc = XmlObject.Factory.parse(sInput).newCursor();
+ String sXPath = "//text()";
+ String sExpected1 = Common.XMLFRAG_BEGINTAG + "foo" + Common.XMLFRAG_ENDTAG;
+ String sExpected2 = Common.XMLFRAG_BEGINTAG + "text" + Common.XMLFRAG_ENDTAG;
+ m_xc.selectPath(sXPath);
+ assertEquals(m_xc.getSelectionCount(), 2);
+ m_xc.toNextSelection();
+ assertEquals(m_xc.xmlText(), sExpected1);
+ m_xc.toNextSelection();
+ assertEquals(m_xc.xmlText(), sExpected2);
+ }
- public void testTextObject()throws Exception{
- String sInput="<?xml-stylesheet type=\"text/xsl\" xmlns=\"http://openuri.org/shipping/\"?><br>foo<foo>text</foo></br>";
- m_xo= XmlObject.Factory.parse(sInput);
- String sXPath="//text()";
- String sExpected1=Common.XMLFRAG_BEGINTAG+"foo"+Common.XMLFRAG_ENDTAG;
- String sExpected2=Common.XMLFRAG_BEGINTAG+"text"+Common.XMLFRAG_ENDTAG;
- XmlObject[] res=m_xo.selectPath(sXPath);
- assertEquals(res.length,2);
- assertEquals(res[0].xmlText(),sExpected1);
- assertEquals(res[1].xmlText(),sExpected2);
- }
+ @Test
+ public void testTextObject() throws Exception {
+ String sInput = "<?xml-stylesheet type=\"text/xsl\" xmlns=\"http://openuri.org/shipping/\"?><br>foo<foo>text</foo></br>";
+ m_xo = XmlObject.Factory.parse(sInput);
+ String sXPath = "//text()";
+ String sExpected1 = Common.XMLFRAG_BEGINTAG + "foo<foo>text</foo>" + Common.XMLFRAG_ENDTAG;
+ String sExpected2 = Common.XMLFRAG_BEGINTAG + "text" + Common.XMLFRAG_ENDTAG;
+ XmlObject[] res = m_xo.selectPath(sXPath);
+ assertEquals(res.length, 2);
+ assertEquals(res[0].xmlText(), sExpected1);
+ assertEquals(res[1].xmlText(), sExpected2);
+ }
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/ContainerCommentTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/ContainerCommentTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/ContainerCommentTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/ContainerCommentTest.java Fri Jan 18 23:08:44 2019
@@ -16,68 +16,56 @@ package xmlcursor.xpath.complex.checkin;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
- * Date: Apr 12, 2005
- * Time: 1:08:39 PM
* This class tests the execution of an XQuery where the
* starting point of the query is a comment
*/
-public class ContainerCommentTest extends TestCase
-{
- public static void testFunctionPathWithCursor() throws Exception
- {
-
-
- XmlObject employees = XmlObject.Factory.parse(sXml);
- String m_namespaceDeclaration =
- "declare namespace xq='http://xmlbeans.apache.org/samples/xquery/employees';";
-
- boolean hasResults = false;
- String[] names;
-
- XmlCursor cursor = employees.newCursor();
- cursor.toNextToken();
-
- cursor.selectPath(m_namespaceDeclaration + "$this//xq:employee");
- if (cursor.getSelectionCount() > 0)
- {
- hasResults = true;
- cursor.toNextSelection();
-
- names = new String[cursor.getSelectionCount()];
-
- for (int i = 0; i < cursor.getSelectionCount(); i++)
- {
- XmlCursor nameCursor = cursor.newCursor();
- nameCursor.selectPath(m_namespaceDeclaration +
- "$this/xq:name/text()");
- nameCursor.toNextSelection();
- names[i] = nameCursor.getTextValue();
- cursor.toNextSelection();
- System.out.println(names[i]);
- }
- }
- }
-
- static String prolog="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<!-- My Comment -->";
- public static String sXml=prolog+
- "<employees xmlns=\"http://xmlbeans.apache.org/samples/xquery/employees\">\n" +
- " <employee>\n" +
- " <name>Fred Jones</name>\n" +
- " <address location=\"home\">\n" +
- " <street>900 Aurora Ave.</street>\n" +
- " <city>Seattle</city>\n" +
- " <state>WA</state>\n" +
- " <zip>98115</zip>\n" +
- " </address>\n" +
- " <phone location=\"work\">(425)555-5665</phone>\n" +
- " <phone location=\"home\">(206)555-5555</phone>\n" +
- " <phone location=\"mobile\">(206)555-4321</phone>\n" +
- " </employee>\n" +
- " </employees>";
-
+public class ContainerCommentTest {
+ @Test
+ public void testFunctionPathWithCursor() throws Exception {
+ String sXml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<!-- My Comment -->" +
+ "<employees xmlns=\"http://xmlbeans.apache.org/samples/xquery/employees\">\n" +
+ " <employee>\n" +
+ " <name>Fred Jones</name>\n" +
+ " <address location=\"home\">\n" +
+ " <street>900 Aurora Ave.</street>\n" +
+ " <city>Seattle</city>\n" +
+ " <state>WA</state>\n" +
+ " <zip>98115</zip>\n" +
+ " </address>\n" +
+ " <phone location=\"work\">(425)555-5665</phone>\n" +
+ " <phone location=\"home\">(206)555-5555</phone>\n" +
+ " <phone location=\"mobile\">(206)555-4321</phone>\n" +
+ " </employee>\n" +
+ " </employees>";
+
+ XmlObject employees = XmlObject.Factory.parse(sXml);
+ String m_namespaceDeclaration =
+ "declare namespace xq='http://xmlbeans.apache.org/samples/xquery/employees';";
+
+ XmlCursor cursor = employees.newCursor();
+ cursor.toNextToken();
+
+ cursor.selectPath(m_namespaceDeclaration + "$this//xq:employee");
+ if (cursor.getSelectionCount() > 0) {
+ cursor.toNextSelection();
+
+ String[] names = new String[cursor.getSelectionCount()];
+
+ for (int i = 0; i < cursor.getSelectionCount(); i++) {
+ XmlCursor nameCursor = cursor.newCursor();
+ nameCursor.selectPath(m_namespaceDeclaration +
+ "$this/xq:name/text()");
+ nameCursor.toNextSelection();
+ names[i] = nameCursor.getTextValue();
+ cursor.toNextSelection();
+ System.out.println(names[i]);
+ }
+ }
+ }
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/JaxenXPathTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/JaxenXPathTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/JaxenXPathTests.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/JaxenXPathTests.java Fri Jan 18 23:08:44 2019
@@ -14,26 +14,19 @@
*/
package xmlcursor.xpath.complex.checkin;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
-import xmlcursor.common.Common;
+import org.junit.Before;
+import org.junit.Test;
import xmlcursor.xpath.common.XPathCommon;
-import java.io.IOException;
-import java.io.StringWriter;
import java.io.PrintWriter;
+import java.io.StringWriter;
-/**
- *
- */
-public class JaxenXPathTests
- extends TestCase
-{
- String sXml =
+import static org.junit.Assert.assertNull;
+
+public class JaxenXPathTests {
+ private final String sXml =
"<?xml version=\"1.0\"?>" +
"<doc xmlns:ext=\"http://somebody.elses.extension\">" +
"<a test=\"test\" />" +
@@ -44,48 +37,35 @@ public class JaxenXPathTests
"</b>" +
"</doc><!-- --> ";
+ private String[][] expected = null;
+ private String[] xpath = null;
- public JaxenXPathTests(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(JaxenXPathTests.class);
- }
+ @Test
public void testConformance()
- throws Exception
- {
+ throws Exception {
XmlObject doc = XmlObject.Factory.parse(sXml);
runAll(doc, xpath);
}
- private void runAll(XmlObject doc, String[] xpathes)
- throws Exception
- {
- StringBuffer errors = new StringBuffer();
+ private void runAll(XmlObject doc, String[] xpathes) {
+ StringBuilder errors = new StringBuilder();
boolean bFail = false;
- for (int i = 0; i < xpathes.length; i++)
- {
- try
- {
+ for (int i = 0; i < xpathes.length; i++) {
+ try {
runXpath2(doc, xpathes[i], i);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
bFail = true;
errors.append("**********************Failed at test " + i +
- "\n path:" + xpathes[i] + "\n");
+ "\n path:" + xpathes[i] + "\n");
// if (e.getMessage() == null)
// {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- errors.append(sw);
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ errors.append(sw);
// }
// else
- errors.append(e.getMessage());
+ errors.append(e.getMessage());
errors.append("\n\n");
}
}
@@ -126,23 +106,17 @@ public class JaxenXPathTests
// }
// }
- private void runXpath2(XmlObject doc, String xpathStr, int i)
- throws Exception
- {
+ private void runXpath2(XmlObject doc, String xpathStr, int i) throws Exception {
XmlCursor xc = doc.newCursor();
xc.selectPath(xpathStr);
check(i, xc);
xc.dispose();
}
- private void check(int expresionNumber,
- XmlCursor actual)
- throws Exception
- {
-
- if (actual.getSelectionCount() == 0)
- {
- assertEquals(null, expected[expresionNumber]);
+ private void check(int expresionNumber, XmlCursor actual) throws Exception {
+
+ if (actual.getSelectionCount() == 0) {
+ assertNull(expected[expresionNumber]);
return;
}
@@ -154,28 +128,17 @@ public class JaxenXPathTests
expected_val[i] = XmlObject.Factory.parse(
expected[expresionNumber][i]);
- try
- {
+ try {
XPathCommon.compare(actual, expected_val);
- }
- catch (Throwable e)
- {
+ } catch (Throwable e) {
throw new Exception(e.getMessage());
}
}
- /**
- * This is only used to regen the expected files.
- */
- private void generateExpected(int expresionNumber, int resultNumber,
- String content)
- {
- expected[expresionNumber][resultNumber] = content;
- }
-
- public void setUp()
- {
+ @Before
+ public void setUp() {
+ int numExpressions = 25;
expected = new String[numExpressions][];
@@ -208,15 +171,13 @@ public class JaxenXPathTests
String[] steps = new String[12];
- final String DEFAULT_NS =
- "<xml-fragment xmlns:xml=\"http://www.w3.org/XML/1998/namespace\"/>";
steps[0] =
"<xml-fragment xmlns:ext=\"http://somebody.elses.extension\"/>";
steps[1] = "<doc xmlns:ext=\"http://somebody.elses.extension\">" +
- "<a test=\"test\" />" +
- "<b attr1=\"a1\" attr2=\"a2\" " +
- "xmlns:java=\"http://xml.apache.org/xslt/java\">" +
- " <a /> </b></doc>";
+ "<a test=\"test\" />" +
+ "<b attr1=\"a1\" attr2=\"a2\" " +
+ "xmlns:java=\"http://xml.apache.org/xslt/java\">" +
+ " <a /> </b></doc>";
steps[2] =
"<a test=\"test\" xmlns:ext=\"http://somebody.elses.extension\"/>";
steps[3] =
@@ -239,19 +200,20 @@ public class JaxenXPathTests
"xmlns:ext=\"http://somebody.elses.extension\" />";
steps[8] = "<xml-fragment><!-- --></xml-fragment>";
steps[9] = " <xml-fragment xmlns:java=\"http://xml.apache.org/xslt/java\"" +
- " xmlns:ext=\"http://somebody.elses.extension\" />";
+ " xmlns:ext=\"http://somebody.elses.extension\" />";
steps[10] = "<a> </a>";
steps[11] = "<xml-fragment> </xml-fragment>";
expected[0] = new String[]{steps[2]};
+ String XMLFRAG_EMPTY = "<xml-fragment/>";
expected[1] = new String[]{sXml,
- steps[1],
- steps[2],
- steps[5],
- XMLFRAG_EMPTY,
- steps[10],
- XMLFRAG_EMPTY,
- steps[8],
+ steps[1],
+ steps[2],
+ steps[5],
+ XMLFRAG_EMPTY,
+ steps[10],
+ XMLFRAG_EMPTY,
+ steps[8],
};
expected[2] = new String[]{steps[1]};
@@ -264,16 +226,16 @@ public class JaxenXPathTests
expected[5] = new String[]{sXml};
expected[6] = new String[]{sXml,
- steps[2],
- steps[5],
- steps[10]};
+ steps[2],
+ steps[5],
+ steps[10]};
expected[7] = new String[]{steps[1]};
expected[8] =
new String[]{
steps[2],
steps[6]};
- /**
+ /*
* This is tricky:
* The expression "*" is true for the principal axis: since the axis is
* self, so we're looking for elements: doc elt
@@ -286,7 +248,7 @@ public class JaxenXPathTests
steps[6],
steps[7],
steps[8]
- };
+ };
expected[10] = new String[]{
steps[1],
@@ -297,15 +259,15 @@ public class JaxenXPathTests
expected[11] = null; //new String[]{steps[0],DEFAULT_NS};
expected[12] = new String[]{steps[8]};
expected[13] = new String[]{steps[2],
- steps[4]
+ steps[4]
};
expected[14] = new String[]{steps[3],
- steps[6],
- steps[7]};
+ steps[6],
+ steps[7]};
expected[15] = new String[]{steps[1],
- steps[5],
- steps[4]};
+ steps[5],
+ steps[4]};
expected[16] = new String[]{steps[5]};
//TODO: BUGBUG: fix this
expected[17] = null;
@@ -313,7 +275,7 @@ public class JaxenXPathTests
expected[18] = new String[]{
steps[2],
steps[5],
- steps[11],
+ steps[11],
steps[10],
steps[11]
};
@@ -339,18 +301,13 @@ public class JaxenXPathTests
}
- private String[][] expected = null;
- private String[] xpath = null;
- private int numExpressions = 25;
- private String XMLFRAG_EMPTY = "<xml-fragment/>";
-
- public void testDelete() throws Exception
- {
- String query="*";
+ @Test
+ public void testDelete() throws Exception {
+ String query = "*";
- XmlCursor xc = XmlObject.Factory.parse(sXml).newCursor();
+ XmlCursor xc = XmlObject.Factory.parse(sXml).newCursor();
xc.selectPath(query);
while (xc.toNextSelection())
- System.out.println(xc.xmlText());
+ System.out.println(xc.xmlText());
}
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/DeclareNamespaceTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/DeclareNamespaceTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/DeclareNamespaceTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/DeclareNamespaceTest.java Fri Jan 18 23:08:44 2019
@@ -12,22 +12,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- package xmlcursor.xpath.complex.detailed;
+package xmlcursor.xpath.complex.detailed;
-import org.apache.xmlbeans.*;
-import junit.framework.TestCase;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlLong;
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
import xmlcursor.common.Common;
-/**
- *
- */
-public class DeclareNamespaceTest
- extends TestCase
-{
-
- public static void testDeclareNSPath()
- throws Exception
- {
+import static org.junit.Assert.*;
+
+public class DeclareNamespaceTest {
+
+ @Test
+ public void testDeclareNSPath() throws Exception {
XmlObject s = XmlObject.Factory.parse(
"<a xmlns:ack='abc' ack:attr='val1'>foo<b>bar</b></a>");
XmlObject[] res;
@@ -50,14 +49,13 @@ public class DeclareNamespaceTest
c1.toFirstContentToken();
XmlObject o = c1.getObject();
- assertTrue(o != res[0]);
+ assertNotSame(o, res[0]);
assertEquals(res[0].xmlText(),
"<xml-fragment ack:attr=\"val1\" xmlns:ack=\"abc\"/>");
}
- public static void testDefaultNSPath()
- throws Exception
- {
+ @Test
+ public void testDefaultNSPath() throws Exception {
XmlObject s = XmlObject.Factory.parse(
"<a xmlns='abc'>foo<b>bar</b></a>");
XmlObject[] res;
@@ -75,13 +73,12 @@ public class DeclareNamespaceTest
c1.toFirstContentToken();
XmlObject o = c1.getObject();
- assertTrue(o != res[0]);
+ assertNotSame(o, res[0]);
assertEquals(res[0].xmlText(), "<abc:b xmlns:abc=\"abc\">bar</abc:b>");
}
- public void testSequence()
- throws Exception
- {
+ @Test
+ public void testSequence() throws Exception {
XmlObject o = XmlObject.Factory.parse(
"<a xmlns='abc'>foo<b>bar</b></a>");
XmlObject[] res = null;
@@ -101,16 +98,14 @@ public class DeclareNamespaceTest
a = ((XmlLong) res[0]);
expXml = "<xml-fragment>10</xml-fragment>";
assertEquals(expXml, a.xmlText());
- for (int i = 1; i < 5; i++)
- {
+ for (int i = 1; i < 5; i++) {
a = ((XmlLong) res[i]);
assertEquals(Common.wrapInXmlFrag(i + ""), a.xmlText());
}
}
- public void testSequenceUnion()
- throws Exception
- {
+ @Test
+ public void testSequenceUnion() throws Exception {
XmlObject o = XmlObject.Factory.parse("<a><b>1</b>1</a>");
XmlObject[] res = o.selectPath("//a union //b");
assertEquals(2, res.length);
@@ -123,9 +118,8 @@ public class DeclareNamespaceTest
assertEquals("<xml-fragment>1</xml-fragment>", a.xmlText());
}
- public void testSequenceIntersect()
- throws Exception
- {
+ @Test
+ public void testSequenceIntersect() throws Exception {
XmlCursor o = XmlObject.Factory.parse("<a><b>1</b>1</a>").newCursor();
o.selectPath("//b intersect //b");
assertEquals(1, o.getSelectionCount());
@@ -133,9 +127,8 @@ public class DeclareNamespaceTest
assertEquals("<b>1</b>", o.xmlText());
}
- public void testSequenceExcept()
- throws Exception
- {
+ @Test
+ public void testSequenceExcept() throws Exception {
XmlCursor o = XmlObject.Factory.parse("<a><b>1</b>1</a>").newCursor();
o.selectPath("/a except /a");
assertEquals(0, o.getSelectionCount());
@@ -148,18 +141,10 @@ public class DeclareNamespaceTest
//If an operand of union, intersect, or except
// contains an item that is not a node, a type error is raised.
- public void testSequenceTypeError()
- throws Exception
- {
- try
- {
- XmlCursor o = XmlObject.Factory.parse("<a/>").newCursor();
- o.selectPath("(0 to 4) except (0 to 4)");
- fail("Type error expected");
- }
- catch (Throwable t)
- {
- }
+ @Test(expected = RuntimeException.class)
+ public void testSequenceTypeError() throws XmlException {
+ XmlCursor o = XmlObject.Factory.parse("<a/>").newCursor();
+ o.selectPath("(0 to 4) except (0 to 4)");
+ o.toNextSelection();
}
-
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/NodeCopyTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/NodeCopyTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/NodeCopyTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/NodeCopyTest.java Fri Jan 18 23:08:44 2019
@@ -14,17 +14,20 @@
*/
package xmlcursor.xpath.complex.detailed;
-import junit.framework.TestCase;
-import org.apache.xmlbeans.*;
-//import xbean.scomp.element.globalEltDefault.GlobalEltDefaultIntDocument;
-
-/**
- *
- */
-public class NodeCopyTest extends TestCase {
-
- public static void testNS() throws Exception{
- XmlObject s=XmlObject.Factory.parse("<a xmlns:ack='abc' ack:attr='val1'>foo<b>bar</b></a>");
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlLong;
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Ignore;
+import org.junit.Test;
+import xbean.scomp.element.globalEltDefault.GlobalEltDefaultIntDocument;
+
+import static org.junit.Assert.*;
+
+public class NodeCopyTest {
+
+ @Test
+ public void testNS() throws Exception {
+ XmlObject s = XmlObject.Factory.parse("<a xmlns:ack='abc' ack:attr='val1'>foo<b>bar</b></a>");
XmlObject[] res;
/*
res=s.selectPath("./a");
@@ -32,71 +35,73 @@ public class NodeCopyTest extends TestCa
assertEquals( res[0].xmlText(),"<xml-fragment ack:attr=\"val1\" xmlns:ack=\"abc\">foo<b>bar</b></xml-fragment>");
//"for $e in ./a return <doc>{ $e } </doc>"
*/
- XmlCursor s1=s.newCursor().execQuery("./a");
- assertEquals("<a ack:attr=\"val1\" xmlns:ack=\"abc\">foo<b>bar</b></a>",s1.xmlText());
+ XmlCursor s1 = s.newCursor().execQuery("./a");
+ assertEquals("<a ack:attr=\"val1\" xmlns:ack=\"abc\">foo<b>bar</b></a>", s1.xmlText());
- res=s.execQuery("./a");
- XmlCursor c1=s.newCursor();
+ res = s.execQuery("./a");
+ XmlCursor c1 = s.newCursor();
c1.toFirstContentToken();
XmlObject o = c1.getObject();
- assertTrue(o != res[0]);
- assertEquals("<a ack:attr=\"val1\" xmlns:ack=\"abc\">foo<b>bar</b></a>",res[0].xmlText());
+ assertNotSame(o, res[0]);
+ assertEquals("<a ack:attr=\"val1\" xmlns:ack=\"abc\">foo<b>bar</b></a>", res[0].xmlText());
}
- public static void testText() throws Exception{
- XmlObject s=XmlObject.Factory.parse("<a><b>bar</b>foo</a>");
+ @Test
+ public void testText() throws Exception {
+ XmlObject s = XmlObject.Factory.parse("<a><b>bar</b><c>foo</c></a>");
XmlObject[] res;
- res=s.selectPath(".//text()");
+ res = s.selectPath(".//text()");
assertEquals(2, res.length);
- assertEquals("<xml-fragment>bar</xml-fragment>",res[0].xmlText());
- assertEquals("<xml-fragment>foo</xml-fragment>",res[1].xmlText());
+ assertEquals("<xml-fragment>bar</xml-fragment>", res[0].xmlText());
+ assertEquals("<xml-fragment>foo</xml-fragment>", res[1].xmlText());
}
- public static void testCount() throws Exception{
- XmlObject s=XmlObject.Factory.parse("<a><b>bar</b>foo</a>");
+ @Test
+ public void testCount() throws Exception {
+ XmlObject s = XmlObject.Factory.parse("<a><b>bar</b>foo</a>");
XmlObject[] res;
- res=s.selectPath("count(.//b)");
+ res = s.selectPath("count(.//b)");
System.out.println(res[0].xmlText());
- XmlLong i=(XmlLong)res[0];
- assertEquals((long)1, i.getLongValue());
+ XmlLong i = (XmlLong) res[0];
+ assertEquals((long) 1, i.getLongValue());
// res= s.selectPath("//b");
}
- /*
- public void testInt()throws Exception{
- GlobalEltDefaultIntDocument d=
- GlobalEltDefaultIntDocument.Factory
- .parse("<GlobalEltDefaultInt xmlns='http://xbean/scomp/element/GlobalEltDefault'>" +
- "3"+
- "</GlobalEltDefaultInt>");
+ @Test
+ @Ignore
+ public void testInt() throws Exception {
+ GlobalEltDefaultIntDocument d =
+ GlobalEltDefaultIntDocument.Factory
+ .parse("<GlobalEltDefaultInt xmlns='http://xbean/scomp/element/GlobalEltDefault'>" +
+ "3" +
+ "</GlobalEltDefaultInt>");
d.getGlobalEltDefaultInt();
}
- */
- public void testXmlObjectSelectPath(){
+ @Test
+ public void testXmlObjectSelectPath() {
}
- public void testDeleteMe() throws Exception
- {
- XmlObject t= XmlObject.Factory.parse("<a><b/><b/></a>");
+ @Test
+ public void testDeleteMe() throws Exception {
+ XmlObject t = XmlObject.Factory.parse("<a><b/><b/></a>");
XmlCursor cursor =
t.newCursor();
System.out.println(cursor.getObject());
// use xpath to select elements
cursor.selectPath("*/*");
- System.out.println("cnt "+cursor.getSelectionCount());
+ System.out.println("cnt " + cursor.getSelectionCount());
// iterate over the selection
- while (cursor.toNextSelection())
- {
+ while (cursor.toNextSelection()) {
// two views of the same data:
// move back and forth between XmlObject <-> XmlCursor
- XmlObject trans =cursor.getObject();
+ XmlObject trans = cursor.getObject();
- System.out.println("Trans "+trans.xmlText());
- System.out.println("xmlText "+cursor.xmlText());
+ System.out.println("Trans " + trans.xmlText());
+ System.out.println("xmlText " + cursor.xmlText());
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/TypesTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/TypesTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/TypesTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/TypesTest.java Fri Jan 18 23:08:44 2019
@@ -14,50 +14,40 @@
*/
package xmlcursor.xpath.complex.detailed;
-import org.apache.xmlbeans.GDurationSpecification;
-import org.apache.xmlbeans.GDurationBuilder;
-import org.apache.xmlbeans.XmlDate;
-import org.apache.xmlbeans.XmlDecimal;
-import org.apache.xmlbeans.XmlObject;
-//import org.apache.xmlbeans.XmlInt;
-import org.apache.xmlbeans.XmlLong;
-import org.apache.xmlbeans.XmlTime;
-//import org.apache.xmlbeans.XmlByte;
-import org.apache.xmlbeans.XmlAnyURI;
-//import org.apache.xmlbeans.XmlDateTime;
+import org.apache.xmlbeans.*;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+import java.util.Calendar;
-/**
- *
- */
-public class TypesTest
- extends TestCase
-{
- XmlObject o;
- XmlObject[] res;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TypesTest {
+ private XmlObject o;
+ private XmlObject[] res;
+ @Before
public void setUp()
- throws Exception
- {
+ throws Exception {
o = XmlObject.Factory.parse("<a/>");
}
- public void testDate()
- {
+ @Test
+ public void testDate() {
res = o.selectPath("xs:date(\"2000-01-01\")");
assertEquals(1, res.length);
- XmlDate d = ((XmlDate) res[0]);
- assertEquals(
- "<xml-fragment>Fri Dec 31 16:00:00 PST 1999</xml-fragment>",
- d.xmlText());
+ Calendar d = ((XmlDate) res[0]).getCalendarValue();
+ assertEquals(2000, d.get(Calendar.YEAR));
+// assertEquals(
+// "<xml-fragment>Fri Dec 31 16:00:00 PST 1999</xml-fragment>",
+// d.xmlText());
}
- public void testDecimal()
- {
- res =
- o.selectPath(
- "seconds-from-dateTime(xs:dateTime('1997-07-16T19:20:30+01:00'))");
+ @Test
+ public void testDecimal() {
+ res = o.selectPath(
+ "seconds-from-dateTime(xs:dateTime('1997-07-16T19:20:30+01:00'))");
assertEquals(1, res.length);
XmlDecimal dec = ((XmlDecimal) res[0]);
assertEquals("<xml-fragment>30</xml-fragment>", dec.xmlText());
@@ -65,8 +55,8 @@ public class TypesTest
//Saxon returns string here, though the string is a valid duration
//representation
- public void testDuration() throws Exception
- {
+ @Test
+ public void testDuration() {
res = o.selectPath("xs:dayTimeDuration(\"PT12H\")*4");
assertEquals(1, res.length);
System.out.println(res[0].schemaType());
@@ -76,23 +66,22 @@ public class TypesTest
int j = s.indexOf("\")");
assertTrue(0 < i);
assertTrue(i < j);
- String duration = s.substring(i+2, j);
+ String duration = s.substring(i + 2, j);
System.out.println(duration);
GDurationSpecification gDur = new GDurationBuilder(duration);
System.out.println(gDur.getDay());
assertEquals(2, gDur.getDay());
}
- public static void testTypes()
- throws Exception
- {
+ @Test
+ public void testTypes() throws Exception {
XmlObject o = XmlObject.Factory.parse(
"<a xml:base='abc'>foo<b>bar</b></a>");
XmlObject[] res = null;
//Long
res = o.selectPath("hours-from-dateTime(" +
- "current-dateTime()) cast as xs:integer");
+ "current-dateTime()) cast as xs:integer");
assertEquals(1, res.length);
System.out.println(res[0].schemaType());
XmlLong xl = ((XmlLong) res[0]);
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathExpressionTestImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathExpressionTestImpl.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathExpressionTestImpl.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathExpressionTestImpl.java Fri Jan 18 23:08:44 2019
@@ -15,54 +15,38 @@
package xmlcursor.xpath.complex.detailed;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
import xmlcursor.common.Common;
import xmlcursor.xpath.common.XPathExpressionTest;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlCursor;
+import static org.junit.Assert.*;
/**
* Verifies XPath with Expressions
* http://www.w3schools.com/xpath/xpath_expressions.asp
*/
-public class XPathExpressionTestImpl
- extends XPathExpressionTest
-{
- public XPathExpressionTestImpl(String name)
- {
- super(name);
- }
-
- public String getQuery(String testName, int testCase)
- throws IllegalArgumentException
- {
- Object queries;
-
- if ((queries = testMap.get(testName)) == null)
- throw new IllegalArgumentException("No queries for test" +
- testName);
- else if (((String[]) queries).length <= testCase)
- throw new IllegalArgumentException("No query " + testCase +
- " for test" + testName);
- else
- return ((String[]) queries)[testCase];
+public class XPathExpressionTestImpl extends XPathExpressionTest {
+ public String getQuery(String testName, int testCase) throws IllegalArgumentException {
+ String[] queries = testMap.get(testName);
+ assertNotNull("No queries for test", queries);
+ assertFalse("No query " + testCase + " for test" + testName, queries.length <= testCase);
+ return queries[testCase];
}
- private void verifySelection(XmlCursor c, String[] expected)
- {
+ private void verifySelection(XmlCursor c, String[] expected) {
int count = c.getSelectionCount();
assertEquals(expected.length, count);
- for (int i = 0; i < count; i++)
- {
+ for (int i = 0; i < count; i++) {
c.toNextSelection();
assertEquals(expected[i], c.xmlText());
}
}
- public void testForExpression()
- throws Exception
- {
+ @Test
+ public void testForExpression() throws Exception {
String sXml = "<bib>\n" +
" <book>\n" +
" <title>TCP/IP Illustrated</title>\n" +
@@ -102,9 +86,8 @@ public class XPathExpressionTestImpl
verifySelection(c, exp);
}
- public void testFor_1()
- throws Exception
- {
+ @Test
+ public void testFor_1() throws Exception {
XmlCursor c = XmlObject.Factory.parse("<a/>").newCursor();
String query = "for $i in (10, 20),\n" +
" $j in (1, 2)\n" +
@@ -119,9 +102,8 @@ public class XPathExpressionTestImpl
verifySelection(c, expected);
}
- public void testFor_2()
- throws Exception
- {
+ @Test
+ public void testFor_2() throws Exception {
XmlCursor c = XmlObject.Factory.parse("<a/>").newCursor();
String query = "sum (for $i in (10, 20)" +
"return $i)";
@@ -131,9 +113,8 @@ public class XPathExpressionTestImpl
assertEquals(Common.wrapInXmlFrag("30"), c.xmlText());
}
- public void testIf()
- throws Exception
- {
+ @Test
+ public void testIf() throws Exception {
XmlCursor c = XmlObject.Factory.parse("<root>" +
"<book price='20'>Pooh</book>" +
"<cd price='25'>Pooh</cd>" +
@@ -165,9 +146,8 @@ public class XPathExpressionTestImpl
assertEquals("<cd price=\"25\">Maid</cd>", c.xmlText());
}
- public void testQuantifiedExpression()
- throws Exception
- {
+ @Test
+ public void testQuantifiedExpression() throws Exception {
XmlCursor c = XmlObject.Factory.parse("<root></root>").newCursor();
String query =
"some $x in (1, 2, 3), $y in (2, 3, 4) " +
@@ -177,5 +157,4 @@ public class XPathExpressionTestImpl
c.toNextSelection();
assertEquals("<xml-fragment>true</xml-fragment>", c.xmlText());
}
-
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathFunctionAuxTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathFunctionAuxTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathFunctionAuxTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathFunctionAuxTest.java Fri Jan 18 23:08:44 2019
@@ -15,49 +15,30 @@
package xmlcursor.xpath.complex.detailed;
+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 xmlcursor.xpath.common.XPathCommon;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.Assert;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlException;
-import tools.util.JarUtil;
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Verifies XPath using functions
* http://www.w3schools.com/xpath/xpath_functions.asp
- *
- * @status inactive
*/
-public class XPathFunctionAuxTest
- extends BasicCursorTestCase
-{
- public XPathFunctionAuxTest(String sName)
- {
- super(sName);
- }
-
- public static Test suite()
- {
- return new TestSuite(XPathFunctionAuxTest.class);
- }
+public class XPathFunctionAuxTest extends BasicCursorTestCase {
- static String fixPath(String path)
- {
+ private static String fixPath(String path) {
return path;
}
- public void testFunctionCount_caseB()
- throws Exception
- {
+ @Test
+ public void testFunctionCount_caseB() throws Exception {
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/cdcatalog.xml"));
@@ -73,9 +54,8 @@ public class XPathFunctionAuxTest
x1.dispose();
}
- public void testFunctionConcat_caseB()
- throws Exception
- {
+ @Test
+ public void testFunctionConcat_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.00</price>" +
"<price at=\"val1\">2</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
@@ -88,10 +68,8 @@ public class XPathFunctionAuxTest
assertEquals(sExpected, m_xc.xmlText());
}
- public void testFunctionStringLength_caseB()
- throws Exception
- {
-
+ @Test
+ public void testFunctionStringLength_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.00</price><price at=\"val1\">2</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
@@ -102,9 +80,8 @@ public class XPathFunctionAuxTest
assertEquals(sExpected, m_xc.xmlText());
}
- public void testFunctionSubString_caseB()
- throws Exception
- {
+ @Test
+ public void testFunctionSubString_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.00</price><price at=\"val1\">2</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
@@ -115,13 +92,10 @@ public class XPathFunctionAuxTest
assertEquals(XmlCursor.TokenType.TEXT,
m_xc.currentTokenType());
assertEquals(sExpected, m_xc.xmlText());
-
}
- public void testFunctionSubStringAfter_caseB()
- throws Exception
- {
-
+ @Test
+ public void testFunctionSubStringAfter_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.00</price><price at=\"val1\">2</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
@@ -130,13 +104,10 @@ public class XPathFunctionAuxTest
m_xc.selectPath(fixPath(sXPath));
m_xc.toNextSelection();
assertEquals(sExpected, m_xc.xmlText());
-
}
- public void testFunctionSubStringBefore_caseB()
- throws Exception
- {
-
+ @Test
+ public void testFunctionSubStringBefore_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.00</price><price at=\"val1\">2</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
@@ -148,9 +119,8 @@ public class XPathFunctionAuxTest
assertEquals(sExpected, m_xc.xmlText());
}
- public void testFunctionTranslate_caseB()
- throws Exception
- {
+ @Test
+ public void testFunctionTranslate_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.00</price><price at=\"val1\">2</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
@@ -163,9 +133,8 @@ public class XPathFunctionAuxTest
assertEquals(sExpected, m_xc.xmlText());
}
- public void testFunctionNumber_caseB()
- throws Exception
- {
+ @Test
+ public void testFunctionNumber_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.00</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
String sXPath = "number(//price/text())+10";
@@ -173,12 +142,10 @@ public class XPathFunctionAuxTest
m_xc.selectPath(fixPath(sXPath));
m_xc.toNextSelection();
assertEquals(sExpected, m_xc.xmlText());
-
}
- public void testFunctionRound_caseB()
- throws Exception
- {
+ @Test
+ public void testFunctionRound_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.15</price><price at=\"val1\">2.87</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
@@ -191,10 +158,8 @@ public class XPathFunctionAuxTest
assertEquals(sExpected, m_xc.xmlText());
}
- public void testFunctionSum_caseB()
- throws Exception
- {
-
+ @Test
+ public void testFunctionSum_caseB() throws Exception {
String sXml = "<foo><bar><price at=\"val0\">3.00</price><price at=\"val1\">2</price></bar><bar1>3.00</bar1></foo>";
m_xc = XmlObject.Factory.parse(sXml).newCursor();
@@ -204,11 +169,9 @@ public class XPathFunctionAuxTest
m_xc.toNextSelection();
assertEquals(sExpected, m_xc.xmlText());
}
-//
- public void testFunctionBoolean_caseB_delete()
- throws Exception
- {
+ @Test
+ public void testFunctionBoolean_caseB_delete() throws Exception {
String sXml = "<foo><bar>" +
"<price at=\"val0\">3.00</price>" +
"<price at=\"val1\">2</price>" +
@@ -231,9 +194,8 @@ public class XPathFunctionAuxTest
// System.out.println("HERE " + m_xc.xmlText());
}
- public void testFunctionBoolean_caseB()
- throws Exception
- {
+ @Test
+ public void testFunctionBoolean_caseB() throws Exception {
String sXml = "<foo><bar>" +
"<price at=\"val0\">3.00</price>" +
"<price at=\"val1\">2</price>" +
@@ -278,20 +240,17 @@ public class XPathFunctionAuxTest
m_xc.toNextSelection();
assertEquals(Common.wrapInXmlFrag("false"), m_xc.xmlText());
m_xc.clearSelections();
-
}
- public void testFunctionFalse_caseB()
- throws Exception
- {
+ @Test
+ public void testFunctionFalse_caseB() throws Exception {
m_xc =
XmlObject.Factory.parse(
"<foo><price at=\"val0\">3.00</price></foo>")
- .newCursor();
+ .newCursor();
m_xc.selectPath("name(//*[boolean(text())=false()])");
String sExpected = Common.wrapInXmlFrag("foo");
m_xc.toNextSelection();
assertEquals(sExpected, m_xc.xmlText());
-
}
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathFunctionTestImpl.java Fri Jan 18 23:08:44 2019
@@ -15,21 +15,22 @@
package xmlcursor.xpath.complex.detailed;
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Before;
+import org.junit.Test;
import xmlcursor.xpath.common.XPathFunctionTest;
-import org.apache.xmlbeans.XmlObject;
+import static org.junit.Assert.*;
/**
* Queries here overwrite whatever is loaded in the query map if
* the syntax is different
*/
-public class XPathFunctionTestImpl
- extends XPathFunctionTest
-{
- public XPathFunctionTestImpl(String name)
- {
- super(name);
+public class XPathFunctionTestImpl extends XPathFunctionTest {
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
testMap.put("testFunctionCount", new String[]{
"count(//cd)",
@@ -73,49 +74,32 @@ public class XPathFunctionTestImpl
"//*[boolean(@at)=true()]"});
}
- public String getQuery(String testName, int testCase)
- throws IllegalArgumentException
- {
- Object queries;
-
- if ((queries = testMap.get(testName)) == null)
- throw new IllegalArgumentException("No queries for test" +
- testName);
- else if (((String[]) queries).length <= testCase)
- throw new IllegalArgumentException("No query " + testCase +
- " for test" + testName);
- else
- return ((String[]) queries)[testCase];
- }
-
- public void testErrorMessages()
- throws Exception
- {
+ public String getQuery(String testName, int testCase) throws IllegalArgumentException {
+ String[] queries = testMap.get(testName);
+ assertNotNull("No queries for test" + testName, queries);
+ assertFalse("No query " + testCase + " for test" + testName, queries.length <= testCase);
+ return queries[testCase];
+ }
+
+ @Test
+ public void testErrorMessages() throws Exception {
//do nothing for Jaxen
}
//ensure Jaxen is not in the classpath
- public void testAntiJaxenTest()
- {
- try
- {
- m_xc.selectPath("//*");
- fail("XQRL shouldn't handle absolute paths");
- }
- catch (Throwable t)
- {
- }
- }
-
- public void testExternalVariable()
- throws Exception
- {
+ @Test(expected = Throwable.class)
+ public void testAntiJaxenTest() {
+ // XQRL shouldn't handle absolute paths
+ m_xc.selectPath("//*");
+ }
+
+ @Test
+ public void testExternalVariable() throws Exception {
}
- public void testExternalFunction()
- throws Exception
- {
+ @Test
+ public void testExternalFunction() throws Exception {
String query = "" +
"declare function local:toc($book-or-section as element()) as element()*;" +
" local:toc($book-or-section/section)";
@@ -173,5 +157,4 @@ public class XPathFunctionTestImpl
assertEquals(1, res.length);
assertEquals("", res[0].xmlText());
}
-
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathNodeTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathNodeTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathNodeTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathNodeTest.java Fri Jan 18 23:08:44 2019
@@ -14,23 +14,20 @@
*/
package xmlcursor.xpath.complex.detailed;
-import javax.xml.namespace.QName;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
-import junit.framework.TestCase;
+import org.junit.Test;
import xmlcursor.common.Common;
-/**
- *
- */
-public class XPathNodeTest
- extends TestCase
-{
- public void testNodeEquality()
- throws Exception
- {
- XmlCursor c = XmlObject.Factory.parse("<root>" +
- "<book isbn='012345' id='09876'/></root>")
+import javax.xml.namespace.QName;
+
+import static org.junit.Assert.assertEquals;
+
+public class XPathNodeTest {
+ @Test
+ public void testNodeEquality() throws Exception {
+ XmlCursor c = XmlObject.Factory.parse(
+ "<root><book isbn='012345' id='09876'/></root>")
.newCursor();
c.selectPath("//book[@isbn='012345'] is //book[@id='09876']");
assertEquals(1, c.getSelectionCount());
@@ -38,11 +35,10 @@ public class XPathNodeTest
assertEquals(Common.wrapInXmlFrag("true"), c.xmlText());
}
- public void testNodeOrder()
- throws Exception
- {
- XmlCursor c = XmlObject.Factory.parse("<root>" +
- "<book isbn='012345'/><book id='09876'/></root>")
+ @Test
+ public void testNodeOrder() throws Exception {
+ XmlCursor c = XmlObject.Factory.parse(
+ "<root><book isbn='012345'/><book id='09876'/></root>")
.newCursor();
c.selectPath("//book[@isbn='012345'] << //book[@id='09876']");
assertEquals(1, c.getSelectionCount());
@@ -55,9 +51,8 @@ public class XPathNodeTest
assertEquals(Common.wrapInXmlFrag("false"), c.xmlText());
}
- public void testParent()
- throws Exception
- {
+ @Test
+ public void testParent() throws Exception {
String input = "<A><B><C></C></B></A>";
XmlObject o;
XmlCursor c = XmlObject.Factory.parse(input).newCursor();
@@ -71,10 +66,9 @@ public class XPathNodeTest
assertEquals("<B><C/></B>", res[0].newCursor().xmlText());
}
- public void testParent1()
- throws Exception
- {
- String input =
+ @Test
+ public void testParent1() throws Exception {
+ String input =
"<AttributeCertificate " +
"xmlns=\"http://www.eurecom.fr/security/xac#\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
@@ -99,5 +93,4 @@ public class XPathNodeTest
assertEquals("http://www.eurecom.fr/security/xac#", qn.getNamespaceURI());
assertEquals("Content", qn.getLocalPart());
}
-
}
Modified: xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xpath/complex/detailed/XPathTest.java Fri Jan 18 23:08:44 2019
@@ -15,20 +15,12 @@
package xmlcursor.xpath.complex.detailed;
-import xmlcursor.common.BasicCursorTestCase;
-import xmlcursor.common.Common;
-import xmlcursor.xpath.common.XPathCommon;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.Assert;
-import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.junit.Test;
import tools.util.JarUtil;
-import tools.xml.XmlComparator;
-
-import java.io.IOException;
+import xmlcursor.common.BasicCursorTestCase;
+import xmlcursor.xpath.common.XPathCommon;
/**
* Verifies XPath impl using examples from
@@ -36,18 +28,7 @@ import java.io.IOException;
* includes expanded notations as well
*
*/
-public class XPathTest
- extends BasicCursorTestCase
-{
- public XPathTest(String sName)
- {
- super(sName);
- }
-
- public static Test suite()
- {
- return new TestSuite(XPathTest.class);
- }
+public class XPathTest extends BasicCursorTestCase {
static String fixPath(String path)
{
@@ -55,13 +36,8 @@ public class XPathTest
return path;
}
-
- /**
- * @throws Exception
- */
- public void testZvonExample1()
- throws Exception
- {
+ @Test
+ public void testZvonExample1() throws Exception {
System.out.println("====== Example-1 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon1.xml"));
@@ -109,12 +85,8 @@ public class XPathTest
x3.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample2()
- throws Exception
- {
+ @Test
+ public void testZvonExample2() throws Exception {
System.out.println("====== Example-2 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
@@ -147,15 +119,10 @@ public class XPathTest
x2.selectPath(fixPath(ex2Simple));
XPathCommon.compare(x2, exXml2);
x2.dispose();
-
}
- /**
- * @throws Exception
- */
- public void testZvonExample3()
- throws Exception
- {
+ @Test
+ public void testZvonExample3() throws Exception {
System.out.println("====== Example-3 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon3.xml"));
@@ -259,12 +226,8 @@ public class XPathTest
}
- /**
- * @throws Exception
- */
- public void testZvonExample4()
- throws Exception
- {
+ @Test
+ public void testZvonExample4() throws Exception {
System.out.println("====== Example-4 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon4.xml"));
@@ -288,15 +251,10 @@ public class XPathTest
//XPathCommon.display(x2);
XPathCommon.compare(x2, exXml);
x2.dispose();
-
}
- /**
- * @throws Exception
- */
- public void testZvonExample5()
- throws Exception
- {
+ @Test
+ public void testZvonExample5() throws Exception {
System.out.println("====== Example-5 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon5.xml"));
@@ -364,12 +322,8 @@ public class XPathTest
x5.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample6()
- throws Exception
- {
+ @Test
+ public void testZvonExample6() throws Exception {
System.out.println("====== Example-16 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon6.xml"));
@@ -410,12 +364,8 @@ public class XPathTest
x3.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample7()
- throws Exception
- {
+ @Test
+ public void testZvonExample7() throws Exception {
System.out.println("====== Example-7 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon7.xml"));
@@ -456,12 +406,8 @@ public class XPathTest
x3.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample8()
- throws Exception
- {
+ @Test
+ public void testZvonExample8() throws Exception {
System.out.println("====== Example-8 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon8.xml"));
@@ -524,12 +470,8 @@ public class XPathTest
x3.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample9()
- throws Exception
- {
+ @Test
+ public void testZvonExample9() throws Exception {
System.out.println("====== Example-9 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon9.xml"));
@@ -570,12 +512,8 @@ public class XPathTest
x3.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample10()
- throws Exception
- {
+ @Test
+ public void testZvonExample10() throws Exception {
System.out.println("====== Example-10 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon10.xml"));
@@ -628,12 +566,8 @@ public class XPathTest
x3.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample11()
- throws Exception
- {
+ @Test
+ public void testZvonExample11() throws Exception {
System.out.println("====== Example-11 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon11.xml"));
@@ -693,12 +627,8 @@ public class XPathTest
x5.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample12()
- throws Exception
- {
+ @Test
+ public void testZvonExample12() throws Exception {
System.out.println("====== Example-12 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon12.xml"));
@@ -779,12 +709,8 @@ public class XPathTest
x4.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample13()
- throws Exception
- {
+ @Test
+ public void testZvonExample13() throws Exception {
System.out.println("====== Example-13 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon13.xml"));
@@ -808,12 +734,8 @@ public class XPathTest
x1.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample14()
- throws Exception
- {
+ @Test
+ public void testZvonExample14() throws Exception {
System.out.println("====== Example-14 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon14.xml"));
@@ -855,12 +777,8 @@ public class XPathTest
}
- /**
- * @throws Exception
- */
- public void testZvonExample15()
- throws Exception
- {
+ @Test
+ public void testZvonExample15() throws Exception {
System.out.println("====== Example-15 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon15.xml"));
@@ -892,12 +810,8 @@ public class XPathTest
}
- /**
- * @throws Exception
- */
- public void testZvonExample16()
- throws Exception
- {
+ @Test
+ public void testZvonExample16() throws Exception {
System.out.println("====== Example-16 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon16.xml"));
@@ -929,12 +843,8 @@ public class XPathTest
}
- /**
- * @throws Exception
- */
- public void testZvonExample17()
- throws Exception
- {
+ @Test
+ public void testZvonExample17() throws Exception {
System.out.println("====== Example-17 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon17.xml"));
@@ -979,12 +889,9 @@ public class XPathTest
* the preceding axis contains all nodes that are descendants of the root
* of the tree in which the context node is found, are not ancestors of
* the context node, and occur before the context node in document order
- *
- * @throws Exception
*/
- public void testZvonExample18()
- throws Exception
- {
+ @Test
+ public void testZvonExample18() throws Exception {
System.out.println("====== Example-18 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon18.xml"));
@@ -1035,12 +942,8 @@ public class XPathTest
}
- /**
- * @throws Exception
- */
- public void testZvonExample19()
- throws Exception
- {
+ @Test
+ public void testZvonExample19() throws Exception {
System.out.println("====== Example-19 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon19.xml"));
@@ -1083,12 +986,8 @@ public class XPathTest
}
- /**
- * @throws Exception
- */
- public void testZvonExample20()
- throws Exception
- {
+ @Test
+ public void testZvonExample20() throws Exception {
System.out.println("====== Example-20 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon20.xml"));
@@ -1132,12 +1031,8 @@ public class XPathTest
}
- /**
- * @throws Exception
- */
- public void testZvonExample21()
- throws Exception
- {
+ @Test
+ public void testZvonExample21() throws Exception {
System.out.println("====== Example-21 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon21.xml"));
@@ -1257,12 +1152,8 @@ public class XPathTest
x6.dispose();
}
- /**
- * @throws Exception
- */
- public void testZvonExample22()
- throws Exception
- {
+ @Test
+ public void testZvonExample22() throws Exception {
System.out.println("====== Example-22 ==========");
XmlObject xDoc = XmlObject.Factory.parse(
JarUtil.getResourceFromJar("xbean/xmlcursor/xpath/zvon22.xml"));
@@ -1301,25 +1192,4 @@ public class XPathTest
XPathCommon.compare(x3, ex3Xml);
x3.dispose();
}
-
-
- /* public static void main(String[] rgs)
- {
- try
- {
- new XPathTest("").testZvonExample21();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- */
-// public void testZvonExample() throws Exception {
-// XmlObject xDoc = XmlObject.Factory.parse(JarUtil.getResourceFromJar(Common.XMLCASES_JAR,
-// "xbean/xmlcursor/xpath/zvon.xml"));
-// XmlCursor xc = xDoc.newCursor();
-// }
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org