Skip to content

Commit 91ca16f

Browse files
committed
Upgrades MySql for testing to 8.0.24.
This version of the docker container doesn't allow to use `root` as the database user name. We still have to connect as `root` so we can create alternative schemata.
1 parent fc8acde commit 91ca16f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/MySqlDataSourceConfiguration.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ protected DataSource createDataSource() {
5252

5353
if (MYSQL_CONTAINER == null) {
5454

55-
MySQLContainer<?> container = new MySQLContainer<>()
56-
.withUsername("root")
57-
.withPassword("")
55+
MySQLContainer<?> container = new MySQLContainer<>("mysql:8.0.24")
56+
.withUsername("test")
57+
.withPassword("test")
5858
.withConfigurationOverride("");
5959

6060
container.start();
@@ -64,7 +64,7 @@ protected DataSource createDataSource() {
6464

6565
MysqlDataSource dataSource = new MysqlDataSource();
6666
dataSource.setUrl(MYSQL_CONTAINER.getJdbcUrl());
67-
dataSource.setUser(MYSQL_CONTAINER.getUsername());
67+
dataSource.setUser("root");
6868
dataSource.setPassword(MYSQL_CONTAINER.getPassword());
6969
dataSource.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
7070

@@ -79,4 +79,15 @@ public void initDatabase() throws SQLException {
7979
new ByteArrayResource("DROP DATABASE test;CREATE DATABASE test;".getBytes()));
8080
}
8181
}
82+
83+
private DataSource createRootDataSource() {
84+
85+
MysqlDataSource dataSource = new MysqlDataSource();
86+
dataSource.setUrl(MYSQL_CONTAINER.getJdbcUrl());
87+
dataSource.setUser("root");
88+
dataSource.setPassword(MYSQL_CONTAINER.getPassword());
89+
dataSource.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
90+
91+
return dataSource;
92+
}
8293
}

0 commit comments

Comments
 (0)