Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the handling of the ejblitejsf vehicle type #115

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tools/tck-rewrite-ant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,9 @@ public static TestPackageInfoBuilder fromSystemProperty() throws FileNotFoundExc

* @param clazz - a test class in the EE10 TCK
* @param testMethods - the test methods to include in the test client
* @return
* @return the {@link TestPackageInfo} instance for the test class
* @throws IOException - on failure to parse the build.xml file
* @deprecated use {@link #buildTestPackgeInfoEx(Class, List, EE11toEE10Mapping)} instead
*/
@Deprecated(since = "1.0.0", forRemoval = true)
public TestPackageInfo buildTestPackgeInfo(Class<?> clazz, List<String> testMethods) throws IOException {
ArrayList<TestMethodInfo> testMethodInfos = new ArrayList<>();
for (String testMethod : testMethods) {
testMethodInfos.add(new TestMethodInfo(testMethod, Exception.class.getSimpleName()));
}

return buildTestPackgeInfoEx(clazz, testMethodInfos, DefaultEEMapping.getInstance());
}
public TestPackageInfo buildTestPackgeInfoEx(Class<?> clazz, List<TestMethodInfo> testMethods, EE11toEE10Mapping mapping) throws IOException {
TestPackageInfo testPackageInfo = new TestPackageInfo(clazz, testMethods, mapping);
List<TestClientInfo> testClientInfos = buildTestClientsEx(clazz, testMethods, mapping);
Expand All @@ -126,26 +116,6 @@ public TestPackageInfo buildTestPackgeInfoEx(Class<?> clazz, List<TestMethodInfo
return testPackageInfo;
}

/**
* Parses the ant build.xml file for the test directory associated with the pkg and returns the
* Arquillian deployment methods for the test deployment artifacts that should be generated.
* This builds a list of {@link TestClientInfo} instances for the test class with java.lang.Exception
* as the throws type and class {@link #buildTestClientsEx(Class, List, EE11toEE10Mapping)}

* @param clazz - a test class in the EE10 TCK
* @param testMethods - the test method names to include in the test client
* @return
* @throws IOException - on failure to parse the build.xml file
*/
@Deprecated(since = "1.0.0", forRemoval = true)
public List<TestClientInfo> buildTestClients(Class<?> clazz, List<String> testMethods) throws IOException {
ArrayList<TestMethodInfo> testMethodInfos = new ArrayList<>();
for (String testMethod : testMethods) {
testMethodInfos.add(new TestMethodInfo(testMethod, Exception.class.getSimpleName()));
}
return buildTestClientsEx(clazz, testMethodInfos, DefaultEEMapping.getInstance());
}

/**
* Parses the ant build.xml file for the test directory associated with the pkg and returns the
* Arquillian deployment methods for the test deployment artifacts that should be generated. This version
Expand Down Expand Up @@ -209,13 +179,21 @@ public List<TestClientInfo> buildTestClientsEx(Class<?> clazz, List<TestMethodIn
testClientInfo.setTags(extraTags);
testClientInfos.add(testClientInfo);
} else {

for(String vehicle : vehicles) {
VehicleType vehicleType = VehicleType.valueOf(vehicle);
// Skip unsupported vehicles
if(vehicleType == VehicleType.ejbembed) {
continue;
}
// ejblitejsf vehicle only applies to the JsfClient class
if (vehicleType == VehicleType.ejblitejsf && !testClassSimpleName.equals("JsfClient")) {
info("Skipping ejblitejsf vehicle for class: %s\n", testClassSimpleName);
continue;
}
if(testClassSimpleName.equals("JsfClient") && vehicleType != VehicleType.ejblitejsf) {
info("Skipping non-ejblitejsf vehicle for class: %s\n", testClassSimpleName);
continue;
}
Project project = initProject(buildXml);
debug("Parsing(%s)\n", buildXml);
ProjectHelper.configureProject(project, buildXml.toFile());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package tck.conversion;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
* One off program to read in the junit xml from an EE10 module test run and compare it to the output of the EE11
* module test run. This reads in the single xml result from the glassfish ci and the multiple xml results from the
* EE11 module test run and compares them.
*/
public class CompareTestRuns {
public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.out.println("Usage: CompareTestRuns <ee10-junit-xml> <ee11-junit-xml-dir>");
System.exit(1);
}
String ee10JunitXml = args[0];
String ee11JunitXmlDir = args[1];
System.out.println("Comparing " + ee10JunitXml + " to " + ee11JunitXmlDir);
// EE10
try {
List<Testcase> ee10Testcases = parseJunitXml(ee10JunitXml);
System.out.println("Found " + ee10Testcases.size() + " testcases in " + ee10JunitXml);
/*
for (Testcase testcase : ee10Testcases) {
System.out.println(testcase);
}
*/
// Summarize test count by test package
System.out.println("--- EE10 test count by package:");
summarizeTestCountByPackage(ee10Testcases);
} catch (DocumentException e) {
e.printStackTrace();
}

// EE11
List<Path> testXmlFiles = Files.walk(Paths.get(ee11JunitXmlDir))
.filter(Files::isRegularFile)
.filter(path -> path.toString().endsWith(".xml"))
.toList()
;
List<Testcase> ee11Testcases = new ArrayList<>();
for (Path testXmlFile : testXmlFiles) {
try {
List<Testcase> testcases = parseJunitXml(testXmlFile.toString());
ee11Testcases.addAll(testcases);
} catch (DocumentException e) {
e.printStackTrace();
}
}
System.out.println("Found " + ee11Testcases.size() + " testcases in " + ee11JunitXmlDir);
System.out.println("--- EE11 test count by package:");
summarizeTestCountByPackage(ee11Testcases);
}

record Testcase(String name, String classname, int time) {
}
static List<Testcase> parseJunitXml(String junitXml) throws DocumentException {
SAXReader reader = new SAXReader();
Document document = reader.read(Paths.get(junitXml).toFile());
List<Node> list = document.selectNodes("//testcase");
return list.stream()
.map(CompareTestRuns::parseTestcase)
.toList();
}
static Testcase parseTestcase(Node node) {
String name = node.valueOf("@name");
String classname = node.valueOf("@classname");
String time = node.valueOf("@time");
int seconds = Float.valueOf(time).intValue();
return new Testcase(name, classname, seconds);
}
static void summarizeTestCountByPackage(List<Testcase> ee10Testcases) {
HashMap<String, Integer> testCountByPackage = new HashMap<>();
for (Testcase testcase : ee10Testcases) {
String packageName = testcase.classname().substring(0, testcase.classname().lastIndexOf('.'));
testCountByPackage.put(packageName, testCountByPackage.getOrDefault(packageName, 0) + 1);
}
for(String packageName : testCountByPackage.keySet()) {
System.out.println(packageName + ": " + testCountByPackage.get(packageName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,19 @@ public void testejb32_lite_timer_basic_concurrency() throws IOException {
@Test
public void testejb32_lite_timer_basic_concurrency_ejblitejsf() throws IOException {
TestPackageInfoBuilder builder = new TestPackageInfoBuilder(tsHome);
Class<?> baseTestClass = com.sun.ts.tests.ejb32.lite.timer.basic.concurrency.Client.class;
List<TestMethodInfo> testMethods = Arrays.asList(
new TestMethodInfo("lookupTimerService", "InterruptedException, java.util.concurrent.ExecutionException"),
new TestMethodInfo("writeLockTimeout", "")
);
Class<?> baseTestClass = com.sun.ts.tests.ejb32.lite.timer.basic.concurrency.JsfClient.class;
TestPackageInfo packageInfo = builder.buildTestPackgeInfoEx(baseTestClass, testMethods, DefaultEEMapping.getInstance());
System.out.println(packageInfo);
System.out.println(packageInfo.getTestClientFiles());
}
@Test
public void testejb32_lite_timer_basic_concurrency_ejblitejsf2() throws IOException {
TestPackageInfoBuilder builder = new TestPackageInfoBuilder(tsHome);
Class<?> baseTestClass = com.sun.ts.tests.ejb32.lite.timer.basic.concurrency.JsfClient.class;
DeploymentMethodInfo deploymentMethodInfo = builder.forTestClassAndVehicle(baseTestClass, VehicleType.ejblitejsf);
System.out.println(deploymentMethodInfo);
System.out.printf("War.content: %s\n", deploymentMethodInfo.getDebugInfo().getWar().getWebContent());
Expand Down