Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laglangyue committed Oct 16, 2022
1 parent 893637e commit 4f86020
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public void startUp() throws Exception {
given().ignoreExceptions()
.await()
.atMost(180, TimeUnit.SECONDS)
.untilAsserted(this::initializeDbServer);
.untilAsserted(this::initializeJdbcConnection);
initializeJdbcTable();
}

@Override
Expand All @@ -86,7 +87,7 @@ public void tearDown() throws Exception {
}
}

private void initializeDbServer() throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
private void initializeJdbcConnection() throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
Properties properties = new Properties();
properties.setProperty("user", USER);
properties.setProperty("password", PASSWORD);
Expand All @@ -97,7 +98,6 @@ private void initializeDbServer() throws SQLException, ClassNotFoundException, I
Assertions.assertTrue(resultSet.next());
resultSet.close();
statement.close();
initializeJdbcTable();
}

/**
Expand Down Expand Up @@ -127,7 +127,11 @@ private void initializeJdbcTable() {
}
}

private void assertHasData(String table) throws SQLException {
private void assertHasData(String table) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
if(jdbcConnection.isValid(10)){
initializeJdbcConnection();
}

try (Statement statement = jdbcConnection.createStatement()) {
String sql = String.format("select * from \"%s\".%s", USER, table);
ResultSet source = statement.executeQuery(sql);
Expand All @@ -138,13 +142,13 @@ private void assertHasData(String table) throws SQLException {
}

@Test
void pullImageOK() throws SQLException {
void pullImageOK() throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
assertHasData(SOURCE_TABLE);
}

@TestTemplate
@DisplayName("JDBC-DM end to end test")
public void testJdbcSourceAndSink(TestContainer container) throws IOException, InterruptedException, SQLException {
public void testJdbcSourceAndSink(TestContainer container) throws IOException, InterruptedException, SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
assertHasData(SOURCE_TABLE);
Container.ExecResult execResult = container.executeJob("/jdbc_db2_source_and_sink.conf");
Assertions.assertEquals(0, execResult.getExitCode());
Expand Down

0 comments on commit 4f86020

Please sign in to comment.