1616import org .testcontainers .containers .GenericContainer ;
1717
1818import java .sql .Connection ;
19+ import java .sql .DriverManager ;
1920import java .sql .SQLException ;
2021import java .util .Arrays ;
22+ import java .util .Collections ;
2123import java .util .List ;
2224import java .util .Map ;
2325
@@ -33,6 +35,7 @@ public class EmbeddedEvoMasterController extends EmbeddedSutController {
3335 .withEnv ("POSTGRES_PASSWORD" , POSTGRES_PASSWORD )
3436 .withEnv ("POSTGRES_HOST_AUTH_METHOD" , "trust" ) //to allow all connections without a password
3537 .withEnv ("POSTGRES_DB" , "tiltaksgjennomforing" )
38+ .withTmpFs (Collections .singletonMap ("/var/lib/postgresql/data" , "rw" ))
3639 .withExposedPorts (POSTGRES_PORT );
3740
3841 private ConfigurableApplicationContext ctx ;
@@ -62,7 +65,7 @@ public static void main(String[] args) {
6265
6366 @ Override
6467 public boolean isSutRunning () {
65- return ctx .isRunning ();
68+ return ctx != null && ctx .isRunning ();
6669 }
6770
6871 @ Override
@@ -78,7 +81,7 @@ public List<AuthenticationDto> getInfoForAuthentication() {
7881 @ Override
7982 public ProblemInfo getProblemInfo () {
8083 return new RestProblem (
81- "http://localhost:" + getSutPort () + "/assets/swagger.json " ,
84+ "http://localhost:" + getSutPort () + "/v3/api-docs " ,
8285 null
8386 );
8487 }
@@ -94,6 +97,21 @@ public String startSut() {
9497
9598 String postgresURL = "jdbc:postgresql://" + postgresContainer .getHost () + ":" + postgresContainer .getMappedPort (POSTGRES_PORT ) + "/tiltaksgjennomforing" ;
9699
100+
101+ //TODO should go through all the environment variables in application properties
102+ System .setProperty ("KAFKA_BROKERS" ,"KAFKA_BROKERS" );
103+ System .setProperty ("KAFKA_TRUSTSTORE_PATH" ,"KAFKA_TRUSTSTORE_PATH" );
104+ System .setProperty ("KAFKA_CREDSTORE_PASSWORD" ,"KAFKA_CREDSTORE_PASSWORD" );
105+ System .setProperty ("KAFKA_KEYSTORE_PATH" ,"KAFKA_KEYSTORE_PATH" );
106+ System .setProperty ("KAFKA_CREDSTORE_PASSWORD" ,"KAFKA_CREDSTORE_PASSWORD" );
107+ System .setProperty ("KAFKA_SCHEMA_REGISTRY" ,"KAFKA_SCHEMA_REGISTRY" );
108+ System .setProperty ("KAFKA_SCHEMA_REGISTRY_USER" ,"KAFKA_SCHEMA_REGISTRY_USER" );
109+ System .setProperty ("KAFKA_SCHEMA_REGISTRY_PASSWORD" ,"KAFKA_SCHEMA_REGISTRY_PASSWORD" );
110+ System .setProperty ("AZURE_APP_TENANT_ID" ,"AZURE_APP_TENANT_ID" );
111+ System .setProperty ("AZURE_APP_CLIENT_ID" ,"AZURE_APP_CLIENT_ID" );
112+ System .setProperty ("AZURE_APP_CLIENT_SECRET" ,"AZURE_APP_CLIENT_SECRET" );
113+ System .setProperty ("beslutter.ad.gruppe" ,"99ea78dc-db77-44d0-b193-c5dc22f01e1d" );
114+
97115 ctx = SpringApplication .run (TiltaksgjennomforingApplication .class , new String []{
98116 "--server.port=0" ,
99117 "--spring.profiles.active=dev" ,
@@ -105,13 +123,10 @@ public String startSut() {
105123 "--sentry.logging.enabled=false" ,
106124 "--sentry.environment=local" ,
107125 "--logging.level.root=OFF" ,
108- "--logback.configurationFile=src/main/resources/logback.xml" ,
109- "--logging.level.org.springframework=OFF" ,
110- "--spring.main.web-application-type=none"
126+ "--logging.config=classpath:logback-spring.xml" ,
127+ "--logging.level.org.springframework=INFO" ,
111128 });
112129
113- // https://www.baeldung.com/spring-boot-application-context-exception
114- // spring.main.web-application-type=none
115130
116131 if (sqlConnection != null ) {
117132 try {
@@ -121,13 +136,13 @@ public String startSut() {
121136 }
122137 }
123138
124- JdbcTemplate jdbc = ctx .getBean (JdbcTemplate .class );
125139 try {
126- sqlConnection = jdbc . getDataSource (). getConnection ();
140+ sqlConnection = DriverManager . getConnection (postgresURL , "postgres" , POSTGRES_PASSWORD );
127141 } catch (SQLException e ) {
128142 throw new RuntimeException (e );
129143 }
130144
145+
131146 dbSpecification = Arrays .asList (new DbSpecification (DatabaseType .POSTGRES , sqlConnection ));
132147
133148 return "http://localhost:" + getSutPort ();
@@ -142,7 +157,7 @@ protected int getSutPort() {
142157 @ Override
143158 public void stopSut () {
144159 postgresContainer .stop ();
145- ctx .stop ();
160+ if ( ctx != null ) ctx .stop ();
146161 }
147162
148163 @ Override
0 commit comments