List of usage examples for org.springframework.beans.factory.support DefaultListableBeanFactory getSingletonCount
@Override public int getSingletonCount()
From source file:org.jasig.springframework.web.portlet.context.PortletContextLoaderTests.java
@Test public void testSingletonDestructionOnStartupFailure() throws IOException { try {//from w w w . jav a 2 s.c o m new ClassPathXmlApplicationContext( new String[] { "/org/springframework/web/context/WEB-INF/applicationContext.xml", "/org/springframework/web/context/WEB-INF/fail.xml" }) { public void refresh() throws BeansException { try { super.refresh(); } catch (BeanCreationException ex) { DefaultListableBeanFactory factory = (DefaultListableBeanFactory) getBeanFactory(); assertEquals(0, factory.getSingletonCount()); throw ex; } } }; fail("Should have thrown BeanCreationException"); } catch (BeanCreationException ex) { // expected } }
From source file:org.springframework.beans.factory.xml.XmlBeanFactoryTests.java
@Test public void testComplexFactoryReferenceCircle() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(COMPLEX_FACTORY_CIRCLE_CONTEXT); xbf.getBean("proxy1"); // check that unused instances from autowiring got removed assertEquals(4, xbf.getSingletonCount()); // properly create the remaining two instances xbf.getBean("proxy2"); assertEquals(5, xbf.getSingletonCount()); }