From e38dc37c840eef8b677f4fba6a929c0a2c423095 Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Tue, 24 Jul 2018 07:30:05 -0400 Subject: [PATCH 1/2] [TEST] Fix failure due to exception message in java11 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. --- .../xpack/rollup/RollupResponseTranslationTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java index 98e3ad8197a51..5734dbfd4b11d 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java @@ -510,8 +510,10 @@ public void testMismatch() throws IOException { InternalAggregation.ReduceContext reduceContext = new InternalAggregation.ReduceContext(bigArrays, scriptService, true); Exception e = expectThrows(RuntimeException.class, () -> RollupResponseTranslator.combineResponses(msearch, reduceContext)); - assertThat(e.getMessage(), equalTo("org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds " + - "cannot be cast to org.elasticsearch.search.aggregations.InternalMultiBucketAggregation")); + assertThat(e.getMessage(), + containsString("org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds")); + assertThat(e.getMessage(), + containsString("org.elasticsearch.search.aggregations.InternalMultiBucketAggregation")); } public void testDateHisto() throws IOException { From 8bf52bab8773c1db9ce7c2e2af210ab88808b4d2 Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Tue, 24 Jul 2018 08:52:38 -0400 Subject: [PATCH 2/2] Catch ClassCastException explicitly --- .../xpack/rollup/RollupResponseTranslationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java index 5734dbfd4b11d..35d9f0d133a3d 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupResponseTranslationTests.java @@ -508,7 +508,7 @@ public void testMismatch() throws IOException { BigArrays bigArrays = new MockBigArrays(new MockPageCacheRecycler(Settings.EMPTY), new NoneCircuitBreakerService()); ScriptService scriptService = mock(ScriptService.class); InternalAggregation.ReduceContext reduceContext = new InternalAggregation.ReduceContext(bigArrays, scriptService, true); - Exception e = expectThrows(RuntimeException.class, + ClassCastException e = expectThrows(ClassCastException.class, () -> RollupResponseTranslator.combineResponses(msearch, reduceContext)); assertThat(e.getMessage(), containsString("org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds"));