|
40 | 40 | import java.util.concurrent.Executors; |
41 | 41 | import java.util.concurrent.TimeUnit; |
42 | 42 | 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; |
43 | 46 | import org.apache.commons.lang3.StringUtils; |
44 | 47 | import org.cactoos.io.TeeInput; |
45 | 48 | import org.cactoos.scalar.LengthOf; |
46 | 49 | import org.hamcrest.MatcherAssert; |
47 | 50 | import org.hamcrest.Matchers; |
48 | 51 | import org.hamcrest.core.IsEqual; |
| 52 | +import org.junit.jupiter.api.Assertions; |
49 | 53 | import org.junit.jupiter.api.Test; |
50 | 54 | import org.w3c.dom.Document; |
51 | 55 | import org.w3c.dom.Element; |
@@ -411,13 +415,18 @@ void appliesXpathToClonedNode() { |
411 | 415 |
|
412 | 416 | @Test |
413 | 417 | 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 | + ); |
414 | 426 | 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") |
420 | 430 | ); |
421 | 431 | } |
422 | | - |
423 | 432 | } |
0 commit comments