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 a87eb359d Add MatrixTestSuite root node class; make toDynamicNodes
package-private
a87eb359d is described below
commit a87eb359dcf50facc44a8c68506a83e91ed646a6
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Sat Feb 28 10:00:36 2026 +0000
Add MatrixTestSuite root node class; make toDynamicNodes package-private
Introduce MatrixTestSuite as the public entry point that owns the root
Guice injector and child nodes. Its toDynamicNodes(List<Filter>) method
is the convenient API for @TestFactory methods.
The three-argument toDynamicNodes on MatrixTestNode, MatrixTestContainer
and MatrixTest is now package-private since it is only called internally
by MatrixTestSuite and between nodes.
Exclusion filters are passed by the consumer (implementation under test)
rather than owned by the suite, since they vary per implementation while
the suite structure is defined by the test suite author.
---
docs/design/test-suite-pattern.md | 58 ++++++++++++++++++++++++++++++---------
1 file changed, 45 insertions(+), 13 deletions(-)
diff --git a/docs/design/test-suite-pattern.md
b/docs/design/test-suite-pattern.md
index ca33783ca..47bb85f9c 100644
--- a/docs/design/test-suite-pattern.md
+++ b/docs/design/test-suite-pattern.md
@@ -216,7 +216,7 @@ accumulated injector can satisfy all `@Inject` dependencies
for the test case cl
* {@link MatrixTest} uses it to instantiate the test class.
*/
public abstract class MatrixTestNode {
- public abstract Stream<DynamicNode> toDynamicNodes(Injector parentInjector,
+ abstract Stream<DynamicNode> toDynamicNodes(Injector parentInjector,
Dictionary<String, String> inheritedParameters,
List<Filter> excludes);
}
@@ -258,7 +258,7 @@ public class MatrixTestContainer<D extends Dimension>
extends MatrixTestNode {
}
@Override
- public Stream<DynamicNode> toDynamicNodes(Injector parentInjector,
+ Stream<DynamicNode> toDynamicNodes(Injector parentInjector,
Dictionary<String, String> inheritedParameters,
List<Filter> excludes) {
return dimensions.stream().map(dimension -> {
@@ -330,7 +330,7 @@ public class MatrixTest extends MatrixTestNode {
}
@Override
- public Stream<DynamicNode> toDynamicNodes(Injector injector,
+ Stream<DynamicNode> toDynamicNodes(Injector injector,
Dictionary<String, String> inheritedParameters,
List<Filter> excludes) {
for (Filter exclude : excludes) {
@@ -347,6 +347,37 @@ public class MatrixTest extends MatrixTestNode {
}
```
+```java
+/**
+ * Root of a test suite. Owns the Guice root injector and the tree of
+ * {@link MatrixTestNode} instances. Provides a {@link #toDynamicNodes(List)}
+ * method that converts the tree to JUnit 5 dynamic nodes, applying the
+ * supplied exclusion filters.
+ *
+ * <p>Exclusion filters are <em>not</em> owned by the suite itself because
+ * they are specific to each consumer (implementation under test), whereas
+ * the suite structure and bindings are defined by the test suite author.
+ */
+public class MatrixTestSuite {
+ private final Injector rootInjector;
+ private final List<MatrixTestNode> children = new ArrayList<>();
+
+ public MatrixTestSuite(Module... modules) {
+ this.rootInjector = Guice.createInjector(modules);
+ }
+
+ public void addChild(MatrixTestNode child) {
+ children.add(child);
+ }
+
+ public Stream<DynamicNode> toDynamicNodes(List<Filter> excludes) {
+ return children.stream()
+ .flatMap(child -> child.toDynamicNodes(
+ rootInjector, new Hashtable<>(), excludes));
+ }
+}
+```
+
#### Guice injector hierarchy
The injector hierarchy mirrors the `MatrixTestContainer` nesting. The root
injector
@@ -453,32 +484,33 @@ MatrixTestContainer(SOAPSpec.class, [SOAPSpec.SOAP11,
SOAPSpec.SOAP12])
→ TestGetOwnerDocument (filtered against {spec=soap12})
```
-Consumers apply exclusions and create the root injector:
+Consumers build a `MatrixTestSuite` and return its dynamic nodes:
```java
class SAAJRITests {
@TestFactory
Stream<DynamicNode> saajTests() {
SAAJImplementation impl = new SAAJImplementation(new
SAAJMetaFactoryImpl());
- Injector rootInjector = Guice.createInjector(new AbstractModule() {
+ MatrixTestSuite suite = new MatrixTestSuite(new AbstractModule() {
@Override
protected void configure() {
bind(SAAJImplementation.class).toInstance(impl);
}
});
- MatrixTestContainer<SOAPSpec> root = new MatrixTestContainer<>(
+ MatrixTestContainer<SOAPSpec> specs = new MatrixTestContainer<>(
SOAPSpec.class, Multiton.getInstances(SOAPSpec.class));
- root.addChild(new MatrixTest(TestAddChildElementReification.class));
- root.addChild(new
MatrixTest(TestExamineMustUnderstandHeaderElements.class));
- root.addChild(new MatrixTest(TestAddChildElementLocalName.class));
- root.addChild(new
MatrixTest(TestAddChildElementLocalNamePrefixAndURI.class));
- root.addChild(new MatrixTest(TestSetParentElement.class));
- root.addChild(new MatrixTest(TestGetOwnerDocument.class));
+ 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);
List<Filter> excludes = new ArrayList<>();
excludes.add(Filter.forClass(TestGetOwnerDocument.class,
"(spec=soap12)"));
- return root.toDynamicNodes(rootInjector, new Hashtable<>(), excludes);
+ return suite.toDynamicNodes(excludes);
}
}
```