Skip to content

Commit f0e754d

Browse files
committed
update with smartdbclean
1 parent a55844c commit f0e754d

37 files changed

Lines changed: 235 additions & 230 deletions

File tree

jdk_11_gradle/em/embedded/graphql/patio-api/src/main/java/em/embedded/patio/EmbeddedEvoMasterController.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.sql.Connection;
2121
import java.sql.DriverManager;
2222
import java.sql.SQLException;
23+
import java.util.Arrays;
2324
import java.util.Collections;
2425
import java.util.List;
2526

@@ -39,8 +40,8 @@ public static void main(String[] args){
3940
}
4041

4142
private ApplicationContext ctx;
42-
private Connection connection;
43-
private DbSpecification dbSpecification;
43+
private Connection sqlConnection;
44+
private List<DbSpecification> dbSpecification;
4445

4546
private final int portApp = 8080; //Hardcoded. will need fixing
4647
// TODO maybe report at https://github.com/micronaut-projects/micronaut-core/issues
@@ -79,25 +80,25 @@ public String startSut() {
7980
});
8081

8182

82-
if (connection != null) {
83+
if (sqlConnection != null) {
8384
try {
84-
connection.close();
85+
sqlConnection.close();
8586
} catch (SQLException e) {
8687
throw new RuntimeException(e);
8788
}
8889
}
8990

9091
try {
91-
connection = DriverManager.getConnection(url, "patio", "patio");
92+
sqlConnection = DriverManager.getConnection(url, "patio", "patio");
9293
} catch (SQLException e) {
9394
throw new RuntimeException(e);
9495
}
9596

96-
dbSpecification = new DbSpecification(){{
97+
dbSpecification = Arrays.asList(new DbSpecification(){{
9798
dbType = DatabaseType.POSTGRES;
98-
schemaName = "public";
99+
schemaNames = Arrays.asList("public");
99100
initSqlOnResourcePath = "/initDb.sql";
100-
}};
101+
}});
101102

102103
return "http://localhost:" + getSutPort();
103104
}
@@ -161,15 +162,15 @@ public List<AuthenticationDto> getInfoForAuthentication() {
161162
}
162163

163164
public Connection getConnection() {
164-
return connection;
165+
return sqlConnection;
165166
}
166167

167168
@Override
168169
public String getDatabaseDriverName() {
169170
return "org.postgresql.Driver";
170171
}
171172

172-
public DbSpecification getDbSpecification() {
173+
public List<DbSpecification> getDbSpecifications() {
173174
return dbSpecification;
174175
}
175176

jdk_11_gradle/em/external/graphql/patio-api/src/main/java/em/external/patio/ExternalEvoMasterController.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.sql.Connection;
1717
import java.sql.DriverManager;
1818
import java.sql.SQLException;
19+
import java.util.Arrays;
1920
import java.util.Collections;
2021
import java.util.List;
2122

@@ -61,8 +62,8 @@ public static void main(String[] args) {
6162
private final int timeoutSeconds;
6263
private final int sutPort;
6364
private String jarLocation;
64-
private Connection connection;
65-
private DbSpecification dbSpecification;
65+
private Connection sqlConnection;
66+
private List<DbSpecification> dbSpecification;
6667

6768
private static final GenericContainer postgres = new GenericContainer("postgres:9")
6869
.withEnv("POSTGRES_HOST_AUTH_METHOD","trust")
@@ -151,12 +152,12 @@ public void postStart() {
151152

152153
try {
153154
Class.forName(getDatabaseDriverName());
154-
connection = DriverManager.getConnection(dbUrl(), "patio", "patio");
155-
dbSpecification = new DbSpecification(){{
155+
sqlConnection = DriverManager.getConnection(dbUrl(), "patio", "patio");
156+
dbSpecification = Arrays.asList(new DbSpecification(){{
156157
dbType = DatabaseType.POSTGRES;
157-
schemaName = "public";
158+
schemaNames = Arrays.asList("public");
158159
initSqlOnResourcePath = "/initDb.sql";
159-
}};
160+
}});
160161
} catch (Exception e) {
161162
throw new RuntimeException(e);
162163
}
@@ -179,13 +180,13 @@ public void postStop() {
179180
}
180181

181182
private void closeDataBaseConnection() {
182-
if (connection != null) {
183+
if (sqlConnection != null) {
183184
try {
184-
connection.close();
185+
sqlConnection.close();
185186
} catch (SQLException e) {
186187
e.printStackTrace();
187188
}
188-
connection = null;
189+
sqlConnection = null;
189190
}
190191
}
191192

@@ -206,7 +207,7 @@ public SutInfoDto.OutputFormat getPreferredOutputFormat() {
206207

207208
@Override
208209
public Connection getConnection() {
209-
return connection;
210+
return sqlConnection;
210211
}
211212

212213
@Override
@@ -231,7 +232,7 @@ public List<AuthenticationDto> getInfoForAuthentication() {
231232
}
232233

233234
@Override
234-
public DbSpecification getDbSpecification() {
235+
public List<DbSpecification> getDbSpecifications() {
235236
return dbSpecification;
236237
}
237238
}

jdk_11_maven/em/embedded/graphql/timbuctoo/src/main/java/em/embedded/nl/knaw/huygens/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void resetStateOfSUT() {
154154
}
155155

156156
@Override
157-
public DbSpecification getDbSpecification() {
157+
public List<DbSpecification> getDbSpecifications() {
158158
return null;
159159
}
160160

jdk_11_maven/em/embedded/rest/cwa-verification/src/main/java/em/embedded/app/coronawarn/verification/EmbeddedEvoMasterController.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public static void main(String[] args) {
4242

4343

4444
private ConfigurableApplicationContext ctx;
45-
private Connection connection;
46-
private DbSpecification dbSpecification;
45+
private Connection sqlConnection;
46+
private List<DbSpecification> dbSpecification;
4747

4848

4949
public EmbeddedEvoMasterController() {
@@ -65,26 +65,24 @@ public String startSut() {
6565
"--spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;"
6666
});
6767

68-
if (connection != null) {
68+
if (sqlConnection != null) {
6969
try {
70-
connection.close();
70+
sqlConnection.close();
7171
} catch (SQLException e) {
7272
throw new RuntimeException(e);
7373
}
7474
}
75-
JdbcTemplate jdbc = ctx.getBean(JdbcTemplate.class);
76-
77-
try {
78-
connection = jdbc.getDataSource().getConnection();
75+
JdbcTemplate jdbc = ctx.getBean(JdbcTemplate.class);try {
76+
sqlConnection = jdbc.getDataSource().getConnection();
7977
} catch (SQLException e) {
8078
throw new RuntimeException(e);
8179
}
8280

8381
// need to check tablesToSkip with DATABASECHANGELOG
84-
dbSpecification = new DbSpecification(){{
82+
dbSpecification = Arrays.asList(new DbSpecification(){{
8583
dbType = DatabaseType.H2;
86-
connections = Arrays.asList(connection);
87-
}};
84+
connection = sqlConnection;
85+
}});
8886

8987
return "http://localhost:" + getSutPort();
9088
}
@@ -139,12 +137,12 @@ public List<AuthenticationDto> getInfoForAuthentication() {
139137
}
140138

141139
public Connection getConnection() {
142-
return connection;
140+
return sqlConnection;
143141
}
144142

145143

146144
@Override
147-
public DbSpecification getDbSpecification() {
145+
public List<DbSpecification> getDbSpecifications() {
148146
return dbSpecification;
149147
}
150148
}

jdk_11_maven/em/external/graphql/timbuctoo/src/main/java/em/external/nl/knaw/huygens/ExternalEvoMasterController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public Connection getConnection() {
229229
}
230230

231231
@Override
232-
public DbSpecification getDbSpecification() {
232+
public List<DbSpecification> getDbSpecifications() {
233233
return null;
234234
}
235235
}

jdk_11_maven/em/external/rest/cwa-verification/src/main/java/em/external/app/coronawarn/verification/ExternalEvoMasterController.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public static void main(String[] args) {
5959
private final int sutPort;
6060
private final int dbPort;
6161
private String jarLocation;
62-
private Connection connection;
63-
private DbSpecification dbSpecification;
62+
private Connection sqlConnection;
63+
private List<DbSpecification> dbSpecification;
6464
private Server h2;
6565

6666
public ExternalEvoMasterController() {
@@ -146,11 +146,11 @@ public void postStart() {
146146

147147
try {
148148
Class.forName("org.h2.Driver");
149-
connection = DriverManager.getConnection(dbUrl(), "sa", "");
150-
dbSpecification = new DbSpecification(){{
149+
sqlConnection = DriverManager.getConnection(dbUrl(), "sa", "");
150+
dbSpecification = Arrays.asList(new DbSpecification(){{
151151
dbType = DatabaseType.H2;
152-
connections = Arrays.asList(connection);
153-
}};
152+
connection = sqlConnection;
153+
}});
154154
} catch (Exception e) {
155155
throw new RuntimeException(e);
156156
}
@@ -174,13 +174,13 @@ public void postStop() {
174174
}
175175

176176
private void closeDataBaseConnection() {
177-
if (connection != null) {
177+
if (sqlConnection != null) {
178178
try {
179-
connection.close();
179+
sqlConnection.close();
180180
} catch (SQLException e) {
181181
e.printStackTrace();
182182
}
183-
connection = null;
183+
sqlConnection = null;
184184
}
185185
}
186186

@@ -214,11 +214,11 @@ public List<AuthenticationDto> getInfoForAuthentication() {
214214

215215
@Override
216216
public Connection getConnection() {
217-
return connection;
217+
return sqlConnection;
218218
}
219219

220220
@Override
221-
public DbSpecification getDbSpecification() {
221+
public List<DbSpecification> getDbSpecifications() {
222222
return dbSpecification;
223223
}
224224
}

jdk_8_maven/em/embedded/graphql/graphql-ncs/src/main/java/em/embedded/org/graphqlncs/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public String getDatabaseDriverName() {
106106
}
107107

108108
@Override
109-
public DbSpecification getDbSpecification() {
109+
public List<DbSpecification> getDbSpecifications() {
110110
return null;
111111
}
112112
}

jdk_8_maven/em/embedded/graphql/graphql-scs/src/main/java/em/embedded/org/graphqlscs/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public String getDatabaseDriverName() {
104104
}
105105

106106
@Override
107-
public DbSpecification getDbSpecification() {
107+
public List<DbSpecification> getDbSpecifications() {
108108
return null;
109109
}
110110
}

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public static void main(String[] args){
4040
}
4141

4242
private ConfigurableApplicationContext ctx;
43-
private Connection connection;
44-
private DbSpecification dbSpecification;
43+
private Connection sqlConnection;
44+
private List<DbSpecification> dbSpecification;
4545

4646
private static final GenericContainer postgres = new GenericContainer("postgres:9")
4747
.withExposedPorts(5432)
@@ -76,29 +76,30 @@ public String startSut() {
7676
"--spring.jmx.enabled=false",
7777
});
7878

79-
if (connection != null) {
79+
if (sqlConnection != null) {
8080
try {
81-
connection.close();
81+
sqlConnection.close();
8282
} catch (SQLException e) {
8383
throw new RuntimeException(e);
8484
}
8585
}
8686
JdbcTemplate jdbc = ctx.getBean(JdbcTemplate.class);
87-
8887
try {
89-
connection = jdbc.getDataSource().getConnection();
88+
sqlConnection = jdbc.getDataSource().getConnection();
9089
} catch (SQLException e) {
9190
throw new RuntimeException(e);
9291
}
9392

94-
dbSpecification = new DbSpecification(){{
93+
SqlScriptRunnerCached.runScriptFromResourceFile(sqlConnection,"/db/postgresql/initDB.sql");
94+
95+
dbSpecification = Arrays.asList(new DbSpecification(){{
9596
dbType = DatabaseType.POSTGRES;
96-
connections = Arrays.asList(connection);
97-
schemaName = "public";
97+
connection = sqlConnection;
98+
schemaNames = Arrays.asList("public");
9899
initSqlOnResourcePath = "/db/postgresql/populateDB.sql";
99-
}};
100+
}});
101+
100102

101-
// SqlScriptRunnerCached.runScriptFromResourceFile(connection,"/db/postgresql/initDB.sql");
102103

103104
return "http://localhost:" + getSutPort();
104105
}
@@ -149,7 +150,7 @@ public List<AuthenticationDto> getInfoForAuthentication() {
149150
}
150151

151152
public Connection getConnection() {
152-
return connection;
153+
return sqlConnection;
153154
}
154155

155156
@Override
@@ -158,7 +159,7 @@ public String getDatabaseDriverName() {
158159
}
159160

160161
@Override
161-
public DbSpecification getDbSpecification() {
162+
public List<DbSpecification> getDbSpecifications() {
162163
return dbSpecification;
163164
}
164165
}

0 commit comments

Comments
 (0)