Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A subsequent query on an XPath result doesn't work #148

Open
Glusk opened this issue Jul 20, 2018 · 2 comments
Open

A subsequent query on an XPath result doesn't work #148

Glusk opened this issue Jul 20, 2018 · 2 comments

Comments

@Glusk
Copy link

Glusk commented Jul 20, 2018

I've run into a problem working with the library. I'm not entirely sure what's wrong, but this test (minimized in this commit) fails. Code in question:

@Test
public void bug() throws Exception {
    final XML xml = new XMLDocument(
        "<r><p a='1'/><p a='2'/></r>"
    );
    MatcherAssert.assertThat(
        xml.nodes("//p")
           .get(1)
           .xpath("//p/@a")
           .get(0),
        Matchers.equalTo("2")
    );
}

produces this error:

java.lang.AssertionError: 

Expected: "2"
     but: was "1"
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
	at com.jcabi.xml.XMLDocumentTest.bug(XMLDocumentTest.java:472)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:393)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

May be related to: #62

@0crat
Copy link

0crat commented Jul 20, 2018

@yegor256/z please, pay attention to this issue

@0crat
Copy link

0crat commented Jul 20, 2018

@glusk2/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!

Glusk added a commit to Glusk/jcabi-xml that referenced this issue Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants