Skip to content

Commit

Permalink
Fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Jul 19, 2023
1 parent 97a306a commit 3aeb427
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected String getClasspath() {

// Get JDK modules from jimage
// Add JDK classes to classpath
File jimageOutput = new File(getTestInfo().getJImageDir());
File jimageOutput = new File(SigTestData.getJImageDir());
for (String module : jdkModules) {
Path modulePath = Paths.get(jimageOutput.getAbsolutePath(), module);
if (Files.isDirectory(modulePath)) {
Expand Down Expand Up @@ -227,9 +227,9 @@ public void signatureTest() throws Fault {
log.info("Exception while creating temp files :" + ex);
}

String[] packagesUnderTest = getPackages(getTestInfo().getVehicle());
String[] classesUnderTest = getClasses(getTestInfo().getVehicle());
String optionalPkgToIgnore = getTestInfo().getOptionalTechPackagesToIgnore();
String[] packagesUnderTest = getPackages(SigTestData.getVehicle());
String[] classesUnderTest = getClasses(SigTestData.getVehicle());
String optionalPkgToIgnore = SigTestData.getOptionalTechPackagesToIgnore();

// unlisted optional packages are technology packages for those optional
// technologies (e.g. jsr-88) that might not have been specified by the
Expand All @@ -243,7 +243,7 @@ public void signatureTest() throws Fault {
Properties sysProps = System.getProperties();
String version = (String) sysProps.get("java.version");
if (!version.startsWith("1.")) {
String jimageDir = getTestInfo().getJImageDir();
String jimageDir = SigTestData.getJImageDir();
File f = new File(jimageDir);
f.mkdirs();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected SignatureTestDriver getSigTestDriver() {
* @return String The path and name of the package list file.
*/
protected String getPackageFile() {
return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir());
return getSigTestDriver().getPackageFileImpl(SigTestData.getBinDir());
}

/**
Expand All @@ -85,7 +85,7 @@ protected String getPackageFile() {
* @return String The path and name of the signature map file.
*/
protected String getMapFile() {
return getSigTestDriver().getMapFileImpl(testInfo.getBinDir());
return getSigTestDriver().getMapFileImpl(SigTestData.getBinDir());
}

/**
Expand All @@ -98,7 +98,7 @@ protected String getMapFile() {
* @return String The signature repository directory.
*/
protected String getRepositoryDir() {
return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome());
return getSigTestDriver().getRepositoryDirImpl(SigTestData.getTSHome());
}

/**
Expand Down Expand Up @@ -155,8 +155,6 @@ protected String[] getClasses() {

} // END getClasses

private SigTestData testInfo; // holds the bin.dir property

/**
* Called by the test framework to initialize this test. The method simply
* retrieves some state information that is necessary to run the test when when
Expand All @@ -168,7 +166,6 @@ protected String[] getClasses() {
public void setup() {
try {
System.out.println("$$$ SigTest.setup() called");
this.testInfo = new SigTestData();
System.out.println("$$$ SigTest.setup() complete");
} catch (Exception e) {
System.out.println("Unexpected exception " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,51 +27,51 @@
* setup phase. This allows us to keep the passed data separate and reuse the
* data between the signature test framework base classes.
*/
public class SigTestData {
public final class SigTestData {

private Properties props;

public SigTestData() {
this.props = System.getProperties();
private SigTestData() {
// Helper class
}

public String getVehicle() {
private static Properties props = System.getProperties();

public static String getVehicle() {
return props.getProperty("vehicle", "");
}

public String getBinDir() {
public static String getBinDir() {
return props.getProperty("bin.dir", "");
}

public String getTSHome() {
public static String getTSHome() {
return props.getProperty("ts_home", "");
}

public String getTestClasspath() {
public static String getTestClasspath() {
return props.getProperty("sigTestClasspath", "");
}

public String getJavaeeLevel() {
public static String getJavaeeLevel() {
return props.getProperty("javaee.level", "");
}

public String getCurrentKeywords() {
public static String getCurrentKeywords() {
return props.getProperty("current.keywords", "");
}

public String getProperty(final String prop) {
public static String getProperty(final String prop) {
return props.getProperty(prop);
}

public String getOptionalTechPackagesToIgnore() {
public static String getOptionalTechPackagesToIgnore() {
return props.getProperty("optional.tech.packages.to.ignore", "");
}

public String getJtaJarClasspath() {
public static String getJtaJarClasspath() {
return props.getProperty("jtaJarClasspath", "");
}

public String getJImageDir() {
public static String getJImageDir() {
return props.getProperty("jimage.dir", "");
}
} // end class SigTestData
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected SignatureTestDriver getSigTestDriver() {
* @return String The path and name of the package list file.
*/
protected String getPackageFile() {
return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir());
return getSigTestDriver().getPackageFileImpl(SigTestData.getBinDir());
}

/**
Expand All @@ -84,7 +84,7 @@ protected String getPackageFile() {
* @return String The path and name of the signature map file.
*/
protected String getMapFile() {
return getSigTestDriver().getMapFileImpl(testInfo.getBinDir());
return getSigTestDriver().getMapFileImpl(SigTestData.getBinDir());
}

/**
Expand All @@ -97,7 +97,7 @@ protected String getMapFile() {
* @return String The signature repository directory.
*/
protected String getRepositoryDir() {
return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome());
return getSigTestDriver().getRepositoryDirImpl(SigTestData.getTSHome());
}

/**
Expand Down Expand Up @@ -182,8 +182,6 @@ protected String[] getClasses(final String vehicleName) {

} // END getClasses

private SigTestData testInfo; // holds the bin.dir and vehicle properties

/**
* Called by the test framework to initialize this test. The method simply
* retrieves some state information that is necessary to run the test when when
Expand All @@ -192,21 +190,12 @@ protected String[] getClasses(final String vehicleName) {
public void setup() {
try {
System.out.println("$$$ SigTestEE.setup() called");
this.testInfo = new SigTestData();
System.out.println("$$$ SigTestEE.setup() complete");
} catch (Exception e) {
System.out.println("Unexpected exception " + e.getMessage());
}
}

protected SigTestData getTestInfo() {
if (testInfo == null) {
setup();
}

return testInfo;
}

/**
* Called by the test framework to run this test. This method utilizes the state
* information set in the setup method to run the signature tests. All signature
Expand All @@ -220,11 +209,11 @@ public void signatureTest() throws Fault {
SigTestResult results = null;
String mapFile = getMapFile();
String repositoryDir = getRepositoryDir();
String[] packages = getPackages(testInfo.getVehicle());
String[] classes = getClasses(testInfo.getVehicle());
String[] packages = getPackages(SigTestData.getVehicle());
String[] classes = getClasses(SigTestData.getVehicle());
String packageFile = getPackageFile();
String testClasspath = testInfo.getTestClasspath();
String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore();
String testClasspath = SigTestData.getTestClasspath();
String optionalPkgToIgnore = SigTestData.getOptionalTechPackagesToIgnore();

// unlisted optional packages are technology packages for those optional
// technologies (e.g. jsr-88) that might not have been specified by the
Expand All @@ -238,7 +227,7 @@ public void signatureTest() throws Fault {
Properties sysProps = System.getProperties();
String version = (String) sysProps.get("java.version");
if (!version.startsWith("1.")) {
String jimageDir = testInfo.getJImageDir();
String jimageDir = SigTestData.getJImageDir();
File f = new File(jimageDir);
f.mkdirs();

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.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
Expand All @@ -24,11 +25,14 @@
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.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;

import ee.jakarta.tck.concurrent.common.signature.ConcurrencySignatureTestRunner;
import ee.jakarta.tck.concurrent.framework.junit.anno.Common;
import ee.jakarta.tck.concurrent.framework.junit.anno.Signature;

/**
* This extension will intercept archives before they are deployed to the
Expand All @@ -39,9 +43,16 @@ public class TCKArchiveProcessor implements ApplicationArchiveProcessor {

@Override
public void process(final Archive<?> applicationArchive, final TestClass testClass) {
String applicationName = applicationArchive.getName() == null ? applicationArchive.getId()
String applicationName = applicationArchive.getName() == null
? applicationArchive.getId()
: applicationArchive.getName();

appendCommonPackages(applicationArchive, testClass, applicationName);
appendSignaturePackages(applicationArchive, testClass, applicationName);

}

private static void appendCommonPackages(final Archive<?> applicationArchive, final TestClass testClass, final String applicationName) {
if (!testClass.isAnnotationPresent(Common.class)) {
return;
}
Expand All @@ -59,6 +70,33 @@ public void process(final Archive<?> applicationArchive, final TestClass testCla
packages.stream().forEach(pkg -> ((ClassContainer<?>) applicationArchive).addPackage(pkg));

}
}

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

if (!testClass.isAnnotationPresent(Signature.class)) {
return;
}

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]");
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,
// Get local resource based on JDK level
isJava21orAbove ? ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_21"
: ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_17",
// Target same package as test
signaturePackage.getName().replace(".", "/") + "/" + ConcurrencySignatureTestRunner.SIG_FILE_NAME);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class TCKLoadableExtension implements LoadableExtension {
@Override
public void register(final ExtensionBuilder builder) {
builder.service(ApplicationArchiveProcessor.class, TCKArchiveProcessor.class);
builder.service(ApplicationArchiveProcessor.class, TCKSignatureProcessor.class);
builder.service(AuxiliaryArchiveAppender.class, TCKFrameworkAppender.class);
}
}

This file was deleted.

0 comments on commit 3aeb427

Please sign in to comment.