This is an automated email from the ASF dual-hosted git repository. afs pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit b33f53e9db3d0c62a96e48122ad5e401612a8448 Author: Andy Seaborne <[email protected]> AuthorDate: Mon Sep 7 20:52:00 2026 +0100 GH-3236: Remove more JUnit3 --- jena-core/pom.xml | 3 +- .../jena/assembler/MockTransactionModel.java | 4 +- .../apache/jena/assembler/TestModelAssembler.java | 2 - .../jena/assembler/TestPrefixMappingAssembler.java | 2 - .../java/org/apache/jena/graph/GraphTestLib.java | 20 +- .../org/apache/jena/graph/RecordingListener.java | 8 +- .../org/apache/jena/graph/TestGraphListener.java | 2 +- .../jena/junit/AbstractRecordingListener.java | 14 +- .../java/org/apache/jena/junit/GraphHelper.java | 18 +- .../java/org/apache/jena/junit/TestUtils4.java | 13 +- .../org/apache/jena/ontology/impl/OntTestBase.java | 8 - .../org/apache/jena/ontology/impl/OntTestUtil.java | 6 - .../org/apache/jena/rdf/model/ModelTestLib.java | 8 +- .../jena/rdf/model/RecordingModelListener.java | 10 +- .../apache/jena/rdf/model/helpers/ModelHelper.java | 17 +- .../rdf/model/helpers/RecordingModelListener.java | 10 +- .../{TS3_xmlinput1.java => TS3_rdfxml_arp.java} | 10 +- .../jena/rdfxml/xmloutput/BaseTestXMLOutput.java | 3 +- .../jena/reasoner/rulesys/TS6_RuleReasoners.java | 8 +- .../jena/reasoner/rulesys/test/OWLWGTester.java | 4 +- .../jena/reasoner/rulesys/test/TestBasicLP.java | 3 - .../jena/reasoner/rulesys/test/TestLPRDFS.java | 67 +++--- .../reasoner/rulesys/test/TestOWLConsistency.java | 86 ++++---- .../jena/reasoner/rulesys/test/TestRDFS9.java | 42 ++-- .../jena/reasoner/rulesys/test/TestRDFSRules.java | 73 +++---- .../jena/reasoner/rulesys/test/TestRuleLoader.java | 25 ++- .../reasoner/rulesys/test/TestTrialOWLRules.java | 226 --------------------- .../apache/jena/reasoner/test/ReasonerTester.java | 4 +- .../jena/reasoner/test/TestCurrentRDFWG.java | 159 --------------- .../apache/jena/reasoner/test/TestInfModel.java | 2 - .../jena/reasoner/test/TestRDFSReasoners.java | 3 +- .../org/apache/jena/reasoner/test/TestUtil.java | 7 +- .../jena/reasoner/test/WGReasonerTester.java | 4 +- .../JenaCoreTestAll_JU3.java} | 27 ++- .../org/apache/jena/test/JenaCoreTestAll_JU4.java | 103 ---------- .../java/org/apache/jena/test/JenaTestLib.java | 4 +- .../org/apache/jena/util/iterator/TestAndThen.java | 10 +- .../jena/util/iterator/TestAsCollection.java | 2 +- .../org/apache/jena/util/iterator/TestFilters.java | 2 +- .../jena/util/iterator/TestWrappedIterator.java | 2 +- .../org/apache/jena/vocabulary/VocabTestLib.java | 2 +- 41 files changed, 230 insertions(+), 793 deletions(-) diff --git a/jena-core/pom.xml b/jena-core/pom.xml index 9f3e3e69e3..5e32552799 100644 --- a/jena-core/pom.xml +++ b/jena-core/pom.xml @@ -75,6 +75,7 @@ <scope>test</scope> </dependency> + <!-- Only for TS3_rdfxml_arp --> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> @@ -149,7 +150,7 @@ <argLine>-XX:+EnableDynamicAgentLoading -Xshare:off</argLine> <includes> <include>org/apache/jena/test/JenaCoreTestAll_JU6.java</include> - <include>org/apache/jena/test/JenaCoreTestAll_JU4.java</include> + <include>org/apache/jena/test/JenaCoreTestAll_JU3.java</include> </includes> </configuration> </plugin> diff --git a/jena-core/src/test/java/org/apache/jena/assembler/MockTransactionModel.java b/jena-core/src/test/java/org/apache/jena/assembler/MockTransactionModel.java index c65f8a17c5..f68886d0ce 100644 --- a/jena-core/src/test/java/org/apache/jena/assembler/MockTransactionModel.java +++ b/jena-core/src/test/java/org/apache/jena/assembler/MockTransactionModel.java @@ -28,7 +28,7 @@ import org.apache.jena.graph.GraphMemFactory; import org.apache.jena.rdf.model.*; import org.apache.jena.rdf.model.impl.ModelCom; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * A model assembler that creates a model with controllable supporting of @@ -55,7 +55,7 @@ final class MockTransactionModel extends ModelAssembler { @Override public Model begin() { history.add("begin"); - Assert.assertTrue(isEmpty()); + assertTrue(isEmpty()); return this; } diff --git a/jena-core/src/test/java/org/apache/jena/assembler/TestModelAssembler.java b/jena-core/src/test/java/org/apache/jena/assembler/TestModelAssembler.java index d7e20c3f32..0461db21d9 100644 --- a/jena-core/src/test/java/org/apache/jena/assembler/TestModelAssembler.java +++ b/jena-core/src/test/java/org/apache/jena/assembler/TestModelAssembler.java @@ -21,8 +21,6 @@ package org.apache.jena.assembler; -import static org.junit.jupiter.api.Assertions.*; - import org.junit.jupiter.api.Test; import org.apache.jena.assembler.assemblers.ContentAssembler; diff --git a/jena-core/src/test/java/org/apache/jena/assembler/TestPrefixMappingAssembler.java b/jena-core/src/test/java/org/apache/jena/assembler/TestPrefixMappingAssembler.java index 70e4717564..eb6418ad0b 100644 --- a/jena-core/src/test/java/org/apache/jena/assembler/TestPrefixMappingAssembler.java +++ b/jena-core/src/test/java/org/apache/jena/assembler/TestPrefixMappingAssembler.java @@ -21,8 +21,6 @@ package org.apache.jena.assembler; -import static org.junit.jupiter.api.Assertions.*; - import org.junit.jupiter.api.Test; import org.apache.jena.assembler.assemblers.PrefixMappingAssembler; diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphTestLib.java b/jena-core/src/test/java/org/apache/jena/graph/GraphTestLib.java index b8f5c12567..b9556fad21 100644 --- a/jena-core/src/test/java/org/apache/jena/graph/GraphTestLib.java +++ b/jena-core/src/test/java/org/apache/jena/graph/GraphTestLib.java @@ -21,6 +21,11 @@ package org.apache.jena.graph; +import static org.apache.jena.test.JenaTestLib.getConstructor; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.FileNotFoundException; import java.lang.reflect.Constructor; import java.net.URISyntaxException; @@ -34,9 +39,6 @@ import org.apache.jena.shared.PrefixMapping; import org.apache.jena.util.CollectionFactory; import org.apache.jena.util.iterator.ExtendedIterator; -import static junit.framework.TestCase.*; -import static org.apache.jena.test.JenaTestLib.getConstructor; - public class GraphTestLib { /** @@ -263,7 +265,7 @@ public class GraphTestLib { * containing <code>name</code>. */ public static void assertContains(String name, String s, Graph g) { - assertTrue(name + " must contain " + s, g.contains(triple(s))); + assertTrue(g.contains(triple(s)), name + " must contain " + s); } /** @@ -283,7 +285,7 @@ public class GraphTestLib { <code>name</code>. */ public static void assertOmits(String name, Graph g, String s) { - assertFalse(name + " must not contain " + s, g.contains(triple(s))); + assertFalse(g.contains(triple(s)), name + " must not contain " + s); } /** @@ -310,7 +312,7 @@ public class GraphTestLib { */ public static void testContains(Graph g, Triple[] triples) { for ( Triple triple : triples ) { - assertTrue("contains " + triple, g.contains(triple)); + assertTrue(g.contains(triple), "contains " + triple); } } @@ -344,7 +346,7 @@ public class GraphTestLib { */ public static void testOmits(Graph g, Triple[] triples) { for ( Triple triple : triples ) { - assertFalse("", g.contains(triple)); + assertFalse(g.contains(triple)); } } @@ -354,7 +356,7 @@ public class GraphTestLib { */ public static void testOmits(Graph g, List<Triple> triples) { for ( Triple triple : triples ) { - assertFalse("", g.contains(triple)); + assertFalse(g.contains(triple)); } } @@ -363,7 +365,7 @@ public class GraphTestLib { */ public static void testOmits(Graph g, Iterator<Triple> it) { while (it.hasNext()) - assertFalse("", g.contains(it.next())); + assertFalse(g.contains(it.next())); } /** diff --git a/jena-core/src/test/java/org/apache/jena/graph/RecordingListener.java b/jena-core/src/test/java/org/apache/jena/graph/RecordingListener.java index f6d8919167..a2bee05c61 100644 --- a/jena-core/src/test/java/org/apache/jena/graph/RecordingListener.java +++ b/jena-core/src/test/java/org/apache/jena/graph/RecordingListener.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.fail; import org.apache.jena.atlas.iterator.Iter; @@ -125,7 +125,7 @@ public class RecordingListener implements GraphListener { public void assertHas(List<Object> things) { if ( has(things) == false ) - Assert.fail("expected " + things + " but got " + history); + fail("expected " + things + " but got " + history); } public void assertHas(Object[] things) { @@ -135,12 +135,12 @@ public class RecordingListener implements GraphListener { public void assertHasStart(Object[] start) { List<Object> L = Arrays.asList(start); if ( hasStart(L) == false ) - Assert.fail("expected " + L + " at the beginning of " + history); + fail("expected " + L + " at the beginning of " + history); } public void assertHasEnd(Object[] end) { List<Object> L = Arrays.asList(end); if ( hasEnd(L) == false ) - Assert.fail("expected " + L + " at the end of " + history); + fail("expected " + L + " at the end of " + history); } } diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestGraphListener.java b/jena-core/src/test/java/org/apache/jena/graph/TestGraphListener.java index a8988195dc..3462612819 100644 --- a/jena-core/src/test/java/org/apache/jena/graph/TestGraphListener.java +++ b/jena-core/src/test/java/org/apache/jena/graph/TestGraphListener.java @@ -41,7 +41,7 @@ public class TestGraphListener extends BaseTestGraph { /** * The implementation used for the listener's copy of the graph. Extending - * MetaTestGraph_JU6 would inherit its argument source as well as this one, running + * MetaTestGraph would inherit its argument source as well as this one, running * every test once per implementation on top of these. */ @Parameter diff --git a/jena-core/src/test/java/org/apache/jena/junit/AbstractRecordingListener.java b/jena-core/src/test/java/org/apache/jena/junit/AbstractRecordingListener.java index ce69217c78..5485f5a618 100644 --- a/jena-core/src/test/java/org/apache/jena/junit/AbstractRecordingListener.java +++ b/jena-core/src/test/java/org/apache/jena/junit/AbstractRecordingListener.java @@ -27,7 +27,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.fail; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Statement; @@ -103,14 +103,14 @@ public class AbstractRecordingListener { public final void assertHas(Object... things) { if (has(things) == false) { int idx = differ(things); - Assert.fail("expected " + Arrays.asList(things) + " but got " + fail("expected " + Arrays.asList(things) + " but got " + history + " differ at position " + idx); } } public final void assertEmpty() { if (history.size() > 0) { - Assert.fail("Should be no history but got " + history); + fail("Should be no history but got " + history); } } @@ -135,25 +135,25 @@ public class AbstractRecordingListener { public final void assertHas(List<?> things) { if (has(things) == false) - Assert.fail("expected " + things + " but got " + history); + fail("expected " + things + " but got " + history); } public final void assertContains(Object... things) { if (contains(things) == false) - Assert.fail(String.format("expected %s but got %s", + fail(String.format("expected %s but got %s", Arrays.asList(things), history)); } public final void assertHasStart(Object... start) { List<Object> L = Arrays.asList(start); if (hasStart(L) == false) - Assert.fail("expected " + L + " at the beginning of " + history); + fail("expected " + L + " at the beginning of " + history); } public final void assertHasEnd(Object... end) { List<Object> L = Arrays.asList(end); if (hasEnd(L) == false) - Assert.fail("expected " + L + " at the end of " + history); + fail("expected " + L + " at the end of " + history); } public final void clear() { diff --git a/jena-core/src/test/java/org/apache/jena/junit/GraphHelper.java b/jena-core/src/test/java/org/apache/jena/junit/GraphHelper.java index 388a06ecb3..8008bff734 100644 --- a/jena-core/src/test/java/org/apache/jena/junit/GraphHelper.java +++ b/jena-core/src/test/java/org/apache/jena/junit/GraphHelper.java @@ -24,9 +24,9 @@ package org.apache.jena.junit; /** * Foo set of static test helpers. Generally included as a static. */ -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.lang.reflect.Constructor; import java.util.*; @@ -316,7 +316,7 @@ public class GraphHelper { * message containing <code>name</code>. */ public static void assertContains(String name, String s, Graph g) { - assertTrue(name + " must contain " + s, g.contains(triple(s))); + assertTrue(g.contains(triple(s)), name + " must contain " + s); } /** @@ -336,7 +336,7 @@ public class GraphHelper { <code>name</code>. */ public static void assertOmits(String name, Graph g, String s) { - assertFalse(name + " must not contain " + s, g.contains(triple(s))); + assertFalse(g.contains(triple(s)), name + " must not contain " + s); } /** @@ -363,7 +363,7 @@ public class GraphHelper { */ public static void testContains(Graph g, Triple[] triples) { for (int i = 0; i < triples.length; i += 1) - assertTrue("contains " + triples[i], g.contains(triples[i])); + assertTrue(g.contains(triples[i]), "contains " + triples[i]); } /** @@ -395,7 +395,7 @@ public class GraphHelper { */ public static void testOmits(Graph g, Triple[] triples) { for (int i = 0; i < triples.length; i += 1) - assertFalse("", g.contains(triples[i])); + assertFalse(g.contains(triples[i])); } /** @@ -404,7 +404,7 @@ public class GraphHelper { */ public static void testOmits(Graph g, List<Triple> triples) { for (int i = 0; i < triples.size(); i += 1) - assertFalse("", g.contains(triples.get(i))); + assertFalse(g.contains(triples.get(i))); } /** @@ -413,7 +413,7 @@ public class GraphHelper { */ public static void testOmits(Graph g, Iterator<Triple> it) { while (it.hasNext()) - assertFalse("", g.contains(it.next())); + assertFalse(g.contains(it.next())); } /** diff --git a/jena-core/src/test/java/org/apache/jena/junit/TestUtils4.java b/jena-core/src/test/java/org/apache/jena/junit/TestUtils4.java index 05c4f4f30a..4e54ae8df2 100644 --- a/jena-core/src/test/java/org/apache/jena/junit/TestUtils4.java +++ b/jena-core/src/test/java/org/apache/jena/junit/TestUtils4.java @@ -23,12 +23,11 @@ package org.apache.jena.junit; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * Basis for Jena test cases which provides assertFalse and assertDiffer. * Often the logic of the names is clearer than using a negation. - * JUnit4. */ public class TestUtils4 { // do not instantiate, do not subclass. @@ -104,9 +103,9 @@ public class TestUtils4 { * @param o2 */ public static void assertEquivalent(String msg, Object o1, Object o2) { - assertEquals(msg, o1, o2); - assertEquals(msg, o2, o1); - assertEquals(msg, o1.hashCode(), o2.hashCode()); + assertEquals(o1, o2, msg); + assertEquals(o2, o1, msg); + assertEquals(o1.hashCode(), o2.hashCode(), msg); } /** @@ -116,8 +115,8 @@ public class TestUtils4 { * @param o2 */ public static void assertNotEquivalent(String msg, Object o1, Object o2) { - assertNotEquals(msg, o1, o2); - assertNotEquals(msg, o2, o1); + assertNotEquals(o1, o2, msg); + assertNotEquals(o2, o1, msg); } // FIXME this is to be removed when testing is complete diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestBase.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestBase.java index 98c7f5b3ad..b4ba3f373c 100644 --- a/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestBase.java +++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestBase.java @@ -37,14 +37,6 @@ import org.apache.jena.test.JenaTestLib; * <p> * Generic test case for ontology unit testing. * </p> - * <p> - * JUnit6 counterpart of {@link OntTestBase}. The JUnit3 original was a - * {@code TestSuite} that built one {@code TestCase} per entry of - * {@link #getTests}; here the same array becomes one {@link DynamicTest} per - * entry, so the test count is unchanged. {@code OntTestCase} keeps the - * constructor and {@code ontTest} contract of the original, so sub-classes - * carry over unaltered. - * </p> */ @SuppressWarnings("removal") public abstract class OntTestBase diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestUtil.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestUtil.java index 999de2ae11..baf8f2d903 100644 --- a/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestUtil.java +++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestUtil.java @@ -33,12 +33,6 @@ import org.apache.jena.rdf.model.Statement; /** * Collection of utilities to assist with unit testing. - * <p> - * The {@code assertIterator*} methods are derived from - * {@link org.apache.jena.reasoner.test.TestUtil} so that this package can be - * migrated to JUnit6 independently. The {@code junit.framework.TestCase} - * argument of the originals has been dropped: it served only to label failure - * messages and to name the logger, both of which JUnit6 reports for itself. */ class OntTestUtil { diff --git a/jena-core/src/test/java/org/apache/jena/rdf/model/ModelTestLib.java b/jena-core/src/test/java/org/apache/jena/rdf/model/ModelTestLib.java index 6c3e7648cb..f3da446331 100644 --- a/jena-core/src/test/java/org/apache/jena/rdf/model/ModelTestLib.java +++ b/jena-core/src/test/java/org/apache/jena/rdf/model/ModelTestLib.java @@ -21,9 +21,9 @@ package org.apache.jena.rdf.model; -import java.util.*; +import static org.junit.jupiter.api.Assertions.fail; -import org.junit.Assert; +import java.util.*; import org.apache.jena.graph.Graph; import org.apache.jena.graph.GraphTestLib; @@ -56,13 +56,11 @@ public class ModelTestLib { * @param title a String appearing at the beginning of the failure message * @param wanted the model value that is expected * @param got the model value to check - * @exception junit.framework.AssertionFailedError if the models are not - * isomorphic */ public static void assertIsoModels(final String title, final Model wanted, final Model got) { if ( wanted.isIsomorphicWith(got) == false ) { final Map<Node, Object> map = CollectionFactory.createHashedMap(); - Assert.fail(title + ": expected " + GraphTestLib.nice(wanted.getGraph(), map) + "\n but had " + fail(title + ": expected " + GraphTestLib.nice(wanted.getGraph(), map) + "\n but had " + GraphTestLib.nice(got.getGraph(), map)); } } diff --git a/jena-core/src/test/java/org/apache/jena/rdf/model/RecordingModelListener.java b/jena-core/src/test/java/org/apache/jena/rdf/model/RecordingModelListener.java index c56bbcc0b9..0b2b4ae341 100644 --- a/jena-core/src/test/java/org/apache/jena/rdf/model/RecordingModelListener.java +++ b/jena-core/src/test/java/org/apache/jena/rdf/model/RecordingModelListener.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.fail; import org.apache.jena.atlas.iterator.Iter; @@ -104,7 +104,7 @@ public class RecordingModelListener implements ModelChangedListener { public void assertHas(Object[] things) { if ( has(things) == false ) - Assert.fail("expected " + Arrays.asList(things) + " but got " + history); + fail("expected " + Arrays.asList(things) + " but got " + history); } public boolean has(List<? > things) { @@ -121,19 +121,19 @@ public class RecordingModelListener implements ModelChangedListener { public void assertHas(List<? > things) { if ( has(things) == false ) - Assert.fail("expected " + things + " but got " + history); + fail("expected " + things + " but got " + history); } public void assertHasStart(Object[] start) { List<Object> L = Arrays.asList(start); if ( hasStart(L) == false ) - Assert.fail("expected " + L + " at the beginning of " + history); + fail("expected " + L + " at the beginning of " + history); } public void assertHasEnd(Object[] end) { List<Object> L = Arrays.asList(end); if ( hasEnd(L) == false ) - Assert.fail("expected " + L + " at the end of " + history); + fail("expected " + L + " at the end of " + history); } public void clear() { diff --git a/jena-core/src/test/java/org/apache/jena/rdf/model/helpers/ModelHelper.java b/jena-core/src/test/java/org/apache/jena/rdf/model/helpers/ModelHelper.java index c64a71b9f0..00a1d73d42 100644 --- a/jena-core/src/test/java/org/apache/jena/rdf/model/helpers/ModelHelper.java +++ b/jena-core/src/test/java/org/apache/jena/rdf/model/helpers/ModelHelper.java @@ -21,10 +21,9 @@ package org.apache.jena.rdf.model.helpers; -import java.util.*; +import static org.junit.jupiter.api.Assertions.fail; -import junit.framework.TestCase; -import org.junit.Ignore; +import java.util.*; import org.apache.jena.graph.GraphTestLib; import org.apache.jena.graph.Node; @@ -36,18 +35,9 @@ import org.apache.jena.util.CollectionFactory; /** provides useful functionality for testing models, eg building small models from strings, testing equality, etc. - - Currently this class extends TestCase. - - TODO: Refactoring should remove the TestCase dependency in future. - */ -@Ignore // ignore this class as a test case. -public class ModelHelper extends TestCase +public class ModelHelper { - private ModelHelper(String name) - { super(name); } - protected static Model aModel; static { @@ -175,7 +165,6 @@ public class ModelHelper extends TestCase @param title a String appearing at the beginning of the failure message @param wanted the model value that is expected @param got the model value to check - @exception junit.framework.AssertionFailedError the models are not isomorphic */ public static void assertIsoModels( String title, Model wanted, Model got ) { diff --git a/jena-core/src/test/java/org/apache/jena/rdf/model/helpers/RecordingModelListener.java b/jena-core/src/test/java/org/apache/jena/rdf/model/helpers/RecordingModelListener.java index b5f9a34e42..ef36b54dcc 100644 --- a/jena-core/src/test/java/org/apache/jena/rdf/model/helpers/RecordingModelListener.java +++ b/jena-core/src/test/java/org/apache/jena/rdf/model/helpers/RecordingModelListener.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.fail; import org.apache.jena.atlas.iterator.Iter; import org.apache.jena.rdf.model.Model; @@ -74,7 +74,7 @@ public class RecordingModelListener implements ModelChangedListener { if (has(things) == false) { - Assert.fail("expected " + things + " but got " + history); + fail("expected " + things + " but got " + history); } } @@ -82,7 +82,7 @@ public class RecordingModelListener implements ModelChangedListener { if (has(things) == false) { - Assert.fail("expected " + Arrays.asList(things) + " but got " + fail("expected " + Arrays.asList(things) + " but got " + history); } } @@ -92,7 +92,7 @@ public class RecordingModelListener implements ModelChangedListener final List<Object> L = Arrays.asList(end); if (hasEnd(L) == false) { - Assert.fail("expected " + L + " at the end of " + history); + fail("expected " + L + " at the end of " + history); } } @@ -101,7 +101,7 @@ public class RecordingModelListener implements ModelChangedListener final List<Object> L = Arrays.asList(start); if (hasStart(L) == false) { - Assert.fail("expected " + L + " at the beginning of " + history); + fail("expected " + L + " at the beginning of " + history); } } diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/arp1tests/TS3_xmlinput1.java b/jena-core/src/test/java/org/apache/jena/rdfxml/arp1tests/TS3_rdfxml_arp.java similarity index 88% rename from jena-core/src/test/java/org/apache/jena/rdfxml/arp1tests/TS3_xmlinput1.java rename to jena-core/src/test/java/org/apache/jena/rdfxml/arp1tests/TS3_rdfxml_arp.java index ecb14d51dd..3c4cd10e6a 100644 --- a/jena-core/src/test/java/org/apache/jena/rdfxml/arp1tests/TS3_xmlinput1.java +++ b/jena-core/src/test/java/org/apache/jena/rdfxml/arp1tests/TS3_rdfxml_arp.java @@ -22,13 +22,17 @@ package org.apache.jena.rdfxml.arp1tests; import junit.framework.TestSuite; +import org.apache.jena.test.JenaTestLib; + +public class TS3_rdfxml_arp extends TestSuite { + + static { JenaTestLib.setup(); } -public class TS3_xmlinput1 extends TestSuite { static public TestSuite suite() { - return new TS3_xmlinput1(); + return new TS3_rdfxml_arp(); } - private TS3_xmlinput1() { + private TS3_rdfxml_arp() { super("RDF/XML Input ARP1"); addTest(TestURIs.suite()); addTest(TestSuiteWG_RDFXML.suite()); diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/BaseTestXMLOutput.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/BaseTestXMLOutput.java index 99d71e4a05..104ab60504 100644 --- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/BaseTestXMLOutput.java +++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmloutput/BaseTestXMLOutput.java @@ -217,5 +217,4 @@ public abstract class BaseTestXMLOutput assertEquals(errorExpected, errorsFound, "Errors (not) detected."); } - - } +} diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/TS6_RuleReasoners.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/TS6_RuleReasoners.java index 6087f50d53..01e34d6b91 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/TS6_RuleReasoners.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/TS6_RuleReasoners.java @@ -59,7 +59,13 @@ import org.apache.jena.test.JenaTestLib; TestLPBRuleCloseBug.class, ConcurrencyTest.class, - TestRestrictionsDontNeedTyping.class + TestRestrictionsDontNeedTyping.class, + + TestLPRDFS.class, + TestOWLConsistency.class, + TestRuleLoader.class, + TestRDFSRules.class, + TestRDFS9.class }) public class TS6_RuleReasoners { diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/OWLWGTester.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/OWLWGTester.java index c395776579..7a5db4920c 100755 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/OWLWGTester.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/OWLWGTester.java @@ -37,7 +37,7 @@ import org.apache.jena.shared.JenaException; import org.apache.jena.util.FileManager; import org.apache.jena.vocabulary.RDF; import org.apache.jena.vocabulary.ReasonerVocabulary; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -225,7 +225,7 @@ public class OWLWGTester { // Signal the results if (testcase != null) { - Assert.assertTrue("Test: " + test + "\n" + reasonerF.getURI() + "\n" + description, correct); + assertTrue(correct, "Test: " + test + "\n" + reasonerF.getURI() + "\n" + description); } return correct; } diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestBasicLP.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestBasicLP.java index 282743dad8..1b1bd46fc3 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestBasicLP.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestBasicLP.java @@ -1199,9 +1199,6 @@ public class TestBasicLP { } out.flush(); - // PrintUtil.print renders a URI node with no matching prefix as <uri>. This - // expectation predates that and had gone stale unnoticed: the class was not - // reached by the JUnit 3 suite, so these tests had not been running. String testString = TestUtil.normalizeWhiteSpace("Rule testRule3 concluded (<a> <p> <C3>) <-\n" + " Rule testRule1 concluded (<C2> <p> <C3>) <-\n" + " Fact (<C1> <p> <C3>)\r\n" + diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestLPRDFS.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestLPRDFS.java index c8d7f465ff..d54c7b7bc2 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestLPRDFS.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestLPRDFS.java @@ -19,24 +19,23 @@ * SPDX-License-Identifier: Apache-2.0 */ + package org.apache.jena.reasoner.rulesys.test; import java.io.IOException; +import java.util.List; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.jena.reasoner.*; -import org.apache.jena.reasoner.rulesys.*; -import org.apache.jena.reasoner.test.ReasonerTester; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.junit.jupiter.api.Test; -import java.util.*; +import org.apache.jena.reasoner.Reasoner; +import org.apache.jena.reasoner.rulesys.FBRuleReasoner; +import org.apache.jena.reasoner.rulesys.Rule; +import org.apache.jena.reasoner.test.ReasonerTester; /** * Test an FB hybrid using the emerging LP engine on the basic RDFS tests. */ -public class TestLPRDFS extends TestCase { +public class TestLPRDFS { /** The location of the OWL rule definitions on the class path */ public static final String RULE_FILE = "etc/rdfs-fb-lp-expt.rules"; @@ -44,105 +43,92 @@ public class TestLPRDFS extends TestCase { /** The parsed rules */ protected static List<Rule> ruleSet; - /** The tester utility */ - protected ReasonerTester tester; - - static Logger logger = LoggerFactory.getLogger(TestLPRDFS.class); - - /** - * Boilerplate for junit - */ - public TestLPRDFS( String name ) { - super( name ); - } - - /** - * Boilerplate for junit. - * This is its own test suite - */ - public static TestSuite suite() { - return new TestSuite(TestLPRDFS.class); -// TestSuite suite = new TestSuite(); -// try { -// TestRDFSReasoners.constructQuerytests( -// suite, -// "rdfs/manifest-nodirect-noresource.rdf", -// makeReasoner()); -// } catch (IOException e) { -// // failed to even built the test harness -// logger.error("Failed to construct RDFS test harness", e); -// } -// return suite; - } - + @Test public void test1() throws IOException { doTest("test1"); } + @Test public void test2() throws IOException { doTest("test2"); } + @Test public void test3() throws IOException { doTest("test3"); } + @Test public void test4() throws IOException { doTest("test4"); } + @Test public void test5() throws IOException { doTest("test5"); } + @Test public void test6() throws IOException { doTest("test6"); } + @Test public void test7() throws IOException { doTest("test7"); } + @Test public void test8() throws IOException { doTest("test8"); } + @Test public void test9() throws IOException { doTest("test9"); } + @Test public void test10() throws IOException { doTest("test10"); } + @Test public void test11() throws IOException { doTest("test11"); } + @Test public void test12() throws IOException { doTest("test12"); } + @Test public void test13() throws IOException { doTest("test13"); } + @Test public void test14() throws IOException { doTest("test14"); } + @Test public void test15() throws IOException { doTest("test15"); } + @Test public void test16() throws IOException { doTest("test16"); } + @Test public void test18() throws IOException { doTest("test18"); } + @Test public void test20() throws IOException { doTest("test20"); } @@ -171,5 +157,4 @@ public class TestLPRDFS extends TestCase { if (ruleSet == null) ruleSet = FBRuleReasoner.loadRules( RULE_FILE ); return ruleSet; } - } diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestOWLConsistency.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestOWLConsistency.java index fe182547f7..8f8f1c2674 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestOWLConsistency.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestOWLConsistency.java @@ -19,46 +19,32 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.jena.reasoner.rulesys.test; +package org.apache.jena.reasoner.rulesys.test; -//import java.util.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.jena.rdf.model.*; -import org.apache.jena.reasoner.*; +import org.apache.jena.rdf.model.InfModel; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.reasoner.Reasoner; +import org.apache.jena.reasoner.ReasonerRegistry; +import org.apache.jena.reasoner.ValidityReport; import org.apache.jena.util.FileManager; /** * Test the preliminary OWL validation rules. */ -public class TestOWLConsistency extends TestCase { - +public class TestOWLConsistency { + /** The tbox/ontology file to test against sample data */ public static final String testTbox = "file:testing/reasoners/owl/tbox.owl"; - + /** A cached copy of the bound reasoner */ public static Reasoner reasonerCache; - - /** - * Boilerplate for junit - */ - public TestOWLConsistency( String name ) { - super( name ); - } - - /** - * Boilerplate for junit. - * This is its own test suite - */ - public static TestSuite suite() { - return new TestSuite( TestOWLConsistency.class ); -// TestSuite suite = new TestSuite(); -// suite.addTest(new TestOWLConsistency( "testInconsistent5" )); -// return suite; - } /** * Create, or retrieve from cache, an OWL reasoner already bound @@ -71,75 +57,71 @@ public class TestOWLConsistency extends TestCase { } return reasonerCache; } - + /** * Should be consistent. */ + @Test public void testConsistent() { assertTrue(doTestOn("file:testing/reasoners/owl/consistentData.rdf")); } - + /** * Should find problem due to overlap of disjoint classes. */ + @Test public void testInconsistent1() { - assertTrue( ! doTestOn("file:testing/reasoners/owl/inconsistent1.rdf")); + assertFalse(doTestOn("file:testing/reasoners/owl/inconsistent1.rdf")); } - + /** * Should find problem due to type violations */ + @Test public void testInconsistent2() { - assertTrue( ! doTestOn("file:testing/reasoners/owl/inconsistent2.rdf")); + assertFalse(doTestOn("file:testing/reasoners/owl/inconsistent2.rdf")); } - + /** * Should find problem due to count violations */ + @Test public void testInconsistent3() { - assertTrue( ! doTestOn("file:testing/reasoners/owl/inconsistent3.rdf")); + assertFalse(doTestOn("file:testing/reasoners/owl/inconsistent3.rdf")); } - + /** * Should find distinct values for a functional property */ + @Test public void testInconsistent4() { - assertTrue( ! doTestOn("file:testing/reasoners/owl/inconsistent4.rdf")); + assertFalse(doTestOn("file:testing/reasoners/owl/inconsistent4.rdf")); } - + /** * Should find type clash due to allValuesFrom rdfs:Literal */ + @Test public void testInconsistent5() { - assertTrue( ! doTestOn("file:testing/reasoners/owl/inconsistent5.rdf")); + assertFalse(doTestOn("file:testing/reasoners/owl/inconsistent5.rdf")); } - + /** * Should find distinct literal values for a functional property * via an indirect sameAs */ + @Test public void testInconsistent7() { - assertTrue( ! doTestOn("file:testing/reasoners/owl/inconsistent7.rdf")); + assertFalse(doTestOn("file:testing/reasoners/owl/inconsistent7.rdf")); } - + /** * Run a single consistency test on the given data file. */ private boolean doTestOn(String dataFile) { -// System.out.println("Test: " + dataFile); Model data = FileManager.getInternal().loadModelInternal(dataFile); InfModel infmodel = ModelFactory.createInfModel(makeReasoner(), data); ValidityReport reportList = infmodel.validate(); - /* Debug only - if (reportList.isValid()) { - System.out.println("No reported problems"); - } else { - for (Iterator i = reportList.getReports(); i.hasNext(); ) { - ValidityReport.Report report = (ValidityReport.Report)i.next(); - System.out.println("- " + report); - } - } - */ return reportList.isValid(); } } diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRDFS9.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRDFS9.java index 762a6d5828..0a78a4c7d7 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRDFS9.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRDFS9.java @@ -19,51 +19,45 @@ * SPDX-License-Identifier: Apache-2.0 */ + package org.apache.jena.reasoner.rulesys.test; -import java.util.*; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Iterator; + +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.jena.graph.*; +import org.apache.jena.graph.Graph; +import org.apache.jena.graph.GraphMemFactory; +import org.apache.jena.graph.Node; +import org.apache.jena.graph.NodeFactory; +import org.apache.jena.graph.Triple; import org.apache.jena.graph.compose.Union; -import org.apache.jena.reasoner.*; +import org.apache.jena.reasoner.InfGraph; +import org.apache.jena.reasoner.ReasonerRegistry; import org.apache.jena.reasoner.test.TestUtil; -import org.apache.jena.vocabulary.*; +import org.apache.jena.vocabulary.RDF; +import org.apache.jena.vocabulary.RDFS; /** * Test harness used in debugging some issues with execution * of modified versions of rule rdfs9. */ -public class TestRDFS9 extends TestCase { - - /** - * Boilerplate for junit - */ - public TestRDFS9( String name ) { - super( name ); - } - - /** - * Boilerplate for junit. - * This is its own test suite - */ - public static TestSuite suite() { - return new TestSuite(TestRDFS9.class); - } +public class TestRDFS9 { - private static Graph createGraphForTest() { + private static Graph createGraphForTest() { return GraphMemFactory.createDefaultGraph(); } /** * Test a type inheritance example. */ + @Test public void testRDFSInheritance() { Node C1 = NodeFactory.createURI("C1"); Node C2 = NodeFactory.createURI("C2"); Node C3 = NodeFactory.createURI("C3"); - Node C4 = NodeFactory.createURI("C4"); Node D = NodeFactory.createURI("D"); Node a = NodeFactory.createURI("a"); Node b = NodeFactory.createURI("b"); diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRDFSRules.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRDFSRules.java old mode 100755 new mode 100644 index 5fb60d7852..1b1abba0ef --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRDFSRules.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRDFSRules.java @@ -19,10 +19,19 @@ * SPDX-License-Identifier: Apache-2.0 */ + package org.apache.jena.reasoner.rulesys.test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.util.Iterator; + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; @@ -36,87 +45,68 @@ import org.apache.jena.reasoner.test.ReasonerTester; import org.apache.jena.vocabulary.OWL; import org.apache.jena.vocabulary.RDF; import org.apache.jena.vocabulary.RDFS; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.Iterator; /** Test suite to test the production rule version of the RDFS implementation. * <p> The tests themselves have been replaced by an updated version * of the top level TestRDFSReasoners but this file is maintained for now since * the top level timing test can sometimes be useful. </p> */ -public class TestRDFSRules extends TestCase { +public class TestRDFSRules { /** Base URI for the test names */ public static final String NAMESPACE = "http://www.hpl.hp.com/semweb/2003/query_tester/"; - + protected static Logger logger = LoggerFactory.getLogger(TestRDFSRules.class); - - /** - * Boilerplate for junit - */ - public TestRDFSRules( String name ) { - super( name ); - } - - /** - * Boilerplate for junit. - * This is its own test suite - */ - public static TestSuite suite() { - return new TestSuite(TestRDFSRules.class); -// TestSuite suite = new TestSuite(); -// suite.addTest(new TestRDFSRules( "hiddenTestRDFSReasonerDebug" )); -// return suite; - } /** * Test a single RDFS case. + * Not run as part of the suite - the name does not start "test". */ public void hiddenTestRDFSReasonerDebug() throws IOException { ReasonerTester tester = new ReasonerTester("rdfs/manifest-nodirect-noresource.rdf"); ReasonerFactory rf = RDFSRuleReasonerFactory.theInstance(); - - assertTrue("RDFS hybrid-tgc reasoner test", tester.runTest("http://www.hpl.hp.com/semweb/2003/query_tester/rdfs/test11", rf, this, null)); + + assertTrue(tester.runTest("http://www.hpl.hp.com/semweb/2003/query_tester/rdfs/test11", rf, this, null), + "RDFS hybrid-tgc reasoner test"); } /** * Test the basic functioning of the hybrid RDFS rule reasoner */ + @Test public void testRDFSFBReasoner() throws IOException { ReasonerTester tester = new ReasonerTester("rdfs/manifest-nodirect-noresource.rdf"); ReasonerFactory rf = RDFSFBRuleReasonerFactory.theInstance(); - assertTrue("RDFS hybrid reasoner tests", tester.runTests(rf, this, null)); + assertTrue(tester.runTests(rf, this, null), "RDFS hybrid reasoner tests"); } /** * Test the basic functioning of the hybrid RDFS rule reasoner with TGC cache */ + @Test public void testRDFSExptReasoner() throws IOException { ReasonerTester tester = new ReasonerTester("rdfs/manifest-nodirect-noresource.rdf"); ReasonerFactory rf = RDFSRuleReasonerFactory.theInstance(); - assertTrue("RDFS experimental (hybrid+tgc) reasoner tests", tester.runTests(rf, this, null)); + assertTrue(tester.runTests(rf, this, null), "RDFS experimental (hybrid+tgc) reasoner tests"); } /** * Test the capabilities description. */ + @Test public void testRDFSDescription() { ReasonerFactory rf = RDFSFBRuleReasonerFactory.theInstance(); Reasoner r = rf.create(null); - assertTrue(r.supportsProperty(RDFS.subClassOf)); - assertTrue(r.supportsProperty(RDFS.domain)); - assertTrue( ! r.supportsProperty(OWL.allValuesFrom)); + assertTrue(r.supportsProperty(RDFS.subClassOf)); + assertTrue(r.supportsProperty(RDFS.domain)); + assertFalse(r.supportsProperty(OWL.allValuesFrom)); } - + /** * Time a trial list of results from an inf graph. */ private static void doTiming(Reasoner r, Model tbox, Model data, String name, int loop) { Resource C1 = ResourceFactory.createResource("http://www.hpl.hp.com/semweb/2003/eg#C1"); - Resource C2 = ResourceFactory.createResource("http://www.hpl.hp.com/semweb/2003/eg#C2"); - + long t1 = System.currentTimeMillis(); int count = 0; for (int lp = 0; lp < loop; lp++) { @@ -129,12 +119,5 @@ public class TestRDFSRules extends TestCase { long time = time10/10; long timeFraction = time10 - (time*10); System.out.println(name + ": " + count +" results in " + time + "." + timeFraction +"ms"); -// t1 = System.currentTimeMillis(); -// for (int j = 0; j < 10; j++) { -// count = 0; -// for (Iterator i = m.listStatements(null, RDF.type, C1); i.hasNext(); i.next()) count++; -// } -// t2 = System.currentTimeMillis(); -// System.out.println(name + ": " + count + " results in " + (t2-t1)/10 +"ms"); - } + } } diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRuleLoader.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRuleLoader.java index 8d8c0f3d9d..05d607cf3b 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRuleLoader.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestRuleLoader.java @@ -19,24 +19,27 @@ * SPDX-License-Identifier: Apache-2.0 */ + package org.apache.jena.reasoner.rulesys.test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.List; + +import org.junit.jupiter.api.Test; + import org.apache.jena.reasoner.rulesys.BuiltinRegistry; import org.apache.jena.reasoner.rulesys.MapBuiltinRegistry; import org.apache.jena.reasoner.rulesys.Rule; import org.apache.jena.reasoner.rulesys.builtins.BaseBuiltin; import org.apache.jena.shared.RulesetNotFoundException; import org.apache.jena.shared.WrappedIOException; -import org.junit.Test; - -import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; /** * Tests for the rule loader */ -public class TestRuleLoader { +public class TestRuleLoader { private static BuiltinRegistry createBuiltinRegistry() { BuiltinRegistry br = new MapBuiltinRegistry(); @@ -49,9 +52,10 @@ public class TestRuleLoader { return br; } - @Test(expected=RulesetNotFoundException.class) + @Test public void load_from_file_uri_non_existent() { - Rule.rulesFromURL("file:///no-such-file.txt"); + assertThrows(RulesetNotFoundException.class, + () -> Rule.rulesFromURL("file:///no-such-file.txt")); } @Test @@ -61,9 +65,10 @@ public class TestRuleLoader { assertEquals("file:testing/reasoners/includeAlt.rules", e.getURI()); } - @Test(expected=WrappedIOException.class) + @Test public void load_from_file_bad_encoding() { - Rule.rulesFromURL("testing/reasoners/bugs/bad-encoding.rules"); + assertThrows(WrappedIOException.class, + () -> Rule.rulesFromURL("testing/reasoners/bugs/bad-encoding.rules")); } /** diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestTrialOWLRules.java b/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestTrialOWLRules.java deleted file mode 100644 index 8bf0452b28..0000000000 --- a/jena-core/src/test/java/org/apache/jena/reasoner/rulesys/test/TestTrialOWLRules.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 - * - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.apache.jena.reasoner.rulesys.test; - -import junit.framework.TestCase; - -import junit.framework.*; - -import java.io.IOException; - -import org.apache.jena.rdf.model.*; -import org.apache.jena.reasoner.*; -import org.apache.jena.reasoner.rulesys.*; -import org.apache.jena.util.FileManager; -import org.apache.jena.vocabulary.RDF; -import org.apache.jena.vocabulary.ReasonerVocabulary; - -/** - * Test suite to test experimental versions of the OWL reasoner, not - * included in the main regression test suite. - */ -public class TestTrialOWLRules extends TestCase { - - /** The name of the manifest file to test */ - protected String manifest; - - /** Flag to control whether tracing and logging enabled */ - protected static boolean enableTracing = false; - - /** Flag to control whether to print performance stats as we go */ - protected static boolean printStats = true; - - /** Configuration spec for the reasoner under test */ - protected static Resource configuration; - - static { - Model m = ModelFactory.createDefaultModel(); - configuration = m.createResource(GenericRuleReasonerFactory.URI); - configuration.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid"); - configuration.addProperty(ReasonerVocabulary.PROPruleSet, "etc/owl-fb-test.rules"); - configuration.addProperty(ReasonerVocabulary.PROPenableOWLTranslation, "true" ); - } - - /** - * Boilerplate for junit - */ - public TestTrialOWLRules( String manifest ) { - super( manifest ); - this.manifest = manifest; - } - - /** - * Boilerplate for junit. - * This is its own test suite - */ - public static TestSuite suite() { - TestSuite suite = new TestSuite(); - - // Basic property and equivalence tests - suite.addTest(new TestTrialOWLRules("SymmetricProperty/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest002.rdf")); - suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest003.rdf")); - suite.addTest(new TestTrialOWLRules("InverseFunctionalProperty/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("InverseFunctionalProperty/Manifest002.rdf")); - suite.addTest(new TestTrialOWLRules("InverseFunctionalProperty/Manifest003.rdf")); - suite.addTest(new TestTrialOWLRules("rdf-charmod-uris/Manifest.rdf")); - suite.addTest(new TestTrialOWLRules("I5.5/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("I5.5/Manifest002.rdf")); - suite.addTest(new TestTrialOWLRules("I5.5/Manifest003.rdf")); - suite.addTest(new TestTrialOWLRules("I5.5/Manifest004.rdf")); - suite.addTest(new TestTrialOWLRules("inverseOf/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("TransitiveProperty/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest001.rdf")); // bx - long - suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest002.rdf")); // bx - long but terminates - suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest003.rdf")); // bx - long but terminates - suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest005.rdf")); // bx - timeout - suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest001.rdf")); // bx - long but terminates - suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest002.rdf")); // bx - long but terminates - suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest003.rdf")); - suite.addTest(new TestTrialOWLRules("I4.6/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("I4.6/Manifest002.rdf")); - suite.addTest(new TestTrialOWLRules("I5.1/Manifest001.rdf")); // bx - v. long but terminates - suite.addTest(new TestTrialOWLRules("I5.24/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("I5.24/Manifest002-mod.rdf")); - suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest006.rdf")); - suite.addTest(new TestTrialOWLRules("intersectionOf/Manifest001.rdf")); // bx - takes a long time - - // Disjointness tests - suite.addTest(new TestTrialOWLRules("differentFrom/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("disjointWith/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("disjointWith/Manifest002.rdf")); - suite.addTest(new TestTrialOWLRules("AllDifferent/Manifest001.rdf")); // bx gets lost - - // Restriction tests - suite.addTest(new TestTrialOWLRules("allValuesFrom/Manifest001.rdf")); // bx - long but terminates - suite.addTest(new TestTrialOWLRules("allValuesFrom/Manifest002.rdf")); // bx - slow - suite.addTest(new TestTrialOWLRules("someValuesFrom/Manifest002.rdf")); // bx - slow - suite.addTest(new TestTrialOWLRules("maxCardinality/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("maxCardinality/Manifest002.rdf")); - suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest005-mod.rdf")); - suite.addTest(new TestTrialOWLRules("I5.24/Manifest004-mod.rdf")); // bx - long - suite.addTest(new TestTrialOWLRules("localtests/Manifest001.rdf")); // bx - long but terminates - suite.addTest(new TestTrialOWLRules("localtests/Manifest002.rdf")); // bx - long but terminates - suite.addTest(new TestTrialOWLRules("cardinality/Manifest001-mod.rdf")); // bx gets lost - suite.addTest(new TestTrialOWLRules("cardinality/Manifest002-mod.rdf")); // bx gets lost - suite.addTest(new TestTrialOWLRules("cardinality/Manifest003-mod.rdf")); // bx gets lost - suite.addTest(new TestTrialOWLRules("cardinality/Manifest004-mod.rdf")); // bx gets lost - suite.addTest(new TestTrialOWLRules("I5.24/Manifest003-mod.rdf")); - suite.addTest(new TestTrialOWLRules("cardinality/Manifest005-mod.rdf")); // bx gets lost - suite.addTest(new TestTrialOWLRules("cardinality/Manifest006-mod.rdf")); // bx gets lost - suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest004.rdf")); // bx - timeout - - // Needs prototype creation rule -// suite.addTest(new TestTrialOWLRules("someValuesFrom/Manifest001.rdf")); // bx needs creation rule - - // Duplications of tests included earlier -// suite.addTest(new TestTrialOWLRules("differentFrom/Manifest002.rdf")); // Duplication of AllDifferent#1 -// suite.addTest(new TestTrialOWLRules("distinctMembers/Manifest001.rdf")); // Duplication of AllDifferent#1 - - // Consistency tests - not yet implemented by tester -// suite.addTest(new TestTrialOWLRules("I5.3/Manifest005.rdf")); -// suite.addTest(new TestTrialOWLRules("I5.3/Manifest006.rdf")); -// suite.addTest(new TestTrialOWLRules("I5.3/Manifest007.rdf")); -// suite.addTest(new TestTrialOWLRules("I5.3/Manifest008.rdf")); -// suite.addTest(new TestTrialOWLRules("I5.3/Manifest009.rdf")); -// suite.addTest(new TestTrialOWLRules("Nothing/Manifest001.rdf")); -// suite.addTest(new TestTrialOWLRules("miscellaneous/Manifest001.rdf")); -// suite.addTest(new TestTrialOWLRules("miscellaneous/Manifest002.rdf")); - - // Non-feature tests -// suite.addTest(new TestTrialOWLRules("I3.2/Manifest001.rdf")); -// suite.addTest(new TestTrialOWLRules("I3.2/Manifest002.rdf")); -// suite.addTest(new TestTrialOWLRules("I3.2/Manifest003.rdf")); -// suite.addTest(new TestTrialOWLRules("I3.4/Manifest001.rdf")); -// suite.addTest(new TestTrialOWLRules("I4.1/Manifest001.rdf")); - - // Outside (f)lite set - hasValue, oneOf, complementOf, unionOf - /* - suite.addTest(new TestTrialOWLRules("unionOf/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("unionOf/Manifest002.rdf")); - suite.addTest(new TestTrialOWLRules("oneOf/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("oneOf/Manifest002.rdf")); - suite.addTest(new TestTrialOWLRules("oneOf/Manifest003.rdf")); - suite.addTest(new TestTrialOWLRules("oneOf/Manifest004.rdf")); - suite.addTest(new TestTrialOWLRules("complementOf/Manifest001.rdf")); - suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest004.rdf")); - suite.addTest(new TestTrialOWLRules("InverseFunctionalProperty/Manifest004.rdf")); - suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest007.rdf")); - suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest006.rdf")); - suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest004.rdf")); - suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest005.rdf")); - suite.addTest(new TestTrialOWLRules("Nothing/Manifest002.rdf")); - */ - - return suite; - } - - /** - * The test runner - */ - @Override - protected void runTest() throws IOException { - OWLWGTester tester = new OWLWGTester(GenericRuleReasonerFactory.theInstance(), this, configuration); -// OWLWGTester tester = new OWLWGTester(OWLExptRuleReasonerFactory.theInstance(), this, null); - tester.runTests(manifest, enableTracing, printStats); - } - - /** - * Boiler plate code for loading up and exploring a specific test case - * for use during debugging. - */ - public static void main(String[] args) { - Model premises = FileManager.getInternal().loadModelInternal("file:testing/wg/someValuesFrom/premises001.rdf"); - Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(configuration); - InfModel conclusions = ModelFactory.createInfModel(reasoner, premises); - - System.out.println("Premises = "); - for (StmtIterator i = premises.listStatements(); i.hasNext(); ) { - System.out.println(" - " + i.next()); - } - - Resource i = conclusions.getResource("http://www.w3.org/2002/03owlt/someValuesFrom/premises001#i"); - Property p = conclusions.getProperty("http://www.w3.org/2002/03owlt/someValuesFrom/premises001#p"); - Resource c = conclusions.getResource("http://www.w3.org/2002/03owlt/someValuesFrom/premises001#c"); - Resource r = conclusions.getResource("http://www.w3.org/2002/03owlt/someValuesFrom/premises001#r"); - Resource v = (Resource)i.getRequiredProperty(p).getObject(); - System.out.println("Value of i.p = " + v); - System.out.println("Types of v are: "); - for (StmtIterator it2 = conclusions.listStatements(v, RDF.type, (RDFNode)null); it2.hasNext(); ) { - System.out.println(" - " + it2.next()); - } -// System.out.println("Things of type r are: "); -// for (Iterator it = conclusions.listStatements(null, RDF.type, r); it.hasNext(); ) { -// System.out.println(" - " + it.next()); -// } -// System.out.println("Types of i are: "); -// for (Iterator it = conclusions.listStatements(i, RDF.type, (RDFNode)null); it.hasNext(); ) { -// System.out.println(" - " + it.next()); -// } -// System.out.println("Things of type r are: "); -// for (Iterator it = conclusions.listStatements(null, RDF.type, r); it.hasNext(); ) { -// System.out.println(" - " + it.next()); -// } - - } -} diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/ReasonerTester.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/ReasonerTester.java index 339f0efcbe..918cae9fcc 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/test/ReasonerTester.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/ReasonerTester.java @@ -42,7 +42,7 @@ import org.apache.jena.reasoner.TriplePattern; import org.apache.jena.reasoner.rulesys.Node_RuleVariable; import org.apache.jena.shared.JenaException; import org.apache.jena.vocabulary.RDF; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -322,7 +322,7 @@ public class ReasonerTester { */ // ... end of debugging hack if (testcase != null) { - Assert.assertTrue(description, correct); + assertTrue(correct, description); } return correct; } diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestCurrentRDFWG.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestCurrentRDFWG.java deleted file mode 100644 index 1029277429..0000000000 --- a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestCurrentRDFWG.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 - * - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.apache.jena.reasoner.test; - -import java.io.IOException; - -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; -import org.apache.jena.rdf.model.Resource; -import org.apache.jena.reasoner.ReasonerFactory; -import org.apache.jena.reasoner.rulesys.RDFSRuleReasonerFactory; -import org.apache.jena.shared.impl.JenaParameters; -import org.apache.jena.vocabulary.OWLResults; -import org.apache.jena.vocabulary.RDFS; -import org.apache.jena.vocabulary.ReasonerVocabulary; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Test the default RDFS reasoner against the current set of working group tests - */ -public class TestCurrentRDFWG extends TestCase { - - /** Location of the test file directory */ - public static final String TEST_DIR = "testing/wg20031010/"; -// public static final String TEST_DIR = "testing/wg/"; - - /** The base URI for the results file */ - public static String BASE_RESULTS_URI = "http://jena.apache.org/data/rdf-results.rdf"; - - /** The model describing the results of the run */ - Model testResults; - - /** The resource which acts as a description for the Jena instance being tested */ - Resource jena; - - protected static Logger logger = LoggerFactory.getLogger(TestCurrentRDFWG.class); - - /** - * Boilerplate for junit - */ - public TestCurrentRDFWG( String name ) { - super( name ); - } - - /** - * Initialize the result model. - */ - public void initResults() { - testResults = ModelFactory.createDefaultModel(); - jena = testResults.createResource(BASE_RESULTS_URI + "#jena2"); - jena.addProperty(RDFS.label, "Jena2"); - testResults.setNsPrefix("results", OWLResults.NS); - } - - /** - * Boilerplate for junit. - * This is its own test suite - */ - public static TestSuite suite() { - TestSuite suite = new TestSuite(); - try { - Resource config = ReasonerTestLib.newResource() - .addProperty(ReasonerVocabulary.PROPsetRDFSLevel, "full"); - constructRDFWGtests(suite, RDFSRuleReasonerFactory.theInstance(), config); - - } catch (IOException e) { - // failed to even built the test harness - logger.error("Failed to construct RDF WG test harness", e); - } - return suite; - } - - /** - * Build the working group tests for the given reasoner. - */ - private static void constructRDFWGtests(TestSuite suite, ReasonerFactory rf, Resource config) throws IOException { - JenaParameters.enableWhitespaceCheckingOfTypedLiterals = true; - WGReasonerTester tester = new WGReasonerTester("Manifest.rdf", TEST_DIR); - for ( String test : tester.listTests() ) - { - suite.addTest( new TestReasonerWG( tester, test, rf, config ) ); - } - } - - /** - * Inner class defining a test framework for invoking a single - * RDFCore working group test. - */ - static class TestReasonerWG extends TestCase { - - /** The tester which already has the test manifest loaded */ - WGReasonerTester tester; - - /** The name of the specific test to run */ - String test; - - /** The factory for the reasoner type under test */ - ReasonerFactory reasonerFactory; - - /** An optional configuration model */ - Resource config; - - /** Constructor */ - TestReasonerWG(WGReasonerTester tester, String test, - ReasonerFactory reasonerFactory, Resource config) { - super(test); - this.tester = tester; - this.test = test; - this.reasonerFactory = reasonerFactory; - this.config = config; - } - - /** - * The test runner - */ - @Override - public void runTest() throws IOException { - boolean success = tester.runTest(test, reasonerFactory, this, config); -// Resource resultType = null; -// if (test.hasProperty(RDF.type, OWLTest.NegativeEntailmentTest) -// || test.hasProperty(RDF.type, OWLTest.ConsistencyTest)) { -// resultType = success ? OWLResults.PassingRun : OWLResults.FailingRun; -// } else { -// resultType = success ? OWLResults.PassingRun : OWLResults.IncompleteRun; -// } -// // log to the rdf result format -// Resource result = testResults.createResource() -// .addProperty(RDF.type, OWLResults.TestRun) -// .addProperty(RDF.type, resultType) -// .addProperty(OWLResults.test, test) -// .addProperty(OWLResults.system, jena2); - - } - - } - -} diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfModel.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfModel.java index c9febee7f0..a7086bda2f 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfModel.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfModel.java @@ -21,8 +21,6 @@ package org.apache.jena.reasoner.test; -import static org.junit.jupiter.api.Assertions.*; - import org.junit.jupiter.api.Test; import org.apache.jena.ontology.OntModel; diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestRDFSReasoners.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestRDFSReasoners.java index 8263150c6d..6088bf79f0 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestRDFSReasoners.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestRDFSReasoners.java @@ -62,8 +62,7 @@ public class TestRDFSReasoners { /** - * The RDFS reasoner tests, one dynamic test per manifest entry. This was a - * hand-built {@code TestSuite} of {@code TestCase} subclasses. + * The RDFS reasoner tests, one dynamic test per manifest entry. */ @TestFactory public Stream<DynamicTest> rdfsReasonerTests() { diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestUtil.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestUtil.java index 0eba8d84b0..4c8d5f5558 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestUtil.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestUtil.java @@ -33,11 +33,6 @@ import org.apache.jena.rdf.model.Statement; /** * Collection of utilities to assist with unit testing. - * <p> - * JUnit6 counterpart of the {@code assertIterator*} methods of {@link TestUtil}. - * The {@code junit.framework.TestCase} argument of the originals has been - * dropped: it served only to label failure messages and to name the logger, - * both of which JUnit6 reports for itself. */ public class TestUtil { @@ -104,7 +99,7 @@ public class TestUtil { /** * Replace all blocks of white space by a single space character, just * used for creating test cases. - * + * * @param src the original string * @return normalized version of src */ diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/WGReasonerTester.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/WGReasonerTester.java index 6751b2e07d..5ceda3b120 100644 --- a/jena-core/src/test/java/org/apache/jena/reasoner/test/WGReasonerTester.java +++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/WGReasonerTester.java @@ -30,7 +30,7 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.jena.graph.Graph; import org.apache.jena.graph.GraphMemFactory; @@ -385,7 +385,7 @@ public class WGReasonerTester { // System.out.println("**** expected"); // conclusions.write(System.out, "TTL"); // } - Assert.assertTrue("Test: " + test + "\n" + description, correct); + assertTrue(correct, "Test: " + test + "\n" + description); } return correct?goodResult:FAIL; } diff --git a/jena-core/src/test/java/org/apache/jena/vocabulary/VocabTestLib.java b/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU3.java similarity index 58% copy from jena-core/src/test/java/org/apache/jena/vocabulary/VocabTestLib.java copy to jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU3.java index 04e719dfd7..074b7aed6d 100644 --- a/jena-core/src/test/java/org/apache/jena/vocabulary/VocabTestLib.java +++ b/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU3.java @@ -19,21 +19,28 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.jena.vocabulary; +package org.apache.jena.test; -import org.apache.jena.rdf.model.Property; -import org.apache.jena.rdf.model.Resource; +import junit.framework.TestCase; +import junit.framework.TestSuite; -import static org.junit.Assert.assertEquals; +/** + * Jena core test suite. JUnit3 remaining + */ +public class JenaCoreTestAll_JU3 extends TestCase { -public class VocabTestLib { + static public TestSuite suite() { + JenaTestLib.setup(); - public static void assertProperty(String uri, Property p) { - assertResource(uri, p); + TestSuite ts = new TestSuite(); + ts.setName("Jena Core [legacy]"); + addTest(ts, "XML Input [ARP1]", org.apache.jena.rdfxml.arp1tests.TS3_rdfxml_arp.suite()); + return ts; } - public static void assertResource(String uri, Resource r) { - assertEquals(uri, r.getURI()); + private static void addTest(TestSuite ts, String name, TestSuite tc) { + if ( name != null ) + tc.setName(name); + ts.addTest(tc); } - } diff --git a/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU4.java b/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU4.java deleted file mode 100644 index 85d53ee94c..0000000000 --- a/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU4.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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 - * - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.apache.jena.test; - -import junit.framework.JUnit4TestAdapter; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Jena core test suite. - * Tests using JUnit 4, and JUnit3 wrapped as JUnit4. - */ -public class JenaCoreTestAll_JU4 extends TestCase { - - static public TestSuite suite() { - JenaTestLib.setup(); - - TestSuite ts = new TestSuite(); - ts.setName("Jena Core [legacy]"); - -//JU6 addTest(ts, "IRIx", adaptJUnit4(org.apache.jena.irix.TS_IRIx.class)); -//JU6 addTest(ts, "LangTagX", adaptJUnit4(org.apache.jena.langtagx.TS4_LangTagX.class)); -//JU6 addTest(ts, "Datatypes", adaptJUnit4(org.apache.jena.datatypes.TS4_dt.class)); - - // ** COMPLEX - // Generates tests. -//JU6 addTest(ts, "Enhanced", org.apache.jena.enhanced.TS3_enh.suite()); -//JU6 addTest(ts, "Graph", adaptJUnit4(org.apache.jena.graph.TS3_graph.class)); - -//JU6 addTest(ts, "Mem", adaptJUnit4(org.apache.jena.mem.TS4_GraphMem.class)); -//JU6 addTest(ts, "MemValue", adaptJUnit4(org.apache.jena.memvalue.TS3_GraphMemValue.class)); - - // ** COMPLEX -//JU6 addTest(ts, "Model1", org.apache.jena.rdf.model.TS3_Model1.suite()); - // ** COMPLEX -//JU6 addTest(ts, "Default Model", org.apache.jena.rdf.model.TestDefaultModel.suite()); - - // Test suite building - addTest(ts, "XML Input [ARP1]", org.apache.jena.rdfxml.arp1tests.TS3_xmlinput1.suite()); -//JU6 addTest(ts, "XML Output", org.apache.jena.rdfxml.xmloutput.TS3_xmloutput.suite()); - -//JU6 addTest(ts, "Util", adaptJUnit4(org.apache.jena.util.TS4_coreutil.class)); -//JU6 addTest(ts, "Jena iterator", adaptJUnit4(org.apache.jena.util.iterator.test.TS3_coreiter.class)); - -//JU6 addTest(ts, "Assembler", adaptJUnit4(org.apache.jena.assembler.TS3_Assembler.class)); - -//JU6 addTest(ts, "Vocabularies", adaptJUnit4(org.apache.jena.vocabulary.TS3_Vocabularies.class)); -//JU6 addTest(ts, "Shared", adaptJUnit4(org.apache.jena.shared.TS_SharedPackage.class)); - - // ** COMPLEX -//JU6 addTest(ts, "Composed graphs", org.apache.jena.graph.compose.TS3_compose.suite() ); - -//JU6 addTest(ts, "Reasoners", adaptJUnit4(org.apache.jena.reasoner.test.TS3_reasoners.class)); -//JU6 addTest(ts, "RuleReasoners", adaptJUnit4(org.apache.jena.reasoner.rulesys.TS3_RuleReasoners.class)); - -//JU6 addTest(ts, "Ontology ModelMaker", adaptJUnit4(org.apache.jena.ontology.makers.TS3_ModelMakers.class)); -//JU6 addTest(ts, "Ontology", adaptJUnit4(org.apache.jena.ontology.impl.TS3_ont.class)); - - // Local TTL parser for tests - not fully compliant. -//JU6 addTest(ts, "Turtle", adaptJUnit4(org.apache.jena.ttl_test.test_turtle.TS_TestTurtle.class)); - // ** Generated tests -//JU6 addTest(ts, "Turtle:Manifest", org.apache.jena.ttl_test.test_turtle.TurtleTestSuiteManifest.suite()); - return ts; - } - - // JUnit4 in a JUnit3 test runner. - private static Test adaptJUnit4(Class<?> testClass) { - return new JUnit4TestAdapter(testClass); - } - - private static void addTest(TestSuite ts, String name, TestSuite tc) { - if ( name != null ) - tc.setName(name); - ts.addTest(tc); - } - - private static void addTest(TestSuite ts, String name, Test test) { - // Extra level but does name the test suite. - TestSuite ts2 = new TestSuite(name); - ts2.addTest(test); - ts.addTest(ts2); - } -} diff --git a/jena-core/src/test/java/org/apache/jena/test/JenaTestLib.java b/jena-core/src/test/java/org/apache/jena/test/JenaTestLib.java index 7d07723ca1..91611bc3fc 100644 --- a/jena-core/src/test/java/org/apache/jena/test/JenaTestLib.java +++ b/jena-core/src/test/java/org/apache/jena/test/JenaTestLib.java @@ -21,6 +21,8 @@ package org.apache.jena.test; +import static org.junit.jupiter.api.Assertions.fail; + import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -33,8 +35,6 @@ import org.apache.jena.util.CollectionFactory; import org.apache.jena.util.iterator.ExtendedIterator; import org.apache.jena.util.iterator.WrappedIterator; -import static junit.framework.TestCase.*; - public class JenaTestLib { /** diff --git a/jena-core/src/test/java/org/apache/jena/util/iterator/TestAndThen.java b/jena-core/src/test/java/org/apache/jena/util/iterator/TestAndThen.java index 4671add7a4..8c2f104b23 100644 --- a/jena-core/src/test/java/org/apache/jena/util/iterator/TestAndThen.java +++ b/jena-core/src/test/java/org/apache/jena/util/iterator/TestAndThen.java @@ -21,9 +21,9 @@ package org.apache.jena.util.iterator; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertSame; -import static junit.framework.TestCase.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; @@ -63,8 +63,8 @@ public class TestAndThen { ExtendedIterator<String> cat = L.andThen(M).andThen(R); cat.next(); cat.close(); - assertTrue("middle iterator should have been closed", M.isClosed()); - assertTrue("final iterator should have been closed", R.isClosed()); + assertTrue(M.isClosed(), "middle iterator should have been closed"); + assertTrue(R.isClosed(), "final iterator should have been closed"); } @Test diff --git a/jena-core/src/test/java/org/apache/jena/util/iterator/TestAsCollection.java b/jena-core/src/test/java/org/apache/jena/util/iterator/TestAsCollection.java index 1787cc27c7..24c24ca72f 100644 --- a/jena-core/src/test/java/org/apache/jena/util/iterator/TestAsCollection.java +++ b/jena-core/src/test/java/org/apache/jena/util/iterator/TestAsCollection.java @@ -21,7 +21,7 @@ package org.apache.jena.util.iterator; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; import java.util.Set; diff --git a/jena-core/src/test/java/org/apache/jena/util/iterator/TestFilters.java b/jena-core/src/test/java/org/apache/jena/util/iterator/TestFilters.java index df26cdf6c0..7d4e1388f0 100644 --- a/jena-core/src/test/java/org/apache/jena/util/iterator/TestFilters.java +++ b/jena-core/src/test/java/org/apache/jena/util/iterator/TestFilters.java @@ -21,7 +21,7 @@ package org.apache.jena.util.iterator; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Iterator; import java.util.function.Predicate; diff --git a/jena-core/src/test/java/org/apache/jena/util/iterator/TestWrappedIterator.java b/jena-core/src/test/java/org/apache/jena/util/iterator/TestWrappedIterator.java index 247819a120..9c0a393126 100644 --- a/jena-core/src/test/java/org/apache/jena/util/iterator/TestWrappedIterator.java +++ b/jena-core/src/test/java/org/apache/jena/util/iterator/TestWrappedIterator.java @@ -21,7 +21,7 @@ package org.apache.jena.util.iterator; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/jena-core/src/test/java/org/apache/jena/vocabulary/VocabTestLib.java b/jena-core/src/test/java/org/apache/jena/vocabulary/VocabTestLib.java index 04e719dfd7..5181236104 100644 --- a/jena-core/src/test/java/org/apache/jena/vocabulary/VocabTestLib.java +++ b/jena-core/src/test/java/org/apache/jena/vocabulary/VocabTestLib.java @@ -24,7 +24,7 @@ package org.apache.jena.vocabulary; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class VocabTestLib {
