Example usage for org.apache.commons.lang3.reflect ExtendedConstructorUtils newInstance

List of usage examples for org.apache.commons.lang3.reflect ExtendedConstructorUtils newInstance

Introduction

In this page you can find the example usage for org.apache.commons.lang3.reflect ExtendedConstructorUtils newInstance.

Prototype

public static <T> T newInstance(Class<T> cls, Object[] args, Class<?>[] parameterTypes) 

Source Link

Usage

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());
    }
}