Skip to content

Commit ed74b04

Browse files
committed
Move web-related test for BeanUtilsRuntimeHints to spring-web
The dependency on spring-web from spring-beans makes it impossible to import the projects in Eclipse IDE due to cycles between projects. This commit therefore moves the web-related test for BeanUtilsRuntimeHints to spring-web. See gh-30491
1 parent 6cfb11a commit ed74b04

File tree

3 files changed

+60
-12
lines changed

3 files changed

+60
-12
lines changed

spring-beans/spring-beans.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ dependencies {
1212
testImplementation(testFixtures(project(":spring-core")))
1313
testImplementation(project(":spring-core-test"))
1414
testImplementation("jakarta.annotation:jakarta.annotation-api")
15-
testImplementation(project(":spring-web"))
1615
testFixturesApi("org.junit.jupiter:junit-jupiter-api")
1716
testFixturesImplementation("org.assertj:assertj-core")
1817
}

spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
2626
import org.springframework.core.io.ResourceEditor;
2727
import org.springframework.core.io.support.SpringFactoriesLoader;
28-
import org.springframework.http.MediaTypeEditor;
2928
import org.springframework.util.ClassUtils;
3029

3130
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,23 +33,18 @@
3433
* Tests for {@link BeanUtilsRuntimeHints}.
3534
*
3635
* @author Sebastien Deleuze
36+
* @since 6.0.10
37+
* @see org.springframework.http.WebBeanUtilsRuntimeHintsTests
3738
*/
3839
class BeanUtilsRuntimeHintsTests {
3940

40-
private RuntimeHints hints;
41+
private final RuntimeHints hints = new RuntimeHints();
4142

4243
@BeforeEach
4344
void setup() {
44-
this.hints = new RuntimeHints();
4545
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
46-
.load(RuntimeHintsRegistrar.class).forEach(registrar -> registrar
47-
.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
48-
}
49-
50-
@Test
51-
void mediaTypeEditorHasHints() {
52-
assertThat(RuntimeHintsPredicates.reflection().onType(MediaTypeEditor.class)
53-
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints);
46+
.load(RuntimeHintsRegistrar.class)
47+
.forEach(registrar -> registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
5448
}
5549

5650
@Test
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2002-2023 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.http;
18+
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
21+
22+
import org.springframework.aot.hint.MemberCategory;
23+
import org.springframework.aot.hint.RuntimeHints;
24+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
25+
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
26+
import org.springframework.core.io.support.SpringFactoriesLoader;
27+
import org.springframework.util.ClassUtils;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
31+
/**
32+
* Web-related tests for {@link BeanUtilsRuntimeHints}.
33+
*
34+
* @author Sebastien Deleuze
35+
* @since 6.0.10
36+
* @see org.springframework.beans.BeanUtilsRuntimeHintsTests
37+
*/
38+
class WebBeanUtilsRuntimeHintsTests {
39+
40+
private final RuntimeHints hints = new RuntimeHints();
41+
42+
@BeforeEach
43+
void setup() {
44+
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
45+
.load(RuntimeHintsRegistrar.class)
46+
.forEach(registrar -> registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
47+
}
48+
49+
@Test
50+
void mediaTypeEditorHasHints() {
51+
assertThat(RuntimeHintsPredicates.reflection().onType(MediaTypeEditor.class)
52+
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints);
53+
}
54+
55+
}

0 commit comments

Comments
 (0)