List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext getBean
@Override public <T> T getBean(String name, Class<T> requiredType) throws BeansException
From source file:org.springframework.integration.core.MessageIdGenerationTests.java
@Test public void testCustomIdGenerationWithChildRegistrar() throws Exception { ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext( "MessageIdGenerationTests-context.xml", this.getClass()); ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext( new String[] { "MessageIdGenerationTests-context-withGenerator.xml" }, this.getClass(), parent); IdGenerator idGenerator = child.getBean("idGenerator", IdGenerator.class); Mockito.reset(idGenerator);/* w w w .ja v a2s.c o m*/ MessageChannel inputChannel = child.getBean("input", MessageChannel.class); inputChannel.send(new GenericMessage<Integer>(0)); verify(idGenerator, atLeastOnce()).generateId(); child.close(); parent.close(); this.assertDestroy(); }
From source file:org.springframework.integration.core.MessageIdGenerationTests.java
@Test public void testCustomIdGenerationWithChildRegistrarClosed() throws Exception { ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext( "MessageIdGenerationTests-context.xml", this.getClass()); ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext( new String[] { "MessageIdGenerationTests-context-withGenerator.xml" }, this.getClass(), parent); IdGenerator idGenerator = child.getBean("idGenerator", IdGenerator.class); Mockito.reset(idGenerator);//from w w w.ja va2s . c o m MessageChannel inputChannel = child.getBean("input", MessageChannel.class); inputChannel.send(new GenericMessage<Integer>(0)); verify(idGenerator, atLeastOnce()).generateId(); child.close(); parent.close(); this.assertDestroy(); }