Hibernate.orgCommunity Documentation
This chapter explains how to obtain the TCK and supporting software and provides recommendations for how to install/extract it on your system.
You can obtain a release of the Bean Validation TCK project via the
official Bean Validation home
page. The Bean Validation TCK is distributed as a ZIP file, which
contains the TCK artifacts (the test suite binary and source, the test
suite descriptor, the audit source and report), the TCK library
dependencies in /lib
and documentation in
/doc
.
You can also download the current source code from Github - https://github.com/beanvalidation/beanvalidation-tck.
The TCK project is available in the JBoss Maven 2 repository as
org.hibernate.jsr303.tck:
org.hibernate.jsr303.tck; the POM
defines all dependencies required to run the TCK.
Executing the TCK requires a Java EE 5 or better runtime environment (i.e., application server), to which the test artifacts are deployed and the individual tests are invoked. The TCK does not depend on any particular Java EE implementation.
The JSR-303: Bean Validation reference implementation (RI) project is named Hibernate Validator. You can obtain the latest Hibernate Validator release from the download page on Hibernate website.
Hibernate Validator is not required for running the Bean Validation TCK, but it can be used as a reference for familiarizing yourself with the TCK before testing your own Bean Validation implementation.
The TCK requires the following two Java runtime environments:
Java 5 or better
Java EE 5 or better (e.g., JBoss AS 5.x or GlassFish V3)
You should refer to vendor instructions for how to install the runtime.
The rest of the TCK software can simply be extracted. It's recommended that you create a folder named jsr303 to hold all of the jsr303-related projects. Then, extract the TCK distribution into a subfolder named tck. You can also check out the full Hibernate Validator source into a subfolder ri. This will allow you to run the TCK against Hibernate Validator.
git clone git://github.com/hibernate/hibernate-validator.git ri git checkout 4.2.0.Final
If you have downloaded the Hibernate Validator distribution, extract it into a sibling folder named hibernate-validator. The resulting folder structure is shown here:
jsr303/ ri/ tck/
Each test class is treated as an individual artifact (hence the
@Artifact(artifactType = ArtifactType.JSR303)
annotation on the class). All test methods (i.e., methods annotated with
@Test
) in the test class are run.
Using ArtifactType.JSR303
is an additional
artifact type to the standard WAR and EAR types offered by the JBoss
Test Harness. It is basically a normal WAR file with a
validation.xml
file at the root of the classpath.
The validation.xml
file can be specified with the
@ValidationXml
annotation. Using
ArtifactType.JSR303
together with
@ValidationXml
also allows to have test with
custom validation.xml files running in standalone mode. This is possible
by modifying the classloader in standalone mode as shown in
org.hibernate.jsr303.tck.util.StandaloneContainersImpl
.
This container implementation is also the default for sandalone
mode.
First, you should download the latest JBoss AS 7 release from the JBoss AS project page.
Set the JBOSS_HOME
environment variable to
the location of the JBoss AS software.
Change to the
ri/hibernate-validator-tck-runner
directory.
You need to install Maven. You can find documention on how to
install Maven 2 in the Maven:
The Definitive Guide book published by Sonatype. Web Beans
bundles a copy of Maven in the lib/maven
directory.
Next, instruct Maven to run the TCK:
mvn test -Dincontainer
TestNG will report, via Maven, the outcome of the run, and
report any failures on the console. Details can be found in
target/surefire-reports/TestSuite.txt
.
Copyright © 2009 - 2011 Red Hat, Inc.