diff --git a/tools/tck-rewrite-ant/pom.xml b/tools/tck-rewrite-ant/pom.xml index a97434f46..1250e6cfd 100644 --- a/tools/tck-rewrite-ant/pom.xml +++ b/tools/tck-rewrite-ant/pom.xml @@ -208,6 +208,18 @@ slf4j-jdk14 1.7.36 + + org.dom4j + dom4j + 2.1.4 + test + + + jaxen + jaxen + 1.2.0 + test + diff --git a/tools/tck-rewrite-ant/src/main/java/tck/jakarta/platform/ant/api/TestPackageInfoBuilder.java b/tools/tck-rewrite-ant/src/main/java/tck/jakarta/platform/ant/api/TestPackageInfoBuilder.java index 77cde9fb5..41224552e 100644 --- a/tools/tck-rewrite-ant/src/main/java/tck/jakarta/platform/ant/api/TestPackageInfoBuilder.java +++ b/tools/tck-rewrite-ant/src/main/java/tck/jakarta/platform/ant/api/TestPackageInfoBuilder.java @@ -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 testMethods) throws IOException { - ArrayList 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 testMethods, EE11toEE10Mapping mapping) throws IOException { TestPackageInfo testPackageInfo = new TestPackageInfo(clazz, testMethods, mapping); List testClientInfos = buildTestClientsEx(clazz, testMethods, mapping); @@ -126,26 +116,6 @@ public TestPackageInfo buildTestPackgeInfoEx(Class clazz, List buildTestClients(Class clazz, List testMethods) throws IOException { - ArrayList 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 @@ -209,13 +179,21 @@ public List buildTestClientsEx(Class clazz, List "); + System.exit(1); + } + String ee10JunitXml = args[0]; + String ee11JunitXmlDir = args[1]; + System.out.println("Comparing " + ee10JunitXml + " to " + ee11JunitXmlDir); + // EE10 + try { + List 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 testXmlFiles = Files.walk(Paths.get(ee11JunitXmlDir)) + .filter(Files::isRegularFile) + .filter(path -> path.toString().endsWith(".xml")) + .toList() + ; + List ee11Testcases = new ArrayList<>(); + for (Path testXmlFile : testXmlFiles) { + try { + List 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 parseJunitXml(String junitXml) throws DocumentException { + SAXReader reader = new SAXReader(); + Document document = reader.read(Paths.get(junitXml).toFile()); + List 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 ee10Testcases) { + HashMap 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)); + } + } +} diff --git a/tools/tck-rewrite-ant/src/test/java/tck/conversion/ant/api/DeploymentMethodTest.java b/tools/tck-rewrite-ant/src/test/java/tck/conversion/ant/api/DeploymentMethodTest.java index 420798c82..391469908 100644 --- a/tools/tck-rewrite-ant/src/test/java/tck/conversion/ant/api/DeploymentMethodTest.java +++ b/tools/tck-rewrite-ant/src/test/java/tck/conversion/ant/api/DeploymentMethodTest.java @@ -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 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());