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 c5b0ea409 Refactor ParentNode into an immutable class using 
ImmutableList
c5b0ea409 is described below

commit c5b0ea409d5a08b404f8c5c1db16de6469b45e6b
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Sat Mar 7 18:54:18 2026 +0000

    Refactor ParentNode into an immutable class using ImmutableList
    
    Replace the mutable ArrayList + addChild() pattern with an ImmutableList
    passed at construction time. All subclasses (AbstractFanOutNode,
    DimensionFanOutNode, ParameterFanOutNode, InjectorNode) now accept children
    as a constructor parameter. Update SAAJTestSuite and documentation
    (README.md, migration.md) accordingly.
---
 testing/matrix-testsuite/README.md                 | 29 ++++++++++--------
 testing/matrix-testsuite/migration.md              | 34 ++++++++++++----------
 .../axiom/testutils/suite/AbstractFanOutNode.java  |  4 ++-
 .../axiom/testutils/suite/DimensionFanOutNode.java |  7 +++--
 .../apache/axiom/testutils/suite/InjectorNode.java | 11 ++++---
 .../axiom/testutils/suite/ParameterFanOutNode.java |  5 ++--
 .../apache/axiom/testutils/suite/ParentNode.java   | 15 ++++++----
 .../org/apache/axiom/ts/saaj/SAAJTestSuite.java    | 33 +++++++++++----------
 8 files changed, 81 insertions(+), 57 deletions(-)

diff --git a/testing/matrix-testsuite/README.md 
b/testing/matrix-testsuite/README.md
index 7673c2b25..31750d8fd 100644
--- a/testing/matrix-testsuite/README.md
+++ b/testing/matrix-testsuite/README.md
@@ -86,6 +86,9 @@ value, it:
 3. Produces a `DynamicContainer` containing the results of recursing into its
    child nodes.
 
+Child nodes are supplied at construction time via an 
`ImmutableList<MatrixTestNode>`
+parameter; the resulting instance is immutable.
+
 Subclasses:
 
 - **`DimensionFanOutNode<D extends Dimension>`** — for types that implement the
@@ -106,8 +109,9 @@ exclusion filters.
 
 A node that creates a child Guice injector from the supplied modules and 
threads
 it through its children. Can be used at any level of the test tree to introduce
-additional bindings. Accepts either an `ImmutableList<Module>` (primary
-constructor) or a single `Module` (convenience constructor). Provides:
+additional bindings. Accepts an `ImmutableList<Module>` (primary constructor) 
or
+a single `Module` (convenience constructor), together with an
+`ImmutableList<MatrixTestNode>` of child nodes. Provides:
 
 ```java
 public Stream<DynamicNode> toDynamicNodes(BiPredicate<Class<?>, Map<String, 
String>> excludes)
@@ -154,21 +158,22 @@ leaf nodes:
 public class MyTestSuite {
     public static InjectorNode create(SomeFactory factory) {
         SomeImplementation impl = new SomeImplementation(factory);
-        InjectorNode suite = new InjectorNode(new AbstractModule() {
-            @Override
-            protected void configure() {
-                bind(SomeImplementation.class).toInstance(impl);
-            }
-        });
 
         ParameterFanOutNode<SomeDimension> dimensions = new 
ParameterFanOutNode<>(
                 SomeDimension.class,
                 Multiton.getInstances(SomeDimension.class),
                 "dimension",
-                SomeDimension::getName);
-        dimensions.addChild(new MatrixTest(TestSomeBehavior.class));
-        dimensions.addChild(new MatrixTest(TestOtherBehavior.class));
-        suite.addChild(dimensions);
+                SomeDimension::getName,
+                ImmutableList.of(
+                        new MatrixTest(TestSomeBehavior.class),
+                        new MatrixTest(TestOtherBehavior.class)));
+
+        InjectorNode suite = new InjectorNode(new AbstractModule() {
+            @Override
+            protected void configure() {
+                bind(SomeImplementation.class).toInstance(impl);
+            }
+        }, ImmutableList.of(dimensions));
 
         return suite;
     }
diff --git a/testing/matrix-testsuite/migration.md 
b/testing/matrix-testsuite/migration.md
index ed28287f6..c677cbcd9 100644
--- a/testing/matrix-testsuite/migration.md
+++ b/testing/matrix-testsuite/migration.md
@@ -138,8 +138,10 @@ The old `*TestSuiteBuilder` class extends 
`MatrixTestSuiteBuilder` and overrides
 1. Creates an `InjectorNode` with a Guice module that binds
    implementation-level objects. Pass a single `Module` directly (convenience
    constructor) or an `ImmutableList<Module>` when you need multiple modules.
+   Child nodes are supplied via an `ImmutableList<MatrixTestNode>` parameter.
 2. Creates fan-out nodes for each dimension.
-3. Adds `MatrixTest` leaf nodes for each test case class.
+3. Adds `MatrixTest` leaf nodes as children of the fan-out nodes at 
construction
+   time.
 
 Use `ParameterFanOutNode` for types that don't implement `Dimension` 
(supplying a
 parameter name and a function to extract the display value). Use
@@ -175,22 +177,22 @@ public class SAAJTestSuiteBuilder extends 
MatrixTestSuiteBuilder {
 public class SAAJTestSuite {
     public static InjectorNode create(SAAJMetaFactory metaFactory) {
         SAAJImplementation impl = new SAAJImplementation(metaFactory);
-        InjectorNode suite = new InjectorNode(new AbstractModule() {
-            @Override
-            protected void configure() {
-                bind(SAAJImplementation.class).toInstance(impl);
-            }
-        });
 
         ParameterFanOutNode<SOAPSpec> specs = new ParameterFanOutNode<>(
                 SOAPSpec.class,
                 Multiton.getInstances(SOAPSpec.class),
                 "spec",
-                SOAPSpec::getName);
-        specs.addChild(new MatrixTest(TestAddChildElementReification.class));
-        specs.addChild(new MatrixTest(TestGetOwnerDocument.class));
-        // ...
-        suite.addChild(specs);
+                SOAPSpec::getName,
+                ImmutableList.of(
+                        new MatrixTest(TestAddChildElementReification.class),
+                        new MatrixTest(TestGetOwnerDocument.class)));
+
+        InjectorNode suite = new InjectorNode(new AbstractModule() {
+            @Override
+            protected void configure() {
+                bind(SAAJImplementation.class).toInstance(impl);
+            }
+        }, ImmutableList.of(specs));
 
         return suite;
     }
@@ -199,8 +201,9 @@ public class SAAJTestSuite {
 
 Key differences:
 
-- Test classes are registered **once** as `MatrixTest` instances under the
-  appropriate fan-out node, rather than once per dimension combination.
+- Test classes are registered **once** as `MatrixTest` instances, passed as
+  children to the appropriate fan-out node at construction time, rather than 
once
+  per dimension combination.
 - Dimension values are listed via `Multiton.getInstances()` (or an explicit 
list)
   in the fan-out node, not iterated manually.
 - No constructor arguments are passed to test classes.
@@ -283,7 +286,8 @@ is in place and all consumers have been updated.
       constructor
 - [ ] All test case classes: constructor removed, `runTest()` unchanged
 - [ ] Suite factory class: creates `InjectorNode` with Guice module, builds
-      fan-out tree with `MatrixTest` leaves
+      immutable fan-out tree with `MatrixTest` leaves supplied at construction
+      time
 - [ ] Consumer test class: uses `@TestFactory` returning `Stream<DynamicNode>`
 - [ ] Exclusions: converted to `MatrixTestFilters.builder()` calls
 - [ ] `pom.xml`: `junit-jupiter`, `guice`, and (if needed) `multiton` added
diff --git 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/AbstractFanOutNode.java
 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/AbstractFanOutNode.java
index d8d9d35bd..fed282128 100644
--- 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/AbstractFanOutNode.java
+++ 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/AbstractFanOutNode.java
@@ -52,7 +52,9 @@ public abstract class AbstractFanOutNode<T> extends 
ParentNode {
     private final Class<T> type;
     private final ImmutableList<T> values;
 
-    protected AbstractFanOutNode(Class<T> type, ImmutableList<T> values) {
+    protected AbstractFanOutNode(
+            Class<T> type, ImmutableList<T> values, 
ImmutableList<MatrixTestNode> children) {
+        super(children);
         this.type = type;
         this.values = values;
     }
diff --git 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/DimensionFanOutNode.java
 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/DimensionFanOutNode.java
index 91baef503..83994dc30 100644
--- 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/DimensionFanOutNode.java
+++ 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/DimensionFanOutNode.java
@@ -33,8 +33,11 @@ import com.google.common.collect.ImmutableList;
  * @param <D> the dimension type
  */
 public class DimensionFanOutNode<D extends Dimension> extends 
AbstractFanOutNode<D> {
-    public DimensionFanOutNode(Class<D> dimensionType, ImmutableList<D> 
dimensions) {
-        super(dimensionType, dimensions);
+    public DimensionFanOutNode(
+            Class<D> dimensionType,
+            ImmutableList<D> dimensions,
+            ImmutableList<MatrixTestNode> children) {
+        super(dimensionType, dimensions, children);
     }
 
     @Override
diff --git 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/InjectorNode.java
 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/InjectorNode.java
index 0f2255b8f..927519536 100644
--- 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/InjectorNode.java
+++ 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/InjectorNode.java
@@ -40,11 +40,13 @@ public class InjectorNode extends ParentNode {
     private final ImmutableList<Module> modules;
 
     /**
-     * Creates a new node with the given list of modules.
+     * Creates a new node with the given list of modules and child nodes.
      *
      * @param modules the Guice modules to install when creating the child 
injector
+     * @param children the child nodes of this node
      */
-    public InjectorNode(ImmutableList<Module> modules) {
+    public InjectorNode(ImmutableList<Module> modules, 
ImmutableList<MatrixTestNode> children) {
+        super(children);
         this.modules = modules;
     }
 
@@ -52,9 +54,10 @@ public class InjectorNode extends ParentNode {
      * Convenience constructor for the common case of a single module.
      *
      * @param module the Guice module to install when creating the child 
injector
+     * @param children the child nodes of this node
      */
-    public InjectorNode(Module module) {
-        this(ImmutableList.of(module));
+    public InjectorNode(Module module, ImmutableList<MatrixTestNode> children) 
{
+        this(ImmutableList.of(module), children);
     }
 
     @Override
diff --git 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParameterFanOutNode.java
 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParameterFanOutNode.java
index 996462914..23d92059e 100644
--- 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParameterFanOutNode.java
+++ 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParameterFanOutNode.java
@@ -38,8 +38,9 @@ public class ParameterFanOutNode<T> extends 
AbstractFanOutNode<T> {
             Class<T> type,
             ImmutableList<T> values,
             String parameterName,
-            Function<T, String> parameterValueFunction) {
-        super(type, values);
+            Function<T, String> parameterValueFunction,
+            ImmutableList<MatrixTestNode> children) {
+        super(type, values, children);
         this.parameterName = parameterName;
         this.parameterValueFunction = parameterValueFunction;
     }
diff --git 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParentNode.java
 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParentNode.java
index 4c20ea42d..0fbb1451c 100644
--- 
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParentNode.java
+++ 
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParentNode.java
@@ -18,22 +18,25 @@
  */
 package org.apache.axiom.testutils.suite;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Map;
 import java.util.function.BiPredicate;
 import java.util.stream.Stream;
 
 import org.junit.jupiter.api.DynamicNode;
 
+import com.google.common.collect.ImmutableList;
 import com.google.inject.Injector;
 
-/** A {@link MatrixTestNode} that maintains an ordered list of child nodes. */
+/**
+ * A {@link MatrixTestNode} that holds an immutable, ordered list of child 
nodes.
+ *
+ * <p>Children are supplied at construction time; instances are immutable 
after creation.
+ */
 public abstract class ParentNode extends MatrixTestNode {
-    private final List<MatrixTestNode> children = new ArrayList<>();
+    private final ImmutableList<MatrixTestNode> children;
 
-    public final void addChild(MatrixTestNode child) {
-        children.add(child);
+    protected ParentNode(ImmutableList<MatrixTestNode> children) {
+        this.children = children;
     }
 
     protected final Stream<DynamicNode> childDynamicNodes(
diff --git 
a/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuite.java
 
b/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuite.java
index e0b438b0c..37f700eee 100644
--- 
a/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuite.java
+++ 
b/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuite.java
@@ -32,11 +32,27 @@ import 
org.apache.axiom.ts.saaj.element.TestSetParentElement;
 import org.apache.axiom.ts.saaj.header.TestExamineMustUnderstandHeaderElements;
 import org.apache.axiom.ts.soap.SOAPSpec;
 
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 
 public class SAAJTestSuite {
     public static InjectorNode create(SAAJMetaFactory metaFactory) {
         SAAJImplementation impl = new SAAJImplementation(metaFactory);
+
+        ParameterFanOutNode<SOAPSpec> specs =
+                new ParameterFanOutNode<>(
+                        SOAPSpec.class,
+                        Multiton.getInstances(SOAPSpec.class),
+                        "spec",
+                        SOAPSpec::getName,
+                        ImmutableList.of(
+                                new 
MatrixTest(TestAddChildElementReification.class),
+                                new 
MatrixTest(TestExamineMustUnderstandHeaderElements.class),
+                                new 
MatrixTest(TestAddChildElementLocalName.class),
+                                new 
MatrixTest(TestAddChildElementLocalNamePrefixAndURI.class),
+                                new MatrixTest(TestSetParentElement.class),
+                                new MatrixTest(TestGetOwnerDocument.class)));
+
         InjectorNode suite =
                 new InjectorNode(
                         new AbstractModule() {
@@ -44,21 +60,8 @@ public class SAAJTestSuite {
                             protected void configure() {
                                 
bind(SAAJImplementation.class).toInstance(impl);
                             }
-                        });
-
-        ParameterFanOutNode<SOAPSpec> specs =
-                new ParameterFanOutNode<>(
-                        SOAPSpec.class,
-                        Multiton.getInstances(SOAPSpec.class),
-                        "spec",
-                        SOAPSpec::getName);
-        specs.addChild(new MatrixTest(TestAddChildElementReification.class));
-        specs.addChild(new 
MatrixTest(TestExamineMustUnderstandHeaderElements.class));
-        specs.addChild(new MatrixTest(TestAddChildElementLocalName.class));
-        specs.addChild(new 
MatrixTest(TestAddChildElementLocalNamePrefixAndURI.class));
-        specs.addChild(new MatrixTest(TestSetParentElement.class));
-        specs.addChild(new MatrixTest(TestGetOwnerDocument.class));
-        suite.addChild(specs);
+                        },
+                        ImmutableList.of(specs));
 
         return suite;
     }

Reply via email to