下面列出了org.springframework.beans.factory.BeanDefinitionStoreException#getCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* This is factored out to permit use in a unit test.
*
* @param additionalFilePathnames
* @return
*/
public static ApplicationContext getApplicationContext(List<String> additionalFilePathnames) {
BusApplicationContext busApplicationContext = BusFactory.getDefaultBus()
.getExtension(BusApplicationContext.class);
GenericApplicationContext appContext = new GenericApplicationContext(busApplicationContext);
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
List<URL> urls = ClassLoaderUtils.getResources("META-INF/cxf/java2wsbeans.xml",
SpringServiceBuilderFactory.class);
for (URL url : urls) {
reader.loadBeanDefinitions(new UrlResource(url));
}
for (String pathname : additionalFilePathnames) {
try {
reader.loadBeanDefinitions(new FileSystemResource(pathname));
} catch (BeanDefinitionStoreException bdse) {
throw new ToolException("Unable to open bean definition file " + pathname, bdse.getCause());
}
}
appContext.refresh();
return appContext;
}
@Test
public void unknownExceptionClass() throws Exception {
beansXml = "<breeze:topology id='t1'>" +
"<breeze:spout id='s1' beanType='eu.icolumbo.breeze.TestBean' signature='ping()' outputFields='feed'>" +
" <breeze:exception type='com.example.DoesNotExist' delay='2000'/>" +
"</breeze:spout>" +
"</breeze:topology>";
try {
refresh();
fail("no exception");
} catch (BeanDefinitionStoreException e) {
Throwable cause = e.getCause();
assertNotNull("cause", cause);
assertEquals("No such class: com.example.DoesNotExist", cause.getMessage());
}
}