Skip to content

Commit 6cf7588

Browse files
authored
[TEST] Fix failure due to exception message in java11 (#32321)
Java 11 uses more verbose exceptions messages, causing this assertion to fail. Changed the test to be less restrictive and only look for the classes we care about.
1 parent 5a12c63 commit 6cf7588

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,12 @@ public void testMismatch() throws IOException {
508508
BigArrays bigArrays = new MockBigArrays(new MockPageCacheRecycler(Settings.EMPTY), new NoneCircuitBreakerService());
509509
ScriptService scriptService = mock(ScriptService.class);
510510
InternalAggregation.ReduceContext reduceContext = new InternalAggregation.ReduceContext(bigArrays, scriptService, true);
511-
Exception e = expectThrows(RuntimeException.class,
511+
ClassCastException e = expectThrows(ClassCastException.class,
512512
() -> RollupResponseTranslator.combineResponses(msearch, reduceContext));
513-
assertThat(e.getMessage(), equalTo("org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds " +
514-
"cannot be cast to org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"));
513+
assertThat(e.getMessage(),
514+
containsString("org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds"));
515+
assertThat(e.getMessage(),
516+
containsString("org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"));
515517
}
516518

517519
public void testDateHisto() throws IOException {

0 commit comments

Comments
 (0)