Class CompatibilityTestSuite

  • All Implemented Interfaces:
    org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Orderable, org.junit.runner.manipulation.Sortable

    public class CompatibilityTestSuite
    extends org.junit.runners.Suite
    Run all tests found in resources files located in the classpath, for a given Syntax. The algorithm is the following:
    • Look for cts/[scope] resources in the classpath where [scope] represents the value of the @Scope annotation prefixed by cts\\.. By default if no Scope annotation is defined, .*\\.xml is used, leading to a total regex of cts\\..*\\.xml. This is the regex that's used to look for resources in the classpath. For example the following test file would match: cts/simple/bold/bold1.inout.xml. We call these CTS resources.
    • For each CTS resource found look for equivalent test input and output files for the tested Syntax. For example if we have cts/simple/bold/bold1.inout.xml then if the Syntax is xwiki/2.0 look for xwiki20/simple/bold/bold1.[in|out|inout].txt test files. We call them SYN resources.
    • For each SYN IN resource, parse it with the corresponding Syntax parser and render the generated XDOM with the CTS Renderer, and compare the results with the CTS OUT resource. Note that if no SYN IN resource is found generate a warning in the test logs.
    • For each SYN OUT resource, parse the CTS IN resource with the CTS Syntax parser and render the generated XDOM with the Syntax Renderer, and compare the results with the SYN OUT resource. Note that if no SYN OUT resource is found generate a warning in the test logs.

    Usage Example

     public class IntegrationTests

    It's also possible to get access to the underlying Component Manager used, for example in order to register Mock implementations of components. For example:

     public class IntegrationTests
         public void initialize(ComponentManager componentManager)
             // Init mocks here for example
    $Id: d7b8432b89dd84bc83464de880868a8c331949f9 $
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.junit.runners.Suite

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected List<org.junit.runner.Runner> getChildren()  
      org.junit.runner.Description getDescription()
      • Methods inherited from class org.junit.runners.Suite

        describeChild, emptySuite, runChild
      • Methods inherited from class org.junit.runners.ParentRunner

        childrenInvoker, classBlock, classRules, collectInitializationErrors, createTestClass, filter, getName, getRunnerAnnotations, getTestClass, isIgnored, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
      • Methods inherited from class org.junit.runner.Runner

    • Constructor Detail

      • CompatibilityTestSuite

        public CompatibilityTestSuite​(Class<?> klass)
                               throws Exception
        Only called reflectively. Do not use programmatically.
        klass - the test instance class on which this Test Suite is applied
        Exception - if we fail to locate or load test data, if the RenderingTest isn't a valid JUnit Test class or if we cannot locate the Component Manager
    • Method Detail

      • getChildren

        protected List<org.junit.runner.Runner> getChildren()
        getChildren in class org.junit.runners.Suite
      • getDescription

        public org.junit.runner.Description getDescription()

        We override this method so that the JUnit results are not displayed in a test hierarchy with a single test result for each node (as it would be otherwise since RenderingTest has a single test method).

        Specified by:
        getDescription in interface org.junit.runner.Describable
        getDescription in class org.junit.runners.ParentRunner<org.junit.runner.Runner>