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 voidallValueTest()DoesXQuery.allValue(String)return the text contents of the matching elements, recursively?voidattrEmptyTest()DoesXQuery.attr()return an empty map of attributes when there are none?voidattrManyTest()DoesXQuery.attr()return a map of multiple attributes?voidattrTest()DoesXQuery.attr()return a map of attributes?voidcdataTest()Are CDATA elements read as text?voidexistsTest()DoesXQuery.exists(String)return a correct answer.voidgetMultipleFailTest()DoesXQuery.get(String)throw an exception if multiple elements are found?voidgetNoneFailTest()DoesXQuery.get(String)throw an exception if there is no such element?voidgetTest()DoesXQuery.get(String)return a single element?voidinit()Sets up a newXQueryinstance.voidnoCommentTest()Are comments ignored?voidparentOfRootTest()DoesXQuery.parent()return empty on root?voidparentTest()DoesXQuery.parent()return the correct parent node?voidparserFailTest()Test parser error on bad XML.voidparserReaderTest()TestReaderbased parser.voidparserStringTest()TestStringbased parser.voidrootOfRootTest()DoesXQuery.parent()return empty on root?voidrootTest()DoesXQuery.parent()return the correct parent node?voidselectFailTest()DoesXQuery.select(String)fail on bad XPath?voidselectTest()DoesXQuery.select(String)return the correct elements? DoesXQuery.text()return the text content?voidsiblingTest()DoesXQuery.previousSibling()andXQuery.nextSibling()return the correct siblings?voidstreamTest()Does theXQuery.stream()of the rootXQueryreturn the root element?voidsubStreamTest()Does theXQuery.stream()of a subelement return the child elements of that element?voidvalue3Test()DoesXQuery.select(String)andXQuery.allText()return the text contents of the entire subtree?voidvalueNonRecursiveTest()IsXQuery.value(String)non-recursive, i.e.voidvalueTest()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 newXQueryinstance.- Throws:
IOException
-
parserReaderTest
public void parserReaderTest() throws IOException
TestReaderbased parser.- Throws:
IOException
-
parserStringTest
public void parserStringTest() throws IOException
TestStringbased 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 rootXQueryreturn 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
-
-