Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JdbcDatabaseContainer#getDriverClassName public #743

Merged
merged 2 commits into from Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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