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

XmlUnit 2.6.[3,4] is not compatible with AssertJ-Core 3.15.0 #181

Closed
jwalter opened this issue Apr 28, 2020 · 7 comments
Closed

XmlUnit 2.6.[3,4] is not compatible with AssertJ-Core 3.15.0 #181

jwalter opened this issue Apr 28, 2020 · 7 comments
Labels
AssertJ Support the xmlunit-assertj module
Milestone

Comments

@jwalter
Copy link

jwalter commented Apr 28, 2020

The following test:

@Test
  fun `assertThatXml_valueByXPath should work`() {
    val xml = """
      <fruit>
        <color>yellow</color>
      </fruit>
    """
    assertThatXml(xml).valueByXPath("//color").isEqualTo("yellow")
  }

will throw an error when trying to run with assertj 3.15.0 on the classpath:

java.lang.NoSuchMethodError: org.xmlunit.assertj.ValueAssert.describedAs(Ljava/lang/String;[Ljava/lang/Object;)Lorg/assertj/core/api/AbstractAssert;

	at org.xmlunit.assertj.ValueAssert.create(ValueAssert.java:68)
	at org.xmlunit.assertj.XmlAssert.valueByXPath(XmlAssert.java:202)

The cause is that assertj 3.15.0 moved the `describedAs´method from AbstractAssert to Descriptable and due to type erasure the method return type changed on the byte code level from AbstractAssert to Object.

This currently affects all Spring Boot projects using the milestone M2, M3 or M4 builds of Spring Boot 2.3.0.

@bodewig
Copy link
Member

bodewig commented Apr 28, 2020

I'm not an AssertJ user myself. I wonder whether the AssertJ devs realize they are breaking binary compatibility repeatedly and make people who provide custom assertions unhappy. This is not the first time, see #135 and #166

I'll try to see whether there is a way to adapt without breaking support for older versions - unless @krystiankaluzny beats me to it.

@bodewig bodewig added the AssertJ Support the xmlunit-assertj module label Apr 28, 2020
@bodewig bodewig added this to the 2.6.5 milestone May 4, 2020
@bodewig bodewig closed this as completed in 4ee9379 May 4, 2020
@bodewig
Copy link
Member

bodewig commented May 4, 2020

I've simply overridden the method and duplicated the implementation -which hasn't changed since at least 2.9.0. Calling super would - of course - not work because of the same NoSuchMethod exception.

I've also added an easier setup for compatibility tests in Travis.

@bodewig
Copy link
Member

bodewig commented May 9, 2020

I've just published a 2.7.0-SNAPSHOT version. @jwalter it would be good if yo could confirm this version works for you.

@jwalter
Copy link
Author

jwalter commented May 12, 2020

2.7.0-SNAPSHOT solves the reported issue for me. Thanks!

@snicoll
Copy link

snicoll commented May 12, 2020

@jwalter thanks for testing!

@bodewig for the record we are releasing Spring Boot 2.3 GA this Thursday if that makes sense (and if you have time) to squeeze a release of XMLUnit in the meantime.

@bodewig
Copy link
Member

bodewig commented May 12, 2020

will do tonight (CEST :-) )

Thanks for testing.

@bodewig
Copy link
Member

bodewig commented May 12, 2020

2.7.0 should show up in maven central soonish, I've just released the Nexus repo.

bodewig added a commit that referenced this issue Nov 3, 2020
Right now this is a repackaged copy of xmlunit-assertj with the
workarounds for #181 and #161 removed.

This is not the final solution, I'll try to extract common APIs (and
tests) for xmlunit-assertj and xmlunit-assertj3 in order to reduce
code duplication later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AssertJ Support the xmlunit-assertj module
Projects
None yet
Development

No branches or pull requests

3 participants