This is an automated email from the ASF dual-hosted git repository.

veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git


The following commit(s) were added to refs/heads/master by this push:
     new d148a7815 Migrate SerializerConformanceTest to MatrixTestNode framework
d148a7815 is described below

commit d148a78159206e0b7535c20496a479f29c88b4a6
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Sun Mar 8 11:45:53 2026 +0000

    Migrate SerializerConformanceTest to MatrixTestNode framework
    
    Split the self-contained SerializerConformanceTest into:
    - SerializerConformanceTestCase: extends TestCase, uses @Inject for 
XMLSample
    - SerializerConformanceTest: JUnit 5 @TestFactory with ParameterFanOutNode
    
    Added junit-jupiter, guice, and multiton dependencies to core-streams 
pom.xml.
    
    Updated migration.md: suite class must be named *Test (not *TestSuite) so 
that
    Maven Surefire discovers it.
---
 components/core-streams/pom.xml                    | 16 +++++
 .../serializer/SerializerConformanceTest.java      | 71 ++++++----------------
 ...est.java => SerializerConformanceTestCase.java} | 29 +++------
 testing/matrix-testsuite/migration.md              | 17 +++---
 4 files changed, 48 insertions(+), 85 deletions(-)

diff --git a/components/core-streams/pom.xml b/components/core-streams/pom.xml
index 1742cde14..f51981389 100644
--- a/components/core-streams/pom.xml
+++ b/components/core-streams/pom.xml
@@ -72,6 +72,22 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>multiton</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>xml-testsuite</artifactId>
diff --git 
a/components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTest.java
 
b/components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTest.java
index 6d50e6ae9..cb68bb4e6 100644
--- 
a/components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTest.java
+++ 
b/components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTest.java
@@ -18,61 +18,24 @@
  */
 package org.apache.axiom.core.stream.serializer;
 
-import static com.google.common.truth.Truth.assertAbout;
-import static org.apache.axiom.testing.multiton.Multiton.getInstances;
-import static org.apache.axiom.truth.xml.XMLTruth.xml;
+import java.util.stream.Stream;
 
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.axiom.core.stream.XmlReader;
-import org.apache.axiom.core.stream.dom.input.DOMInput;
-import org.apache.axiom.testutils.suite.MatrixTestCase;
-import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
+import org.apache.axiom.testing.multiton.Multiton;
+import org.apache.axiom.testutils.suite.MatrixTest;
+import org.apache.axiom.testutils.suite.ParameterFanOutNode;
 import org.apache.axiom.ts.xml.XMLSample;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-
-import junit.framework.TestSuite;
-
-public class SerializerConformanceTest extends MatrixTestCase {
-    private final XMLSample sample;
-
-    public SerializerConformanceTest(XMLSample sample) {
-        this.sample = sample;
-        addTestParameter("sample", sample.getName());
-    }
-
-    @Override
-    protected void runTest() throws Throwable {
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        factory.setNamespaceAware(true);
-        factory.setExpandEntityReferences(false);
-        Document document = 
factory.newDocumentBuilder().parse(sample.getUrl().toString());
-        StringWriter sw = new StringWriter();
-        XmlReader reader = new DOMInput(document, false).createReader(new 
Serializer(sw));
-        while (!reader.proceed()) {
-            // Just loop
-        }
-        InputSource is = new InputSource(new StringReader(sw.toString()));
-        is.setSystemId(sample.getUrl().toString());
-        assertAbout(xml())
-                .that(is)
-                .ignoringWhitespaceInPrologAndEpilog()
-                .treatingElementContentWhitespaceAsText() // TODO
-                .hasSameContentAs(document);
-    }
-
-    public static TestSuite suite() {
-        return new MatrixTestSuiteBuilder() {
-            @Override
-            protected void addTests() {
-                for (XMLSample sample : getInstances(XMLSample.class)) {
-                    addTest(new SerializerConformanceTest(sample));
-                }
-            }
-        }.build();
+import org.junit.jupiter.api.DynamicNode;
+import org.junit.jupiter.api.TestFactory;
+
+public class SerializerConformanceTest {
+    @TestFactory
+    public Stream<DynamicNode> tests() {
+        return new ParameterFanOutNode<>(
+                        XMLSample.class,
+                        Multiton.getInstances(XMLSample.class),
+                        "sample",
+                        XMLSample::getName,
+                        new MatrixTest(SerializerConformanceTestCase.class))
+                .toDynamicNodes();
     }
 }
diff --git 
a/components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTest.java
 
b/components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTestCase.java
similarity index 72%
copy from 
components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTest.java
copy to 
components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTestCase.java
index 6d50e6ae9..250754bd8 100644
--- 
a/components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTest.java
+++ 
b/components/core-streams/src/test/java/org/apache/axiom/core/stream/serializer/SerializerConformanceTestCase.java
@@ -19,7 +19,6 @@
 package org.apache.axiom.core.stream.serializer;
 
 import static com.google.common.truth.Truth.assertAbout;
-import static org.apache.axiom.testing.multiton.Multiton.getInstances;
 import static org.apache.axiom.truth.xml.XMLTruth.xml;
 
 import java.io.StringReader;
@@ -27,23 +26,20 @@ import java.io.StringWriter;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
 import org.apache.axiom.core.stream.XmlReader;
 import org.apache.axiom.core.stream.dom.input.DOMInput;
-import org.apache.axiom.testutils.suite.MatrixTestCase;
-import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
 import org.apache.axiom.ts.xml.XMLSample;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
-import junit.framework.TestSuite;
+import junit.framework.TestCase;
 
-public class SerializerConformanceTest extends MatrixTestCase {
-    private final XMLSample sample;
-
-    public SerializerConformanceTest(XMLSample sample) {
-        this.sample = sample;
-        addTestParameter("sample", sample.getName());
-    }
+public class SerializerConformanceTestCase extends TestCase {
+    @Inject
+    @Named("sample")
+    private XMLSample sample;
 
     @Override
     protected void runTest() throws Throwable {
@@ -64,15 +60,4 @@ public class SerializerConformanceTest extends 
MatrixTestCase {
                 .treatingElementContentWhitespaceAsText() // TODO
                 .hasSameContentAs(document);
     }
-
-    public static TestSuite suite() {
-        return new MatrixTestSuiteBuilder() {
-            @Override
-            protected void addTests() {
-                for (XMLSample sample : getInstances(XMLSample.class)) {
-                    addTest(new SerializerConformanceTest(sample));
-                }
-            }
-        }.build();
-    }
 }
diff --git a/testing/matrix-testsuite/migration.md 
b/testing/matrix-testsuite/migration.md
index f1bc48b34..35041b199 100644
--- a/testing/matrix-testsuite/migration.md
+++ b/testing/matrix-testsuite/migration.md
@@ -32,9 +32,9 @@ There are two common shapes:
 - **Self-contained test suites** — the test case, suite structure, and consumer
   live in a single class. After migration, these are split into a test case
   class (e.g. `StAXPivotTransformerTestCase`) and a suite class (e.g.
-  `StAXPivotTransformerTestSuite`). They typically don't need `InjectorNode`
+  `StAXPivotTransformerTest`). They typically don't need `InjectorNode`
   at all; fan-out nodes with `MatrixTest` leaves are sufficient. See
-  `StAXPivotTransformerTestSuite` / `StAXPivotTransformerTestCase` in
+  `StAXPivotTransformerTest` / `StAXPivotTransformerTestCase` in
   `components/core-streams` for an example.
 
 The step-by-step guide below focuses on reusable API test suites. For
@@ -312,10 +312,9 @@ However, the result must be **two** classes:
   `TestCase` and contains the test logic. Name it with a `*TestCase` suffix
   (not `*Test`) so that Maven Surefire does not try to run it directly as a
   JUnit 3/4 test.
-- A **suite class** (e.g. `StAXPivotTransformerTestSuite`) with a 
`@TestFactory`
+- A **suite class** (e.g. `StAXPivotTransformerTest`) with a `@TestFactory`
   method that builds the fan-out tree and returns `Stream<DynamicNode>`. Name
-  it with a `*TestSuite` suffix (not `*Test`) so that Maven Surefire does not
-  try to run it as a JUnit 3/4 test either.
+  it with a `*Test` suffix so that Maven Surefire discovers and runs it.
 
 Steps:
 
@@ -324,7 +323,7 @@ Steps:
    constructor parameters.
 2. Remove the constructor and all `addTestParameter()` calls.
 3. Remove the `static suite()` method.
-4. Create a new suite class with a `*TestSuite` suffix. Add a `@TestFactory`
+4. Create a new suite class with a `*Test` suffix. Add a `@TestFactory`
    **instance** method called `tests` that builds the fan-out tree and calls
    `toDynamicNodes()` on the root node.
    No `InjectorNode` is needed unless you have additional bindings beyond the
@@ -383,10 +382,10 @@ public class StAXPivotTransformerTestCase extends 
TestCase {
 }
 ```
 
-**After** (`StAXPivotTransformerTestSuite.java` — JUnit 5 suite):
+**After** (`StAXPivotTransformerTest.java` — JUnit 5 suite):
 
 ```java
-public class StAXPivotTransformerTestSuite {
+public class StAXPivotTransformerTest {
     @TestFactory
     public Stream<DynamicNode> tests() {
         return new ParameterFanOutNode<>(
@@ -430,7 +429,7 @@ example by filtering the list of instances passed to the 
fan-out node.
 
 - [ ] Test case class: renamed to `*TestCase` suffix, extends `TestCase`, uses
       `@Inject` fields, no constructor, `static suite()` removed
-- [ ] Suite class: named with `*TestSuite` suffix, has `@TestFactory` instance
+- [ ] Suite class: named with `*Test` suffix, has `@TestFactory` instance
       method `tests()` building fan-out tree and calling `toDynamicNodes()`
 - [ ] `pom.xml`: `junit-jupiter`, `guice`, and (if needed) `multiton` added
 - [ ] Tests pass: `mvn clean test -pl <module> -am`

Reply via email to