org.xwiki.rendering.test.cts
Class TestDataParser

java.lang.Object
  extended by org.xwiki.rendering.test.cts.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: d3e1c0369d2fb4e29fc5fe3110765ab48c1ce7b7 $
See Also:
CompatibilityTestSuite

Constructor Summary
TestDataParser()
           
 
Method Summary
 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.
 List<TestData> parseSingleTestData(String syntaxDirectory, String ctsRootPackageName, String relativeDirectoryName, TestDataConfiguration configuration, ClassLoader classLoader)
          Parse data for single test.
 TestDataConfiguration parseTestConfiguration(String syntaxDirectory, String ctsRootPackageName, ClassLoader classLoader)
          Parse Test configuration by looking for a config.properties file in the Syntax directory.
 List<TestData> parseTestData(String syntaxId, String ctsRootPackageName, String packageFilter, String pattern)
          Read all test data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 IOException
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:
IOException - in case of error while reading test data

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


Copyright © 2004-2013 XWiki. All Rights Reserved.