...
|
...
|
@@ -36,16 +36,24 @@ import java.util.Properties; |
36
|
36
|
@Slf4j
|
37
|
37
|
public class CustomSqlUnit extends ExternalResource {
|
38
|
38
|
|
39
|
|
- private List<String> sqlFiles;
|
40
|
|
- private String dropAllTablesSqlFile;
|
41
|
|
- private String dbUrl;
|
42
|
|
- private String dbUserName;
|
43
|
|
- private String dbPassword;
|
|
39
|
+ private final List<String> sqlFiles;
|
|
40
|
+ private final String dropAllTablesSqlFile;
|
|
41
|
+ private final String dbUrl;
|
|
42
|
+ private final String dbUserName;
|
|
43
|
+ private final String dbPassword;
|
44
|
44
|
|
45
|
|
- public CustomSqlUnit(List<String> sqlFiles, String configurationFileName, String dropAllTablesSqlFile) {
|
|
45
|
+ public CustomSqlUnit(List<String> sqlFiles, String dropAllTablesSqlFile, String configurationFileName) {
|
46
|
46
|
this.sqlFiles = sqlFiles;
|
47
|
47
|
this.dropAllTablesSqlFile = dropAllTablesSqlFile;
|
48
|
|
- loadProperties(configurationFileName);
|
|
48
|
+ final Properties properties = new Properties();
|
|
49
|
+ try (final InputStream stream = this.getClass().getClassLoader().getResourceAsStream(configurationFileName)) {
|
|
50
|
+ properties.load(stream);
|
|
51
|
+ this.dbUrl = properties.getProperty("spring.datasource.url");
|
|
52
|
+ this.dbUserName = properties.getProperty("spring.datasource.username");
|
|
53
|
+ this.dbPassword = properties.getProperty("spring.datasource.password");
|
|
54
|
+ } catch (IOException e) {
|
|
55
|
+ throw new RuntimeException(e.getMessage(), e);
|
|
56
|
+ }
|
49
|
57
|
}
|
50
|
58
|
|
51
|
59
|
@Override
|
...
|
...
|
@@ -91,17 +99,4 @@ public class CustomSqlUnit extends ExternalResource { |
91
|
99
|
}
|
92
|
100
|
}
|
93
|
101
|
}
|
94
|
|
-
|
95
|
|
- private void loadProperties(String fileName) {
|
96
|
|
- final Properties properties = new Properties();
|
97
|
|
- try (final InputStream stream = this.getClass().getClassLoader().getResourceAsStream(fileName)) {
|
98
|
|
- properties.load(stream);
|
99
|
|
- this.dbUrl = properties.getProperty("spring.datasource.url");
|
100
|
|
- this.dbUserName = properties.getProperty("spring.datasource.username");
|
101
|
|
- this.dbPassword = properties.getProperty("spring.datasource.password");
|
102
|
|
- } catch (IOException e) {
|
103
|
|
- throw new RuntimeException(e.getMessage(), e);
|
104
|
|
- }
|
105
|
|
-
|
106
|
|
- }
|
107
|
102
|
} |
...
|
...
|
|