24
24
import org .junit .jupiter .params .provider .Arguments ;
25
25
import org .junit .jupiter .params .provider .MethodSource ;
26
26
27
- import org .springframework .core .annotation .AnnotationUtils ;
28
27
import org .springframework .test .context .ContextConfiguration ;
29
- import org .springframework .test .context .ContextLoader ;
28
+ import org .springframework .test .context .ContextConfigurationAttributes ;
29
+ import org .springframework .test .context .SmartContextLoader ;
30
30
import org .springframework .util .ObjectUtils ;
31
31
32
32
import static org .assertj .core .api .Assertions .assertThat ;
35
35
36
36
/**
37
37
* Unit test which verifies proper
38
- * {@link ContextLoader#processLocations(Class, String...) processing} of
38
+ * {@linkplain SmartContextLoader#processContextConfiguration processing} of
39
39
* {@code resource locations} by a {@link GenericXmlContextLoader}
40
40
* configured via {@link ContextConfiguration @ContextConfiguration}.
41
41
* Specifically, this test addresses the issues raised in <a
@@ -55,10 +55,12 @@ class GenericXmlContextLoaderResourceLocationsTests {
55
55
@ MethodSource ("contextConfigurationLocationsData" )
56
56
void assertContextConfigurationLocations (Class <?> testClass , String [] expectedLocations ) throws Exception {
57
57
ContextConfiguration contextConfig = testClass .getAnnotation (ContextConfiguration .class );
58
- ContextLoader contextLoader = new GenericXmlContextLoader ();
59
- String [] configuredLocations = (String []) AnnotationUtils .getValue (contextConfig );
60
- @ SuppressWarnings ("deprecation" )
61
- String [] processedLocations = contextLoader .processLocations (testClass , configuredLocations );
58
+ String [] configuredLocations = contextConfig .value ();
59
+ ContextConfigurationAttributes configAttributes =
60
+ new ContextConfigurationAttributes (testClass , configuredLocations , null , false , null , false , GenericXmlContextLoader .class );
61
+ GenericXmlContextLoader contextLoader = new GenericXmlContextLoader ();
62
+ contextLoader .processContextConfiguration (configAttributes );
63
+ String [] processedLocations = configAttributes .getLocations ();
62
64
63
65
if (logger .isDebugEnabled ()) {
64
66
logger .debug ("----------------------------------------------------------------------" );
@@ -67,7 +69,8 @@ void assertContextConfigurationLocations(Class<?> testClass, String[] expectedLo
67
69
logger .debug ("Processed locations: " + ObjectUtils .nullSafeToString (processedLocations ));
68
70
}
69
71
70
- assertThat (processedLocations ).as ("Verifying locations for test [" + testClass + "]." ).isEqualTo (expectedLocations );
72
+ assertThat (processedLocations ).as ("locations for test class [" + testClass .getName () + "]" )
73
+ .isEqualTo (expectedLocations );
71
74
}
72
75
73
76
static Stream <Arguments > contextConfigurationLocationsData () {
0 commit comments