Skip to content

Commit

Permalink
Cleanup signature testing
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Aug 1, 2023
1 parent 3aeb427 commit 0eea2c0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
15 changes: 14 additions & 1 deletion tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<properties>
<jakarta.concurrent.api.version>3.1.0-SNAPSHOT</jakarta.concurrent.api.version>
<sigtest.version>1.6</sigtest.version>
<shrinkwrap.resolver.version>3.2.1</shrinkwrap.resolver.version>
</properties>

<dependencies>
Expand All @@ -58,36 +59,42 @@
<version>${jakarta.concurrent.api.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.ejb</groupId>
<artifactId>jakarta.ejb-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.interceptor</groupId>
<artifactId>jakarta.interceptor-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.netbeans.tools</groupId>
<artifactId>sigtest-maven-plugin</artifactId>
<version>${sigtest.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -99,6 +106,12 @@
<artifactId>arquillian-junit5-container</artifactId>
<version>${arquillian.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<version>${shrinkwrap.resolver.version}</version>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ protected String getSigFileName(final String baseName, final String repositoryDi
*
* @param packageName The package under test
* @param mapFile The name of the file that maps package names to versions
* @param repositoryDir The directory that conatisn all signature files
* @param repositoryDir The directory that contains all signature files
*
* @return String The path and name of the siganture file that contains the
* specified package's signatures
Expand Down Expand Up @@ -533,7 +533,7 @@ protected SignatureFileInfo getSigFileInfo(final String originalPackage, final S
throw new Exception(
"Package \"" + originalPackage + "\" not specified in mapping file \"" + mapFile + "\".");
}
packageName.substring(0, index);
packageName = packageName.substring(0, index);
} // end while

/* Return the expected name of the signature file */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package ee.jakarta.tck.concurrent.framework.arquillian.extensions;

import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
Expand All @@ -25,10 +26,12 @@
import org.jboss.arquillian.test.spi.TestClass;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.container.ClassContainer;
import org.jboss.shrinkwrap.api.container.LibraryContainer;
import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;

import ee.jakarta.tck.concurrent.common.signature.ConcurrencySignatureTestRunner;
import ee.jakarta.tck.concurrent.framework.junit.anno.Common;
Expand All @@ -54,14 +57,18 @@ public void process(final Archive<?> applicationArchive, final TestClass testCla

private static void appendCommonPackages(final Archive<?> applicationArchive, final TestClass testClass, final String applicationName) {
if (!testClass.isAnnotationPresent(Common.class)) {
return;
return; //Nothing to append
}

List<String> packages = Stream.of(testClass.getAnnotation(Common.class).value())
.map(pkg -> pkg.getPackageName()).collect(Collectors.toList());

if (packages.isEmpty()) {
return; //Nothing to append
}

// TODO research to see if there is a way around this
if (applicationArchive instanceof EnterpriseArchive && !packages.isEmpty()) {
if (applicationArchive instanceof EnterpriseArchive) {
throw new RuntimeException("Cannot append packages to Enterprise Archives since modules are immutable");
}

Expand All @@ -73,22 +80,27 @@ private static void appendCommonPackages(final Archive<?> applicationArchive, fi
}

private static void appendSignaturePackages(final Archive<?> applicationArchive, final TestClass testClass, final String applicationName) {

if (!testClass.isAnnotationPresent(Signature.class)) {
return;
return; //Nothing to append
}

final boolean isJava21orAbove = Integer.parseInt(System.getProperty("java.specification.version")) >= 21;
final Package signaturePackage = ConcurrencySignatureTestRunner.class.getPackage();

if (applicationArchive instanceof ClassContainer) {
log.info("Application Archive [" + applicationName + "] is being appended with packages ["
+ signaturePackage + ", com.sun.tdk, org.netbeans.apitest]");

// Add the Concurrency runner
log.info("Application Archive [" + applicationName + "] is being appended with packages [" + signaturePackage + "]");
((ClassContainer<?>) applicationArchive).addPackage(signaturePackage);

// Add the sigtest plugin library
File sigTestDep = Maven.resolver().resolve("org.netbeans.tools:sigtest-maven-plugin:1.6").withoutTransitivity().asSingleFile();
log.info("Application Archive [" + applicationName + "] is being appended with library " + sigTestDep.getName());
((LibraryContainer<?>) applicationArchive).addAsLibrary(sigTestDep);

// Add signature resources
log.info("Application Archive [" + applicationName + "] is being appended with resources "
+ Arrays.asList(ConcurrencySignatureTestRunner.SIG_RESOURCES));
((ClassContainer<?>) applicationArchive).addPackage(signaturePackage);
// These are the packages from the sig-test plugin that are needed to run the test.
((ClassContainer<?>) applicationArchive).addPackages(true, "com.sun.tdk", "org.netbeans.apitest");
((ResourceContainer<?>) applicationArchive).addAsResources(signaturePackage,
ConcurrencySignatureTestRunner.SIG_MAP_NAME, ConcurrencySignatureTestRunner.SIG_PKG_NAME);
((ResourceContainer<?>) applicationArchive).addAsResource(signaturePackage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
* This extension will intercept all archives before they are deployed to the
* container and append a library with the following:
*
* Package - ee.jakarta.tck.concurrent.framework Package -
* ee.jakarta.tck.concurrent.framework.arquillian.extensions Package -
* ee.jakarta.tck.concurrent.framework.junit.extensions
* Package - ee.jakarta.tck.concurrent.framework
* Package - ee.jakarta.tck.concurrent.framework.arquillian.extensions
* Package - ee.jakarta.tck.concurrent.framework.junit.extensions
*
*/
public class TCKFrameworkAppender implements AuxiliaryArchiveAppender {
Expand Down

0 comments on commit 0eea2c0

Please sign in to comment.