jakartaee / rest

Jakarta RESTful Web Services
Other
362 stars 117 forks source link

TCK Migration: Move standalone jaxrs tck signature tests from jakartaee-tck #1044

Closed alwin-joseph closed 2 years ago

alwin-joseph commented 2 years ago

This PR is to migrate the signature tests to new REST standalone tck from jakartaee-tck repository.

We are using the same framework to run the signature tests as from jakartaee-tck. But the procedure to generate and run the tests are changed from both TCK developer and user perspective. Also we are using the sigtest-maven-plugin.jar for generating and running the signature tests, which is available in maven central repository.

Major changes in this repo compared to that of jakartaee-tck

  1. We use sigtest-maven-plugin.jar from maven instead of sigtest.jar and sigtestdev.jar to generate and run the signature tests.
  2. The signature, mapping and the package list files are now renamed to jakarta.ws.rs.sig_${version}, sig-test.map, sig-test-pkg-list.txt files respectively.
  3. The property names are now renamed and need to be set as System properties instead of in ts.jte file. There is no ts.jte file in the new TCK.
  4. Changes are made to remove dependency on JTharness and run the test as Junit.

For TCK developers (jaxrs-api team now) :-

  1. Generate Signature Files : The signature file will have to be generated by the TCK team using jaxrs-tck/pom.xml by running mvn install -Precord-signature. The classpath should contain the api jar for which we are generating the signature file.

The signature file name expected is jakarta.ws.rs.sig_${version} , where version is the api version for which the signature is generated.

  1. Place the required files in the TCK folder :

All the below files has to be placed in the folder jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/signaturetest, so they are included as part of the TCK jar during the build.

For TCK users (to run the signature test as a Junit test) :-

  1. The signature test related files will need to be extracted from the jar to a known location to be used for running the test. For eg: in maven we can use the below code to extract the signature file, mapping file and package list file to ${project.build.directory}/signaturedirectory as done in this PR.
<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-dependency-plugin</artifactId>
 <version>3.2.0</version>
 <execution>
   <id>copy-jaxrs-tck-signature-files</id>
   <phase>generate-test-sources</phase>
   <goals>
     <goal>unpack</goal>
   </goals>
   <configuration>
   <artifactItems>
     <artifactItem>
     <groupId>jakarta.ws.rs</groupId>
     <artifactId>jakarta.ws.rs-tck</artifactId>
     <version>3.1-SNAPSHOT</version>
     <type>jar</type>
     <overWrite>true</overWrite>
   </artifactItem>
 </artifactItems>
<!-- We need the signature file, mapping file and package list file -->
<includes>**/*sig-test*,**/*jakarta.ws.rs.sig_*</includes>
<outputDirectory>${project.build.directory}/signaturedirectory</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
  1. We would need to set the below system properties correctly :
jimage.dir //The jdk9+(jdk11 for this release) will be extracted to this location as to use the Java modules in the path.
optional.tech.packages.to.ignore // The optional package that should be ignored while running the signature test
signature.mapfile //The full path of the signature mapping file
signature.repositoryDir // The directory where the signature file is placed.
signature.packagelist //The full path of the list of packages that will be tested.
signature.sigTestClasspath // the sigTestClasspath that will contain the implementation jar that needs to be tested along with dependent jars.

For eg: they are set in this PR as below.

<jimage.dir>${project.build.directory}/jdk11-bundle</jimage.dir>
<optional.tech.packages.to.ignore>jakarta.xml.bind</optional.tech.packages.to.ignore>
<signature.mapfile>${project.build.directory}/signaturedirectory/jakarta/ws/rs/tck/signaturetest/sig-test.map</signature.mapfile>
<signature.repositoryDir>${project.build.directory}/signaturedirectory/jakarta/ws/rs/tck/signaturetest</signature.repositoryDir>
<signature.packagelist>${project.build.directory}/signaturedirectory/jakarta/ws/rs/tck/signaturetest/sig-test-pkg-list.txt</signature.packagelist>
<signature.sigTestClasspath>${project.build.directory}/glassfish6/glassfish/modules/jakarta.ws.rs-api.jar:${project.build.directory}/glassfish6/glassfish/modules/jakarta.xml.bind-api.jar:${project.build.directory}/jdk11-bundle/java.base:${project.build.directory}/jdk11-bundle/java.rmi:${project.build.directory}/jdk11-bundle/java.sql:${project.build.directory}/jdk11-bundle/java.naming</signature.sigTestClasspath>
  1. The signature test alone can be run using below command within jersey-tck/ direcotry.

mvn clean verify -Parq-glassfish-managed -Dit.test=jakarta.ws.rs.tck.signaturetest.**

Can you please review this and suggest your opinions on this. @jansupol @gurunrao @spericas @scottmarlow