mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-28 05:05:14 +01:00
Datasource integration tests - fix split by newline
- Make split of SQL file aware that new lines may be \r\n - Remove split of new lines in MySQL as it's not necessary
This commit is contained in:
parent
1d1605314a
commit
95e3943be0
@ -30,8 +30,8 @@ public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
|
||||
|
||||
/** Mock of a settings instance. */
|
||||
private static NewSetting settings;
|
||||
/** Collection of SQL statements to execute for initialization of a test. */
|
||||
private static String[] sqlInitialize;
|
||||
/** SQL statement to execute before running a test. */
|
||||
private static String sqlInitialize;
|
||||
/** Connection to the H2 test database. */
|
||||
private HikariDataSource hikariSource;
|
||||
|
||||
@ -56,7 +56,7 @@ public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
|
||||
ConsoleLoggerTestInitializer.setupLogger();
|
||||
|
||||
Path sqlInitFile = TestHelper.getJarPath("/datasource-integration/sql-initialize.sql");
|
||||
sqlInitialize = new String(Files.readAllBytes(sqlInitFile)).split(";\\n");
|
||||
sqlInitialize = new String(Files.readAllBytes(sqlInitFile));
|
||||
}
|
||||
|
||||
@Before
|
||||
@ -73,9 +73,7 @@ public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
|
||||
|
||||
try (Statement st = connection.createStatement()) {
|
||||
st.execute("DROP TABLE IF EXISTS authme");
|
||||
for (String statement : sqlInitialize) {
|
||||
st.execute(statement);
|
||||
}
|
||||
st.execute(sqlInitialize);
|
||||
}
|
||||
hikariSource = ds;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
|
||||
Path sqlInitFile = TestHelper.getJarPath("/datasource-integration/sql-initialize.sql");
|
||||
// Note ljacqu 20160221: It appears that we can only run one statement per Statement.execute() so we split
|
||||
// the SQL file by ";\n" as to get the individual statements
|
||||
sqlInitialize = new String(Files.readAllBytes(sqlInitFile)).split(";\\n");
|
||||
sqlInitialize = new String(Files.readAllBytes(sqlInitFile)).split(";(\\r?)\\n");
|
||||
}
|
||||
|
||||
@Before
|
||||
|
Loading…
Reference in New Issue
Block a user