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 992068609 Update matrix-testsuite docs to match actual FanOutNode API
992068609 is described below
commit 9920686091fe29e844e597f614ca512a50c51469
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Thu Mar 19 22:10:14 2026 +0000
Update matrix-testsuite docs to match actual FanOutNode API
Replace references to non-existent ParameterFanOutNode, DimensionFanOutNode,
and AbstractFanOutNode with FanOutNode, which is the single concrete fan-out
class. Update code examples to use the actual FanOutNode constructor
signature
(ImmutableList, Binding, ParameterBinding, child) and remove incorrect
@Named
annotations from injection sites.
---
testing/matrix-testsuite/README.md | 54 ++++++++++++----------------
testing/matrix-testsuite/migration.md | 66 +++++++++++++++--------------------
2 files changed, 51 insertions(+), 69 deletions(-)
diff --git a/testing/matrix-testsuite/README.md
b/testing/matrix-testsuite/README.md
index 5e4495ff3..b7c5e84f9 100644
--- a/testing/matrix-testsuite/README.md
+++ b/testing/matrix-testsuite/README.md
@@ -77,30 +77,28 @@ abstract Stream<DynamicNode> toDynamicNodes(
BiPredicate<Class<?>, Map<String, String>> excludes);
```
-### `AbstractFanOutNode<T>`
+### `FanOutNode<T>`
-Abstract fan-out node that iterates over a list of values of type `T`. For each
+Fan-out node that iterates over an `ImmutableList<T>` of values. For each
value, it:
-1. Creates a child Guice injector binding `T` to the value.
-2. Extracts test parameters (via the abstract `extractParameters` method).
+1. Creates a child Guice injector using the supplied `Binding<T>` lambda.
+2. Registers test parameters via the supplied `ParameterBinding<? super T>`
+ lambda.
3. Produces a `DynamicContainer` containing the results of recursing into its
single child node.
-Extends `MatrixTestNode` directly and holds exactly one child node. When
-multiple children are needed, wrap them in a `ParentNode`.
+Holds exactly one child node. When multiple children are needed, wrap them in a
+`ParentNode`.
-Subclasses:
-
-- **`DimensionFanOutNode<D extends Dimension>`** — for types that implement the
- `Dimension` interface. Parameters are extracted via
- `Dimension.addTestParameters()`. The value is bound as a plain (unannotated)
- type binding.
-
-- **`ParameterFanOutNode<T>`** — for arbitrary types. The caller supplies a
- parameter name and a `Function<T, String>` to extract the parameter value.
- The value is bound with a `@Named` annotation whose value is the parameter
- name; injection sites must use `@Inject @Named("paramName")`.
+The `Binding<T>` lambda receives a `Binder` and the current value, and
+configures the Guice binding (e.g.
+`(binder, value) -> binder.bind(MyType.class).toInstance(value)`). The
+`ParameterBinding<? super T>` lambda registers test parameters for display and
+filtering (e.g.
+`(params, value) -> params.addTestParameter("name", value.getName())`).
+For types implementing `Dimension`, use the predefined
+`ParameterBinding.DIMENSION` constant.
### `MatrixTest`
@@ -142,14 +140,10 @@ override `runTest()`. Dependencies are declared with
`@Inject` — either on fie
or via constructor. The test case does **not** receive parameters through its
constructor and does **not** call `addTestParameter()`.
-For values bound by `DimensionFanOutNode`, use a plain `@Inject`. For values
-bound by `ParameterFanOutNode`, add `@Named("paramName")` matching the
-parameter name passed to the fan-out node.
-
```java
public abstract class MyTestCase extends TestCase {
@Inject protected SomeImplementation impl;
- @Inject @Named("dimension") protected SomeDimension dimension;
+ @Inject protected SomeDimension dimension;
// convenience methods using impl and dimension ...
}
@@ -175,21 +169,17 @@ public class MyTestSuite {
public static InjectorNode create(SomeFactory factory) {
SomeImplementation impl = new SomeImplementation(factory);
- ParameterFanOutNode<SomeDimension> dimensions = new
ParameterFanOutNode<>(
- SomeDimension.class,
+ FanOutNode<SomeDimension> dimensions = new FanOutNode<>(
Multiton.getInstances(SomeDimension.class),
- "dimension",
- SomeDimension::getName,
+ (binder, value) ->
binder.bind(SomeDimension.class).toInstance(value),
+ (params, value) -> params.addTestParameter("dimension",
value.getName()),
new ParentNode(
new MatrixTest(TestSomeBehavior.class),
new MatrixTest(TestOtherBehavior.class)));
- InjectorNode suite = new InjectorNode(new AbstractModule() {
- @Override
- protected void configure() {
- bind(SomeImplementation.class).toInstance(impl);
- }
- }, dimensions);
+ InjectorNode suite = new InjectorNode(
+ binder ->
binder.bind(SomeImplementation.class).toInstance(impl),
+ dimensions);
return suite;
}
diff --git a/testing/matrix-testsuite/migration.md
b/testing/matrix-testsuite/migration.md
index 24a3e6592..d0b807baa 100644
--- a/testing/matrix-testsuite/migration.md
+++ b/testing/matrix-testsuite/migration.md
@@ -100,7 +100,7 @@ public abstract class SAAJTestCase extends MatrixTestCase {
```java
public abstract class SAAJTestCase extends TestCase {
@Inject protected SAAJImplementation saajImplementation;
- @Inject @Named("spec") protected SOAPSpec spec;
+ @Inject protected SOAPSpec spec;
protected final MessageFactory newMessageFactory() throws SOAPException {
return
spec.getAdapter(FactorySelector.class).newMessageFactory(saajImplementation);
@@ -108,9 +108,6 @@ public abstract class SAAJTestCase extends TestCase {
}
```
-Note: the `@Named("spec")` annotation is required because `ParameterFanOutNode`
-binds values with `@Named` using the parameter name. Use
`com.google.inject.name.Named`.
-
### 2. Update each test case class
Each test case class currently accepts constructor parameters and forwards them
@@ -163,12 +160,12 @@ The old `*TestSuiteBuilder` class extends
`MatrixTestSuiteBuilder` and overrides
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); the value is bound
-with `@Named(parameterName)`, so injection sites must use
-`@Inject @Named("...")`. Use `DimensionFanOutNode` for types that implement
-`Dimension` (plain unannotated binding). Both fan-out node types accept a
single
-`MatrixTestNode` child; use `ParentNode` to group multiple children.
+Use `FanOutNode` for each dimension, supplying:
+- an `ImmutableList<T>` of values (e.g. from `Multiton.getInstances()`),
+- a `Binding<T>` lambda that configures the Guice binding for each value,
+- a `ParameterBinding<? super T>` lambda that registers test parameters for
+ display and filtering,
+- a single `MatrixTestNode` child; use `ParentNode` to group multiple children.
**Before:**
@@ -200,21 +197,16 @@ public class SAAJTestSuiteBuilder extends
MatrixTestSuiteBuilder {
public class SAAJTestSuite {
public static InjectorNode create(SAAJMetaFactory metaFactory) {
return new InjectorNode(
- new AbstractModule() {
- @Override
- protected void configure() {
- bind(SAAJImplementation.class)
- .toInstance(new
SAAJImplementation(metaFactory));
- }
- },
- new ParameterFanOutNode<>(
- SOAPSpec.class,
+ binder ->
+ binder.bind(SAAJImplementation.class)
+ .toInstance(new
SAAJImplementation(metaFactory)),
+ new FanOutNode<>(
Multiton.getInstances(SOAPSpec.class),
- "spec",
- SOAPSpec::getName,
+ (binder, value) ->
binder.bind(SOAPSpec.class).toInstance(value),
+ (params, value) -> params.addTestParameter("spec",
value.getName()),
new ParentNode(
new
MatrixTest(TestAddChildElementReification.class),
- new MatrixTest(TestGetOwnerDocument.class)))));
+ new MatrixTest(TestGetOwnerDocument.class))));
}
}
```
@@ -371,8 +363,8 @@ public class StAXPivotTransformerTest extends
MatrixTestCase {
```java
public class StAXPivotTransformerTestCase extends TestCase {
- @Inject @Named("xslt") private XSLTImplementation xsltImplementation;
- @Inject @Named("sample") private XMLSample sample;
+ @Inject private XSLTImplementation xsltImplementation;
+ @Inject private XMLSample sample;
@Override
protected void runTest() throws Throwable {
@@ -387,17 +379,16 @@ public class StAXPivotTransformerTestCase extends
TestCase {
public class StAXPivotTransformerTest {
@TestFactory
public Stream<DynamicNode> tests() {
- return new ParameterFanOutNode<>(
- XSLTImplementation.class,
- Multiton.getInstances(XSLTImplementation.class),
- "xslt",
- XSLTImplementation::getName,
- new ParameterFanOutNode<>(
- XMLSample.class,
- Multiton.getInstances(XMLSample.class),
- "sample",
- XMLSample::getName,
- new MatrixTest(StAXPivotTransformerTestCase.class)))
+ return new FanOutNode<>(
+ Multiton.getInstances(XSLTImplementation.class),
+ (binder, value) ->
binder.bind(XSLTImplementation.class).toInstance(value),
+ (params, value) -> params.addTestParameter("xslt",
value.getName()),
+ new FanOutNode<>(
+ Multiton.getInstances(XMLSample.class),
+ (binder, value) ->
binder.bind(XMLSample.class).toInstance(value),
+ (params, value) ->
+ params.addTestParameter("sample",
value.getName()),
+ new
MatrixTest(StAXPivotTransformerTestCase.class)))
.toDynamicNodes();
}
}
@@ -405,8 +396,9 @@ public class StAXPivotTransformerTest {
Note that filtering logic (e.g. skipping values based on a condition like
`xsltImplementation.supportsStAXSource()`) that was previously expressed as
-`if` guards in the `addTests()` loop should be handled differently — for
-example by filtering the list of instances passed to the fan-out node.
+`if` guards in the `addTests()` loop should be handled by filtering the
+`ImmutableList` of values passed to the `FanOutNode` (e.g.
+`.stream().filter(...).collect(ImmutableList.toImmutableList())`).
## Checklist