Class TestDataParser


  • public class TestDataParser
    extends Object
    Finds all test files in the current classloader, read them and return test data to represent them. See CompatibilityTestSuite for a description of the algorithm.
    Since:
    4.1M1
    Version:
    $Id: b54262ae990c998944b70444e61cf908ddabb028 $
    See Also:
    CompatibilityTestSuite
    • Constructor Detail

      • TestDataParser

        public TestDataParser()
    • Method Detail

      • parseTestData

        public List<TestData> parseTestData​(String syntaxId,
                                            String ctsRootPackageName,
                                            String packageFilter,
                                            String pattern)
                                     throws Exception
        Read all test data. See CompatibilityTestSuite for a detailed explanation of the algorithm.
        Parameters:
        syntaxId - the id of the syntax for which to parse data for
        ctsRootPackageName - the root of the CTS resources
        packageFilter - the regex to filter packages
        pattern - a regex to decide which *.xml resources should be found. The default should be to find them all
        Returns:
        the list of test data
        Throws:
        Exception - in case of error while reading test data
      • parseSingleTestData

        public List<TestData> parseSingleTestData​(String syntaxDirectory,
                                                  String ctsRootPackageName,
                                                  String relativeDirectoryName,
                                                  TestDataConfiguration configuration,
                                                  ClassLoader classLoader)
                                           throws Exception
        Parse data for single test.
        Parameters:
        syntaxDirectory - the syntax directory from where to read syntax test data (eg "xwiki20" for "xwiki/2.0" syntax)
        ctsRootPackageName - the root of the CTS resources
        relativeDirectoryName - the name of the relative directory for a CTS test (eg "/simple/bold/bold1")
        configuration - the test configuration
        classLoader - the class loader from which the test data is read from
        Returns:
        the TestData instances for both input and output tests, including possible input alias tests
        Throws:
        Exception - in case of error while reading test data or inherited configurations
      • parseTestConfiguration

        public TestDataConfiguration parseTestConfiguration​(String syntaxDirectory,
                                                            String ctsRootPackageName,
                                                            ClassLoader classLoader)
                                                     throws Exception
        Parse Test configuration by looking for a config.properties file in the Syntax directory.
        Parameters:
        syntaxDirectory - the syntax directory under which to look for the configuration file
        ctsRootPackageName - the root of the CTS resources
        classLoader - the class loader from which the test configuration is read from
        Returns:
        the configuration
        Throws:
        Exception - in case of error while reading test configuration
      • findRelativeTestDirectoryNames

        public Set<String> findRelativeTestDirectoryNames​(String ctsRootPackageName,
                                                          String packageFilter,
                                                          String pattern)
        Find *.xml files in the classpath and return the list of all resources found, without their filename extensions. For example if {ctsDirectoryName}/simple/bold/bold1.*.xml is found, return simple/bold/bold1.
        Parameters:
        ctsRootPackageName - the root of the CTS resources
        packageFilter - the regex to filter packages
        pattern - a regex to decide which *.xml resources should be found. The default should be to find them all
        Returns:
        the list of relative test directories found