<commit_before>package com.selgp.opensauce.automation.core;

import com.metapossum.utils.scanner.reflect.ClassesInPackageScanner;
import com.selgp.opensauce.automation.core.environments.Environments;
import com.selgp.opensauce.automation.core.suites.Suites;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import org.testng.reporters.XMLReporter;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

import java.io.*;
import java.lang.reflect.Method;
import java.util.*;

/**
 * Runs TestNG programatically.
 *
 * @author <EMAIL>
 */
public final class TestRunner {
    private static TestRunner instance = null;
    public static Suites suites;
    public static Environments environments;
    public static String SUITE_NAME = System.getProperty("suite", "unset");
    public static String ENVIRONMENT = System.getProperty("environment", "unset");
    public static String CLASS_NAME;
    public static String PARAMETER;
    public static Properties suitesProps;
    public static Properties environmentProps;

    public static TestRunner getInstance() {
        if (instance == null) {
            instance = new TestRunner();
            init();
        }
        return instance;
    }

    public static void main(String[] args) {
        getInstance();
        run();
        System.exit(0);
    }


    public static void init() {
        suitesProps = new Properties();
        environmentProps = new Properties();
        try {
            suitesProps.load(new InputStreamReader(TestRunner.class.getClassLoader().getResourceAsStream("automation.properties")));
            environmentProps.load(new InputStreamReader(TestRunner.class.getClassLoader().getResourceAsStream("environments.properties")));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        suites = new Suites(suitesProps);
        environments = new Environments(environmentProps);
        SUITE_NAME = suites.getSuiteName().toLowerCase();
        ENVIRONMENT = System.getProperty("environment").toLowerCase();
        CLASS_NAME = System.getProperty("class.name", "unset");
        PARAMETER = System.getProperty("test.parameter", "unset");
    }

    public static void run() {
        List<XmlSuite> xmlSuites = new ArrayList<XmlSuite>();
        String suite = suites.getSuiteName();
        xmlSuites.add(createXmlSuite(suite));
        TestNG testng = new TestNG();
        testng.setDefaultSuiteName(suites.getSuiteName());
        testng.setSuiteThreadPoolSize(suites.getNumThreads());
        testng.setThreadCount(suites.getNumThreads());
        testng.setDataProviderThreadCount(suites.getNumDataProviderThreads());
        testng.setXmlSuites(xmlSuites);
        testng.setUseDefaultListeners(false);
        testng.setParallel("methods");
        testng.setConfigFailurePolicy("continue");
        testng.setVerbose(100);
        XMLReporter xmlReporter = new XMLReporter();
        testng.addListener(xmlReporter);
        testng.addListener(new TestListenerAdapter());
        testng.run();
    }

    private static XmlSuite createXmlSuite(String singleSuite) {
        XmlSuite suite = new XmlSuite();
        suite.setName("Selgp QA - " + singleSuite + " tests");
        suite.setParallel("methods");
        suite.setDataProviderThreadCount(suites.getNumDataProviderThreads());
        suite.setThreadCount(suites.getNumThreads());<commit_msg>Fixes for the execution of the WebDriver Opensauce example<commit_after>package com.selgp.opensauce.automation.core;

import com.metapossum.utils.scanner.reflect.ClassesInPackageScanner;
import com.selgp.opensauce.automation.core.environments.Environments;
import com.selgp.opensauce.automation.core.suites.Suites;
import org.testng.TestNG;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.*;

/**
 * Runs TestNG programatically.
 *
 * @author <EMAIL>
 */
public final class TestRunner {
    private static TestRunner instance = null;
    public static Suites suites;
    public static Environments environments;
    public static String SUITE_NAME = System.getProperty("suite", "unset");
    public static String ENVIRONMENT = System.getProperty("environment", "unset");
    public static String CLASS_NAME;
    public static String PARAMETER;
    public static Properties suitesProps;
    public static Properties environmentProps;

    public static TestRunner getInstance() {
        if (instance == null) {
            instance = new TestRunner();
            init();
        }
        return instance;
    }

    public static void main(String[] args) {
        getInstance();
        run();
        System.exit(0);
    }


    public static void init() {
        suitesProps = new Properties();
        environmentProps = new Properties();
        try {
            suitesProps.load(new InputStreamReader(TestRunner.class.getClassLoader().getResourceAsStream("suites.properties")));
            environmentProps.load(new InputStreamReader(TestRunner.class.getClassLoader().getResourceAsStream("environments.properties")));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        suites = new Suites(suitesProps);
        environments = new Environments(environmentProps);
        SUITE_NAME = suites.getSuiteName().toLowerCase();
        ENVIRONMENT = System.getProperty("environment").toLowerCase();
        CLASS_NAME = System.getProperty("class.name", "unset");
        PARAMETER = System.getProperty("test.parameter", "unset");
    }

    public static void run() {
        List<XmlSuite> xmlSuites = new ArrayList<XmlSuite>();
        String suite = suites.getSuiteName();
        xmlSuites.add(createXmlSuite(suite));
        TestNG testng = new TestNG();
        testng.setDefaultSuiteName(suites.getSuiteName());
        testng.setSuiteThreadPoolSize(suites.getNumThreads());
        testng.setThreadCount(suites.getNumThreads());
        testng.setDataProviderThreadCount(suites.getNumDataProviderThreads());
        testng.setXmlSuites(xmlSuites);
        testng.setUseDefaultListeners(false);
        testng.setParallel("methods");
        testng.setConfigFailurePolicy("continue");
        testng.setVerbose(100);
        testng.run();
    }

    private static XmlSuite createXmlSuite(String singleSuite) {
        XmlSuite suite = new XmlSuite();
        suite.setName("Selgp QA - " + singleSuite + " tests");
        suite.setParallel("methods");
        suite.setDataProviderThreadCount(suites.getNumDataProviderThreads());
        suite.setThreadCount(suites.getNumThreads());
{'fraction_non_alphanumeric': 0.10821759259259259, 'fraction_numerical': 0.0011574074074074073, 'mean_word_length': 3.3808618504435994, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7392915', 'n_tokens_mistral': 1894, 'n_tokens_neox': 1898, 'n_words': 370}