CDI TCK Community Documentation

- Prev
- Next

## Chapter 6. Running the Signature Test

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.

## 6.1. Obtaining the sigtest plugin

The sigtest plugin is availble from Maven Central using a dependency like:

    ...

        <plugin>

        <groupId>org.netbeans.tools</groupId>

        <artifactId>sigtest-maven-plugin</artifactId>

        <version>1.5</version>

        </plugin>

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

## 6.2. Running the signature test

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>

      <!-- For access to staging repos, add -Pstaging -->

      <parent>

        <groupId>org.eclipse.ee4j</groupId>

        <artifactId>project</artifactId>

        <version>1.0.6</version>

      </parent>

      <groupId>jakarta.enterprise</groupId>

      <artifactId>cdi-tck-sigtest</artifactId>

      <version>4.0</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.1.0</annotation.api.version>

        <atinject.api.version>2.0.1</atinject.api.version>

        <interceptor.api.version>2.0.1-RC1</interceptor.api.version>

        <el.api.version>5.0.0</el.api.version>

        <cdi.api.version>4.0.0-RC1</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.lang-model</artifactId>

          <version>${cdi.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.5</version>

            <executions>

              <execution>

                <id>sigtest</id>

                <phase>verify</phase>

                <goals>

                  <goal>check</goal>

                </goals>

              </execution>

            </executions>

            <configuration>

              <sigfile>cdi-api-jdk11.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 4.0
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO]
    ...
    [INFO] --- sigtest-maven-plugin:1.5:check (sigtest) @ cdi-tck-sigtest ---
    [INFO] Packages: jakarta.decorator,jakarta.enterprise
    [INFO] SignatureTest report
    Base version: 4.0.0-SNAPSHOT
    Tested version: 4.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-jdk11.sig
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  1.941 s
    [INFO] Finished at: 2021-12-13T11:38:06-06: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".

## 6.3. Forcing a signature test failure

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

1) Edit cdi-api-jdk11.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

- PrevPart II. Executing and Debugging Tests
- Top of page
- Front page
- NextChapter 7. Executing the Test Suite