use of org.postgresql.util.PSQLState in project debezium by debezium.
the class PostgresConnectorIT method shouldSupportSSLParameters.
@Test
public void shouldSupportSSLParameters() throws Exception {
// the default docker image we're testing against doesn't use SSL, so check that the connector fails to start when
// SSL is enabled
Configuration config = TestHelper.defaultConfig().with(PostgresConnectorConfig.SSL_MODE, PostgresConnectorConfig.SecureConnectionMode.REQUIRED).build();
start(PostgresConnector.class, config, (success, msg, error) -> {
if (TestHelper.shouldSSLConnectionFail()) {
// we expect the task to fail at startup when we're printing the server info
assertThat(success).isFalse();
assertThat(error).isInstanceOf(ConnectException.class);
Throwable cause = error.getCause();
assertThat(cause).isInstanceOf(SQLException.class);
assertThat(PSQLState.CONNECTION_REJECTED).isEqualTo(new PSQLState(((SQLException) cause).getSQLState()));
}
});
if (TestHelper.shouldSSLConnectionFail()) {
assertConnectorNotRunning();
} else {
assertConnectorIsRunning();
Thread.sleep(10000);
stopConnector();
}
}
Aggregations