List of usage examples for org.apache.commons.lang3.reflect ExtendedConstructorUtils newInstance
public static <T> T newInstance(Class<T> cls, Object[] args, Class<?>[] parameterTypes)
From source file:org.springframework.context.RefreshedContextAttacherTest.java
@Test public void testOnContextInitializedNotCalledIfNotContextRefreshedEvent() { final AtomicInteger counter = new AtomicInteger(0); RefreshedContextAttacher attacher = new RefreshedContextAttacher() { @Override/*from www .j av a2 s . c om*/ protected void onContextInitialized(ApplicationContext context) { super.onContextInitialized(context); logger.info("onContextInitialized(" + context.getDisplayName() + ") call count: " + counter.incrementAndGet()); } }; Object[] args = { applicationContext }; Class<?>[] parameterTypes = { ApplicationContext.class }; for (Class<? extends ApplicationContextEvent> eventClass : Arrays.asList(ContextClosedEvent.class, ContextStartedEvent.class, ContextStoppedEvent.class)) { ApplicationContextEvent event = ExtendedConstructorUtils.newInstance(eventClass, args, parameterTypes); attacher.onApplicationEvent(event); Assert.assertEquals("Mismatched number of calls at for " + eventClass.getSimpleName(), 0, counter.get()); } }