Search in sources :

Example 1 with ContextLoader

use of cn.taketoday.test.context.ContextLoader in project today-infrastructure by TAKETODAY.

the class GenericXmlContextLoaderResourceLocationsTests method assertContextConfigurationLocations.

@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("contextConfigurationLocationsData")
void assertContextConfigurationLocations(Class<?> testClass, String[] expectedLocations) throws Exception {
    ContextConfiguration contextConfig = testClass.getAnnotation(ContextConfiguration.class);
    ContextLoader contextLoader = new GenericXmlContextLoader();
    String[] configuredLocations = (String[]) AnnotationUtils.getValue(contextConfig);
    String[] processedLocations = contextLoader.processLocations(testClass, configuredLocations);
    if (logger.isDebugEnabled()) {
        logger.debug("----------------------------------------------------------------------");
        logger.debug("Configured locations: " + ObjectUtils.nullSafeToString(configuredLocations));
        logger.debug("Expected   locations: " + ObjectUtils.nullSafeToString(expectedLocations));
        logger.debug("Processed  locations: " + ObjectUtils.nullSafeToString(processedLocations));
    }
    assertThat(processedLocations).as("Verifying locations for test [" + testClass + "].").isEqualTo(expectedLocations);
}
Also used : ContextLoader(cn.taketoday.test.context.ContextLoader) ContextConfiguration(cn.taketoday.test.context.ContextConfiguration) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with ContextLoader

use of cn.taketoday.test.context.ContextLoader in project today-framework by TAKETODAY.

the class GenericXmlContextLoaderResourceLocationsTests method assertContextConfigurationLocations.

@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("contextConfigurationLocationsData")
void assertContextConfigurationLocations(Class<?> testClass, String[] expectedLocations) throws Exception {
    ContextConfiguration contextConfig = testClass.getAnnotation(ContextConfiguration.class);
    ContextLoader contextLoader = new GenericXmlContextLoader();
    String[] configuredLocations = (String[]) AnnotationUtils.getValue(contextConfig);
    String[] processedLocations = contextLoader.processLocations(testClass, configuredLocations);
    if (logger.isDebugEnabled()) {
        logger.debug("----------------------------------------------------------------------");
        logger.debug("Configured locations: " + ObjectUtils.nullSafeToString(configuredLocations));
        logger.debug("Expected   locations: " + ObjectUtils.nullSafeToString(expectedLocations));
        logger.debug("Processed  locations: " + ObjectUtils.nullSafeToString(processedLocations));
    }
    assertThat(processedLocations).as("Verifying locations for test [" + testClass + "].").isEqualTo(expectedLocations);
}
Also used : ContextLoader(cn.taketoday.test.context.ContextLoader) ContextConfiguration(cn.taketoday.test.context.ContextConfiguration) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ContextConfiguration (cn.taketoday.test.context.ContextConfiguration)2 ContextLoader (cn.taketoday.test.context.ContextLoader)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2