Skip to content

Commit 69e61c7

Browse files
author
Christoph Büscher
committed
[Tests] Fix failure due to changes exception message (#32036)
Java 11 seems to get more verbose on the ClassCastException we check for in SearchDocumentationIT. This changes the test from asserting the exact exception message to only checking the two classes involved are part of the message. Closes #32029
1 parent d4d2df7 commit 69e61c7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,9 @@ public void testSearchRequestAggregations() throws IOException {
337337
Range range = aggregations.get("by_company"); // <1>
338338
// end::search-request-aggregations-get-wrongCast
339339
} catch (ClassCastException ex) {
340-
assertEquals("org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms"
341-
+ " cannot be cast to org.elasticsearch.search.aggregations.bucket.range.Range", ex.getMessage());
340+
String message = ex.getMessage();
341+
assertThat(message, containsString("org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms"));
342+
assertThat(message, containsString("org.elasticsearch.search.aggregations.bucket.range.Range"));
342343
}
343344
assertEquals(3, elasticBucket.getDocCount());
344345
assertEquals(30, avg, 0.0);

0 commit comments

Comments
 (0)