Search in sources :

Example 6 with ContextConfigurationAttributes

use of org.springframework.test.context.ContextConfigurationAttributes in project spring-framework by spring-projects.

the class DelegatingSmartContextLoaderTests method processContextConfigurationWithConfigurationClass.

@Test
public void processContextConfigurationWithConfigurationClass() {
    Class<?>[] classes = new Class<?>[] { getClass() };
    ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(getClass(), EMPTY_STRING_ARRAY, classes, true, null, true, ContextLoader.class);
    loader.processContextConfiguration(configAttributes);
    assertArrayEquals(classes, configAttributes.getClasses());
    assertEmpty(configAttributes.getLocations());
}
Also used : ContextConfigurationAttributes(org.springframework.test.context.ContextConfigurationAttributes) Test(org.junit.Test)

Example 7 with ContextConfigurationAttributes

use of org.springframework.test.context.ContextConfigurationAttributes in project spring-framework by spring-projects.

the class DelegatingSmartContextLoaderTests method processContextConfigurationWithDefaultXmlConfigGeneration.

// --- SmartContextLoader - processContextConfiguration() ------------------
@Test
public void processContextConfigurationWithDefaultXmlConfigGeneration() {
    ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(XmlTestCase.class, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
    loader.processContextConfiguration(configAttributes);
    assertEquals(1, configAttributes.getLocations().length);
    assertEmpty(configAttributes.getClasses());
}
Also used : ContextConfigurationAttributes(org.springframework.test.context.ContextConfigurationAttributes) Test(org.junit.Test)

Example 8 with ContextConfigurationAttributes

use of org.springframework.test.context.ContextConfigurationAttributes in project spring-framework by spring-projects.

the class DelegatingSmartContextLoaderTests method processContextConfigurationWithDefaultXmlConfigAndConfigurationClassGeneration.

@Test
public void processContextConfigurationWithDefaultXmlConfigAndConfigurationClassGeneration() {
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage(containsString("both default locations AND default configuration classes were detected"));
    ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(ImproperDuplicateDefaultXmlAndConfigClassTestCase.class, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
    loader.processContextConfiguration(configAttributes);
}
Also used : ContextConfigurationAttributes(org.springframework.test.context.ContextConfigurationAttributes) Test(org.junit.Test)

Example 9 with ContextConfigurationAttributes

use of org.springframework.test.context.ContextConfigurationAttributes in project spring-framework by spring-projects.

the class DelegatingSmartContextLoaderTests method processContextConfigurationWithDefaultConfigurationClassGeneration.

@Test
public void processContextConfigurationWithDefaultConfigurationClassGeneration() {
    ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(ConfigClassTestCase.class, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
    loader.processContextConfiguration(configAttributes);
    assertEquals(1, configAttributes.getClasses().length);
    assertEmpty(configAttributes.getLocations());
}
Also used : ContextConfigurationAttributes(org.springframework.test.context.ContextConfigurationAttributes) Test(org.junit.Test)

Example 10 with ContextConfigurationAttributes

use of org.springframework.test.context.ContextConfigurationAttributes in project spring-framework by spring-projects.

the class AbstractTestContextBootstrapper method buildDefaultMergedContextConfiguration.

private MergedContextConfiguration buildDefaultMergedContextConfiguration(Class<?> testClass, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate) {
    List<ContextConfigurationAttributes> defaultConfigAttributesList = Collections.singletonList(new ContextConfigurationAttributes(testClass));
    ContextLoader contextLoader = resolveContextLoader(testClass, defaultConfigAttributesList);
    if (logger.isInfoEnabled()) {
        logger.info(String.format("Neither @ContextConfiguration nor @ContextHierarchy found for test class [%s], using %s", testClass.getName(), contextLoader.getClass().getSimpleName()));
    }
    return buildMergedContextConfiguration(testClass, defaultConfigAttributesList, null, cacheAwareContextLoaderDelegate, false);
}
Also used : ContextConfigurationAttributes(org.springframework.test.context.ContextConfigurationAttributes) SmartContextLoader(org.springframework.test.context.SmartContextLoader) ContextLoader(org.springframework.test.context.ContextLoader)

Aggregations

ContextConfigurationAttributes (org.springframework.test.context.ContextConfigurationAttributes)12 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 HashSet (java.util.HashSet)2 ContextConfiguration (org.springframework.test.context.ContextConfiguration)2 ContextHierarchy (org.springframework.test.context.ContextHierarchy)2 ContextLoader (org.springframework.test.context.ContextLoader)2 MergedContextConfiguration (org.springframework.test.context.MergedContextConfiguration)2 SmartContextLoader (org.springframework.test.context.SmartContextLoader)2 LinkedHashMap (java.util.LinkedHashMap)1 ApplicationContextInitializer (org.springframework.context.ApplicationContextInitializer)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 CacheAwareContextLoaderDelegate (org.springframework.test.context.CacheAwareContextLoaderDelegate)1 ContextCustomizer (org.springframework.test.context.ContextCustomizer)1