Package org.shredzone.commons.xml
Class XQueryTest
- java.lang.Object
-
- org.shredzone.commons.xml.XQueryTest
-
public class XQueryTest extends Object
Unit tests forXQuery
.- Author:
- Richard "Shred" Körber
-
-
Constructor Summary
Constructors Constructor Description XQueryTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allValueTest()
DoesXQuery.allValue(String)
return the text contents of the matching elements, recursively?void
attrEmptyTest()
DoesXQuery.attr()
return an empty map of attributes when there are none?void
attrManyTest()
DoesXQuery.attr()
return a map of multiple attributes?void
attrTest()
DoesXQuery.attr()
return a map of attributes?void
cdataTest()
Are CDATA elements read as text?void
existsTest()
DoesXQuery.exists(String)
return a correct answer.void
getMultipleFailTest()
DoesXQuery.get(String)
throw an exception if multiple elements are found?void
getNoneFailTest()
DoesXQuery.get(String)
throw an exception if there is no such element?void
getTest()
DoesXQuery.get(String)
return a single element?void
init()
Sets up a newXQuery
instance.void
noCommentTest()
Are comments ignored?void
parentOfRootTest()
DoesXQuery.parent()
return empty on root?void
parentTest()
DoesXQuery.parent()
return the correct parent node?void
parserFailTest()
Test parser error on bad XML.void
parserReaderTest()
TestReader
based parser.void
parserStringTest()
TestString
based parser.void
rootOfRootTest()
DoesXQuery.parent()
return empty on root?void
rootTest()
DoesXQuery.parent()
return the correct parent node?void
selectFailTest()
DoesXQuery.select(String)
fail on bad XPath?void
selectTest()
DoesXQuery.select(String)
return the correct elements? DoesXQuery.text()
return the text content?void
siblingTest()
DoesXQuery.previousSibling()
andXQuery.nextSibling()
return the correct siblings?void
streamTest()
Does theXQuery.stream()
of the rootXQuery
return the root element?void
subStreamTest()
Does theXQuery.stream()
of a subelement return the child elements of that element?void
value3Test()
DoesXQuery.select(String)
andXQuery.allText()
return the text contents of the entire subtree?void
valueNonRecursiveTest()
IsXQuery.value(String)
non-recursive, i.e.void
valueTest()
DoesXQuery.value(String)
return the text contents of the matching elements?
-
-
-
Constructor Detail
-
XQueryTest
public XQueryTest()
-
-
Method Detail
-
init
public void init() throws IOException
Sets up a newXQuery
instance.- Throws:
IOException
-
parserReaderTest
public void parserReaderTest() throws IOException
TestReader
based parser.- Throws:
IOException
-
parserStringTest
public void parserStringTest() throws IOException
TestString
based parser.- Throws:
IOException
-
parserFailTest
public void parserFailTest() throws IOException
Test parser error on bad XML.- Throws:
IOException
-
streamTest
public void streamTest() throws IOException
Does theXQuery.stream()
of the rootXQuery
return the root element?- Throws:
IOException
-
subStreamTest
public void subStreamTest() throws IOException
Does theXQuery.stream()
of a subelement return the child elements of that element?- Throws:
IOException
-
selectTest
public void selectTest() throws IOException
DoesXQuery.select(String)
return the correct elements? DoesXQuery.text()
return the text content?- Throws:
IOException
-
getTest
public void getTest() throws IOException
DoesXQuery.get(String)
return a single element?- Throws:
IOException
-
getNoneFailTest
public void getNoneFailTest() throws IOException
DoesXQuery.get(String)
throw an exception if there is no such element?- Throws:
IOException
-
getMultipleFailTest
public void getMultipleFailTest() throws IOException
DoesXQuery.get(String)
throw an exception if multiple elements are found?- Throws:
IOException
-
siblingTest
public void siblingTest() throws IOException
DoesXQuery.previousSibling()
andXQuery.nextSibling()
return the correct siblings?- Throws:
IOException
-
existsTest
public void existsTest() throws IOException
DoesXQuery.exists(String)
return a correct answer.- Throws:
IOException
-
selectFailTest
public void selectFailTest() throws IOException
DoesXQuery.select(String)
fail on bad XPath?- Throws:
IOException
-
valueTest
public void valueTest() throws IOException
DoesXQuery.value(String)
return the text contents of the matching elements?- Throws:
IOException
-
allValueTest
public void allValueTest() throws IOException
DoesXQuery.allValue(String)
return the text contents of the matching elements, recursively?- Throws:
IOException
-
valueNonRecursiveTest
public void valueNonRecursiveTest() throws IOException
IsXQuery.value(String)
non-recursive, i.e. does it only return the text of the immediate children?- Throws:
IOException
-
value3Test
public void value3Test() throws IOException
DoesXQuery.select(String)
andXQuery.allText()
return the text contents of the entire subtree?- Throws:
IOException
-
attrTest
public void attrTest() throws IOException
DoesXQuery.attr()
return a map of attributes?- Throws:
IOException
-
attrManyTest
public void attrManyTest() throws IOException
DoesXQuery.attr()
return a map of multiple attributes?- Throws:
IOException
-
attrEmptyTest
public void attrEmptyTest() throws IOException
DoesXQuery.attr()
return an empty map of attributes when there are none?- Throws:
IOException
-
noCommentTest
public void noCommentTest() throws IOException
Are comments ignored?- Throws:
IOException
-
cdataTest
public void cdataTest() throws IOException
Are CDATA elements read as text?- Throws:
IOException
-
parentTest
public void parentTest() throws IOException
DoesXQuery.parent()
return the correct parent node?- Throws:
IOException
-
parentOfRootTest
public void parentOfRootTest() throws IOException
DoesXQuery.parent()
return empty on root?- Throws:
IOException
-
rootTest
public void rootTest() throws IOException
DoesXQuery.parent()
return the correct parent node?- Throws:
IOException
-
rootOfRootTest
public void rootOfRootTest() throws IOException
DoesXQuery.parent()
return empty on root?- Throws:
IOException
-
-