44import org .evomaster .client .java .controller .InstrumentedSutStarter ;
55import org .evomaster .client .java .controller .api .dto .AuthenticationDto ;
66import org .evomaster .client .java .controller .api .dto .SutInfoDto ;
7+ import org .evomaster .client .java .controller .api .dto .database .schema .DatabaseType ;
78import org .evomaster .client .java .controller .db .DbCleaner ;
89import org .evomaster .client .java .controller .internal .SutController ;
10+ import org .evomaster .client .java .controller .internal .db .DbSpecification ;
911import org .evomaster .client .java .controller .problem .ProblemInfo ;
1012import org .evomaster .client .java .controller .problem .RestProblem ;
1113import org .springframework .boot .SpringApplication ;
1416
1517import java .sql .Connection ;
1618import java .sql .SQLException ;
19+ import java .util .Arrays ;
1720import java .util .List ;
1821
1922public class EMDriver extends EmbeddedSutController {
@@ -27,7 +30,8 @@ public static void main(String[] args){
2730 }
2831
2932 private ConfigurableApplicationContext ctx ;
30- private Connection connection ;
33+
34+ private Connection sqlConnection ;
3135
3236 public boolean isSutRunning () {
3337 return ctx !=null && ctx .isRunning ();
@@ -41,9 +45,6 @@ public List<AuthenticationDto> getInfoForAuthentication() {
4145 return null ;
4246 }
4347
44- public Connection getConnection () {
45- return connection ;
46- }
4748
4849 public ProblemInfo getProblemInfo () {
4950 return new RestProblem ("http://localhost:8080/v3/api-docs" , null );
@@ -58,8 +59,9 @@ public String startSut() {
5859 ctx = SpringApplication .run (Application .class );
5960
6061 JdbcTemplate jdbc = ctx .getBean (JdbcTemplate .class );
62+
6163 try {
62- connection = jdbc .getDataSource ().getConnection ();
64+ sqlConnection = jdbc .getDataSource ().getConnection ();
6365 } catch (SQLException throwables ) {
6466 throwables .printStackTrace ();
6567 }
@@ -72,6 +74,13 @@ public void stopSut() {
7274 }
7375
7476 public void resetStateOfSUT () {
75- DbCleaner .clearDatabase_H2 (connection );
77+ }
78+
79+ @ Override
80+ public List <DbSpecification > getDbSpecifications () {
81+ return Arrays .asList (new DbSpecification (){{
82+ dbType = DatabaseType .H2 ;
83+ connection = sqlConnection ;
84+ }});
7685 }
7786}
0 commit comments