Hibernate.orgCommunity Documentation
One of the requirements of an implementation passing the TCK is for it to pass the Bean Validation signature test. This section describes how the signature file is generated and how to run it against your implementation.
You can obtain the Sigtest tool from the Sigtest home page. The TCK uses version 3_0-dev-bin-b09-24_apr_2013 which can be obtained from the SigTest download page. The user guide can be found here (the latest published documentation version is 2.2 but this documentation still applies to SigTest 3.0 in general). The downloadable package contains the jar files used in the commands below.
The TCK package contains the files
validation-api-java6.sig
,
validation-api-java7.sig
and
validation-api-java8.sig
(in the
artifacts
directory) which were created using the
following commands:
// using Java 6 java -jar sigtestdev.jar Setup -classpath $JAVA_HOME/jre/lib/rt.jar:validation-api-1.1.0.Final.jar -package javax.validation -filename validation-api-java6.sig // using Java 7 java -jar sigtestdev.jar Setup -classpath $JAVA_HOME/jre/lib/rt.jar:validation-api-1.1.0.Final.jar -package javax.validation -filename validation-api-java7.sig // using Java 8 java -jar sigtestdev.jar Setup -classpath $JAVA_HOME/jre/lib/rt.jar:validation-api-1.1.0.Final.jar -package javax.validation -filename validation-api-java8.sig
In order to pass the Bean Validation TCK you have to make sure that
your API passes the signature tests against
validation-api.sig.
To run the signature test use:
java -jar sigtest.jar Test -classpath $JAVA_HOME/jre/lib/rt.jar:validation-api-1.1.0.Final.jar -static -package javax.validation -filename validation-api-java6.sig
You have to chose the right version of the signature file depending
on your Java version. In order to run against your own Bean Validation API
replace validation-api-1.1.0.Final.jar with your own API jar. You
should get the message "STATUS:Passed."
.
Just for fun (and to confirm that the signature test is working correctly), you can try the following:
1) Edit validation-api-java6.sig
2) Modify one of the class signatures - in the following example we
change one of the constructors for ValidationException
- here's the original:
CLSS public javax.validation.ValidationException cons public ValidationException() cons public ValidationException(java.lang.String) cons public ValidationException(java.lang.String,java.lang.Throwable) cons public ValidationException(java.lang.Throwable) supr java.lang.RuntimeException
Let's change the default (empty) constructor parameter to one with a
java.lang.Integer
parameter instead:
CLSS public javax.validation.ValidationException cons public ValidationException(java.lang.Integer) cons public ValidationException(java.lang.String) cons public ValidationException(java.lang.String,java.lang.Throwable) cons public ValidationException(java.lang.Throwable) supr java.lang.RuntimeException
3) Now when we run the signature test using the above command, we should get the following errors:
Missing Constructors -------------------- javax.validation.ValidationException: constructor public javax.validation.ValidationException.ValidationException(java.lang.Integer) Added Constructors ------------------ javax.validation.ValidationException: constructor public javax.validation.ValidationException.ValidationException() STATUS:Failed.2 errors
Copyright © 2009 - 2014 Red Hat, Inc.