From 11dac204b2db267490ca1e4388817976241a38a0 Mon Sep 17 00:00:00 2001 From: hsw Date: Thu, 30 Nov 2023 21:00:55 +0900 Subject: [PATCH] Fix processTestAot Related to spring-projects/spring-boot#36997 --- .../apiserver/infra/ApiInfraLayerTest.java | 19 ++----------------- .../study/apiserver/ApiApplicationTests.kt | 2 ++ .../repository/PersonRepositoryTest.kt | 8 ++------ 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/spring-webflux-api/src/test/java/io/syscall/hsw/study/apiserver/infra/ApiInfraLayerTest.java b/spring-webflux-api/src/test/java/io/syscall/hsw/study/apiserver/infra/ApiInfraLayerTest.java index 18fbf7d..ea2c321 100644 --- a/spring-webflux-api/src/test/java/io/syscall/hsw/study/apiserver/infra/ApiInfraLayerTest.java +++ b/spring-webflux-api/src/test/java/io/syscall/hsw/study/apiserver/infra/ApiInfraLayerTest.java @@ -1,26 +1,11 @@ package io.syscall.hsw.study.apiserver.infra; +import io.syscall.hsw.study.apiserver.ApiApplicationTests; import org.junit.jupiter.api.TestInstance; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.availability.ApplicationAvailabilityAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; -import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebFlux; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTypeExcludeFilter; -import org.springframework.boot.test.context.SpringBootTest; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@SpringBootTest(classes = ApiInfraLayerTest.Config.class) -@OverrideAutoConfiguration(enabled = false) -@TypeExcludeFilters(WebFluxTypeExcludeFilter.class) -@AutoConfigureJson -@AutoConfigureWebFlux -@AutoConfigureWebTestClient -@ImportAutoConfiguration(ApplicationAvailabilityAutoConfiguration.class) -public abstract class ApiInfraLayerTest { +public abstract class ApiInfraLayerTest extends ApiApplicationTests { @SpringBootApplication static class Config {} diff --git a/spring-webflux-api/src/test/kotlin/io/syscall/hsw/study/apiserver/ApiApplicationTests.kt b/spring-webflux-api/src/test/kotlin/io/syscall/hsw/study/apiserver/ApiApplicationTests.kt index ef150c5..2a652e5 100644 --- a/spring-webflux-api/src/test/kotlin/io/syscall/hsw/study/apiserver/ApiApplicationTests.kt +++ b/spring-webflux-api/src/test/kotlin/io/syscall/hsw/study/apiserver/ApiApplicationTests.kt @@ -2,9 +2,11 @@ package io.syscall.hsw.study.apiserver import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient import org.springframework.boot.test.context.SpringBootTest @SpringBootTest(classes = [ApiApplication::class]) +@AutoConfigureWebTestClient class ApiApplicationTests { @Test diff --git a/spring-webflux-api/src/test/kotlin/io/syscall/hsw/study/apiserver/example/repository/PersonRepositoryTest.kt b/spring-webflux-api/src/test/kotlin/io/syscall/hsw/study/apiserver/example/repository/PersonRepositoryTest.kt index e3e3a32..b328ceb 100644 --- a/spring-webflux-api/src/test/kotlin/io/syscall/hsw/study/apiserver/example/repository/PersonRepositoryTest.kt +++ b/spring-webflux-api/src/test/kotlin/io/syscall/hsw/study/apiserver/example/repository/PersonRepositoryTest.kt @@ -1,18 +1,14 @@ package io.syscall.hsw.study.apiserver.example.repository -import io.syscall.hsw.study.apiserver.ApiApplication +import io.syscall.hsw.study.apiserver.ApiApplicationTests import io.syscall.hsw.study.apiserver.example.entity.PersonEntity import io.syscall.hsw.study.apiserver.example.model.PersonId import jakarta.persistence.EntityManager import org.assertj.core.api.Assertions.assertThat import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest -import org.springframework.test.context.ContextConfiguration import kotlin.test.Test -@DataJpaTest -@ContextConfiguration(classes = [ApiApplication::class]) -class PersonRepositoryTest { +class PersonRepositoryTest : ApiApplicationTests() { @Autowired lateinit var repository: PersonRepository