Skip to content

Commit 31a6e98

Browse files
committed
Introduce @⁠Disabled AOT tests for @⁠TestBean support
See gh-32933
1 parent d3755ab commit 31a6e98

File tree

3 files changed

+74
-4
lines changed

3 files changed

+74
-4
lines changed

spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,25 @@ void endToEndTestsForEntireSpringTestModule() {
145145
runEndToEndTests(testClasses, false);
146146
}
147147

148+
@Disabled("Comment out to run @TestBean integration tests in AOT mode")
149+
@Test
150+
void endToEndTestsForTestBeanOverrideTestClasses() {
151+
List<Class<?>> testClasses = List.of(
152+
org.springframework.test.context.aot.samples.bean.override.convention.TestBeanJupiterTests.class,
153+
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.class,
154+
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.TestBeanFieldInEnclosingClassTests.class,
155+
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.TestBeanFieldInEnclosingClassTests.TestBeanFieldInEnclosingClassLevel2Tests.class,
156+
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.TestBeanFactoryMethodInEnclosingClassTests.class,
157+
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.TestBeanFactoryMethodInEnclosingClassTests.TestBeanFactoryMethodInEnclosingClassLevel2Tests.class
158+
);
159+
160+
runEndToEndTests(testClasses, true);
161+
}
162+
148163
@Disabled("Comment out to run selected integration tests in AOT mode")
149164
@Test
150165
void endToEndTestsForSelectedTestClasses() {
151166
List<Class<?>> testClasses = List.of(
152-
org.springframework.test.context.bean.override.convention.TestBeanForByNameLookupIntegrationTests.class,
153167
org.springframework.test.context.bean.override.mockito.MockitoBeanForByNameLookupIntegrationTests.class,
154168
org.springframework.test.context.junit4.SpringJUnit4ClassRunnerAppCtxTests.class,
155169
org.springframework.test.context.junit4.ParameterizedDependencyInjectionTests.class
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.test.context.aot.samples.bean.override.convention;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import org.springframework.context.annotation.Bean;
22+
import org.springframework.context.annotation.Configuration;
23+
import org.springframework.test.context.bean.override.convention.TestBean;
24+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
25+
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
28+
/**
29+
* @author Sam Brannen
30+
* @since 6.2
31+
*/
32+
@SpringJUnitConfig
33+
public class TestBeanJupiterTests {
34+
35+
@TestBean
36+
String magicBean;
37+
38+
static String magicBean() {
39+
return "enigma-override";
40+
}
41+
42+
@Test
43+
void tests() {
44+
assertThat(magicBean).isEqualTo("enigma-override");
45+
}
46+
47+
@Configuration(proxyBeanMethods = false)
48+
static class Config {
49+
50+
@Bean
51+
String magicBean() {
52+
return "enigma";
53+
}
54+
}
55+
56+
}

spring-test/src/test/java/org/springframework/test/context/bean/override/convention/TestBeanForByNameLookupIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void fieldWithMethodNameHasOverride(ApplicationContext ctx) {
106106

107107
@Nested
108108
@DisplayName("With @TestBean in the enclosing class of the enclosing class")
109-
class TestBeanFieldInEnclosingClassLevel2Tests {
109+
public class TestBeanFieldInEnclosingClassLevel2Tests {
110110

111111
@Test
112112
void fieldHasOverride(ApplicationContext ctx) {
@@ -130,7 +130,7 @@ void fieldWithMethodNameHasOverride(ApplicationContext ctx) {
130130

131131
@Nested
132132
@DisplayName("With factory method in enclosing class")
133-
class TestBeanFactoryMethodInEnclosingClassTests {
133+
public class TestBeanFactoryMethodInEnclosingClassTests {
134134

135135
@TestBean(methodName = "nestedField", name = "nestedField")
136136
String nestedField2;
@@ -143,7 +143,7 @@ void fieldHasOverride(ApplicationContext ctx) {
143143

144144
@Nested
145145
@DisplayName("With factory method in the enclosing class of the enclosing class")
146-
class TestBeanFactoryMethodInEnclosingClassLevel2Tests {
146+
public class TestBeanFactoryMethodInEnclosingClassLevel2Tests {
147147

148148
@TestBean(methodName = "nestedField", name = "nestedField")
149149
String nestedField2;

0 commit comments

Comments
 (0)