SeamFramework.orgCommunity Documentation
This chapter explains the purpose of a TCK and identifies the foundation elements of the CDI TCK.
A TCK, or Technology Compatibility Kit, is one of the three required pieces for any JSR (the other two being the specification document and the reference implementation). The TCK is a set of tools and tests to verify that an implementation of the technology conforms to the specification. The tests are the primary component, but the tools serve an equally critical role of providing a framework and/or set of SPIs for executing the tests.
The tests in the TCK are derived from assertions in the written specification document. The assertions are itemized in an XML document, where they each get assigned a unique identifier, and materialize as a suite of automated tests that collectively validate whether an implementation complies with the aforementioned assertions, and in turn the specification. For a particular implementation to be certified, all of the required tests must pass (i.e., the provided test suite must be run unmodified).
A TCK is entirely implementation agnostic. Ideally, it should validate assertions by consulting the specficiation's public API. However, when the information returned by the public API is not low-level enough to validate the assertion, the implementation must be consulted directly. In this case, the TCK provides an independent API as part of a porting package that enables this transparency. The porting package must be implemented for each CDI implementation. Section 1.3.4 introduces the porting package and section 4.1 covers the requirements for implementing it.
Sun Microsystems, Inc. will implement the porting package for the CDI RI and test the CDI RI on the Java EE Reference Implementation.
The goal of any specification is to eliminate portability problems so long as the program which uses the implementation also conforms to the rules laid out in the specification.
Executing the TCK is a form of compatibility testing. It's important to understand that compatibility testing is distinctly different from product testing. The TCK is not concerned with robustness, performance or ease of use, and therefore cannot vouch for how well an implementation meets these criteria. What a TCK can do is to ensure the exactness of an implementation as it relates to the specification.
Compatibility testing of any feature relies on both a complete specification and a complete reference implementation. The reference implementation demonstrates how each test can be passed and provides additional context to the implementor during development for the corresponding assertion.
Java platform compatibility is important to different groups involved with Java technologies for different reasons:
Compatibility testing is the means by which the JCP ensures that the Java platform does not become fragmented as it's ported to different operating systems and hardware.
Compatibility testing benefits developers working in the Java programming language, enabling them to write applications once and deploy them across heterogeneous computing environments without porting.
Compatibility testing enables application users to obtain applications from disparate sources and deploy them with confidence.
Conformance testing benefits Java platform implementors by ensuring the same extent of reliability for all Java platform ports.
The CDI specification goes to great lengths to ensure that programs written for Java EE are compatible and the TCK is rigorous about enforcing the rules the specification lays down.
The CDI TCK is designed as a portable, configurable and automated test suite for verifying the compatibility of an implementation of the JSR-299: Contexts and Dependency Injection for Java EE specification. The test suite is built atop TestNG and provides a series of extensions that allow runtime packaging and deployment of JEE artifacts for in-container testing (JBoss Test Harness).
The CDI TCK harness is based on the JBoss Test harness, which provides most of the aforementioned functionality.
Each test class in the suite acts as a deployable unit. The deployable units, or artifacts, are defined declaratively using annotations. The artifact produced can be either a WAR or an EAR.
The declarative approach allows many of the tests to be executed in a standalone implementation of CDI, accounting for a boast in developer productivity. However, an implementation is only valid if all tests pass using the in-container execution mode. The standalone mode is merely a developer convenience.
This section lists the applicable requirements and specifications for the CDI TCK.
Specification requirements - Software requirements for a CDI implementation are itemized in section 1.2, "Relationship to other specifications" in the CDI specification, with details provided throughout the specification. Generally, the CDI specification targets the Java EE 6 platform and is aligned with its specifications.
Contexts and Dependency Injection for Java EE 1.0 API - The Java API defined in the CDI specification and provided by the reference implementation.
JBoss Test Harness - The CDI TCK requires version 1.1.0-CR3 of the JBoss Test Harness. The Harness is based on TestNG 5.x (http://testng.org). You can read more about the harness in Part III, “JBoss Test Harness”.
Porting Package - An implementation of SPIs that are required for the test suite to run the in-container tests and at times extend the CDI 1.0 API to provide extra information to the TCK.
TCK Audit Tool - An itemization of the assertions in the specification documents which are cross referenced by the individual tests. Describes how well the TCK covers the specification.
Reference runtime - The designated reference runtimes for compatibility testing of the CDI specification is the Sun Java Platform, Enterprise Edition (Java EE) 6 reference implementation (RI). See details at Java EE 6 (http://java.sun.com/javaee/6/docs/api/).
JSR-330 - CDI builds on JSR-330, and as such JSR-299 implementations must additionally pass the JSR-330 TCK.
The TCK distribution includes weld/porting-package-lib/weld-inject-tck-runner-X.Y.Z-Q-tests.jar
which contains two classes showing how the CDI RI passes the JSR-330
TCK. The source for these classes is available from http://anonsvn.jboss.org/repos/weld/tags/1.0.0-CR2/inject-tck-runner/src/test/java/org/jboss/weld/atinject/tck/
The CDI TCK includes the following components:
JBoss Test Harness 1.0.0 and related documentation.
TestNG 5.9, the testing framework on which the JBoss Test Harness is based and which provides the extension points for selecting an executing the tests in the test suite.
Porting Package SPIs - Extensions to the CDI SPIs to allow testing of a container.
The test suite, which is a collection of TestNG tests, the TestNG test suite descriptor and supplemental resources that configure CDI and other software components.
The TCK audit is used to list out the assertions identified in the CDI specification. It matches the assertions to testcases in the test suite by unique identifier and produces a coverage report.
The audit document is provided along with the TCK; at least 75% of assertions are tested. Each assertion is defined with a reference to a chapter, section and paragraph from the specification document, making it easy for the implementor to locate the language in the specification document that supports the feature being tested.
TCK documentation accompanied by release notes identifying updates between versions.
Sun Microsystems, Inc. will implement the porting package for the CDI RI and test the CDI RI on the Java EE Reference Implementation .
The CDI TCK has been tested run on following platforms:
JBoss AS 5.2.0.Beta1 using Sun Java SE 6 on Red Hat Enterprise Linux 5.2
CDI supports Java EE 5, Java EE 6, Java EE 6 Web Profile and the Embeddable EJB 3.1. The TCK will execute on any of these runtimes, but is only part of the CTS for Java EE 6 and Java EE 6 Web Profile.