Tests: Fix RemoteScrollableHitSourceTests

With  #23307, the expected exception is wrapped two times into a RuntimeException instead of being thrown directly.
This commit is contained in:
Tanguy Leroux 2017-02-28 11:30:33 +01:00
parent d27a55866c
commit 33eb6a13bf
1 changed files with 5 additions and 3 deletions

View File

@ -462,18 +462,20 @@ public class RemoteScrollableHitSourceTests extends ESTestCase {
public void testNoContentTypeIsError() throws Exception {
Exception e = expectThrows(RuntimeException.class, () ->
sourceWithMockedRemoteCall(false, null, "main/0_20_5.json").lookupRemoteVersion(null));
assertThat(e.getCause().getCause().getMessage(), containsString("Response didn't include Content-Type: body={"));
assertThat(e.getCause().getCause().getCause().getMessage(), containsString("Response didn't include Content-Type: body={"));
}
public void testInvalidJsonThinksRemoveIsNotES() throws IOException {
Exception e = expectThrows(RuntimeException.class, () -> sourceWithMockedRemoteCall("some_text.txt").doStart(null));
assertEquals("Error parsing the response, remote is likely not an Elasticsearch instance", e.getCause().getCause().getMessage());
assertEquals("Error parsing the response, remote is likely not an Elasticsearch instance",
e.getCause().getCause().getCause().getMessage());
}
public void testUnexpectedJsonThinksRemoveIsNotES() throws IOException {
// Use the response from a main action instead of a proper start response to generate a parse error
Exception e = expectThrows(RuntimeException.class, () -> sourceWithMockedRemoteCall("main/2_3_3.json").doStart(null));
assertEquals("Error parsing the response, remote is likely not an Elasticsearch instance", e.getCause().getCause().getMessage());
assertEquals("Error parsing the response, remote is likely not an Elasticsearch instance",
e.getCause().getCause().getCause().getMessage());
}
private RemoteScrollableHitSource sourceWithMockedRemoteCall(String... paths) throws Exception {