CDI TCKCommunity Documentation
This chapter lays out how to configure the TCK Harness by specifying the SPI implementation classes, defining the target container connection information, and various other switches. You then learn how to setup a TCK runner project that executes the TCK test suite, putting these settings into practice.
System properties and/or the resource META-INF/cdi-tck.properties, a Java properties file, are used to configure the TCK.
You should set the following required properties:
Table 4.1. Required TCK Configuration Properties
Property = Example Value | Description |
---|---|
+org.jboss.cdi.tck.libraryDirectory=/path/to/extra/libraries | The directory containing extra JARs to be placed in the test archive library directory such as the porting package implementation. |
org.jboss.cdi.tck.testDataSource=java:jboss/datasources/ExampleDS | A few TCK tests work with Java EE persistence services (JPA, JTA) and require a data source to be provided. This property defines JNDI name of such resource. Required for the tests within the persistence test group. |
org.jboss.cdi.tck.testJmsConnectionFactory=java:/ConnectionFactory | The JNDI name of the JMS test ConnectionFactory. Required for the tests within the jms test group. |
org.jboss.cdi.tck.testJmsQueue=java:/queue/test | The JNDI name of the JMS test Queue. Required for the tests within the jms test group. |
org.jboss.cdi.tck.testJmsTopic=java:/topic/test | The JNDI name of the JMS test Topic. Required for the tests within the jms test group. |
Table 4.2. Optional TCK Configuration Properties
Property = Example Value | Description |
---|---|
org.jboss.cdi.tck.testTimeoutFactor=200 | Tests use this percentage value to adjust the final timeout (e.g. when waiting for some async processing) so that it’s possible to configure timeouts according to the testing runtime performance and throughput. The value must be an integer greater than zero. The default value is 100% - i.e. timeouts will remain the same. |
The Arquillian testing platform will look for configuration settings in a file named arquillian.xml in the root of your classpath. If it exists it will be auto loaded, else default values will be used. This file is not a requirement however it’s very useful for container configuration. See an example configuration for JBoss TCK runner:
weld/jboss-tck-runner/src/test/wildfly/arquillian.xml
The CDI TCK relies on an implementation of the porting package to function. There are times when the tests need to tap directly into the CDI implementation to manipulate behavior or verify results. The porting package is Java package named "org.jboss.cdi.tck.spi" and includes a set of SPIs that provide the TCK with this level of access without tying the tests to a given implementation.
The SPI classes in the CDI TCK are as follows:
Please consult the JavaDoc for these interfaces for the implementation requirements.
You can configure the CDI TCK to just run tests appropriate to the Java EE Web Profile by excluding TestNG group javaee-full, e.g. via maven-surefire-plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>javaee-full</excludedGroups>
</configuration>
</plugin>
The CDI TCK is built atop Arquillian and TestNG, and it’s TestNG that is responsible for selecting the tests to execute, the order of execution, and reporting the results. Detailed TestNG documentation can be found at testng.org.
Certain TestNG configuration file must be run by TestNG 6.3 (described by the TestNG documentation as "with a testng.xml file") unmodified for an implementation to pass the TCK. The TCK distribution contains the configuration file accurate at the date of the release - artifacts/cdi-tck-impl-suite.xml. However this artifact may not be up to date due to unresolved challenges or pending releases. Therefore a canonical configuration file exists. This file is located in the CDI TCK source code repository at ${CORRESPONDING_BRANCH_ROOT}/impl/src/main/resources/tck-tests.xml.
The canonical configuration file for CDI TCK is located at https://github.com/cdi-spec/cdi-tck/blob/master/impl/src/main/resources/tck-tests.xml.
This file also allows tests to be excluded from a run:
<suite name="CDI TCK" verbose="0" configfailurepolicy="continue">
<test name="CDI TCK">
...
<classes>
<class name="org.jboss.cdi.tck.tests.context.application.ApplicationContextTest">
<methods>
<exclude name="testApplicationScopeActiveDuringServiceMethod"/>
</methods>
</class>
</classes>
...
</test>
</suite>
Additionally there is available canonical configuration file at https://github.com/cdi-spec/cdi-tck/blob/master/impl/src/main/resources/tck-tests-previous.xml. Please note that this exclude list serves only for the previous micro version of TCK release! This means that if the latest version of TCK is e.g. 1.2.5.Final then this exclude list is valid only for the version 1.2.4.Final and invalid for any other version!
TestNG provides extensive reporting information. Depending on the build tool or IDE you use, the reporting will take a different format. Please consult the TestNG documentation and the tool documentation for more information.
It’s beyond the scope of this guide to describe in how to set up your build environment to run the TCK. The TestNG documentation provides extensive information on launching TestNG using the Java, Ant, Eclipse or IntelliJ IDEA.
The TCK makes use of the Java 1.4 keyword assert; you must ensure that the JVM used to run the application server is started with assertions enabled. See Programming With Assertions for more information on how to enable assertions.
Tests within the jms test group require some basic Java Message Service configuration. A connection factory, a queue destination for PTP messaging domain and a topic destination for pub/sub messaging domain must be available via JNDI lookup. The corresponding JNDI names are specified with configuration properties - see Section 4.1, “TCK Properties”.
Tests within the persistence test group require basic data source configuration. The data source has to be valid and JTA-based. The JNDI name of the DataSource is specified with configuration property - see Section 4.1, “TCK Properties”.
Tests within the installedLib test group require the CDI TCK cdi-tck-ext-lib artifact to be installed as a library (see also Java EE 6 specification, section EE.8.2.2 "Installed Libraries").
Tests within the systemProperties test group require the following system properties to be set:
Name | Value |
---|---|
cdiTckExcludeDummy | true |
Tests within the security test group require the following mapping of roles to principals:
Principal | Group |
---|---|
student | student |
alarm | alarm, student |
printer | printer, student |
Tests within SE test groups require execution in a separate JVM instance with isolated classpath including all required dependencies.