From 9a991c95e72a68fa0fdec4bea757013482ef6a7f Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 28 Jan 2025 07:17:38 +0100 Subject: [PATCH] fix profile for other tests --- .../config/CasAuthenticationFilterIntegrationTest.java | 1 + .../migration/LiquibaseCompatibilityIntegrationTest.java | 8 ++++---- .../hsadminng/hs/migration/LiquibaseConfig.java | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java index eb00cf33..5c918943 100644 --- a/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java @@ -17,6 +17,7 @@ import static net.hostsharing.hsadminng.config.HttpHeadersBuilder.headers; import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; import static com.github.tomakehurst.wiremock.client.WireMock.*; + @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestPropertySource(properties = {"server.port=0", "hsadminng.cas.server=http://localhost:8088/cas"}) @ActiveProfiles("wiremock") // IMPORTANT: To test prod config, do not use test profile! diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java index ddfcd7b5..edffb33a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java @@ -74,14 +74,14 @@ import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TE @DataJpaTest(properties = { "spring.liquibase.enabled=false" // @Sql should go first, Liquibase will be initialized programmatically }) -@ActiveProfiles("only-office") +@ActiveProfiles({"only-office", "liquibase-migration-test"}) @TestPropertySource(properties = "spring.liquibase.contexts=only-office") @DirtiesContext @Import({ Context.class, JpaAttempt.class, LiquibaseConfig.class }) @Sql(value = "/db/prod-only-office-schema-with-test-data.sql", executionPhase = BEFORE_TEST_CLASS) public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport { - private static final String EXPECTED_CHANGESET = "hs-hosting-SCHEMA"; + private static final String EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION = "hs-hosting-SCHEMA"; private static int initialChangeSetCount = 0; @Autowired @@ -100,7 +100,7 @@ public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport { void test() { final var liquibaseScripts = singleColumnSqlQuery("SELECT id FROM public.databasechangelog"); assertThat(liquibaseScripts).hasSizeGreaterThan(initialChangeSetCount); - assertThat(liquibaseScripts).contains(EXPECTED_CHANGESET); + assertThat(liquibaseScripts).contains(EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION); } private void assertThatDatabaseIsInitialized() { @@ -109,7 +109,7 @@ public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport { final var liquibaseScripts = singleColumnSqlQuery("SELECT * FROM public.databasechangelog"); assertThat(liquibaseScripts).hasSizeGreaterThan(285); - assertThat(liquibaseScripts).doesNotContain(EXPECTED_CHANGESET); + assertThat(liquibaseScripts).doesNotContain(EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION); initialChangeSetCount = liquibaseScripts.size(); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseConfig.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseConfig.java index 91aeb70a..d788f644 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseConfig.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseConfig.java @@ -6,10 +6,12 @@ import liquibase.database.jvm.JdbcConnection; import liquibase.resource.ClassLoaderResourceAccessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import javax.sql.DataSource; @Configuration +@Profile("liquibase-migration-test") public class LiquibaseConfig { @Bean