1212import org .evomaster .client .java .sql .DbSpecification ;
1313import org .springframework .boot .SpringApplication ;
1414import org .springframework .context .ConfigurableApplicationContext ;
15- import org .springframework .jdbc .core .JdbcTemplate ;
1615import org .testcontainers .containers .GenericContainer ;
1716
1817import java .sql .Connection ;
18+ import java .sql .DriverManager ;
1919import java .sql .SQLException ;
2020import java .util .Arrays ;
21+ import java .util .Collections ;
2122import java .util .List ;
2223import java .util .Map ;
2324
@@ -33,6 +34,7 @@ public class EmbeddedEvoMasterController extends EmbeddedSutController {
3334 .withEnv ("POSTGRES_PASSWORD" , POSTGRES_PASSWORD )
3435 .withEnv ("POSTGRES_HOST_AUTH_METHOD" , "trust" ) //to allow all connections without a password
3536 .withEnv ("POSTGRES_DB" , "familiebasak" )
37+ .withTmpFs (Collections .singletonMap ("/var/lib/postgresql/data" , "rw" ))
3638 .withExposedPorts (POSTGRES_PORT );
3739
3840 private ConfigurableApplicationContext ctx ;
@@ -63,7 +65,7 @@ public static void main(String[] args) {
6365
6466 @ Override
6567 public boolean isSutRunning () {
66- return ctx .isRunning ();
68+ return ctx != null && ctx .isRunning ();
6769 }
6870
6971 @ Override
@@ -73,13 +75,14 @@ public String getPackagePrefixesToCover() {
7375
7476 @ Override
7577 public List <AuthenticationDto > getInfoForAuthentication () {
78+ //TODO seems like it uses auth
7679 return null ;
7780 }
7881
7982 @ Override
8083 public ProblemInfo getProblemInfo () {
8184 return new RestProblem (
82- "http://localhost:" + getSutPort () + "/assets/swagger.json " ,
85+ "http://localhost:" + getSutPort () + "/v3/api-docs " ,
8386 null
8487 );
8588 }
@@ -95,8 +98,16 @@ public String startSut() {
9598
9699 String postgresURL = "jdbc:postgresql://" + postgresContainer .getHost () + ":" + postgresContainer .getMappedPort (POSTGRES_PORT ) + "/familiebasak" ;
97100
101+ //TODO should go through all the environment variables in application properties
102+ System .setProperty ("AZUREAD_TOKEN_ENDPOINT_URL" ,"http://foo" );
103+ System .setProperty ("AZURE_OPENID_CONFIG_TOKEN_ENDPOINT" ,"bar" );
104+ System .setProperty ("AZURE_APP_CLIENT_ID" ,"bar" );
105+ System .setProperty ("NAIS_APP_NAME" ,"bar" );
106+ System .setProperty ("UNLEASH_SERVER_API_URL" ,"http://bar" );
107+ System .setProperty ("UNLEASH_SERVER_API_TOKEN" ,"bar" );
98108
99- ctx = SpringApplication .run (ApplicationKt .class , new String []{
109+
110+ ctx = SpringApplication .run (no .nav .familie .ba .sak .FamilieBaSakApplication .class , new String []{
100111 "--server.port=0" ,
101112 "--spring.profiles.active=dev" ,
102113 "--management.server.port=-1" ,
@@ -106,12 +117,15 @@ public String startSut() {
106117 "--spring.datasource.password=" + POSTGRES_PASSWORD ,
107118 "--sentry.logging.enabled=false" ,
108119 "--sentry.environment=local" ,
120+ //TODO check when dealing with Kafka
109121 "--funksjonsbrytere.kafka.producer.enabled=false" ,
110122 "--funksjonsbrytere.enabled=false" ,
111123 "--logging.level.root=OFF" ,
112- "--logback.configurationFile=src/main/resources/logback.xml" ,
113- "--logging.level.org.springframework=OFF" ,
114- "--spring.main.web-application-type=none"
124+ "--logging.config=classpath:logback.xml" ,
125+ //"--logback.configurationFile=src/main/resources/logback.xml",
126+ "--logging.level.org.springframework=INFO" ,
127+ //"--API_SCOPE=api://AZURE_APP_CLIENT_ID/.default"
128+ // "--spring.main.web-application-type=none"
115129 });
116130
117131
@@ -126,8 +140,10 @@ public String startSut() {
126140 }
127141 }
128142
129- JdbcTemplate jdbc = ctx .getBean (JdbcTemplate .class );try {
130- sqlConnection = jdbc .getDataSource ().getConnection ();
143+ //JdbcTemplate jdbc = ctx.getBean(JdbcTemplate.class);
144+ try {
145+ sqlConnection = DriverManager .getConnection (postgresURL , "postgres" , POSTGRES_PASSWORD );
146+ //jdbc.getDataSource().getConnection();
131147 } catch (SQLException e ) {
132148 throw new RuntimeException (e );
133149 }
@@ -138,6 +154,7 @@ public String startSut() {
138154 }
139155
140156 protected int getSutPort () {
157+ // return ctx.getEnvironment().getProperty("server.port", Integer.class);
141158 return (Integer ) ((Map ) ctx .getEnvironment ()
142159 .getPropertySources ().get ("server.ports" ).getSource ())
143160 .get ("local.server.port" );
@@ -146,12 +163,12 @@ protected int getSutPort() {
146163 @ Override
147164 public void stopSut () {
148165 postgresContainer .stop ();
149- ctx .stop ();
166+ if ( ctx != null ) ctx .stop ();
150167 }
151168
152169 @ Override
153170 public void resetStateOfSUT () {
154- DbCleaner .clearDatabase (sqlConnection , List .of (), DatabaseType .POSTGRES );
171+ // DbCleaner.clearDatabase(sqlConnection, List.of(), DatabaseType.POSTGRES);
155172 }
156173
157174 @ Override
0 commit comments