Skip to content

Commit

Permalink
ClickHouse: simplification in JDBCDriverTest, add simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
VladRassokhin committed Aug 23, 2018
1 parent f0f76ba commit 87def1b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void testCleanup() {

@Test
public void test() throws SQLException {
performSimpleTest(jdbcUrl, pmdKnownBroken);
performSimpleTest(jdbcUrl);

if (performTestForScriptedSchema) {
performTestForScriptedSchema(jdbcUrl);
Expand All @@ -102,7 +102,7 @@ public void test() throws SQLException {
}
}

private void performSimpleTest(String jdbcUrl, boolean pmdKnownBroken) throws SQLException {
private void performSimpleTest(String jdbcUrl) throws SQLException {
try (HikariDataSource dataSource = getDataSource(jdbcUrl, 1)) {
boolean result = new QueryRunner(dataSource, pmdKnownBroken).query("SELECT 1", rs -> {
rs.next();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.testcontainers.junit;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.ClickHouseContainer;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;

public class SimpleClickhouseTest {

@Rule
public ClickHouseContainer clickhouse = new ClickHouseContainer();

@Test
public void testSimple() throws SQLException {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(clickhouse.getJdbcUrl());
hikariConfig.setUsername(clickhouse.getUsername());
hikariConfig.setPassword(clickhouse.getPassword());

HikariDataSource ds = new HikariDataSource(hikariConfig);
Statement statement = ds.getConnection().createStatement();
statement.execute("SELECT 1");
ResultSet resultSet = statement.getResultSet();

resultSet.next();
int resultSetInt = resultSet.getInt(1);
assertEquals("A basic SELECT query succeeds", 1, resultSetInt);
}
}

0 comments on commit 87def1b

Please sign in to comment.