32
32
import static org .assertj .core .api .Assertions .assertThatIllegalStateException ;
33
33
34
34
/**
35
- * Tests for {@link AotContextLoader }.
35
+ * Tests for {@link AotTestMappings }.
36
36
*
37
37
* @author Stephane Nicoll
38
38
* @author Sam Brannen
39
39
*/
40
- class AotContextLoaderTests {
40
+ class AotTestMappingsTests {
41
41
42
42
@ Test
43
43
void loadWithClassNameFindsMatchingContextLoader () {
44
- AotContextLoader aotContextLoader = new AotContextLoader (TestMapping .class .getName ());
45
- assertThat (aotContextLoader .getContextLoader (AotContextLoaderTests .class ))
44
+ AotTestMappings aotTestMappings = new AotTestMappings (TestMapping .class .getName ());
45
+ assertThat (aotTestMappings .getContextLoader (AotTestMappingsTests .class ))
46
46
.isInstanceOf (AotSpringBootConfigContextLoader .class );
47
47
}
48
48
49
49
@ Test
50
50
void loadWithClassNameReturnsNullContextLoaderForUnregisteredTest () {
51
- AotContextLoader aotContextLoader = new AotContextLoader (TestMapping .class .getName ());
52
- assertThat (aotContextLoader .getContextLoader (Map .class )).isNull ();
51
+ AotTestMappings aotTestMappings = new AotTestMappings (TestMapping .class .getName ());
52
+ assertThat (aotTestMappings .getContextLoader (Map .class )).isNull ();
53
53
}
54
54
55
55
@ Test
56
56
void loadWithClassNameFindsMatchingContextInitializerClass () {
57
- AotContextLoader aotContextLoader = new AotContextLoader (TestMapping .class .getName ());
58
- assertThat (aotContextLoader .getContextInitializerClass (AotContextLoaderTests .class ))
57
+ AotTestMappings aotTestMappings = new AotTestMappings (TestMapping .class .getName ());
58
+ assertThat (aotTestMappings .getContextInitializerClass (AotTestMappingsTests .class ))
59
59
.isEqualTo (TestApplicationContextInitializer .class );
60
60
}
61
61
62
62
@ Test
63
63
void loadWithClassNameReturnsNullContextInitializerClassForUnregisteredTest () {
64
- AotContextLoader aotContextLoader = new AotContextLoader (TestMapping .class .getName ());
65
- assertThat (aotContextLoader .getContextInitializerClass (Map .class )).isNull ();
64
+ AotTestMappings aotTestMappings = new AotTestMappings (TestMapping .class .getName ());
65
+ assertThat (aotTestMappings .getContextInitializerClass (Map .class )).isNull ();
66
66
}
67
67
68
68
@ Test
69
69
void loadWithClassNameWithoutContextLoadersMethod () {
70
- assertThatIllegalStateException ().isThrownBy (() -> new AotContextLoader (Map .class .getName ()))
70
+ assertThatIllegalStateException ().isThrownBy (() -> new AotTestMappings (Map .class .getName ()))
71
71
.withMessage ("No getContextLoaders() method found on java.util.Map" );
72
72
}
73
73
74
74
@ Test
75
75
void loadWithClassNameWithoutContextInitializersMethod () {
76
76
String className = HalfBakedTestMapping .class .getName ();
77
- assertThatIllegalStateException ().isThrownBy (() -> new AotContextLoader (className ))
77
+ assertThatIllegalStateException ().isThrownBy (() -> new AotTestMappings (className ))
78
78
.withMessage ("No getContextInitializers() method found on " + className );
79
79
}
80
80
81
81
@ Test
82
82
void loadWithClassNameThatDoesNotExist () {
83
83
String className = "com.example.DoesNotExist" ;
84
- assertThatIllegalStateException ().isThrownBy (() -> new AotContextLoader (className ))
84
+ assertThatIllegalStateException ().isThrownBy (() -> new AotTestMappings (className ))
85
85
.withMessageMatching ("Failed to load .+ method in " + Pattern .quote (className ))
86
86
.withCauseInstanceOf (ClassNotFoundException .class );
87
87
}
@@ -91,14 +91,14 @@ public static class TestMapping {
91
91
92
92
public static Map <String , Supplier <SmartContextLoader >> getContextLoaders () {
93
93
Map <String , Supplier <SmartContextLoader >> entries = new HashMap <>();
94
- entries .put (AotContextLoaderTests .class .getName (), () -> new AotSpringBootConfigContextLoader (TestApplicationContextInitializer .class ));
94
+ entries .put (AotTestMappingsTests .class .getName (), () -> new AotSpringBootConfigContextLoader (TestApplicationContextInitializer .class ));
95
95
entries .put ("com.example.SampleTests" , () -> new AotSpringBootConfigContextLoader (TestApplicationContextInitializer .class ));
96
96
return entries ;
97
97
}
98
98
99
99
public static Map <String , Class <? extends ApplicationContextInitializer <?>>> getContextInitializers () {
100
100
Map <String , Class <? extends ApplicationContextInitializer <?>>> map = new HashMap <>();
101
- map .put (AotContextLoaderTests .class .getName (), TestApplicationContextInitializer .class );
101
+ map .put (AotTestMappingsTests .class .getName (), TestApplicationContextInitializer .class );
102
102
map .put ("com.example.SampleTests" , TestApplicationContextInitializer .class );
103
103
return map ;
104
104
}
0 commit comments