Java 类org.springframework.test.context.TestExecutionListener 实例源码

项目:spring4-understanding    文件:AbstractTestContextBootstrapper.java   
private List<TestExecutionListener> instantiateListeners(List<Class<? extends TestExecutionListener>> classesList) {
    List<TestExecutionListener> listeners = new ArrayList<TestExecutionListener>(classesList.size());
    for (Class<? extends TestExecutionListener> listenerClass : classesList) {
        NoClassDefFoundError ncdfe = null;
        try {
            listeners.add(BeanUtils.instantiateClass(listenerClass));
        }
        catch (NoClassDefFoundError err) {
            ncdfe = err;
        }
        catch (BeanInstantiationException ex) {
            if (ex.getCause() instanceof NoClassDefFoundError) {
                ncdfe = (NoClassDefFoundError) ex.getCause();
            }
        }
        if (ncdfe != null) {
            if (logger.isInfoEnabled()) {
                logger.info(String.format("Could not instantiate TestExecutionListener [%s]. "
                        + "Specify custom listener classes or make the default listener classes "
                        + "(and their required dependencies) available. Offending class: [%s]",
                    listenerClass.getName(), ncdfe.getMessage()));
            }
        }
    }
    return listeners;
}
项目:spring4-understanding    文件:AbstractTestContextBootstrapper.java   
/**
 * Get the default {@link TestExecutionListener} classes for this bootstrapper.
 * <p>This method is invoked by {@link #getTestExecutionListeners()} and
 * delegates to {@link #getDefaultTestExecutionListenerClassNames()} to
 * retrieve the class names.
 * <p>If a particular class cannot be loaded, a {@code DEBUG} message will
 * be logged, but the associated exception will not be rethrown.
 */
@SuppressWarnings("unchecked")
protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionListenerClasses() {
    Set<Class<? extends TestExecutionListener>> defaultListenerClasses = new LinkedHashSet<Class<? extends TestExecutionListener>>();
    ClassLoader cl = getClass().getClassLoader();
    for (String className : getDefaultTestExecutionListenerClassNames()) {
        try {
            defaultListenerClasses.add((Class<? extends TestExecutionListener>) ClassUtils.forName(className, cl));
        }
        catch (Throwable ex) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not load default TestExecutionListener class [" + className
                        + "]. Specify custom listener classes or make the default listener classes available.", ex);
            }
        }
    }
    return defaultListenerClasses;
}
项目:Camel    文件:CamelSpringBootRunner.java   
public CamelTestContextManager(Class<?> testClass) {
    super(testClass);

    // turn off auto starting spring as we need to do this later
    System.setProperty("skipStartingCamelContext", "true");

    // is Camel already registered
    if (!alreadyRegistered()) {
        // inject Camel first, and then disable jmx and add the stop-watch
        List<TestExecutionListener> list = getTestExecutionListeners();
        list.add(0, new CamelSpringTestContextLoaderTestExecutionListener());
        list.add(1, new DisableJmxTestExecutionListener());
        list.add(2, new CamelSpringBootExecutionListener());
        list.add(3, new StopWatchTestExecutionListener());
    }
}
项目:Camel    文件:CamelSpringRunner.java   
public CamelTestContextManager(Class<?> testClass) {
    super(testClass);

    // is Camel already registered
    if (!alreadyRegistered()) {
        // inject Camel first, and then disable jmx and add the stop-watch
        List<TestExecutionListener> list = getTestExecutionListeners();
        list.add(0, new CamelSpringTestContextLoaderTestExecutionListener());
        list.add(1, new DisableJmxTestExecutionListener());
        list.add(2, new StopWatchTestExecutionListener());
    }
}
项目:Camel    文件:CamelSpringRunner.java   
private boolean alreadyRegistered() {
    List<TestExecutionListener> list = getTestExecutionListeners();
    if (list != null) {
        for (TestExecutionListener listener : list) {
            if (listener instanceof CamelSpringTestContextLoaderTestExecutionListener) {
                return true;
            }
        }
    }

    return false;
}
项目:Camel    文件:CamelSpringBootRunner.java   
private boolean alreadyRegistered() {
    List<TestExecutionListener> list = getTestExecutionListeners();
    if (list != null) {
        for (TestExecutionListener listener : list) {
            if (listener instanceof CamelSpringTestContextLoaderTestExecutionListener) {
                return true;
            }
        }
    }

    return false;
}
项目:parallel-test-runner    文件:SynchronizedTestContextManager.java   
@Override
public synchronized void registerTestExecutionListeners(List<TestExecutionListener> testExecutionListeners) {
    super.registerTestExecutionListeners(testExecutionListeners);
}
项目:parallel-test-runner    文件:SynchronizedTestContextManager.java   
@Override
public synchronized void registerTestExecutionListeners(TestExecutionListener... testExecutionListeners) {
    super.registerTestExecutionListeners(testExecutionListeners);
}
项目:opennmszh    文件:OpenNMSJUnit4ClassRunner.java   
public int compare(TestExecutionListener o1, TestExecutionListener o2) {
    return o1.getClass().getName().compareTo(o2.getClass().getName());
}
项目:OpenNMS    文件:OpenNMSJUnit4ClassRunner.java   
public int compare(TestExecutionListener o1, TestExecutionListener o2) {
    return o1.getClass().getName().compareTo(o2.getClass().getName());
}
项目:spring4-understanding    文件:AbstractTestContextBootstrapper.java   
/**
 * Get the names of the default {@link TestExecutionListener} classes for
 * this bootstrapper.
 * <p>The default implementation looks up all
 * {@code org.springframework.test.context.TestExecutionListener} entries
 * configured in all {@code META-INF/spring.factories} files on the classpath.
 * <p>This method is invoked by {@link #getDefaultTestExecutionListenerClasses()}.
 * @return an <em>unmodifiable</em> list of names of default {@code TestExecutionListener}
 * classes
 * @see SpringFactoriesLoader#loadFactoryNames
 */
protected List<String> getDefaultTestExecutionListenerClassNames() {
    final List<String> classNames = SpringFactoriesLoader.loadFactoryNames(TestExecutionListener.class,
        getClass().getClassLoader());

    if (logger.isInfoEnabled()) {
        logger.info(String.format("Loaded default TestExecutionListener class names from location [%s]: %s",
            SpringFactoriesLoader.FACTORIES_RESOURCE_LOCATION, classNames));
    }
    return Collections.unmodifiableList(classNames);
}