List of usage examples for org.springframework.beans.factory CannotLoadBeanClassException getResourceDescription
@Nullable
public String getResourceDescription()
From source file:org.springframework.beans.factory.xml.XmlBeanFactoryTests.java
/** * When using a BeanFactory. singletons are of course not pre-instantiated. * So rubbish class names in bean defs must now not be 'resolved' when the * bean def is being parsed, 'cos everything on a bean def is now lazy, but * must rather only be picked up when the bean is instantiated. */// w ww . j a va2 s .c o m @Test public void testClassNotFoundWithDefaultBeanClassLoader() { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(factory).loadBeanDefinitions(CLASS_NOT_FOUND_CONTEXT); // cool, no errors, so the rubbish class name in the bean def was not resolved try { // let's resolve the bean definition; must blow up factory.getBean("classNotFound"); fail("Must have thrown a CannotLoadBeanClassException"); } catch (CannotLoadBeanClassException ex) { assertTrue(ex.getResourceDescription().indexOf("classNotFound.xml") != -1); assertTrue(ex.getCause() instanceof ClassNotFoundException); } }