[[sigtest]]
== Running the Signature Test

One of the requirements of an implementation passing the TCK is for it
to pass the Jakarta Validation signature test. This section describes how to run
it against your implementation as a part of a Maven build.

=== Executing the signature check

The signature file bundled inside this TCK is created using the https://github.com/eclipse-ee4j/jakartaee-tck-tools/tree/master/tools/sigtest
[SigTest Maven plugin].
The same plugin can be used to run a signature test to check for any incompatibilities.
Let's take a look how it can be done as a part of a Maven build.
Note that there must be no dependency declared for this project besides the API artifact you wish to test.

Before running an actual test you need to obtain the signature file first. It is included inside the
validation tck distribution artifacts subdirectory as validation-tck-tests-{tckVersion}-sigtest-jdk17.sig.


To actually run a signature test, the `check` goal of the `sigtest-maven-plugin` can be used.
The TCK distribution setup-examples/maven/pom-local.xml includes a sigtest profile that can be used to run the signature test.

Running a profile with this plugin enabled against that Hibernate Validator 8.1.0.Final release produces:
```
maven % mvn -Psigtest -Pstaging -f pom-local.xml process-sources
...
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< jakarta.validation:tck-runner >--------------------
[INFO] Building Example Jakarta Validation TCK Runner 3.1.0
[INFO]   from pom-local.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- dependency:3.6.1:unpack-dependencies (unpack-dependencies) @ tck-runner ---
[INFO]
[INFO] --- sigtest:2.2:check (default) @ tck-runner ---
[INFO] Packages: jakarta.validation,jakarta.validation.bootstrap,jakarta.validation.constraints,
                                jakarta.validation.constraintvalidation,jakarta.validation.executable,jakarta.validation.groups,
                                jakarta.validation.metadata,jakarta.validation.spi,jakarta.validation.valueextraction
Mar 27, 2024 3:17:33 PM com.sun.tdk.signaturetest.SignatureTest parseParameters
...
[INFO] SignatureTest report
Base version: 3.1.0
Tested version: 3.1.0
Check mode: bin [throws removed]
Constant checking: on



[INFO] /private/tmp/validation-tck-dist-3.1.0/setup-examples/maven/target/surefire-reports/sigtest/TEST-tck-runner-3.1.0.xml: 0 failures in /private/tmp/validation-tck-dist-3.1.0/artifacts/validation-tck-tests-3.1.0-sigtest-jdk17.sig
```

=== Forcing a signature test failure

If you would like to verify that the signature test is running correctly, make a copy of the
signature file somewhere on your local file system and modify it. For example let us change the
`value()` of `jakarta.validation.constraints.Max` to `val()` which should make SigTest fail.

After modifying the signature file, update the `sigfile` parameter of the `sigtest-maven-plugin` to point to the modified file:

```
<sigfile>${path_to_folder_containing_your_modified_signature_file}/validation-api-java8.sig</sigfile>
```

If all is done correctly, while running `mvn sigtest:check` on your project, you should see
an error similar to next:

```
[ERROR] SignatureTest report
Base version: 3.1.0
Tested version: 3.1.0
Check mode: bin [throws removed]
Constant checking: on


Class jakarta.validation.constraints.Max
  "E2.7 - Removing member from annotation type" : method public abstract long jakarta.validation.constraints.Max.val()
```
