Search in sources :

Example 1 with JDK15AnnotationFinder

use of org.testng.internal.annotations.JDK15AnnotationFinder in project druid by druid-io.

the class TestNG method initializeConfiguration.

private void initializeConfiguration() {
    ITestObjectFactory factory = m_objectFactory;
    //
    // Install the listeners found in ServiceLoader (or use the class
    // loader for tests, if specified).
    //
    addServiceLoaderListeners();
    //
    for (XmlSuite s : m_suites) {
        for (String listenerName : s.getListeners()) {
            Class<?> listenerClass = ClassHelper.forName(listenerName);
            // If specified listener does not exist, a TestNGException will be thrown
            if (listenerClass == null) {
                throw new TestNGException("Listener " + listenerName + " was not found in project's classpath");
            }
            Object listener = ClassHelper.newInstance(listenerClass);
            addListener(listener);
        }
        //
        for (XmlMethodSelector methodSelector : s.getMethodSelectors()) {
            addMethodSelector(methodSelector.getClassName(), methodSelector.getPriority());
        }
        //
        if (s.getObjectFactory() != null) {
            if (factory == null) {
                factory = s.getObjectFactory();
            } else {
                throw new TestNGException("Found more than one object-factory tag in your suites");
            }
        }
    }
    m_configuration.setAnnotationFinder(new JDK15AnnotationFinder(getAnnotationTransformer()));
    m_configuration.setHookable(m_hookable);
    m_configuration.setConfigurable(m_configurable);
    m_configuration.setObjectFactory(factory);
}
Also used : XmlSuite(org.testng.xml.XmlSuite) XmlMethodSelector(org.testng.xml.XmlMethodSelector) JDK15AnnotationFinder(org.testng.internal.annotations.JDK15AnnotationFinder)

Aggregations

JDK15AnnotationFinder (org.testng.internal.annotations.JDK15AnnotationFinder)1 XmlMethodSelector (org.testng.xml.XmlMethodSelector)1 XmlSuite (org.testng.xml.XmlSuite)1