Skip to content

Commit

Permalink
Make JdbcDatabaseContainer#getDriverClassName public (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpavic authored and kiview committed Jun 22, 2018
1 parent 246cc7d commit f0e2072
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Expand Up @@ -110,9 +110,28 @@ public void testCommandOverride() throws SQLException {

}

@Test
public void testMySQL8() throws SQLException {
assumeFalse(SystemUtils.IS_OS_WINDOWS);
MySQLContainer container = new MySQLContainer<>("mysql:8.0.11")
.withCommand("mysqld --default-authentication-plugin=mysql_native_password");
container.start();

try {
ResultSet resultSet = performQuery(container, "SELECT VERSION()");
String resultSetString = resultSet.getString(1);

assertTrue("The database version can be set using a container rule parameter", "8.0.11".equals(resultSetString));
}
finally {
container.stop();
}
}

@NonNull
protected ResultSet performQuery(MySQLContainer containerRule, String sql) throws SQLException {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName(containerRule.getDriverClassName());
hikariConfig.setJdbcUrl(containerRule.getJdbcUrl());
hikariConfig.setUsername(containerRule.getUsername());
hikariConfig.setPassword(containerRule.getPassword());
Expand Down
Expand Up @@ -47,7 +47,7 @@ public JdbcDatabaseContainer(@NonNull final Future<String> image) {
/**
* @return the name of the actual JDBC driver to use
*/
protected abstract String getDriverClassName();
public abstract String getDriverClassName();

/**
* @return a JDBC URL that may be used to connect to the dockerized DB
Expand Down

0 comments on commit f0e2072

Please sign in to comment.