diff --git a/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/ApplicationIntegrationTest.java b/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/ApplicationIntegrationTest.java index c58cd48f0..49d14c6ea 100644 --- a/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/ApplicationIntegrationTest.java +++ b/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/ApplicationIntegrationTest.java @@ -1,7 +1,5 @@ package com.example.graphql; -import static org.assertj.core.api.Assertions.assertThat; - import com.example.graphql.common.AbstractIntegrationTest; import com.example.graphql.dtos.Customer; import com.example.graphql.dtos.CustomerDTO; @@ -17,11 +15,6 @@ class ApplicationIntegrationTest extends AbstractIntegrationTest { @Autowired private GraphQlTester graphQlTester; - @Test - void contextLoads() { - assertThat(postgreSQLContainer.isRunning()).isTrue(); - } - @Test void test_query_all_customers() { this.graphQlTester diff --git a/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/TestApplication.java b/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/TestApplication.java new file mode 100644 index 000000000..8d52a61d3 --- /dev/null +++ b/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/TestApplication.java @@ -0,0 +1,21 @@ +package com.example.graphql; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.context.annotation.Bean; +import org.testcontainers.containers.PostgreSQLContainer; + +@TestConfiguration(proxyBeanMethods = false) +public class TestApplication { + + @Bean + @ServiceConnection + PostgreSQLContainer postgreSQLContainer() { + return new PostgreSQLContainer<>("postgres:16.1-alpine"); + } + + public static void main(String[] args) { + SpringApplication.from(Application::main).with(TestApplication.class).run(args); + } +} diff --git a/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/common/AbstractIntegrationTest.java b/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/common/AbstractIntegrationTest.java index af2c22740..3f1e3b09a 100644 --- a/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/common/AbstractIntegrationTest.java +++ b/graphql/boot-graphql-webflux/src/test/java/com/example/graphql/common/AbstractIntegrationTest.java @@ -1,27 +1,17 @@ package com.example.graphql.common; -import static com.example.graphql.utils.AppConstants.PROFILE_IT; import static com.example.graphql.utils.AppConstants.PROFILE_TEST; +import com.example.graphql.TestApplication; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.test.context.ActiveProfiles; -import org.testcontainers.containers.PostgreSQLContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; -@ActiveProfiles({PROFILE_TEST, PROFILE_IT}) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@Testcontainers(disabledWithoutDocker = true) +@ActiveProfiles({PROFILE_TEST}) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TestApplication.class) public abstract class AbstractIntegrationTest { @Autowired protected ObjectMapper objectMapper; - - @Container - @ServiceConnection - protected static final PostgreSQLContainer postgreSQLContainer = - new PostgreSQLContainer<>("postgres:16.1-alpine"); }