Closed
Description
Janne Valkealahti opened SPR-11641 and commented
I have below classes in my tests. This used to work with 4.0.2 but now fails with 4.0.3. I don't know if this is somehow related to work for #16081 and other jira's linked to it.
@RunWith(SpringJUnit4ClassRunner.class)
@CustomMiniYarnClusterTest
public class ComposedAnnotationTests {
@Autowired
private ApplicationContext ctx;
@Resource(name = "yarnConfiguration")
Configuration configuration;
@Test
public void testLoaderAndConfig() {
assertNotNull(ctx);
assertTrue(ctx.containsBean("yarnCluster"));
assertTrue(ctx.containsBean("yarnConfiguration"));
assertTrue(ctx.containsBean("myCustomBean"));
Configuration config = (Configuration) ctx.getBean("yarnConfiguration");
assertNotNull(config);
}
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@ContextConfiguration(loader=YarnDelegatingSmartContextLoader.class)
@MiniYarnCluster
public @interface CustomMiniYarnClusterTest {
@Configuration
public static class Config {
@Bean
public String myCustomBean() {
return "myCustomBean";
}
}
}
This fails with message:
java.lang.IllegalStateException: Neither YarnClusterInjectingXmlContextLoader nor YarnClusterInjectingAnnotationConfigContextLoader was able to detect defaults, and no ApplicationContextInitializers were declared for context configuration [ContextConfigurationAttributes@2eedd06a declaringClass = 'org.springframework.yarn.test.context.YarnClusterInjectingMiniYarnClusterTestContextLoaderTests', locations = '{}', classes = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.yarn.test.context.YarnDelegatingSmartContextLoader']
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.processContextConfiguration(AbstractDelegatingSmartContextLoader.java:200)
at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:703)
at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:656)
at org.springframework.test.context.DefaultTestContext.<init>(DefaultTestContext.java:93)
at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:119)
Affects: 4.0.3
Issue Links:
- ContextLoader is supplied composed annotation class instead of test class for default resource detection [SPR-11455] #16081 ContextLoader is supplied composed annotation class instead of test class for default resource detection
Referenced from: commits spring-attic/spring-hadoop@0ef5c92