Skip to content

Commit 08d9e79

Browse files
test: update proxy tests to handle ClickHouseException and nested error messages
1 parent 57b01a4 commit 08d9e79

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

client-v2/src/test/java/com/clickhouse/client/ProxyTests.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.clickhouse.client.api.Client;
44
import com.clickhouse.client.api.ClientException;
55
import com.clickhouse.client.api.ClientMisconfigurationException;
6+
import com.clickhouse.client.api.ClickHouseException;
67
import com.clickhouse.client.api.enums.Protocol;
78
import com.clickhouse.client.api.enums.ProxyType;
89
import com.clickhouse.client.api.insert.InsertResponse;
@@ -199,9 +200,13 @@ public void testProxyWithDisabledCookies() {
199200
try {
200201
client.get().execute("select 1").get();
201202
} catch (ExecutionException e) {
202-
Assert.assertTrue(e.getCause() instanceof ClientException);
203-
} catch (ClientException e) {
204-
Assert.assertTrue(e.getMessage().contains("Server returned '502 Bad gateway'"));
203+
Assert.assertTrue(e.getCause() instanceof ClickHouseException);
204+
Throwable cause = e.getCause();
205+
Assert.assertTrue(cause.getMessage().contains("Server returned '502 Bad gateway'") ||
206+
(cause.getCause() != null && cause.getCause().getMessage().contains("Server returned '502 Bad gateway'")));
207+
} catch (ClickHouseException e) {
208+
Assert.assertTrue(e.getMessage().contains("Server returned '502 Bad gateway'") ||
209+
(e.getCause() != null && e.getCause().getMessage().contains("Server returned '502 Bad gateway'")));
205210
} catch (Exception e) {
206211
Assert.fail("Should have thrown exception.", e);
207212
}

0 commit comments

Comments
 (0)