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 27595ae9c Migrate CompareTest to the new matrix test suite framework
27595ae9c is described below
commit 27595ae9c59318c1d53f83df4d844b3dacfdd439
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Wed Mar 11 22:43:26 2026 +0000
Migrate CompareTest to the new matrix test suite framework
---
testing/xml-truth/pom.xml | 10 +++
.../org/apache/axiom/truth/xml/CompareTest.java | 82 +++++++++-------------
.../apache/axiom/truth/xml/CompareTestCase.java | 56 +++++++++++++++
3 files changed, 98 insertions(+), 50 deletions(-)
diff --git a/testing/xml-truth/pom.xml b/testing/xml-truth/pom.xml
index b4c2fc95f..1fa151b20 100644
--- a/testing/xml-truth/pom.xml
+++ b/testing/xml-truth/pom.xml
@@ -67,6 +67,16 @@
<artifactId>junit-vintage-engine</artifactId>
<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>
</dependencies>
<build>
diff --git
a/testing/xml-truth/src/test/java/org/apache/axiom/truth/xml/CompareTest.java
b/testing/xml-truth/src/test/java/org/apache/axiom/truth/xml/CompareTest.java
index f8b495a56..c9c7f5a13 100644
---
a/testing/xml-truth/src/test/java/org/apache/axiom/truth/xml/CompareTest.java
+++
b/testing/xml-truth/src/test/java/org/apache/axiom/truth/xml/CompareTest.java
@@ -18,59 +18,41 @@
*/
package org.apache.axiom.truth.xml;
-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 junit.framework.TestSuite;
-
-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.junit.jupiter.api.DynamicNode;
+import org.junit.jupiter.api.TestFactory;
-public class CompareTest extends MatrixTestCase {
- private XMLSample sample;
- private final XMLObjectFactory left;
- private final XMLObjectFactory right;
- private boolean expandEntityReferences;
-
- public CompareTest(
- XMLSample sample,
- XMLObjectFactory left,
- XMLObjectFactory right,
- boolean expandEntityReferences) {
- this.sample = sample;
- this.left = left;
- this.right = right;
- this.expandEntityReferences = expandEntityReferences;
- addTestParameter("sample", sample.getName());
- addTestParameter("left", left.getName());
- addTestParameter("right", right.getName());
- addTestParameter("expandEntityReferences", expandEntityReferences);
- }
-
- @Override
- protected void runTest() throws Throwable {
- assertAbout(xml())
- .that(left.toXMLObject(sample))
- .ignoringWhitespaceInPrologAndEpilog()
- .expandingEntityReferences(expandEntityReferences)
- .hasSameContentAs(right.toXMLObject(sample));
- }
+import com.google.common.collect.ImmutableList;
- public static TestSuite suite() {
- return new MatrixTestSuiteBuilder() {
- @Override
- protected void addTests() {
- for (XMLSample sample : getInstances(XMLSample.class)) {
- for (XMLObjectFactory left :
getInstances(XMLObjectFactory.class)) {
- for (XMLObjectFactory right :
getInstances(XMLObjectFactory.class)) {
- addTest(new CompareTest(sample, left, right,
true));
- addTest(new CompareTest(sample, left, right,
false));
- }
- }
- }
- }
- }.build();
+public class CompareTest {
+ @TestFactory
+ public Stream<DynamicNode> tests() {
+ return new ParameterFanOutNode<>(
+ XMLSample.class,
+ Multiton.getInstances(XMLSample.class),
+ "sample",
+ XMLSample::getName,
+ new ParameterFanOutNode<>(
+ XMLObjectFactory.class,
+ Multiton.getInstances(XMLObjectFactory.class),
+ "left",
+ XMLObjectFactory::getName,
+ new ParameterFanOutNode<>(
+ XMLObjectFactory.class,
+
Multiton.getInstances(XMLObjectFactory.class),
+ "right",
+ XMLObjectFactory::getName,
+ new ParameterFanOutNode<>(
+ Boolean.class,
+ ImmutableList.of(true, false),
+ "expandEntityReferences",
+ String::valueOf,
+ new
MatrixTest(CompareTestCase.class)))))
+ .toDynamicNodes();
}
}
diff --git
a/testing/xml-truth/src/test/java/org/apache/axiom/truth/xml/CompareTestCase.java
b/testing/xml-truth/src/test/java/org/apache/axiom/truth/xml/CompareTestCase.java
new file mode 100644
index 000000000..3fc2b3307
--- /dev/null
+++
b/testing/xml-truth/src/test/java/org/apache/axiom/truth/xml/CompareTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.truth.xml;
+
+import static com.google.common.truth.Truth.assertAbout;
+import static org.apache.axiom.truth.xml.XMLTruth.xml;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.ts.xml.XMLSample;
+
+public class CompareTestCase extends TestCase {
+ @Inject
+ @Named("sample")
+ private XMLSample sample;
+
+ @Inject
+ @Named("left")
+ private XMLObjectFactory left;
+
+ @Inject
+ @Named("right")
+ private XMLObjectFactory right;
+
+ @Inject
+ @Named("expandEntityReferences")
+ private boolean expandEntityReferences;
+
+ @Override
+ protected void runTest() throws Throwable {
+ assertAbout(xml())
+ .that(left.toXMLObject(sample))
+ .ignoringWhitespaceInPrologAndEpilog()
+ .expandingEntityReferences(expandEntityReferences)
+ .hasSameContentAs(right.toXMLObject(sample));
+ }
+}