Search in sources :

Example 1 with PSQLState

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();
    }
}
Also used : Configuration(io.debezium.config.Configuration) SQLException(java.sql.SQLException) PSQLState(org.postgresql.util.PSQLState) Test(org.junit.Test) AbstractConnectorTest(io.debezium.embedded.AbstractConnectorTest)

Aggregations

Configuration (io.debezium.config.Configuration)1 AbstractConnectorTest (io.debezium.embedded.AbstractConnectorTest)1 SQLException (java.sql.SQLException)1 Test (org.junit.Test)1 PSQLState (org.postgresql.util.PSQLState)1