Skip to content

Commit 2b24f09

Browse files
committed
sql init with resource path
1 parent 78a687b commit 2b24f09

File tree

6 files changed

+6
-46
lines changed

6 files changed

+6
-46
lines changed

jdk_8_maven/em/embedded/graphql/petclinic-graphql/src/main/java/em/embedded/org/springframework/samples/petclinic/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ public EmbeddedEvoMasterController() {
6363

6464
public EmbeddedEvoMasterController(int port) {
6565
setControllerPort(port);
66-
67-
try (InputStream in = getClass().getResourceAsStream(INIT_DB_SCRIPT_PATH)) {
68-
initSQLScript = (new SqlScriptRunner()).readSQLCommandsAsString(new InputStreamReader(in));
69-
} catch (Exception e) {
70-
throw new RuntimeException(e);
71-
}
7266
}
7367

7468

@@ -112,7 +106,7 @@ public String startSut() {
112106
DbCleaner.clearDatabase_Postgres(sqlConnection,"public", null);
113107

114108
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.POSTGRES,sqlConnection)
115-
.withSchemas("public").withInitSqlScript(initSQLScript));
109+
.withSchemas("public").withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH));
116110

117111

118112

jdk_8_maven/em/embedded/rest/features-service/src/main/java/em/embedded/org/javiermf/features/EmbeddedEvoMasterController.java

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

5050
private List<DbSpecification> dbSpecification;
5151

52-
private String initSQLScript;
53-
5452

5553
public EmbeddedEvoMasterController() {
5654
this(40100);
@@ -59,11 +57,6 @@ public EmbeddedEvoMasterController() {
5957
public EmbeddedEvoMasterController(int port) {
6058
setControllerPort(port);
6159

62-
try (InputStream in = getClass().getResourceAsStream(INIT_DB_SCRIPT_PATH)) {
63-
initSQLScript = (new SqlScriptRunner()).readSQLCommandsAsString(new InputStreamReader(in));
64-
} catch (Exception e) {
65-
throw new RuntimeException(e);
66-
}
6760
}
6861

6962
@Override
@@ -99,7 +92,7 @@ public String startSut() {
9992
DbCleaner.clearDatabase_H2(sqlConnection);
10093

10194
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection)
102-
.withInitSqlScript(initSQLScript));
95+
.withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH));
10396

10497
return "http://localhost:" + getSutPort();
10598
}

jdk_8_maven/em/embedded/rest/scout-api/src/main/java/em/embedded/se/devscout/scoutapi/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,13 @@ public static void main(String[] args) {
4949

5050
private List<DbSpecification> dbSpecification;
5151

52-
private String initSQLScript;
53-
5452

5553
public EmbeddedEvoMasterController() {
5654
this(40100);
5755
}
5856

5957
public EmbeddedEvoMasterController(int port) {
6058
setControllerPort(port);
61-
62-
try (InputStream in = getClass().getResourceAsStream(INIT_DB_SCRIPT_PATH)) {
63-
initSQLScript = (new SqlScriptRunner()).readSQLCommandsAsString(new InputStreamReader(in));
64-
} catch (Exception e) {
65-
throw new RuntimeException(e);
66-
}
6759
}
6860

6961
@Override
@@ -100,7 +92,7 @@ public String startSut() {
10092
DbCleaner.clearDatabase_H2(sqlConnection);
10193

10294
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection)
103-
.withInitSqlScript(initSQLScript));
95+
.withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH));
10496

10597
resetStateOfSUT();
10698

jdk_8_maven/em/external/graphql/petclinic-graphql/src/main/java/em/external/org/springframework/samples/petclinic/ExternalEvoMasterController.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ public ExternalEvoMasterController(
100100
this.timeoutSeconds = timeoutSeconds;
101101
setControllerPort(controllerPort);
102102
setJavaCommand(command);
103-
104-
try (InputStream in = getClass().getResourceAsStream(INIT_DB_SCRIPT_PATH)) {
105-
initSQLScript = (new SqlScriptRunner()).readSQLCommandsAsString(new InputStreamReader(in));
106-
} catch (Exception e) {
107-
throw new RuntimeException(e);
108-
}
109103
}
110104

111105

@@ -176,7 +170,7 @@ public void postStart() {
176170
DbCleaner.clearDatabase_Postgres(sqlConnection,"public", null);
177171

178172
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.POSTGRES,sqlConnection)
179-
.withSchemas("public").withInitSqlScript(initSQLScript));
173+
.withSchemas("public").withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH));
180174

181175

182176
} catch (Exception e) {

jdk_8_maven/em/external/rest/features-service/src/main/java/em/external/org/javiermf/features/ExternalEvoMasterController.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ public ExternalEvoMasterController(int controllerPort, String jarLocation, int s
8585
this.timeoutSeconds = timeoutSeconds;
8686
setControllerPort(controllerPort);
8787
setJavaCommand(command);
88-
89-
try (InputStream in = getClass().getResourceAsStream(INIT_DB_SCRIPT_PATH)) {
90-
initSQLScript = (new SqlScriptRunner()).readSQLCommandsAsString(new InputStreamReader(in));
91-
} catch (Exception e) {
92-
throw new RuntimeException(e);
93-
}
9488
}
9589

9690
private String dbUrl( ) {
@@ -162,7 +156,7 @@ public void postStart() {
162156
to consistently manage data by evomaster
163157
*/
164158
DbCleaner.clearDatabase_H2(sqlConnection);
165-
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection).withInitSqlScript(initSQLScript));
159+
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection).withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH));
166160
} catch (Exception e) {
167161
throw new RuntimeException(e);
168162
}

jdk_8_maven/em/external/rest/scout-api/src/main/java/em/external/se/devscout/scoutapi/ExternalEvoMasterController.java

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

8080
private String INIT_DB_SCRIPT_PATH = "/init_db.sql";
8181

82-
private String initSQLScript;
8382
private Server h2;
8483

8584

@@ -107,12 +106,6 @@ public ExternalEvoMasterController(int controllerPort,
107106
String base = Paths.get(jarLocation).toAbsolutePath().getParent().normalize().toString();
108107
tmpDir = base + "/temp/tmp_scout_api/temp_"+dbPort;
109108
createConfigurationFile();
110-
111-
try(InputStream in = getClass().getResourceAsStream("/init_db.sql")) {
112-
initSQLScript = (new SqlScriptRunner()).readSQLCommandsAsString(new InputStreamReader(in));
113-
} catch (Exception e){
114-
throw new RuntimeException(e);
115-
}
116109
}
117110

118111
private String dbUrl( ) {
@@ -206,7 +199,7 @@ public void postStart() {
206199
*/
207200
DbCleaner.clearDatabase_H2(sqlConnection);
208201

209-
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection).withInitSqlScript(initSQLScript));
202+
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection).withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH));
210203

211204
} catch (Exception e) {
212205
throw new RuntimeException(e);

0 commit comments

Comments
 (0)