Skip to content

Commit e83ad9a

Browse files
polyfractaljimczi
authored andcommitted
[TEST] Fix failure due to exception message in java11 (elastic#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 a4a2afb commit e83ad9a

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
@@ -509,10 +509,12 @@ public void testMismatch() throws IOException {
509509
BigArrays bigArrays = new MockBigArrays(new MockPageCacheRecycler(Settings.EMPTY), new NoneCircuitBreakerService());
510510
ScriptService scriptService = mock(ScriptService.class);
511511
InternalAggregation.ReduceContext reduceContext = new InternalAggregation.ReduceContext(bigArrays, scriptService, true);
512-
Exception e = expectThrows(RuntimeException.class,
512+
ClassCastException e = expectThrows(ClassCastException.class,
513513
() -> RollupResponseTranslator.combineResponses(msearch, reduceContext));
514-
assertThat(e.getMessage(), equalTo("org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds " +
515-
"cannot be cast to org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"));
514+
assertThat(e.getMessage(),
515+
containsString("org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds"));
516+
assertThat(e.getMessage(),
517+
containsString("org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"));
516518
}
517519

518520
public void testDateHisto() throws IOException {

0 commit comments

Comments
 (0)