CDI TCKCommunity Documentation

Chapter 6. Running the Signature Test

6.1. Obtaining the sigtest plugin
6.2. Running the signature test
6.3. Forcing a signature test failure

One of the requirements of an implementation passing the TCK is for it to pass the CDI signature test. This section describes how the signature file is generated and how to run it against your implementation.

The source for the sigtest plugin can be found here: https://github.com/emilianbold/netbeans-apitest.git

To run the signature test, use a pom file like that found in https://github.com/eclipse-ee4j/cdi-tck/blob/master/impl/src/main/resources/sigtest-pom.xml and shown here:


<?xml version="1.0"?>
<!-- Sample maven pom to verify signatures -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>jakarta.enterprise</groupId>
  <artifactId>cdi-tck-sigtest</artifactId>
  <version>{revnumber}</version>
  <name>CDI TCK Signature Tests</name>
  <description>CDI TCK Signature test validation of CDI dependent API jars</description>
  <properties>
    <!-- Set the api jar artifact versions here -->
    <annotation.api.version>2.0.0</annotation.api.version>
    <atinject.api.version>2.0.0</atinject.api.version>
    <interceptor.api.version>2.0.0</interceptor.api.version>
    <el.api.version>4.0.0</el.api.version>
    <cdi.api.version>3.0.0</cdi.api.version>
  </properties>

  <!-- Set the api jar artifact dependencies here -->
  <dependencies>
    <dependency>
      <groupId>jakarta.annotation</groupId>
      <artifactId>jakarta.annotation-api</artifactId>
      <version>${annotation.api.version}</version>
    </dependency>
    <dependency>
      <groupId>jakarta.el</groupId>
      <artifactId>jakarta.el-api</artifactId>
      <version>${el.api.version}</version>
    </dependency>
    <dependency>
      <groupId>jakarta.interceptor</groupId>
      <artifactId>jakarta.interceptor-api</artifactId>
      <version>${interceptor.api.version}</version>
    </dependency>
    <dependency>
      <groupId>jakarta.inject</groupId>
      <artifactId>jakarta.inject-api</artifactId>
      <version>${atinject.api.version}</version>
    </dependency>
    <dependency>
      <groupId>jakarta.enterprise</groupId>
      <artifactId>jakarta.enterprise.cdi-api</artifactId>
      <version>${cdi.api.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <stripVersion>true</stripVersion>
              <overWriteReleases>true</overWriteReleases>
              <outputDirectory>target/classes</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.netbeans.tools</groupId>
        <artifactId>sigtest-maven-plugin</artifactId>
        <version>1.2</version>
        <executions>
          <execution>
            <id>sigtest</id>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <sigfile>cdi-api-jdk8.sig</sigfile>
          <packages>jakarta.decorator,jakarta.enterprise</packages>
          <classes>target/classes</classes>
          <report>cdi-sig-report.txt</report>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
Scotts-iMacPro:resources starksm$ mvn -f sigtest-pom.xml verify
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< jakarta.enterprise:cdi-tck-sigtest >-----------------
[INFO] Building CDI TCK Signature Tests 3.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
...
[INFO] --- sigtest-maven-plugin:1.2:check (sigtest) @ cdi-tck-sigtest ---
[INFO] Packages: jakarta.decorator,jakarta.enterprise
[INFO] SignatureTest report
Base version: 3.0.0-SNAPSHOT
Tested version: 3.0
Check mode: bin [throws removed]
Constant checking: on

Warning: The return type java.lang.reflect.Member can't be resolved
Warning: The return type java.lang.reflect.Member can't be resolved
Warning: The return type java.lang.reflect.Member can't be resolved


[INFO] /Users/starksm/Dev/JBoss/Jakarta/cdi-tck/impl/src/main/resources/cdi-sig-report.txt: 0 failures in /Users/starksm/Dev/JBoss/Jakarta/cdi-tck/impl/src/main/resources/cdi-api-jdk8.sig
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.887 s
[INFO] Finished at: 2020-05-27T15:55:18-05:00
[INFO] ------------------------------------------------------------------------

You can ignore the following warnings: "The return type java.lang.reflect.Member can't be resolved"

The important thing is that the mvn version shows "BUILD SUCCESS".

Just for fun (and to confirm that the signature test is working correctly), you can try the following:

1) Edit cdi-api.sig

2) Modify one of the class signatures - in the following example we change one of the constructors for BusyConversationException - here’s the original:

CLSS public jakarta.enterprise.context.BusyConversationException
cons public BusyConversationException()
cons public BusyConversationException(java.lang.String)
cons public BusyConversationException(java.lang.String,java.lang.Throwable)
cons public BusyConversationException(java.lang.Throwable)
supr jakarta.enterprise.context.ContextException
hfds serialVersionUID

Let’s change the default (empty) constructor parameter to one with a java.lang.Integer parameter instead:

CLSS public jakarta.enterprise.context.BusyConversationException
cons public BusyConversationException(java.lang.Integer)
cons public BusyConversationException(java.lang.String)
cons public BusyConversationException(java.lang.String,java.lang.Throwable)
cons public BusyConversationException(java.lang.Throwable)
supr jakarta.enterprise.context.ContextException
hfds serialVersionUID

3) Now when we run the signature test using the above command, we should get the following errors:

Missing Constructors
--------------------

jakarta.enterprise.context.BusyConversationException:         constructor public jakarta.enterprise.context.BusyConversationException.BusyConversationException(java.lang.Integer)

Added Constructors
------------------

jakarta.enterprise.context.BusyConversationException:         constructor public jakarta.enterprise.context.BusyConversationException.BusyConversationException()


STATUS:Failed.2 errors