Skip to content

Commit

Permalink
Fix an incompatibility with hamcrest 2.2 (#31395)
Browse files Browse the repository at this point in the history
This test asserts on the message of an AssertionError thrown by a
failing hamcrest assertion. The message changes in the latest versions
of hamcrest.

```
1) testBadCoderIsNotDeterministic(org.apache.beam.sdk.testing.CoderPropertiesTest)
java.lang.AssertionError:
Expected: a string containing "<84>, <101>, <115>, <116>, <68>"
     but: was "
Expected: [<24b>, <84b>, <101b>, <115b>, <116b>, <68b>, <97b>, <116b>, <97b>, <51b>, <51b>, <50b>, <54b>, <49b>, <57b>, <57b>, <52b>, <57b>, <48b>, <57b>, <57b>, <55b>, <48b>, <53b>, <53b>]
     but: was [<24b>, <84b>, <101b>, <115b>, <116b>, <68b>, <97b>, <116b>, <97b>, <51b>, <51b>, <50b>, <54b>, <49b>, <57b>, <57b>, <52b>, <56b>, <50b>, <48b>, <52b>, <49b>, <54b>, <49b>, <53b>]"
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
        at org.apache.beam.sdk.testing.CoderPropertiesTest.testBadCoderIsNotDeterministic(CoderPropertiesTest.java:123)
```
  • Loading branch information
cushon authored May 25, 2024
1 parent 3b9b6ed commit cf3592b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ public void testBadCoderIsNotDeterministic() throws Exception {
error = e;
}
assertNotNull("Expected AssertionError", error);
assertThat(error.getMessage(), CoreMatchers.containsString("<84>, <101>, <115>, <116>, <68>"));
assertThat(
error.getMessage(),
CoreMatchers.anyOf(
CoreMatchers.containsString("<84>, <101>, <115>, <116>, <68>"),
CoreMatchers.containsString("<84b>, <101b>, <115b>, <116b>, <68b>")));
}

@Test
Expand Down

0 comments on commit cf3592b

Please sign in to comment.