use of org.apache.commons.io.input.UnsynchronizedByteArrayInputStream in project exist by eXist-db.
the class MemtreeTest method getParentNodeFor.
@Test
public void getParentNodeFor() throws IOException, ParserConfigurationException, SAXException {
final DocumentImpl doc;
try (final InputStream is = new UnsynchronizedByteArrayInputStream(XML.getBytes(UTF_8))) {
doc = parse(is);
}
// parent of the document node
assertEquals(-1, doc.getParentNodeFor(0));
// parent of <!-- comment before doc 1 -->
assertEquals(0, doc.getParentNodeFor(1));
// parent of <?pi-before-doc-1?>
assertEquals(0, doc.getParentNodeFor(2));
// parent of <!-- comment before doc 2 -->
assertEquals(0, doc.getParentNodeFor(3));
// parent of <?pi-before-doc-2?>
assertEquals(0, doc.getParentNodeFor(4));
// parent of doc-element
assertEquals(0, doc.getParentNodeFor(5));
// parent of doc-element/text()[1]
assertEquals(5, doc.getParentNodeFor(6));
// parent of <!-- comment before e1 -->
assertEquals(5, doc.getParentNodeFor(7));
// parent of doc-element/text()[2]
assertEquals(5, doc.getParentNodeFor(8));
// parent of e1
assertEquals(5, doc.getParentNodeFor(9));
// parent of e1/text()[1]
assertEquals(9, doc.getParentNodeFor(10));
// parent of <?pi-before-e1_1?>
assertEquals(9, doc.getParentNodeFor(11));
// parent of e1/text()[2]
assertEquals(9, doc.getParentNodeFor(12));
// parent of e1_1
assertEquals(9, doc.getParentNodeFor(13));
// parent of e1_1/text()[1]
assertEquals(13, doc.getParentNodeFor(14));
// parent of e1/text()[3]
assertEquals(9, doc.getParentNodeFor(15));
// parent of e1_2
assertEquals(9, doc.getParentNodeFor(16));
// parent of e1_2/text()[1]
assertEquals(16, doc.getParentNodeFor(17));
// parent of e1/text()[4]
assertEquals(9, doc.getParentNodeFor(18));
// parent of doc-element/text()[3]
assertEquals(5, doc.getParentNodeFor(19));
// parent of <!-- comment after e1 -->
assertEquals(5, doc.getParentNodeFor(20));
// parent of doc-element/text()[4]
assertEquals(5, doc.getParentNodeFor(21));
// parent of <?pi-after-doc-1?>
assertEquals(0, doc.getParentNodeFor(22));
// parent of <!-- comment after doc 1 -->
assertEquals(0, doc.getParentNodeFor(23));
// parent of <?pi-after-doc-2?>
assertEquals(0, doc.getParentNodeFor(24));
// <!-- comment after doc 2 -->
assertEquals(0, doc.getParentNodeFor(25));
// <?pi-after-doc-3?>
assertEquals(0, doc.getParentNodeFor(26));
}
use of org.apache.commons.io.input.UnsynchronizedByteArrayInputStream in project exist by eXist-db.
the class MemtreeTest method hasChildNodes.
@Test
public void hasChildNodes() throws IOException, ParserConfigurationException, SAXException {
final DocumentImpl doc;
try (final InputStream is = new UnsynchronizedByteArrayInputStream(XML.getBytes(UTF_8))) {
doc = parse(is);
}
assertTrue(doc.hasChildNodes());
}
use of org.apache.commons.io.input.UnsynchronizedByteArrayInputStream in project exist by eXist-db.
the class MemtreeTest method getChildCountFor.
@Test
public void getChildCountFor() throws IOException, ParserConfigurationException, SAXException {
final DocumentImpl doc;
try (final InputStream is = new UnsynchronizedByteArrayInputStream(XML.getBytes(UTF_8))) {
doc = parse(is);
}
// children of the document node
assertEquals(10, doc.getChildCountFor(0));
// children of <!-- comment before doc 1 -->
assertEquals(0, doc.getChildCountFor(1));
// children of <?pi-before-doc-1?>
assertEquals(0, doc.getChildCountFor(2));
// children of <!-- comment before doc 2 -->
assertEquals(0, doc.getChildCountFor(3));
// children of <?pi-before-doc-2?>
assertEquals(0, doc.getChildCountFor(4));
// children of doc-element
assertEquals(7, doc.getChildCountFor(5));
// children of doc-element/text()[1]
assertEquals(0, doc.getChildCountFor(6));
// children of <!-- comment before e1 -->
assertEquals(0, doc.getChildCountFor(7));
// children of doc-element/text()[2]
assertEquals(0, doc.getChildCountFor(8));
// children of e1
assertEquals(7, doc.getChildCountFor(9));
// children of e1/text()[1]
assertEquals(0, doc.getChildCountFor(10));
// children of <?pi-before-e1_1?>
assertEquals(0, doc.getChildCountFor(11));
// children of e1/text()[2]
assertEquals(0, doc.getChildCountFor(12));
// children of e1_1
assertEquals(1, doc.getChildCountFor(13));
// children of e1_1/text()[1]
assertEquals(0, doc.getChildCountFor(14));
// children of e1/text()[3]
assertEquals(0, doc.getChildCountFor(15));
// children of e1_2
assertEquals(1, doc.getChildCountFor(16));
// children of e1_2/text()[1]
assertEquals(0, doc.getChildCountFor(17));
// children of e1/text()[4]
assertEquals(0, doc.getChildCountFor(18));
// children of doc-element/text()[3]
assertEquals(0, doc.getChildCountFor(19));
// children of <!-- comment after e1 -->
assertEquals(0, doc.getChildCountFor(20));
// children of doc-element/text()[4]
assertEquals(0, doc.getChildCountFor(21));
// children of <?pi-after-doc-1?>
assertEquals(0, doc.getChildCountFor(22));
// children of <!-- comment after doc 1 -->
assertEquals(0, doc.getChildCountFor(23));
// children of <?pi-after-doc-2?>
assertEquals(0, doc.getChildCountFor(24));
// children of <!-- comment after doc 2 -->
assertEquals(0, doc.getChildCountFor(25));
// children of <?pi-after-doc-3?>
assertEquals(0, doc.getChildCountFor(26));
}
use of org.apache.commons.io.input.UnsynchronizedByteArrayInputStream in project exist by eXist-db.
the class MemtreeTest method size.
@Test
public void size() throws IOException, ParserConfigurationException, SAXException {
final DocumentImpl doc;
try (final InputStream is = new UnsynchronizedByteArrayInputStream(XML.getBytes(UTF_8))) {
doc = parse(is);
}
assertEquals(27, doc.getSize());
}
use of org.apache.commons.io.input.UnsynchronizedByteArrayInputStream in project exist by eXist-db.
the class MemtreeTest method getNamespacesCountFor.
@Test
public void getNamespacesCountFor() throws IOException, ParserConfigurationException, SAXException {
final DocumentImpl doc;
try (final InputStream is = new UnsynchronizedByteArrayInputStream(XML.getBytes(UTF_8))) {
doc = parse(is);
}
// namespaces count of the document node
assertEquals(0, doc.getNamespacesCountFor(0));
// namespaces count of <!-- comment before doc 1 -->
assertEquals(0, doc.getNamespacesCountFor(1));
// namespaces count of <?pi-before-doc-1?>
assertEquals(0, doc.getNamespacesCountFor(2));
// namespaces count of <!-- comment before doc 2 -->
assertEquals(0, doc.getNamespacesCountFor(3));
// namespaces count of <?pi-before-doc-2?>
assertEquals(0, doc.getNamespacesCountFor(4));
// namespaces count of doc-element
assertEquals(0, doc.getNamespacesCountFor(5));
// namespaces count of doc-element/text()[1]
assertEquals(0, doc.getNamespacesCountFor(6));
// namespaces count of <!-- comment before e1 -->
assertEquals(0, doc.getNamespacesCountFor(7));
// namespaces count of doc-element/text()[2]
assertEquals(0, doc.getNamespacesCountFor(8));
// namespaces count of e1
assertEquals(0, doc.getNamespacesCountFor(9));
// namespaces count of e1/text()[1]
assertEquals(0, doc.getNamespacesCountFor(10));
// namespaces count of <?pi-before-e1_1?>
assertEquals(0, doc.getNamespacesCountFor(11));
// namespaces count of e1/text()[2]
assertEquals(0, doc.getNamespacesCountFor(12));
// namespaces count of e1_1
assertEquals(0, doc.getNamespacesCountFor(13));
// namespaces count of e1_1/text()[1]
assertEquals(0, doc.getNamespacesCountFor(14));
// namespaces count of e1/text()[3]
assertEquals(0, doc.getNamespacesCountFor(15));
// namespaces count of e1_2
assertEquals(0, doc.getNamespacesCountFor(16));
// namespaces count of e1_2/text()[1]
assertEquals(0, doc.getNamespacesCountFor(17));
// namespaces count of e1/text()[4]
assertEquals(0, doc.getNamespacesCountFor(18));
// namespaces count of doc-element/text()[3]
assertEquals(0, doc.getNamespacesCountFor(19));
// namespaces count of <!-- comment after e1 -->
assertEquals(0, doc.getNamespacesCountFor(20));
// namespaces count of doc-element/text()[4]
assertEquals(0, doc.getNamespacesCountFor(21));
// namespaces count of <?pi-after-doc-1?>
assertEquals(0, doc.getNamespacesCountFor(22));
// namespaces count of <!-- comment after doc 1 -->
assertEquals(0, doc.getNamespacesCountFor(23));
// namespaces count of <?pi-after-doc-2?>
assertEquals(0, doc.getNamespacesCountFor(24));
// namespaces count of <!-- comment after doc 2 -->
assertEquals(0, doc.getNamespacesCountFor(25));
// namespaces count of <?pi-after-doc-3?>
assertEquals(0, doc.getNamespacesCountFor(26));
}
Aggregations