Skip to content

Commit 78a687b

Browse files
committed
market sql script with resource path
1 parent 31ba257 commit 78a687b

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

jdk_11_maven/em/embedded/rest/market/src/main/java/em/embedded/market/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public static void main(String[] args) {
4949
private Connection sqlConnection;
5050
private List<DbSpecification> dbSpecification;
5151

52-
5352
private String INIT_DB_SCRIPT_PATH = "/data.sql";
5453

5554
private String initSQLScript;
@@ -60,12 +59,6 @@ public EmbeddedEvoMasterController() {
6059

6160
public EmbeddedEvoMasterController(int port) {
6261
setControllerPort(port);
63-
64-
try (InputStream in = getClass().getResourceAsStream(INIT_DB_SCRIPT_PATH)) {
65-
initSQLScript = (new SqlScriptRunner()).readSQLCommandsAsString(new InputStreamReader(in));
66-
} catch (Exception e) {
67-
throw new RuntimeException(e);
68-
}
6962
}
7063

7164
@Override
@@ -93,7 +86,7 @@ public String startSut() {
9386
DbCleaner.clearDatabase_H2(sqlConnection);
9487

9588
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection)
96-
.withInitSqlScript(initSQLScript));
89+
.withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH));
9790

9891
return "http://localhost:" + getSutPort();
9992
}

jdk_11_maven/em/external/rest/market/src/main/java/em/external/market/ExternalEvoMasterController.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ public static void main(String[] args) {
7070

7171
private String INIT_DB_SCRIPT_PATH = "/data.sql";
7272

73-
private String initSQLScript;
74-
7573
public ExternalEvoMasterController() {
7674
this(40100, "../core/target", 12345, 120, "java");
7775
}
@@ -88,12 +86,6 @@ public ExternalEvoMasterController(int controllerPort, String jarLocation, int s
8886
this.timeoutSeconds = timeoutSeconds;
8987
setControllerPort(controllerPort);
9088
setJavaCommand(command);
91-
92-
try (InputStream in = getClass().getResourceAsStream(INIT_DB_SCRIPT_PATH)) {
93-
initSQLScript = (new SqlScriptRunner()).readSQLCommandsAsString(new InputStreamReader(in));
94-
} catch (Exception e) {
95-
throw new RuntimeException(e);
96-
}
9789
}
9890

9991
private String dbUrl( ) {
@@ -163,7 +155,7 @@ public void postStart() {
163155
DbCleaner.clearDatabase_H2(sqlConnection);
164156

165157
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection)
166-
.withInitSqlScript(initSQLScript));
158+
.withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH));
167159
} catch (Exception e) {
168160
throw new RuntimeException(e);
169161
}

0 commit comments

Comments
 (0)