Skip to content

Commit 6c4933e

Browse files
feat(#211): show that XPath 2.0 features unavailable
1 parent a153d19 commit 6c4933e

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/test/java/com/jcabi/xml/XMLDocumentTest.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@
4040
import java.util.concurrent.Executors;
4141
import java.util.concurrent.TimeUnit;
4242
import java.util.concurrent.atomic.AtomicInteger;
43+
import javax.xml.transform.TransformerException;
44+
import javax.xml.xpath.XPathExpressionException;
45+
import net.sf.saxon.lib.NamespaceConstant;
4346
import org.apache.commons.lang3.StringUtils;
4447
import org.cactoos.io.TeeInput;
4548
import org.cactoos.scalar.LengthOf;
4649
import org.hamcrest.MatcherAssert;
4750
import org.hamcrest.Matchers;
4851
import org.hamcrest.core.IsEqual;
52+
import org.junit.jupiter.api.Assertions;
4953
import org.junit.jupiter.api.Test;
5054
import org.w3c.dom.Document;
5155
import org.w3c.dom.Element;
@@ -411,13 +415,18 @@ void appliesXpathToClonedNode() {
411415

412416
@Test
413417
void findsXpathWithFunctionThatReturnsSeveralItems() {
418+
final IllegalArgumentException exception = Assertions.assertThrows(
419+
IllegalArgumentException.class,
420+
() ->
421+
new XMLDocument(
422+
"<o><o base='a' ver='1'/><o base='b' ver='2'/></o>"
423+
).xpath("//o[@base and @ver]/concat(@base,'|',@ver)"),
424+
"XMLDocument throws exception if we are trying to use XPath 2.0 functionality. The current implementation supports only XPath 1.0."
425+
);
414426
MatcherAssert.assertThat(
415-
"Can't find xpath with function that returns several items",
416-
new XMLDocument(
417-
"<o><o base='a' ver='1'/><o base='b' ver='2'/></o>")
418-
.xpath("//o[@base and @ver]/concat(@base,'|',@ver)"),
419-
Matchers.hasItems("a|1", "b|2")
427+
"Message should emphasize that XPath 2.0 features are not supported",
428+
exception.getCause().getMessage(),
429+
Matchers.equalTo("javax.xml.transform.TransformerException: Unknown nodetype: concat")
420430
);
421431
}
422-
423432
}

0 commit comments

Comments
 (0)