You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2026/09/09 20:56:33 UTC
(jena) 08/12: GH-3236: Convert jena.graph to JUnit6
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 795cf8bf47933836848b13f779ae700c92164c32
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Mon Sep 7 18:03:53 2026 +0100
GH-3236: Convert jena.graph to JUnit6
---
.../{BaseTestGraph_JU6.java => BaseTestGraph.java} | 4 +-
.../java/org/apache/jena/graph/GraphCreators.java | 62 +++
.../java/org/apache/jena/graph/MetaTestGraph.java | 75 +--
.../jena/graph/{TS3_graph.java => TS6_graph.java} | 30 +-
.../org/apache/jena/graph/TestCoreGraphUtil.java | 23 +-
.../java/org/apache/jena/graph/TestDateTime.java | 25 +-
.../java/org/apache/jena/graph/TestFactory.java | 12 +-
.../org/apache/jena/graph/TestFindLiterals.java | 39 +-
.../test/java/org/apache/jena/graph/TestGraph.java | 67 +--
.../apache/jena/graph/TestGraphBaseToString.java | 25 +-
.../org/apache/jena/graph/TestGraphEvents.java | 12 +-
.../org/apache/jena/graph/TestGraphListener.java | 30 +-
.../jena/graph/TestGraphMatchWithInference.java | 17 +-
.../java/org/apache/jena/graph/TestGraphPlain.java | 10 +-
.../apache/jena/graph/TestGraphPrefixMapping.java | 16 +-
.../java/org/apache/jena/graph/TestGraphUtil.java | 4 +-
.../jena/graph/TestLiteralLabelSameValueAs.java | 12 +-
.../org/apache/jena/graph/TestLiteralLabels.java | 26 +-
.../test/java/org/apache/jena/graph/TestNode.java | 189 +++++---
.../apache/jena/graph/TestNodeCreateStrings.java | 5 +-
.../org/apache/jena/graph/TestNodeEdgeCases.java | 4 +-
.../java/org/apache/jena/graph/TestNodeExtras.java | 20 +-
.../apache/jena/graph/TestRDFStringLiterals.java | 79 ++--
.../jena/graph/TestRegisterGraphListener.java | 16 +-
.../java/org/apache/jena/graph/TestReifier.java | 101 ++--
.../java/org/apache/jena/graph/TestTriple.java | 43 +-
.../org/apache/jena/graph/TestTripleField.java | 26 +-
.../org/apache/jena/graph/TestTypedLiterals.java | 364 ++++++++-------
.../graph/compose/AbstractTestPrefixMapping.java | 79 +++-
.../compose/AbstractTestPrefixMapping_JU6.java | 510 ---------------------
.../org/apache/jena/graph/compose/TestDelta.java | 4 +-
.../org/apache/jena/graph/compose/TestDyadic.java | 4 +-
.../apache/jena/graph/compose/TestMultiUnion.java | 4 +-
.../graph/compose/TestPolyadicPrefixMapping.java | 2 +-
.../apache/jena/memvalue/TestGraphMemModel.java | 2 +-
.../apache/jena/ontology/impl/TestOntGraph.java | 4 +-
.../test}/AbstractTestGraph.java | 18 +-
.../apache/jena/reasoner/test/TestInfGraph.java | 1 -
.../org/apache/jena/test/JenaCoreTestAll_JU4.java | 2 +-
.../org/apache/jena/test/JenaCoreTestAll_JU6.java | 3 +
40 files changed, 814 insertions(+), 1155 deletions(-)
diff --git a/jena-core/src/test/java/org/apache/jena/graph/BaseTestGraph_JU6.java b/jena-core/src/test/java/org/apache/jena/graph/BaseTestGraph.java
similarity index 99%
rename from jena-core/src/test/java/org/apache/jena/graph/BaseTestGraph_JU6.java
rename to jena-core/src/test/java/org/apache/jena/graph/BaseTestGraph.java
index a2a3682f33..910784b4c9 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/BaseTestGraph_JU6.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/BaseTestGraph.java
@@ -40,7 +40,7 @@ import org.apache.jena.util.CollectionFactory;
import org.apache.jena.util.iterator.ClosableIterator;
import org.apache.jena.util.iterator.ExtendedIterator;
-public abstract class BaseTestGraph_JU6 {
+public abstract class BaseTestGraph {
/**
* Returns a Graph to take part in the test. Must be overridden in a subclass.
@@ -881,7 +881,7 @@ public abstract class BaseTestGraph_JU6 {
private InputStream getInputStream(int n, int n2, String suffix) {
String urlStr = String.format("regression/testModelEquals/%s-%s.%s", n, n2, suffix);
- return BaseTestGraph_JU6.class.getClassLoader().getResourceAsStream(urlStr);
+ return BaseTestGraph.class.getClassLoader().getResourceAsStream(urlStr);
}
private void testIsomorphismFile(int n, String lang, String suffix, boolean result) {
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphCreators.java b/jena-core/src/test/java/org/apache/jena/graph/GraphCreators.java
new file mode 100644
index 0000000000..13d94bc098
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphCreators.java
@@ -0,0 +1,62 @@
+/*
+ * 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.graph;
+
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.Named;
+import org.junit.jupiter.params.provider.Arguments;
+
+import org.apache.jena.graph.impl.WrappedGraph;
+import org.apache.jena.mem.GraphMemFast;
+import org.apache.jena.mem.GraphMemLegacy;
+import org.apache.jena.mem.GraphMemRoaring;
+import org.apache.jena.memvalue.GraphMemValue;
+
+/**
+ * The graph implementations the general graph tests run against.
+ * <p>
+ * The JUnit 3 suite built one test case per test method per implementation, by
+ * reflection. A parameterized test class covers all five in one place.
+ */
+@SuppressWarnings("deprecation")
+public class GraphCreators {
+
+ private static Arguments named(String name, Supplier<Graph> maker) {
+ return Arguments.of(Named.of(name, maker));
+ }
+
+ /** The five implementations the general graph tests are run against. */
+ public static Stream<Arguments> graphs() {
+ return Stream.of(named("GraphMemValue", GraphMemValue::new),
+ named("WrappedGraphMem", ()->new WrappedGraph(GraphMemFactory.createDefaultGraph())),
+ named("GraphMemFast", GraphMemFast::new),
+ named("GraphMemLegacy", GraphMemLegacy::new),
+ named("GraphMemRoaring", GraphMemRoaring::new));
+ }
+
+ /** Just {@code GraphMemFast} - the implementation {@link TestGraphListener} uses for its copy. */
+ public static Stream<Arguments> graphMemFast() {
+ return Stream.of(named("GraphMemFast", GraphMemFast::new));
+ }
+}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/MetaTestGraph.java b/jena-core/src/test/java/org/apache/jena/graph/MetaTestGraph.java
index 67d537135d..007f9cd491 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/MetaTestGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/MetaTestGraph.java
@@ -21,76 +21,25 @@
package org.apache.jena.graph;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
+import java.util.function.Supplier;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.jena.shared.JenaException;
-import org.apache.jena.test.JenaTestLib;
+import org.junit.jupiter.params.Parameter;
+import org.junit.jupiter.params.ParameterizedClass;
+import org.junit.jupiter.params.provider.MethodSource;
/**
- * MetaTestGraph
+ * Runs the general graph contract ({@link BaseTestGraph}) against each of the graph
+ * implementations supplied by {@link GraphCreators#graphs}.
*/
-public class MetaTestGraph extends AbstractTestGraph {
- protected final Class<? extends Graph> graphClass;
+@ParameterizedClass(name = "{0}")
+@MethodSource("org.apache.jena.graph.GraphCreators#graphs")
+public class MetaTestGraph extends BaseTestGraph {
- public MetaTestGraph(Class<? extends Graph> graphClass, String name) {
- super(name);
- this.graphClass = graphClass;
- }
-
- public MetaTestGraph(String name) {
- super(name);
- graphClass = null;
- }
-
- /**
- * Construct a suite of tests from the test class <code>testClass</code> by
- * instantiating it three times, once each for the three reification styles, and
- * applying it to the graph <code>graphClass</code>.
- */
- public static TestSuite suite(Class<? extends Test> testClass, Class<? extends Graph> graphClass) {
- TestSuite result = new TestSuite();
- result.addTest(suiteX(testClass, graphClass));
- result.setName("Meta " + testClass.getName());
- return result;
- }
-
- public static TestSuite suiteX(Class<? extends Test> testClass, Class<? extends Graph> graphClass) {
- TestSuite result = new TestSuite();
- for ( Class<? > c = testClass ; Test.class.isAssignableFrom(c) ; c = c.getSuperclass() ) {
- Method[] methods = c.getDeclaredMethods();
- addTestMethods(result, testClass, methods, graphClass);
- }
- result.setName(testClass.getName());
- return result;
- }
-
- public static void addTestMethods(TestSuite result, Class<? extends Test> testClass, Method[] methods,
- Class<? extends Graph> graphClass) {
- for ( Method method : methods ) {
- if ( JenaTestLib.isPublicTestMethod(method) ) {
- result.addTest(makeTest(testClass, graphClass, method.getName()));
- }
- }
- }
-
- public static TestCase makeTest(Class<? extends Test> testClass, Class<? extends Graph> graphClass, String name) {
- Constructor<? > cons = JenaTestLib.getConstructor(testClass, new Class[]{Class.class, String.class});
- if ( cons == null )
- throw new JenaException("cannot find MetaTestGraph constructor");
- try {
- return (TestCase)cons.newInstance(new Object[]{graphClass, name});
- } catch (Exception e) {
- throw new JenaException(e);
- }
- }
+ @Parameter
+ protected Supplier<Graph> graphMaker;
@Override
public Graph getNewGraph() {
- return GraphTestLib.getGraph(this, graphClass);
+ return graphMaker.get();
}
-
}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TS3_graph.java b/jena-core/src/test/java/org/apache/jena/graph/TS6_graph.java
similarity index 75%
rename from jena-core/src/test/java/org/apache/jena/graph/TS3_graph.java
rename to jena-core/src/test/java/org/apache/jena/graph/TS6_graph.java
index cb5e571506..8b01f3f813 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TS3_graph.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TS6_graph.java
@@ -21,11 +21,19 @@
package org.apache.jena.graph;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
+import org.junit.platform.suite.api.BeforeSuite;
+import org.junit.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
+
+import org.apache.jena.test.JenaTestLib;
+
+@Suite
+@SelectClasses({
+ // Parameterized over GraphCreators.graphs().
+ MetaTestGraph.class,
+ TestReifier.class,
+ TestGraphListener.class,
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {
TestFindLiterals.class,
TestLiteralLabels.class,
TestLiteralLabelSameValueAs.class,
@@ -33,7 +41,6 @@ import org.junit.runners.Suite;
TestNodeCreateStrings.class,
TestTriple.class,
TestTripleField.class,
- TestReifier.class,
TestTypedLiterals.class,
TestDateTime.class,
TestFactory.class,
@@ -47,10 +54,13 @@ import org.junit.runners.Suite;
TestNodeExtras.class,
TestRDFStringLiterals.class,
TestNodeEdgeCases.class,
-
- // Has to be in a specific package.
- org.apache.jena.graph.TestGraphUtil.class
-
+ TestGraphUtil.class,
+ TestRegisterGraphListener.class
})
-public class TS3_graph { }
+public class TS6_graph {
+ @BeforeSuite
+ public static void beforeSuite() {
+ JenaTestLib.setup();
+ }
+}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestCoreGraphUtil.java b/jena-core/src/test/java/org/apache/jena/graph/TestCoreGraphUtil.java
index d31aed767f..954a4f3278 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestCoreGraphUtil.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestCoreGraphUtil.java
@@ -21,19 +21,15 @@
package org.apache.jena.graph;
-import junit.framework.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.graph.impl.*;
import org.apache.jena.util.iterator.*;
-public class TestCoreGraphUtil extends TestCase
+public class TestCoreGraphUtil
{
- public TestCoreGraphUtil(String name)
- { super(name); }
-
- public static TestSuite suite()
- {
- return new TestSuite(TestCoreGraphUtil.class);
- }
private static class Bool
{
@@ -41,6 +37,7 @@ public class TestCoreGraphUtil extends TestCase
Bool( boolean value ) { this.value = value; }
}
+ @Test
public void testFindAll()
{
final Bool foundAll = new Bool( false );
@@ -48,14 +45,14 @@ public class TestCoreGraphUtil extends TestCase
{
@Override public ExtendedIterator<Triple> graphBaseFind( Triple t )
{
- assertEquals( Node.ANY, t.getSubject() );
- assertEquals( Node.ANY, t.getPredicate() );
- assertEquals( Node.ANY, t.getObject() );
+ assertEquals(Node.ANY, t.getSubject() );
+ assertEquals(Node.ANY, t.getPredicate() );
+ assertEquals(Node.ANY, t.getObject() );
foundAll.value = true;
return null;
}
};
GraphUtil.findAll( mock );
- assertTrue( "find(ANY, ANY, ANY) called", foundAll.value );
+ assertTrue(foundAll.value, "find(ANY, ANY, ANY) called");
}
}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestDateTime.java b/jena-core/src/test/java/org/apache/jena/graph/TestDateTime.java
index 99dc2bf0a0..f695a5de1e 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestDateTime.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestDateTime.java
@@ -21,37 +21,32 @@
package org.apache.jena.graph;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import java.io.StringReader;
import java.io.StringWriter;
import java.util.Calendar;
import java.util.GregorianCalendar;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.jena.datatypes.xsd.AbstractDateTime;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.datatypes.xsd.XSDDateTime;
import org.apache.jena.rdf.model.*;
-import org.junit.Assert;
/**
* Tests behaviour of the AbstractDateTime support, specifically for comparison
* operations. This complements the main tests in TestTypedLiterals.
*/
-public class TestDateTime extends TestCase {
+public class TestDateTime {
/**
* Boilerplate for junit
*/
- public TestDateTime(String name) {
- super(name);
- }
/**
* This is its own test suite
*/
- public static TestSuite suite() {
- return new TestSuite(TestDateTime.class);
- }
static final XSDDateTime time0 = makeDateTime("2009-08-13T17:54:40.348Z");
static final XSDDateTime time1 = makeDateTime("2009-08-13T18:54:39Z");
@@ -70,6 +65,7 @@ public class TestDateTime extends TestCase {
return (XSDDateTime)XSDDatatype.XSDdateTime.parse(time);
}
+ @Test
public void testXSDOrder() {
assertEquals(time0.compare(time1), AbstractDateTime.LESS_THAN);
assertEquals(time1.compare(time2), AbstractDateTime.LESS_THAN);
@@ -87,6 +83,7 @@ public class TestDateTime extends TestCase {
assertEquals(time5.compare(time10), AbstractDateTime.EQUAL);
}
+ @Test
public void testJavaOrder() {
assertEquals(time0.compareTo(time1), AbstractDateTime.LESS_THAN);
assertEquals(time1.compareTo(time2), AbstractDateTime.LESS_THAN);
@@ -98,6 +95,7 @@ public class TestDateTime extends TestCase {
assertEquals(time7.compareTo(time8), AbstractDateTime.LESS_THAN);
}
+ @Test
public void testRoundTripping1() {
Model m = ModelFactory.createDefaultModel();
Property startTime = m.createProperty("http://jena.hpl.hp.com/test#startTime");
@@ -122,16 +120,19 @@ public class TestDateTime extends TestCase {
}
// Test that the string and calendar versions are the same.
+ @Test
public void testRoundTripping2() {
// String lex = "2013-04-16T15:40:07.3Z";
testCalendarRT(1366126807300L);
}
+ @Test
public void testRoundTripping3() {
// String lex = "2013-04-16T15:40:07.31Z";
testCalendarRT(1366126807310L);
}
+ @Test
public void testRoundTripping4() {
// String lex = "2013-04-16T15:40:07.301Z";
testCalendarRT(1366126807301L);
@@ -143,8 +144,8 @@ public class TestDateTime extends TestCase {
Literal lit1 = ResourceFactory.createTypedLiteral(cal);
Literal lit2 = ResourceFactory.createTypedLiteral(lit1.getLexicalForm(), lit1.getDatatype());
- Assert.assertEquals("equals: ", lit1, lit2);
- Assert.assertEquals("hash code: ", lit1.hashCode(), lit2.hashCode());
+ assertEquals(lit1, lit2, "equals: ");
+ assertEquals(lit1.hashCode(), lit2.hashCode(), "hash code: ");
}
}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestFactory.java b/jena-core/src/test/java/org/apache/jena/graph/TestFactory.java
index 077a99b904..35a0233a01 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestFactory.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestFactory.java
@@ -21,17 +21,11 @@
package org.apache.jena.graph;
-import junit.framework.*;
+import org.junit.jupiter.api.Test;
-public class TestFactory extends TestCase {
- public TestFactory(String name) {
- super(name);
- }
-
- public static TestSuite suite() {
- return new TestSuite(TestFactory.class);
- }
+public class TestFactory {
+ @Test
public void testFactory() {
GraphMemFactory.createDefaultGraph();
}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestFindLiterals.java b/jena-core/src/test/java/org/apache/jena/graph/TestFindLiterals.java
index 2d2b2001db..3bbf4a44a6 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestFindLiterals.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestFindLiterals.java
@@ -21,85 +21,95 @@
package org.apache.jena.graph;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import java.util.Set;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.jena.atlas.iterator.Iter;
import org.apache.jena.graph.impl.LiteralLabelFactory;
import org.apache.jena.junit.NodeCreateUtils;
-public class TestFindLiterals extends TestCase {
- public TestFindLiterals(String name) {
- super(name);
- }
+public class TestFindLiterals {
- public static junit.framework.Test suite() {
- return new TestSuite(TestFindLiterals.class);
- }
private void runTest(String graph, int size, String search, String results) {
Graph g = GraphTestLib.graphWith(graph);
Node literal = NodeCreateUtils.create(search);
- assertEquals("graph has wrong size", size, g.size());
+ assertEquals(size, g.size(), "graph has wrong size");
Set<Node> got = g.find(Node.ANY, Node.ANY, literal).mapWith(t -> t.getObject()).toSet();
assertEquals(GraphTestLib.nodeSet(results), got);
}
+ @Test
public void test01() {
runTest("a P 'simple'", 1, "'simple'", "'simple'");
}
+ @Test
public void test02() {
runTest("a P 'simple'xsd:string", 1, "'simple'", "'simple'xsd:string");
}
+ @Test
public void test03() {
runTest("a P 'simple'", 1, "'simple'xsd:string", "'simple'");
}
+ @Test
public void test04() {
runTest("a P 'simple'xsd:string", 1, "'simple'xsd:string", "'simple'xsd:string");
}
private final int expected = 1; // 2 for RDF 1.0
+ @Test
public void test05() {
runTest("a P 'simple'; a P 'simple'xsd:string", expected, "'simple'", "'simple' 'simple'xsd:string");
}
+ @Test
public void test06() {
runTest("a P 'simple'; a P 'simple'xsd:string", expected, "'simple'xsd:string", "'simple' 'simple'xsd:string");
}
+ @Test
public void test07() {
runTest("a P 1", 1, "1", "1");
}
+ @Test
public void test08() {
runTest("a P '1'xsd:float", 1, "'1'xsd:float", "'1'xsd:float");
}
+ @Test
public void test09() {
runTest("a P '1'xsd:double", 1, "'1'xsd:double", "'1'xsd:double");
}
+ @Test
public void test10() {
runTest("a P '1'xsd:float", 1, "'1'xsd:float", "'1'xsd:float");
}
+ @Test
public void test11() {
runTest("a P '1.1'xsd:float", 1, "'1'xsd:float", "");
}
+ @Test
public void test12() {
runTest("a P '1'xsd:double", 1, "'1'xsd:int", "");
}
+ @Test
public void test13() {
runTest("a P 'abc'rdf:XMLLiteral", 1, "'abc'", "");
}
+ @Test
public void test14() {
runTest("a P 'abc'", 1, "'abc'rdf:XMLLiteral", "");
}
@@ -107,34 +117,42 @@ public class TestFindLiterals extends TestCase {
//
// floats & doubles are not compatible
//
+ @Test
public void test15() {
runTest("a P '1'xsd:float", 1, "'1'xsd:double", "");
}
+ @Test
public void test16() {
runTest("a P '1'xsd:double", 1, "'1'xsd:float", "");
}
+ @Test
public void test17() {
runTest("a P 1", 1, "'1'", "");
}
+ @Test
public void test18() {
runTest("a P 1", 1, "'1'xsd:integer", "'1'xsd:integer");
}
+ @Test
public void test19() {
runTest("a P 1", 1, "'1'", "");
}
+ @Test
public void test20() {
runTest("a P '1'xsd:short", 1, "'1'xsd:integer", "'1'xsd:short");
}
+ @Test
public void test21() {
runTest("a P '1'xsd:int", 1, "'1'xsd:integer", "'1'xsd:int");
}
+ @Test
public void testFloatVsDouble() {
Node A = NodeCreateUtils.create("'1'xsd:float");
Node B = NodeCreateUtils.create("'1'xsd:double");
@@ -144,6 +162,7 @@ public class TestFindLiterals extends TestCase {
}
@SuppressWarnings("deprecation")
+ @Test
public void testProgrammaticValues() {
Node ab = NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral((byte)42));
Node as = NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral((short)42));
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestGraph.java b/jena-core/src/test/java/org/apache/jena/graph/TestGraph.java
index 16bbccdd27..40da57fd5c 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestGraph.java
@@ -21,61 +21,24 @@
package org.apache.jena.graph;
-/**
- Tests that check GraphMem and WrappedGraph for correctness against the Graph
- and reifier test suites.
-*/
+import org.junit.jupiter.api.Test;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.jena.graph.impl.WrappedGraph;
-import org.apache.jena.mem.GraphMemFast;
-import org.apache.jena.mem.GraphMemLegacy;
-import org.apache.jena.mem.GraphMemRoaring;
-import org.apache.jena.memvalue.GraphMemValue;
-
-@SuppressWarnings("deprecation")
-public class TestGraph extends TestCase {
- public TestGraph(String name) {
- super(name);
- }
-
- /**
- * Answer a test suite that runs the Graph tests on GraphMem and on
- * WrappedGraphMem, the latter standing in for testing WrappedGraph.
- */
- public static TestSuite suite() {
- TestSuite result = new TestSuite(TestGraph.class);
-
- result.addTest(suite(MetaTestGraph.class, GraphMemValue.class));
- result.addTest(suite(TestReifier.class, GraphMemValue.class));
-
- result.addTest(suite(MetaTestGraph.class, WrappedGraphMem.class));
- result.addTest(suite(TestReifier.class, WrappedGraphMem.class));
-
- result.addTest(suite(MetaTestGraph.class, GraphMemFast.class));
- result.addTest(suite(TestReifier.class, GraphMemFast.class));
-
- result.addTest(suite(MetaTestGraph.class, GraphMemLegacy.class));
- result.addTest(suite(TestReifier.class, GraphMemLegacy.class));
- result.addTest(suite(MetaTestGraph.class, GraphMemRoaring.class));
- result.addTest(suite(TestReifier.class, GraphMemRoaring.class));
-
- result.addTest(TestGraphListener.suite());
- result.addTestSuite(TestRegisterGraphListener.class);
- return result;
- }
-
- public static TestSuite suite(Class<? extends Test> classWithTests, Class<? extends Graph> graphClass) {
- return MetaTestGraph.suite(classWithTests, graphClass);
- }
+/**
+ * Tests that check GraphMem and WrappedGraph for correctness against the Graph
+ * and reifier test suites.
+ * <p>
+ * The suites themselves are {@link MetaTestGraph}, {@link TestReifier} and
+ * {@link TestGraphListener}, parameterized over {@link GraphCreators#graphs}.
+ */
+public class TestGraph {
/**
* Trivial [incomplete] test that a Wrapped graph pokes through to the underlying
* graph.
*/
+ @Test
public void testWrappedSame() {
Graph m = GraphMemFactory.createDefaultGraph();
Graph w = new WrappedGraph(m);
@@ -84,14 +47,4 @@ public class TestGraph extends TestCase {
GraphTestLib.graphAdd(w, "i write this; you read that");
GraphTestLib.assertIsomorphic(w, m);
}
-
- /**
- * Class to provide a constructor that produces a wrapper round a
- * default choice of in-memory graph.
- */
- public static class WrappedGraphMem extends WrappedGraph {
- public WrappedGraphMem() {
- super(GraphMemFactory.createDefaultGraph());
- }
- }
}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestGraphBaseToString.java b/jena-core/src/test/java/org/apache/jena/graph/TestGraphBaseToString.java
index dce640669e..eed9dd3871 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestGraphBaseToString.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestGraphBaseToString.java
@@ -21,12 +21,15 @@
package org.apache.jena.graph;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import static org.apache.jena.graph.impl.GraphBase.TOSTRING_TRIPLE_BASE;
import static org.apache.jena.graph.impl.GraphBase.TOSTRING_TRIPLE_LIMIT;
import java.util.*;
-import junit.framework.TestCase;
import org.apache.jena.graph.impl.GraphBase;
import org.apache.jena.junit.NodeCreateUtils;
import org.apache.jena.util.iterator.*;
@@ -35,7 +38,7 @@ import org.apache.jena.util.iterator.*;
* Tests for the revisions to GraphBase.toString() to see that it's compact, ie
* outputs no more than LIMIT triples.
*/
-public class TestGraphBaseToString extends TestCase {
+public class TestGraphBaseToString {
private static final class LittleGraphBase extends GraphBase {
Set<Triple> triples = new HashSet<>();
@@ -50,28 +53,28 @@ public class TestGraphBaseToString extends TestCase {
}
}
- public TestGraphBaseToString(String name) {
- super(name);
- }
-
+ @Test
public void testToStringBaseAndLimit() {
- assertTrue("triple base count must be greater than 0", 0 < GraphBase.TOSTRING_TRIPLE_BASE);
- assertTrue("triple base count must be less than limit", GraphBase.TOSTRING_TRIPLE_BASE < GraphBase.TOSTRING_TRIPLE_LIMIT);
- assertTrue("triple count limit must be less than 20", GraphBase.TOSTRING_TRIPLE_LIMIT < 20);
+ assertTrue(0 < GraphBase.TOSTRING_TRIPLE_BASE, "triple base count must be greater than 0");
+ assertTrue(GraphBase.TOSTRING_TRIPLE_BASE < GraphBase.TOSTRING_TRIPLE_LIMIT, "triple base count must be less than limit");
+ assertTrue(GraphBase.TOSTRING_TRIPLE_LIMIT < 20, "triple count limit must be less than 20");
}
+ @Test
public void testEllipsisAbsentForSmallModels() {
Graph g = new LittleGraphBase();
addTriples(g, 1, TOSTRING_TRIPLE_BASE);
- assertFalse("small model must not contain ellipsis cut-off", g.toString().contains("\\.\\.\\."));
+ assertFalse(g.toString().contains("\\.\\.\\."), "small model must not contain ellipsis cut-off");
}
+ @Test
public void testEllipsisPresentForLargeModels() {
Graph g = new LittleGraphBase();
addTriples(g, 1, TOSTRING_TRIPLE_LIMIT + 1);
- assertFalse("large model must contain ellipsis cut-off", g.toString().contains("\\.\\.\\."));
+ assertFalse(g.toString().contains("\\.\\.\\."), "large model must contain ellipsis cut-off");
}
+ @Test
public void testStringTripleCount() {
Graph g = new LittleGraphBase();
int baseCount = TOSTRING_TRIPLE_BASE;
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestGraphEvents.java b/jena-core/src/test/java/org/apache/jena/graph/TestGraphEvents.java
index fbdb1b3294..f916aea136 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestGraphEvents.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestGraphEvents.java
@@ -21,20 +21,22 @@
package org.apache.jena.graph;
-import junit.framework.TestCase;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.junit.NodeCreateUtils;
-public class TestGraphEvents extends TestCase {
- public TestGraphEvents(String name) {
- super(name);
- }
+public class TestGraphEvents {
+ @Test
public void testGraphEventContent() {
testGraphEventContents("testing", "an example");
testGraphEventContents("toasting", Boolean.TRUE);
testGraphEventContents("tasting", NodeCreateUtils.createTriple("we are here"));
}
+ @Test
public void testGraphEventsRemove() {
testGraphEventsRemove("s", "p", "o");
testGraphEventsRemove("s", "p", "17");
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 9db23d22eb..a8988195dc 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
@@ -25,25 +25,29 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import junit.framework.TestSuite;
-import org.apache.jena.mem.GraphMemFast;
+import java.util.function.Supplier;
+
+import org.junit.jupiter.params.Parameter;
+import org.junit.jupiter.params.ParameterizedClass;
+import org.junit.jupiter.params.provider.MethodSource;
/**
* Version of graph tests that set up a listener that copies all changes and verifies
* that after every notification modified graph and original are isomorphic.
*/
-public class TestGraphListener extends MetaTestGraph {
- public TestGraphListener(String name) {
- super(name);
- }
+@ParameterizedClass(name = "{0}")
+@MethodSource("org.apache.jena.graph.GraphCreators#graphMemFast")
+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
+ * every test once per implementation on top of these.
+ */
+ @Parameter
+ protected Supplier<Graph> graphMaker;
- public TestGraphListener(Class<? extends Graph> graphClass, String name) {
- super(graphClass, name);
- }
- public static TestSuite suite() {
- return MetaTestGraph.suite(TestGraphListener.class, GraphMemFast.class);
- }
/**
* A listener to check that a graph is being tracked correctly by its events.
*/
@@ -54,7 +58,7 @@ public class TestGraphListener extends MetaTestGraph {
public CheckChanges(String description, Graph g) {
original = g;
desc = description;
- copy = TestGraphListener.super.getNewGraph();
+ copy = graphMaker.get();
}
protected void verify() {
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestGraphMatchWithInference.java b/jena-core/src/test/java/org/apache/jena/graph/TestGraphMatchWithInference.java
index 891cca4c60..3f7007811a 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestGraphMatchWithInference.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestGraphMatchWithInference.java
@@ -21,23 +21,18 @@
package org.apache.jena.graph;
-import junit.framework.*;
-import org.apache.jena.rdf.model.*;
+import org.junit.jupiter.api.Test;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
/**
* Test that an inferred graph and an identical concrete graph compare as equal.
*/
-public class TestGraphMatchWithInference extends TestCase {
- public TestGraphMatchWithInference(String name) {
- super(name);
- }
-
- public static TestSuite suite() {
- TestSuite result = new TestSuite(TestGraphMatchWithInference.class);
- return result;
- }
+public class TestGraphMatchWithInference {
+ @Test
public void testBasic() {
Model mrdfs = ModelFactory.createRDFSModel(ModelFactory.createDefaultModel());
Model concrete = ModelFactory.createDefaultModel();
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestGraphPlain.java b/jena-core/src/test/java/org/apache/jena/graph/TestGraphPlain.java
index 66ed20452d..3e7cf5fe7c 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestGraphPlain.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestGraphPlain.java
@@ -21,23 +21,21 @@
package org.apache.jena.graph;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
import org.apache.jena.graph.impl.GraphPlain;
import org.apache.jena.util.iterator.ExtendedIterator;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("deprecation")
public class TestGraphPlain {
private static Graph graph;
- @BeforeClass
+ @BeforeAll
public static void setUp() {
// GraphMem is the old in-memory graph which has value-based indexing.
// It is not the default graph implementation.
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestGraphPrefixMapping.java b/jena-core/src/test/java/org/apache/jena/graph/TestGraphPrefixMapping.java
index 328f7ca854..d7efd278e7 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestGraphPrefixMapping.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestGraphPrefixMapping.java
@@ -21,20 +21,16 @@
package org.apache.jena.graph;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.graph.compose.AbstractTestPrefixMapping;
import org.apache.jena.shared.PrefixMapping;
-public class TestGraphPrefixMapping extends TestCase {
- public TestGraphPrefixMapping(String name) {
- super(name);
- }
-
- public static TestSuite suite() {
- return new TestSuite(TestGraphPrefixMapping.class);
- }
+public class TestGraphPrefixMapping {
+ @Test
public void testGraphPrefixMapping() {
Graph g = GraphMemFactory.createDefaultGraph();
AbstractTestPrefixMapping.testUseEasyPrefix("from Graph", g.getPrefixMapping());
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestGraphUtil.java b/jena-core/src/test/java/org/apache/jena/graph/TestGraphUtil.java
index 81e4328f3d..a42d373990 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestGraphUtil.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestGraphUtil.java
@@ -21,9 +21,9 @@
package org.apache.jena.graph;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
// Test for the compare by src.size and step dst case.
public class TestGraphUtil {
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestLiteralLabelSameValueAs.java b/jena-core/src/test/java/org/apache/jena/graph/TestLiteralLabelSameValueAs.java
index cf5a661f3c..19645a7024 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestLiteralLabelSameValueAs.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestLiteralLabelSameValueAs.java
@@ -21,13 +21,12 @@
package org.apache.jena.graph;
-import static org.junit.Assert.*;
-import junit.framework.JUnit4TestAdapter;
+import static org.junit.jupiter.api.Assertions.*;
import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.graph.impl.LiteralLabel;
import org.apache.jena.graph.impl.LiteralLabelFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
// See also TestTypedLiterals
/**
@@ -36,13 +35,10 @@ import org.junit.Test;
public class TestLiteralLabelSameValueAs {
public TestLiteralLabelSameValueAs() {}
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(TestLiteralLabelSameValueAs.class);
- }
private static void testSameValueAs(LiteralLabel lit1, LiteralLabel lit2, boolean sameValue) {
- assertEquals("lit1 sameValueAs lit2", sameValue, lit1.sameValueAs(lit2));
- assertEquals("lit2 sameValueAs lit1", sameValue, lit2.sameValueAs(lit1));
+ assertEquals(sameValue, lit1.sameValueAs(lit2), "lit1 sameValueAs lit2");
+ assertEquals(sameValue, lit2.sameValueAs(lit1), "lit2 sameValueAs lit1");
if ( !sameValue ) {
// ! SameValue => ! equals
assertFalse(lit1.equals(lit2));
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestLiteralLabels.java b/jena-core/src/test/java/org/apache/jena/graph/TestLiteralLabels.java
index 5e062e43a4..7f0d979d04 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestLiteralLabels.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestLiteralLabels.java
@@ -21,59 +21,61 @@
package org.apache.jena.graph;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.datatypes.BaseDatatype;
import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.graph.impl.LiteralLabel;
import org.apache.jena.graph.impl.LiteralLabelFactory;
// See also TestLiteralLabelSameValueAs, TestTypedLiterals
-public class TestLiteralLabels extends TestCase {
- public TestLiteralLabels(String name) {
- super(name);
- }
+public class TestLiteralLabels {
- public static Test suite() {
- return new TestSuite(TestLiteralLabels.class);
- }
+ @Test
public void testHashCode() {
LiteralLabel ll = LiteralLabelFactory.createByValue("test", null);
ll.hashCode();
}
+ @Test
public void testHashCode2() {
LiteralLabel ll1 = LiteralLabelFactory.createByValue("test", null);
LiteralLabel ll2 = LiteralLabelFactory.createByValue("test", null);
assertEquals(ll1.hashCode(), ll2.hashCode());
}
+ @Test
public void testHashCodesForBase64Binary_1() {
LiteralLabel A = GraphTestLib.node("'0123'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral();
LiteralLabel B = GraphTestLib.node("'0123'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral();
assertEquals(A.hashCode(), B.hashCode());
}
+ @Test
public void testHashCodesForBase64Binary_2() {
LiteralLabel A = GraphTestLib.node("'illgeal'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral();
LiteralLabel B = GraphTestLib.node("'illgeal'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral();
assertEquals(A.hashCode(), B.hashCode());
}
+ @Test
public void testHashCodesForHexBinary_1() {
LiteralLabel A = GraphTestLib.node("'0123'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral();
LiteralLabel B = GraphTestLib.node("'0123'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral();
assertEquals(A.hashCode(), B.hashCode());
}
+ @Test
public void testHashCodesForHexBinary_2() {
LiteralLabel A = GraphTestLib.node("'illegal'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral();
LiteralLabel B = GraphTestLib.node("'illegal'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral();
assertEquals(A.hashCode(), B.hashCode());
}
+ @Test
public void testDatatypeIsEqualsNotCalledIfSecondOperandIsNotTyped() {
RDFDatatype d = new BaseDatatype("eh:/FakeDataType") {
@Override
@@ -87,6 +89,7 @@ public class TestLiteralLabels extends TestCase {
assertFalse(A.sameValueAs(B));
}
+ @Test
public void testEquality1() {
LiteralLabel A = LiteralLabelFactory.createTypedLiteral("xyz");
LiteralLabel B = LiteralLabelFactory.createTypedLiteral("xyz");
@@ -95,6 +98,7 @@ public class TestLiteralLabels extends TestCase {
assertEquals(A.hashCode(), B.hashCode());
}
+ @Test
public void testEquality2() {
LiteralLabel A = LiteralLabelFactory.createTypedLiteral("xyz");
LiteralLabel B = LiteralLabelFactory.createTypedLiteral("XYZ");
@@ -102,6 +106,7 @@ public class TestLiteralLabels extends TestCase {
assertFalse(A.sameValueAs(B));
}
+ @Test
public void testEquality3() {
LiteralLabel A = LiteralLabelFactory.createLang("xyz", "en-us");
LiteralLabel B = LiteralLabelFactory.createLang("xyz", "en-uk");
@@ -109,6 +114,7 @@ public class TestLiteralLabels extends TestCase {
assertFalse(A.sameValueAs(B));
}
+ @Test
public void testEquality4() {
LiteralLabel A = LiteralLabelFactory.createLang("xyz", "en-UK");
LiteralLabel B = LiteralLabelFactory.createLang("xyz", "en-uk");
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestNode.java b/jena-core/src/test/java/org/apache/jena/graph/TestNode.java
index f7d6779f18..0a31ccc14e 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestNode.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestNode.java
@@ -21,8 +21,10 @@
package org.apache.jena.graph;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.atlas.lib.Creator;
import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.datatypes.TypeMapper;
@@ -44,63 +46,62 @@ import org.apache.jena.vocabulary.VCARD;
* Exercise nodes. Make sure that the different node types do not overlap and that
* the test predicates work properly on the different node kinds.
*/
-public class TestNode extends TestCase {
- public TestNode(String name) {
- super(name);
- }
-
- public static TestSuite suite() {
- return new TestSuite(TestNode.class);
- }
+public class TestNode {
private static final String U = "http://some.domain.name/magic/spells.incant";
private static final String N = "Alice";
private static final LiteralLabel L = LiteralLabelFactory.createLang("ashes are burning", "en");
private static final String A = BlankNodeId.createFreshId();
+ @Test
public void testBlanks() {
- assertTrue("anonymous nodes are blank", NodeFactory.createBlankNode().isBlank());
- assertFalse("anonymous nodes aren't literal", NodeFactory.createBlankNode().isLiteral());
- assertFalse("anonymous nodes aren't URIs", NodeFactory.createBlankNode().isURI());
- assertFalse("anonymous nodes aren't variables", NodeFactory.createBlankNode().isVariable());
- assertEquals("anonymous nodes have the right id", NodeFactory.createBlankNode(A).getBlankNodeLabel(), A);
+ assertTrue(NodeFactory.createBlankNode().isBlank(), "anonymous nodes are blank");
+ assertFalse(NodeFactory.createBlankNode().isLiteral(), "anonymous nodes aren't literal");
+ assertFalse(NodeFactory.createBlankNode().isURI(), "anonymous nodes aren't URIs");
+ assertFalse(NodeFactory.createBlankNode().isVariable(), "anonymous nodes aren't variables");
+ assertEquals(NodeFactory.createBlankNode(A).getBlankNodeLabel(), A, "anonymous nodes have the right id");
}
@SuppressWarnings("deprecation")
+ @Test
public void testLiterals() {
- assertFalse("literal nodes aren't blank", NodeFactory.createLiteral(L).isBlank());
- assertTrue("literal nodes are literal", NodeFactory.createLiteral(L).isLiteral());
- assertFalse("literal nodes aren't variables", NodeFactory.createLiteral(L).isVariable());
- assertFalse("literal nodes aren't URIs", NodeFactory.createLiteral(L).isURI());
- assertEquals("literal nodes preserve value", NodeFactory.createLiteral(L).getLiteral(), L);
+ assertFalse(NodeFactory.createLiteral(L).isBlank(), "literal nodes aren't blank");
+ assertTrue(NodeFactory.createLiteral(L).isLiteral(), "literal nodes are literal");
+ assertFalse(NodeFactory.createLiteral(L).isVariable(), "literal nodes aren't variables");
+ assertFalse(NodeFactory.createLiteral(L).isURI(), "literal nodes aren't URIs");
+ assertEquals(NodeFactory.createLiteral(L).getLiteral(), L, "literal nodes preserve value");
}
+ @Test
public void testURIs() {
- assertFalse("URI nodes aren't blank", NodeFactory.createURI(U).isBlank());
- assertFalse("URI nodes aren't literal", NodeFactory.createURI(U).isLiteral());
- assertFalse("URI nodes aren't variables", NodeFactory.createURI(U).isVariable());
- assertTrue("URI nodes are URIs", NodeFactory.createURI(U).isURI());
- assertEquals("URI nodes preserve URI", NodeFactory.createURI(U).getURI(), U);
+ assertFalse(NodeFactory.createURI(U).isBlank(), "URI nodes aren't blank");
+ assertFalse(NodeFactory.createURI(U).isLiteral(), "URI nodes aren't literal");
+ assertFalse(NodeFactory.createURI(U).isVariable(), "URI nodes aren't variables");
+ assertTrue(NodeFactory.createURI(U).isURI(), "URI nodes are URIs");
+ assertEquals(NodeFactory.createURI(U).getURI(), U, "URI nodes preserve URI");
}
+ @Test
public void testVariables() {
- assertFalse("variable nodes aren't blank", NodeFactory.createVariable(N).isBlank());
- assertFalse("variable nodes aren't literal", NodeFactory.createVariable(N).isLiteral());
- assertFalse("variable nodes aren't URIs", NodeFactory.createVariable(N).isURI());
- assertTrue("variable nodes are variable", NodeFactory.createVariable(N).isVariable());
- assertEquals("variable nodes keep their name", N, NodeFactory.createVariable(N).getName());
- assertEquals("variable nodes keep their name", N + "x", NodeFactory.createVariable(N + "x").getName());
+ assertFalse(NodeFactory.createVariable(N).isBlank(), "variable nodes aren't blank");
+ assertFalse(NodeFactory.createVariable(N).isLiteral(), "variable nodes aren't literal");
+ assertFalse(NodeFactory.createVariable(N).isURI(), "variable nodes aren't URIs");
+ assertTrue(NodeFactory.createVariable(N).isVariable(), "variable nodes are variable");
+ assertEquals(N, NodeFactory.createVariable(N).getName(), "variable nodes keep their name");
+ assertEquals(N + "x", NodeFactory.createVariable(N + "x").getName(), "variable nodes keep their name");
}
+ @Test
public void testANY() {
- assertFalse("ANY nodes aren't blank", Node.ANY.isBlank());
- assertFalse("ANY nodes aren't literals", Node.ANY.isLiteral());
- assertFalse("ANY nodes aren't URIs", Node.ANY.isURI());
- assertFalse("ANY nodes aren't variables", Node.ANY.isVariable());
- assertFalse("ANY nodes aren't blank", Node.ANY.isBlank());
- assertFalse("ANY nodes aren't blank", Node.ANY.isBlank());
+ assertFalse(Node.ANY.isBlank(), "ANY nodes aren't blank");
+ assertFalse(Node.ANY.isLiteral(), "ANY nodes aren't literals");
+ assertFalse(Node.ANY.isURI(), "ANY nodes aren't URIs");
+ assertFalse(Node.ANY.isVariable(), "ANY nodes aren't variables");
+ assertFalse(Node.ANY.isBlank(), "ANY nodes aren't blank");
+ assertFalse(Node.ANY.isBlank(), "ANY nodes aren't blank");
}
+ @Test
public void testNodeVariableConstructor() {
assertEquals(NodeFactory.createVariable("hello"), new Node_Variable("hello"));
assertEquals(NodeFactory.createVariable("world"), new Node_Variable("world"));
@@ -135,11 +136,12 @@ public class TestNode extends TestCase {
{NodeFactory.createLiteral(LLang1), "9"}, {NodeFactory.createLiteral(LLang2), "10"},};
}
+ @Test
public void testNodeEquals() {
Object[][] tests = eqTestCases();
for ( Object[] I : tests ) {
- assertFalse(I[0] + " should not equal null", I[0].equals(null));
- assertFalse(I[0] + "should not equal 'String'", I[0].equals("String"));
+ assertFalse(I[0].equals(null), I[0] + " should not equal null");
+ assertFalse(I[0].equals("String"), I[0] + "should not equal 'String'");
for ( Object[] J : tests ) {
testEquality(I[1].equals(J[1]), I[0], J[0]);
}
@@ -149,7 +151,7 @@ public class TestNode extends TestCase {
private void testEquality(boolean testEq, Object x, Object y) {
String testName = getType(x) + " " + x + " and " + getType(y) + " " + y;
if ( testEq )
- assertEquals(testName + "should be equal", x, y);
+ assertEquals(x, y, testName + "should be equal");
else
JenaTestLib.assertDiffer(testName + " should differ", x, y);
}
@@ -160,16 +162,17 @@ public class TestNode extends TestCase {
}
@SuppressWarnings("deprecation")
+ @Test
public void testEquals() {
JenaTestLib.assertDiffer("different variables", NodeFactory.createVariable("xx"), NodeFactory.createVariable("yy"));
- assertEquals("same vars", NodeFactory.createVariable("aa"), NodeFactory.createVariable("aa"));
- assertEquals("same URI", NodeFactory.createURI(U), NodeFactory.createURI(U));
- assertEquals("same anon", NodeFactory.createBlankNode(A), NodeFactory.createBlankNode(A));
- assertEquals("same literal", NodeFactory.createLiteral(L), NodeFactory.createLiteral(L));
- assertFalse("distinct URIs", NodeFactory.createURI(U) == NodeFactory.createURI(U));
- assertFalse("distinct hyphens", NodeFactory.createBlankNode(A) == NodeFactory.createBlankNode(A));
- assertFalse("distinct literals", NodeFactory.createLiteral(L) == NodeFactory.createLiteral(L));
- assertFalse("distinct vars", NodeFactory.createVariable("aa") == NodeFactory.createVariable("aa"));
+ assertEquals(NodeFactory.createVariable("aa"), NodeFactory.createVariable("aa"), "same vars");
+ assertEquals(NodeFactory.createURI(U), NodeFactory.createURI(U), "same URI");
+ assertEquals(NodeFactory.createBlankNode(A), NodeFactory.createBlankNode(A), "same anon");
+ assertEquals(NodeFactory.createLiteral(L), NodeFactory.createLiteral(L), "same literal");
+ assertFalse(NodeFactory.createURI(U) == NodeFactory.createURI(U), "distinct URIs");
+ assertFalse(NodeFactory.createBlankNode(A) == NodeFactory.createBlankNode(A), "distinct hyphens");
+ assertFalse(NodeFactory.createLiteral(L) == NodeFactory.createLiteral(L), "distinct literals");
+ assertFalse(NodeFactory.createVariable("aa") == NodeFactory.createVariable("aa"), "distinct vars");
}
/**
@@ -177,12 +180,13 @@ public class TestNode extends TestCase {
* appropriate to that Node.
*/
@SuppressWarnings("deprecation")
+ @Test
public void testLabels() {
String id = BlankNodeId.createFreshId();
- assertEquals("get URI value", U, NodeFactory.createURI(U).getURI());
- assertEquals("get blank value", id, NodeFactory.createBlankNode(id).getBlankNodeLabel());
- assertEquals("get literal value", L, NodeFactory.createLiteral(L).getLiteral());
- assertEquals("get variable name", N, NodeFactory.createVariable(N).getName());
+ assertEquals(U, NodeFactory.createURI(U).getURI(), "get URI value");
+ assertEquals(id, NodeFactory.createBlankNode(id).getBlankNodeLabel(), "get blank value");
+ assertEquals(L, NodeFactory.createLiteral(L).getLiteral(), "get literal value");
+ assertEquals(N, NodeFactory.createVariable(N).getName(), "get variable name");
}
/**
@@ -190,6 +194,7 @@ public class TestNode extends TestCase {
* exception.
*/
@SuppressWarnings("deprecation")
+ @Test
public void testFailingLabels() {
Node u = NodeFactory.createURI(U), b = NodeFactory.createBlankNode();
Node l = NodeFactory.createLiteral(L), v = NodeFactory.createVariable(N);
@@ -244,11 +249,13 @@ public class TestNode extends TestCase {
} catch (UnsupportedOperationException e) {}
}
+ @Test
public void testGetBlankNodeLabelString() {
Node n = NodeFactory.createBlankNode();
assertNotNull(n.getBlankNodeLabel());
}
+ @Test
public void testVariableSupport() {
assertEquals(new Node_Variable("xxx"), new Node_Variable("xxx"));
JenaTestLib.assertDiffer(new Node_Variable("xxx"), new Node_Variable("yyy"));
@@ -257,6 +264,7 @@ public class TestNode extends TestCase {
/**
* Test that the create method does sensible things on null and ""
*/
+ @Test
public void testCreateBadString() {
try {
NodeCreateUtils.create(null);
@@ -271,51 +279,59 @@ public class TestNode extends TestCase {
/**
* Test that anonymous nodes are created with the correct labels
*/
+ @Test
public void testCreateBlankNode() {
String idA = "_xxx";
String idB = "_yyy";
Node a = NodeCreateUtils.create(idA);
Node b = NodeCreateUtils.create(idB);
- assertTrue("both must be bnodes", a.isBlank() && b.isBlank());
+ assertTrue(a.isBlank() && b.isBlank(), "both must be bnodes");
assertEquals(NodeFactory.createBlankNode(idA).getBlankNodeLabel(), a.getBlankNodeLabel());
assertEquals(NodeFactory.createBlankNode(idB).getBlankNodeLabel(), b.getBlankNodeLabel());
}
+ @Test
public void testCreateVariable() {
String V = "wobbly";
Node v = NodeCreateUtils.create("?" + V);
- assertTrue("must be a variable", v.isVariable());
- assertEquals("name must be correct", V, v.getName());
+ assertTrue(v.isVariable(), "must be a variable");
+ assertEquals(V, v.getName(), "name must be correct");
}
+ @Test
public void testCreateANY() {
- assertEquals("?? must denote ANY", Node.ANY, NodeCreateUtils.create("??"));
+ assertEquals(Node.ANY, NodeCreateUtils.create("??"), "?? must denote ANY");
}
+ @Test
public void testCreatePlainLiteralSingleQuotes() {
Node n = NodeCreateUtils.create("'xxx'");
assertEquals("xxx", n.getLiteralLexicalForm());
assertString(n);
}
+ @Test
public void testCreatePlainLiteralDoubleQuotes() {
Node n = NodeCreateUtils.create("\"xxx\"");
assertEquals("xxx", n.getLiteralLexicalForm());
assertString(n);
}
+ @Test
public void testCreateLiteralBackslashEscape() {
testStringConversion("xx\\x", "'xx\\\\x'");
testStringConversion("xx\\x\\y", "'xx\\\\x\\\\y'");
testStringConversion("\\xyz\\", "'\\\\xyz\\\\'");
}
+ @Test
public void testCreateLiteralQuoteEscapes() {
testStringConversion("x\'y", "'x\\'y'");
testStringConversion("x\"y", "'x\\\"y'");
testStringConversion("x\'y\"z", "'x\\\'y\\\"z'");
}
+ @Test
public void testCreateLiteralOtherEscapes() {
testStringConversion(" ", "'\\s'");
testStringConversion("\t", "'\\t'");
@@ -329,6 +345,7 @@ public class TestNode extends TestCase {
assertString(n);
}
+ @Test
public void testCreateLanguagedLiteralEN1() {
Node n = NodeCreateUtils.create("'chat'en-UK");
assertEquals("chat", n.getLiteralLexicalForm());
@@ -336,6 +353,7 @@ public class TestNode extends TestCase {
assertEquals("en-UK", n.getLiteralLanguage());
}
+ @Test
public void testCreateLanguagedLiteralEN2() {
Node n1 = NodeCreateUtils.create("'chat'en-UK");
Node n2 = NodeCreateUtils.create("'chat'EN-UK");
@@ -344,6 +362,7 @@ public class TestNode extends TestCase {
assertTrue(n1.equals(n2));
}
+ @Test
public void testCreateLanguagedLiteralXY() {
Node n = NodeCreateUtils.create("\"chat\"xy-AB");
assertEquals("chat", n.getLiteralLexicalForm());
@@ -351,6 +370,7 @@ public class TestNode extends TestCase {
assertLangString(n);
}
+ @Test
public void testCreateTypedLiteralInteger() {
Node n = NodeCreateUtils.create("'42'xsd:integer");
assertEquals("42", n.getLiteralLexicalForm());
@@ -358,6 +378,7 @@ public class TestNode extends TestCase {
assertEquals(expand("xsd:integer"), n.getLiteralDatatypeURI());
}
+ @Test
public void testCreateTypedLiteralBoolean() {
Node n = NodeCreateUtils.create("\"true\"xsd:boolean");
assertEquals("true", n.getLiteralLexicalForm());
@@ -365,16 +386,19 @@ public class TestNode extends TestCase {
assertEquals(expand("xsd:boolean"), n.getLiteralDatatypeURI());
}
+ @Test
public void testGetPlainLiteralLexicalForm() {
Node n = NodeCreateUtils.create("'stuff'");
assertEquals("stuff", n.getLiteralLexicalForm());
}
+ @Test
public void testGetNumericLiteralLexicalForm() {
Node n = NodeCreateUtils.create("17");
assertEquals("17", n.getLiteralLexicalForm());
}
+ @Test
public void testTypesExpandPrefix() {
testTypeExpandsPrefix("rdf:spoo");
testTypeExpandsPrefix("rdfs:bar");
@@ -389,6 +413,7 @@ public class TestNode extends TestCase {
assertEquals(wanted, n.getLiteralDatatypeURI());
}
+ @Test
public void testCreateURI() {
String uri = "http://www.electric-hedgehog.net/";
testCreateURI(uri);
@@ -400,6 +425,7 @@ public class TestNode extends TestCase {
testCreateURI("owl:wol", OWL.getURI() + "wol");
}
+ @Test
public void testCreateURIOtherMap() {
String myNS = "eh:foo/bar#", suffix = "something";
PrefixMapping mine = PrefixMapping.Factory.create().setNsPrefix("mine", myNS);
@@ -421,11 +447,13 @@ public class TestNode extends TestCase {
}
}
+ @Test
public void testCreatePrefixed() {
PrefixMapping pm = PrefixMapping.Factory.create();
NodeCreateUtils.create(pm, "xyz");
}
+ @Test
public void testToStringWithPrefixMapping() {
PrefixMapping pm = PrefixMapping.Factory.create();
String prefix = "spoo", ns = "abc:def/ghi#";
@@ -434,14 +462,16 @@ public class TestNode extends TestCase {
assertEquals(prefix + ":" + suffix, NodeCreateUtils.create(ns + suffix).toString(pm));
}
+ @Test
public void testNodeHelp() {
- assertTrue("node() making URIs", GraphTestLib.node("hello").isURI());
- assertTrue("node() making literals", GraphTestLib.node("123").isLiteral());
- assertTrue("node() making literals", GraphTestLib.node("'hello'").isLiteral());
- assertTrue("node() making hyphens", GraphTestLib.node("_x").isBlank());
- assertTrue("node() making variables", GraphTestLib.node("?x").isVariable());
+ assertTrue(GraphTestLib.node("hello").isURI(), "node() making URIs");
+ assertTrue(GraphTestLib.node("123").isLiteral(), "node() making literals");
+ assertTrue(GraphTestLib.node("'hello'").isLiteral(), "node() making literals");
+ assertTrue(GraphTestLib.node("_x").isBlank(), "node() making hyphens");
+ assertTrue(GraphTestLib.node("?x").isVariable(), "node() making variables");
}
+ @Test
public void testVisitorPatternNode() {
NodeVisitor returnNode = new NodeVisitor() {
@Override
@@ -509,6 +539,7 @@ public class TestNode extends TestCase {
ng.visitWith(nv);
}
+ @Test
public void testVisitorPatternValue() {
NodeVisitor checkValue = new NodeVisitor() {
@Override
@@ -561,6 +592,7 @@ public class TestNode extends TestCase {
* Test that the appropriate elements of the visitor are called exactly once;
* this relies on the order of the visits in visitExamples.
*/
+ @Test
public void testVisitorPatternCalled() {
final String[] strings = new String[]{""};
NodeVisitor checkCalled = new NodeVisitor() {
@@ -609,17 +641,18 @@ public class TestNode extends TestCase {
};
String desired = " uri variable blank literal any termTriple termGraph";
visitExamples(checkCalled);
- assertEquals("all visits must have been made", desired, strings[0]);
+ assertEquals(desired, strings[0], "all visits must have been made");
}
+ @Test
public void testSimpleMatches() {
assertTrue(NodeCreateUtils.create("S").sameTermAs(NodeCreateUtils.create("S")));
- assertFalse("", NodeCreateUtils.create("S").sameTermAs(NodeCreateUtils.create("T")));
+ assertFalse(NodeCreateUtils.create("S").sameTermAs(NodeCreateUtils.create("T")), "");
assertTrue(NodeCreateUtils.create("_X").sameTermAs(NodeCreateUtils.create("_X")));
- assertFalse("", NodeCreateUtils.create("_X").sameTermAs(NodeCreateUtils.create("_Y")));
+ assertFalse(NodeCreateUtils.create("_X").sameTermAs(NodeCreateUtils.create("_Y")), "");
assertTrue(NodeCreateUtils.create("10").sameTermAs(NodeCreateUtils.create("10")));
- assertFalse("", NodeCreateUtils.create("10").sameTermAs(NodeCreateUtils.create("11")));
+ assertFalse(NodeCreateUtils.create("10").sameTermAs(NodeCreateUtils.create("11")), "");
// Jena6. nulls no longer allowed.
try {
@@ -633,6 +666,7 @@ public class TestNode extends TestCase {
// assertFalse("", Node.ANY.sameTermAs(null));
}
+ @Test
public void testDataSameValue() {
TypeMapper tm = TypeMapper.getInstance();
RDFDatatype dt1 = tm.getTypeByValue(Integer.valueOf(10));
@@ -640,9 +674,10 @@ public class TestNode extends TestCase {
Node a = NodeFactory.createLiteralDT("10", dt1);
Node b = NodeFactory.createLiteralDT("10", dt2);
JenaTestLib.assertDiffer("types must make a difference", a, b);
- assertTrue("A and B must express the same value", a.sameValueAs(b));
+ assertTrue(a.sameValueAs(b), "A and B must express the same value");
}
+ @Test
public void testLiteralToString() {
TypeMapper tm = TypeMapper.getInstance();
RDFDatatype dtInt = tm.getTypeByValue(Integer.valueOf(10));
@@ -654,42 +689,51 @@ public class TestNode extends TestCase {
assertEquals("\"10\"^^xsd:int", typed.toString());
}
+ @Test
public void testGetIndexingValueURI() {
Node u = NodeCreateUtils.create("eh:/telephone");
assertSame(u, u.getIndexingValue());
}
+ @Test
public void testGetIndexingValueBlank() {
Node b = NodeCreateUtils.create("_television");
assertSame(b, b.getIndexingValue());
}
+ @Test
public void testGetIndexingValuePlainString() {
testIndexingValueLiteral(() -> NodeCreateUtils.create("'literally'"));
}
+ @Test
public void testGetIndexingValueLanguagedString() {
testIndexingValueLiteral(() -> NodeCreateUtils.create("'chat'fr"));
}
+ @Test
public void testGetIndexingValueXSDString() {
testIndexingValueLiteral(() -> NodeCreateUtils.create("'string'xsd:string"));
}
// JENA-1936
+ @Test
public void testGetIndexingValueHexBinary1() {
testIndexingValueLiteral(() -> NodeCreateUtils.create("''xsd:hexBinary"));
}
+ @Test
public void testGetIndexingValueHexBinary2() {
testIndexingValueLiteral(() -> NodeCreateUtils.create("'ABCD'xsd:hexBinary"));
}
+ @Test
public void testGetIndexingValueBase64Binary1() {
testIndexingValueLiteral(() -> NodeCreateUtils.create("''xsd:base64Binary"));
}
// "sure." encodes to "c3VyZS4="
+ @Test
public void testGetIndexingValueBase64Binary2() {
testIndexingValueLiteral(() -> NodeCreateUtils.create("'c3VyZS4='xsd:base64Binary"));
}
@@ -706,15 +750,18 @@ public class TestNode extends TestCase {
assertEquals(n1.getLiteral().getIndexingValue().hashCode(), n2.getIndexingValue().hashCode());
}
+ @Test
public void testGetLiteralValuePlainString() {
Node s = NodeCreateUtils.create("'aString'");
assertSame(s.getLiteral().getValue(), s.getLiteralValue());
}
+ @Test
public void testGetLiteralDatatypePlainString() {
assertString(NodeCreateUtils.create("'plain'"));
}
+ @Test
public void testConcrete() {
assertTrue(NodeCreateUtils.create("S").isConcrete());
assertTrue(NodeCreateUtils.create("_P").isConcrete());
@@ -731,17 +778,19 @@ public class TestNode extends TestCase {
* test that URI nodes have namespace/localname splits which are consistent with
* Util.splitNamepace.
*/
+ @Test
public void testNamespace() {
for ( String uri : someURIs ) {
int split = SplitIRI.splitXML(uri);
Node n = NodeCreateUtils.create(uri);
- assertEquals("check namespace", uri.substring(0, split), n.getNameSpace());
- assertEquals("check localname", uri.substring(split), n.getLocalName());
+ assertEquals(uri.substring(0, split), n.getNameSpace(), "check namespace");
+ assertEquals(uri.substring(split), n.getLocalName(), "check localname");
}
}
protected static String[] someNodes = {"42", "'hello'", "_anon", "'robotic'tick", "'teriffic'abc:def"};
+ @Test
public void testHasURI() {
for ( String someURI : someURIs ) {
testHasURI(someURI);
@@ -753,8 +802,8 @@ public class TestNode extends TestCase {
protected void testHasURI(String uri) {
Node n = NodeCreateUtils.create(uri);
- assertTrue(uri, !n.isURI() || n.hasURI(uri));
- assertFalse(uri, n.hasURI(uri + "x"));
+ assertTrue(!n.isURI() || n.hasURI(uri), uri);
+ assertFalse(n.hasURI(uri + "x"), uri);
}
private static void assertString(Node n) {
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestNodeCreateStrings.java b/jena-core/src/test/java/org/apache/jena/graph/TestNodeCreateStrings.java
index efabd02f75..19d59c7b6f 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestNodeCreateStrings.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestNodeCreateStrings.java
@@ -21,11 +21,10 @@
package org.apache.jena.graph;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import org.apache.jena.rdf.model.impl.Util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Testing making string-like RDF terms */
public class TestNodeCreateStrings {
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestNodeEdgeCases.java b/jena-core/src/test/java/org/apache/jena/graph/TestNodeEdgeCases.java
index 4812831bae..15625d0b00 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestNodeEdgeCases.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestNodeEdgeCases.java
@@ -21,11 +21,11 @@
package org.apache.jena.graph;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
import org.apache.jena.datatypes.xsd.impl.RDFDirLangString;
import org.apache.jena.datatypes.xsd.impl.RDFLangString;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestNodeEdgeCases {
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestNodeExtras.java b/jena-core/src/test/java/org/apache/jena/graph/TestNodeExtras.java
index 95ad98c839..284ae94957 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestNodeExtras.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestNodeExtras.java
@@ -21,13 +21,13 @@
package org.apache.jena.graph;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import org.apache.jena.junit.NodeCreateUtils;
import org.apache.jena.rdf.model.impl.Util;
import org.apache.jena.vocabulary.RDF;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** More tests for {@link Node Nodes}. */
public class TestNodeExtras {
@@ -102,16 +102,20 @@ public class TestNodeExtras {
assertFalse(nt1.sameValueAs(nt9));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void term_triple_bad_1() {
- Node n = NodeFactory.createLiteralString("abc");
- n.getTriple();
+ assertThrows(UnsupportedOperationException.class, ()->{
+ Node n = NodeFactory.createLiteralString("abc");
+ n.getTriple();
+ });
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void term_triple_bad_2() {
- Node n = NodeFactory.createURI("http://example/abc");
- n.getTriple();
+ assertThrows(UnsupportedOperationException.class, ()->{
+ Node n = NodeFactory.createURI("http://example/abc");
+ n.getTriple();
+ });
}
@Test
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestRDFStringLiterals.java b/jena-core/src/test/java/org/apache/jena/graph/TestRDFStringLiterals.java
index 346b7f14bf..f7a0e02359 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestRDFStringLiterals.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestRDFStringLiterals.java
@@ -22,10 +22,9 @@
package org.apache.jena.graph;
import static org.apache.jena.graph.TextDirection.RTL;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.datatypes.xsd.XSDDatatype;
@@ -130,14 +129,18 @@ public class TestRDFStringLiterals {
test(n, "abc", "en", RTL, RDF.dtDirLangString, "abc@en");
}
- @Test(expected = JenaException.class)
+ @Test
public void dirLangString02() {
- Node n = NodeFactory.createLiteralDirLang("abc", "en", "LTR");
+ assertThrows(JenaException.class, ()->{
+ Node n = NodeFactory.createLiteralDirLang("abc", "en", "LTR");
+ });
}
- @Test(expected = JenaException.class)
+ @Test
public void dirLangString03() {
- Node n = NodeFactory.createLiteralDirLang("abc", "en", "unk");
+ assertThrows(JenaException.class, ()->{
+ Node n = NodeFactory.createLiteralDirLang("abc", "en", "unk");
+ });
}
@Test
@@ -146,9 +149,11 @@ public class TestRDFStringLiterals {
test(n, "abc", "en", null, RDF.dtLangString, "abc@en");
}
- @Test(expected = JenaException.class)
+ @Test
public void dirLangString05() {
- Node n = NodeFactory.createLiteralDirLang("abc", "en", "x");
+ assertThrows(JenaException.class, ()->{
+ Node n = NodeFactory.createLiteralDirLang("abc", "en", "x");
+ });
}
// -- Via createLiteralLang splitting lang tags on "--"
@@ -172,53 +177,67 @@ public class TestRDFStringLiterals {
assertNotEquals(nDirLangString1, nDirLangString4);
}
- @Test(expected = JenaException.class)
+ @Test
public void dirLangString11() {
- Node n = NodeFactory.createLiteralLang("abc", "en--LTR");
+ assertThrows(JenaException.class, ()->{
+ Node n = NodeFactory.createLiteralLang("abc", "en--LTR");
+ });
}
- @Test(expected = JenaException.class)
+ @Test
public void dirLangString12() {
- Node n = NodeFactory.createLiteralLang("abc", "en--");
+ assertThrows(JenaException.class, ()->{
+ Node n = NodeFactory.createLiteralLang("abc", "en--");
+ });
}
// Errors
- @Test(expected = JenaException.class)
+ @Test
public void rdfStringBad01() {
- // No lang but with a direction
- Node n = NodeFactory.createLiteralDirLang("abc", null, TextDirection.LTR);
+ assertThrows(JenaException.class, ()->{
+ // No lang but with a direction
+ Node n = NodeFactory.createLiteralDirLang("abc", null, TextDirection.LTR);
+ });
}
- @Test(expected = JenaException.class)
+ @Test
public void rdfStringBad02() {
- // No lang but with a direction
- Node n = NodeFactory.createLiteralDirLang("abc", "", TextDirection.LTR);
+ assertThrows(JenaException.class, ()->{
+ // No lang but with a direction
+ Node n = NodeFactory.createLiteralDirLang("abc", "", TextDirection.LTR);
+ });
}
- @Test(expected = NullPointerException.class)
+ @Test
public void rdfStringBad03() {
- Node n = NodeFactory.createLiteralString((String)null);
+ assertThrows(NullPointerException.class, ()->{
+ Node n = NodeFactory.createLiteralString((String)null);
+ });
}
- @Test(expected = NullPointerException.class)
+ @Test
public void rdfStringBad04() {
- Node n = NodeFactory.createLiteralLang((String)null, "en");
+ assertThrows(NullPointerException.class, ()->{
+ Node n = NodeFactory.createLiteralLang((String)null, "en");
+ });
}
- @Test(expected = NullPointerException.class)
+ @Test
public void rdfStringBad05() {
- Node n = NodeFactory.createLiteralDirLang((String)null, "en", TextDirection.LTR);
+ assertThrows(NullPointerException.class, ()->{
+ Node n = NodeFactory.createLiteralDirLang((String)null, "en", TextDirection.LTR);
+ });
}
// ----
private static void test(Node node, String lexicalForm, String lang, TextDirection textDir, RDFDatatype datatype,
String indexingValue) {
- assertEquals("Lexical form:", lexicalForm, node.getLiteralLexicalForm());
- assertEquals("Language:", lang, node.getLiteralLanguage());
- assertEquals("Text Direction:", textDir, node.getLiteralBaseDirection());
- assertEquals("Datatype:", datatype, node.getLiteralDatatype());
- assertEquals("Indexing:", indexingValue, node.getIndexingValue());
+ assertEquals(lexicalForm, node.getLiteralLexicalForm(), "Lexical form:");
+ assertEquals(lang, node.getLiteralLanguage(), "Language:");
+ assertEquals(textDir, node.getLiteralBaseDirection(), "Text Direction:");
+ assertEquals(datatype, node.getLiteralDatatype(), "Datatype:");
+ assertEquals(indexingValue, node.getIndexingValue(), "Indexing:");
}
}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestRegisterGraphListener.java b/jena-core/src/test/java/org/apache/jena/graph/TestRegisterGraphListener.java
index aa60a6304f..a455e7839a 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestRegisterGraphListener.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestRegisterGraphListener.java
@@ -21,16 +21,18 @@
package org.apache.jena.graph;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import java.util.Iterator;
import java.util.List;
-import junit.framework.TestCase;
-
/**
* These tests are for listeners that add or delete other listeners. It motivates the
* use of, e.g. CopyOnWriteArrayList for storing listeners.
*/
-public class TestRegisterGraphListener extends TestCase {
+public class TestRegisterGraphListener {
private ComeAndGoListener all[];
private Graph graph;
@@ -107,9 +109,6 @@ public class TestRegisterGraphListener extends TestCase {
public void notifyEvent(Graph source, Object value) {}
}
- public TestRegisterGraphListener(String name) {
- super(name);
- }
private void testAddingTriple(int addMe, ComeAndGoListener...allx) {
graph = GraphTestLib.newGraph();
@@ -126,6 +125,7 @@ public class TestRegisterGraphListener extends TestCase {
}
}
+ @Test
public void testAddOne() {
testAddingTriple(2, new ComeAndGoListener() {
@Override
@@ -135,6 +135,7 @@ public class TestRegisterGraphListener extends TestCase {
}, new SimpleListener(), new SimpleListener());
}
+ @Test
public void testDelete2nd() {
testAddingTriple(3, new ComeAndGoListener() {
@Override
@@ -144,6 +145,7 @@ public class TestRegisterGraphListener extends TestCase {
}, new SimpleListener(), new SimpleListener());
}
+ @Test
public void testDelete1st() {
testAddingTriple(3, new SimpleListener(), new ComeAndGoListener() {
@Override
@@ -153,6 +155,7 @@ public class TestRegisterGraphListener extends TestCase {
}, new SimpleListener());
}
+ @Test
public void testDeleteSelf() {
testAddingTriple(3, new ComeAndGoListener() {
@Override
@@ -162,6 +165,7 @@ public class TestRegisterGraphListener extends TestCase {
}, new SimpleListener(), new SimpleListener());
}
+ @Test
public void testDeleteAndAddSelf() {
testAddingTriple(3, new ComeAndGoListener() {
@Override
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestReifier.java b/jena-core/src/test/java/org/apache/jena/graph/TestReifier.java
index 3d17fe0302..c926597284 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestReifier.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestReifier.java
@@ -21,17 +21,21 @@
package org.apache.jena.graph;
-import java.lang.reflect.Constructor;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.function.Supplier;
+
+import org.junit.jupiter.params.Parameter;
+import org.junit.jupiter.params.ParameterizedClass;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import org.junit.jupiter.api.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.jena.atlas.iterator.Iter;
import org.apache.jena.junit.NodeCreateUtils;
-import org.apache.jena.mem.GraphMemFast;
import org.apache.jena.rdf.model.impl.ReifierStd;
import org.apache.jena.shared.AlreadyReifiedException;
import org.apache.jena.shared.CannotReifyException;
-import org.apache.jena.shared.JenaException;
import org.apache.jena.test.JenaTestLib;
import org.apache.jena.vocabulary.RDF;
@@ -39,33 +43,15 @@ import org.apache.jena.vocabulary.RDF;
* This class tests the reifiers of ordinary graphs. Old test suite - kept to ensure
* compatibility for the one and only Standard mode
*/
-public class TestReifier extends TestCase {
- protected final Class<? extends Graph> graphClass;
+@ParameterizedClass(name = "{0}")
+@MethodSource("org.apache.jena.graph.GraphCreators#graphs")
+public class TestReifier {
- public TestReifier(String name) {
- super(name);
- graphClass = null;
- }
-
- public TestReifier(Class<? extends Graph> graphClass, String name) {
- super(name);
- this.graphClass = graphClass;
- }
+ @Parameter
+ protected Supplier<Graph> graphMaker;
private Graph getGraph() {
- try {
- Constructor<? > cons = JenaTestLib.getConstructor(graphClass, new Class[]{});
- if ( cons != null )
- return (Graph)cons.newInstance();
- Constructor<? > cons2 = JenaTestLib.getConstructor(graphClass, new Class[]{this.getClass()});
- if ( cons2 != null )
- return (Graph)cons2.newInstance(this);
- throw new JenaException("no suitable graph constructor found for " + graphClass);
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new JenaException(e);
- }
+ return graphMaker.get();
}
private final Graph getGraphWith(String facts) {
@@ -86,6 +72,7 @@ public class TestReifier extends TestCase {
return graphWithUnless(!cond, facts);
}
+ @Test
public void testGetGraphNotNull() {
assertNotNull(getGraph());
}
@@ -93,6 +80,7 @@ public class TestReifier extends TestCase {
/**
* Check that the standard reifier will note, but not hide, reification quads.
*/
+ @Test
public void testStandard() {
Graph g = getGraph();
assertFalse(ReifierStd.hasTriple(g, GraphTestLib.triple("s p o")));
@@ -111,6 +99,7 @@ public class TestReifier extends TestCase {
* Test that the Standard reifier will expose implicit quads arising from
* reifyAs().
*/
+ @Test
public void testStandardExplode() {
Graph g = getGraph();
ReifierStd.reifyAs(g, GraphTestLib.node("a"), GraphTestLib.triple("p Q r"));
@@ -124,6 +113,7 @@ public class TestReifier extends TestCase {
* Ensure that over-specifying a reification means that we don't get a triple
* back. Goodness knows why this test wasn't in right from the beginning.
*/
+ @Test
public void testOverspecificationSuppressesReification() {
Graph g = getGraph();
GraphTestLib.graphAdd(g, "x rdf:subject A; x rdf:predicate P; x rdf:object O; x rdf:type rdf:Statement");
@@ -132,14 +122,17 @@ public class TestReifier extends TestCase {
assertEquals(null, ReifierStd.getTriple(g, GraphTestLib.node("x")));
}
+ @Test
public void testReificationSubjectClash() {
testReificationClash("x rdf:subject SS");
}
+ @Test
public void testReificationPredicateClash() {
testReificationClash("x rdf:predicate PP");
}
+ @Test
public void testReificationObjectClash() {
testReificationClash("x rdf:object OO");
}
@@ -158,6 +151,7 @@ public class TestReifier extends TestCase {
* Test that reifying a triple explicitly has some effect on the graph only for
* Standard reifiers.
*/
+ @Test
public void testManifestQuads() {
Graph g = getGraph();
ReifierStd.reifyAs(g, GraphTestLib.node("A"), GraphTestLib.triple("S P O"));
@@ -165,65 +159,73 @@ public class TestReifier extends TestCase {
GraphTestLib.assertIsomorphic(GraphTestLib.graphWith(reified), g);
}
+ @Test
public void testHiddenVsReification() {
Graph g = getGraph();
ReifierStd.reifyAs(g, GraphTestLib.node("A"), GraphTestLib.triple("S P O"));
assertTrue(ReifierStd.findEither(g, Triple.ANY, false).hasNext());
}
+ @Test
public void testRetrieveTriplesByNode() {
Graph G = getGraph();
Node N = NodeFactory.createBlankNode(), M = NodeFactory.createBlankNode();
ReifierStd.reifyAs(G, N, GraphTestLib.triple("x R y"));
- assertEquals("gets correct triple", GraphTestLib.triple("x R y"), ReifierStd.getTriple(G, N));
+ assertEquals(GraphTestLib.triple("x R y"), ReifierStd.getTriple(G, N), "gets correct triple");
ReifierStd.reifyAs(G, M, GraphTestLib.triple("p S q"));
JenaTestLib.assertDiffer("the anon nodes must be distinct", N, M);
- assertEquals("gets correct triple", GraphTestLib.triple("p S q"), ReifierStd.getTriple(G, M));
+ assertEquals(GraphTestLib.triple("p S q"), ReifierStd.getTriple(G, M), "gets correct triple");
- assertTrue("node is known bound", ReifierStd.hasTriple(G, M));
- assertTrue("node is known bound", ReifierStd.hasTriple(G, N));
- assertFalse("node is known unbound", ReifierStd.hasTriple(G, NodeFactory.createURI("any:thing")));
+ assertTrue(ReifierStd.hasTriple(G, M), "node is known bound");
+ assertTrue(ReifierStd.hasTriple(G, N), "node is known bound");
+ assertFalse(ReifierStd.hasTriple(G, NodeFactory.createURI("any:thing")), "node is known unbound");
}
+ @Test
public void testRetrieveTriplesByTriple() {
Graph G = getGraph();
Triple T = GraphTestLib.triple("x R y"), T2 = GraphTestLib.triple("y R x");
Node N = GraphTestLib.node("someNode");
ReifierStd.reifyAs(G, N, T);
- assertTrue("R must have T", ReifierStd.hasTriple(G, T));
- assertFalse("R must not have T2", ReifierStd.hasTriple(G, T2));
+ assertTrue(ReifierStd.hasTriple(G, T), "R must have T");
+ assertFalse(ReifierStd.hasTriple(G, T2), "R must not have T2");
}
+ @Test
public void testReifyAs() {
Graph G = getGraph();
Node X = NodeFactory.createURI("some:uri");
- assertEquals("node used", X, ReifierStd.reifyAs(G, X, GraphTestLib.triple("x R y")));
- assertEquals("retrieves correctly", GraphTestLib.triple("x R y"), ReifierStd.getTriple(G, X));
+ assertEquals(X, ReifierStd.reifyAs(G, X, GraphTestLib.triple("x R y")), "node used");
+ assertEquals(GraphTestLib.triple("x R y"), ReifierStd.getTriple(G, X), "retrieves correctly");
}
+ @Test
public void testAllNodes() {
Graph G = getGraph();
ReifierStd.reifyAs(G, GraphTestLib.node("x"), GraphTestLib.triple("cows eat grass"));
ReifierStd.reifyAs(G, GraphTestLib.node("y"), GraphTestLib.triple("pigs can fly"));
ReifierStd.reifyAs(G, GraphTestLib.node("z"), GraphTestLib.triple("dogs may bark"));
- assertEquals("", GraphTestLib.nodeSet("z y x"), Iter.toSet(ReifierStd.allNodes(G)));
+ assertEquals(GraphTestLib.nodeSet("z y x"), Iter.toSet(ReifierStd.allNodes(G)), "");
}
+ @Test
public void testRemoveByNode() {
Graph G = getGraph();
Node X = GraphTestLib.node("x"), Y = GraphTestLib.node("y");
ReifierStd.reifyAs(G, X, GraphTestLib.triple("x R a"));
ReifierStd.reifyAs(G, Y, GraphTestLib.triple("y R a"));
ReifierStd.remove(G, X, GraphTestLib.triple("x R a"));
- assertFalse("triple X has gone", ReifierStd.hasTriple(G, X));
- assertEquals("triple Y still there", GraphTestLib.triple("y R a"), ReifierStd.getTriple(G, Y));
+ assertFalse(ReifierStd.hasTriple(G, X), "triple X has gone");
+ assertEquals(GraphTestLib.triple("y R a"), ReifierStd.getTriple(G, Y), "triple Y still there");
}
+ @Test
public void testRemoveFromNothing() {
Graph G = getGraph();
G.delete(GraphTestLib.triple("quint rdf:subject S"));
}
+ @Test
public void testException() {
Graph G = getGraph();
Node X = GraphTestLib.node("x");
@@ -235,6 +237,7 @@ public class TestReifier extends TestCase {
} catch (AlreadyReifiedException e) {}
}
+ @Test
public void testKevinCaseA() {
Graph G = getGraph();
Node X = GraphTestLib.node("x"), a = GraphTestLib.node("a"), b = GraphTestLib.node("b"), c = GraphTestLib.node("c");
@@ -242,6 +245,7 @@ public class TestReifier extends TestCase {
ReifierStd.reifyAs(G, X, Triple.create(a, b, c));
}
+ @Test
public void testKevinCaseB() {
Graph G = getGraph();
Node X = GraphTestLib.node("x"), Y = GraphTestLib.node("y");
@@ -255,6 +259,7 @@ public class TestReifier extends TestCase {
}
}
+ @Test
public void testQuadRemove() {
Graph g = getGraph();
assertEquals(0, g.size());
@@ -274,6 +279,7 @@ public class TestReifier extends TestCase {
assertEquals(0, g.size());
}
+ @Test
public void testEmpty() {
Graph g = getGraph();
assertTrue(g.isEmpty());
@@ -287,27 +293,33 @@ public class TestReifier extends TestCase {
assertFalse(g.isEmpty());
}
+ @Test
public void testReifierEmptyFind() {
Graph g = getGraph();
assertEquals(GraphTestLib.tripleSet(""), ReifierStd.findExposed(g, Triple.ANY).toSet());
}
+ @Test
public void testReifierFindSubject() {
testReifierFind("x rdf:subject S");
}
+ @Test
public void testReifierFindObject() {
testReifierFind("x rdf:object O");
}
+ @Test
public void testReifierFindPredicate() {
testReifierFind("x rdf:predicate P");
}
+ @Test
public void testReifierFindComplete() {
testReifierFind("x rdf:predicate P; x rdf:subject S; x rdf:object O; x rdf:type rdf:Statement");
}
+ @Test
public void testReifierFindFilter() {
Graph g = getGraph();
GraphTestLib.graphAdd(g, "s rdf:subject S");
@@ -324,11 +336,4 @@ public class TestReifier extends TestCase {
assertEquals(GraphTestLib.tripleSet(triples), ReifierStd.findExposed(g, GraphTestLib.triple(pattern)).toSet());
}
- public static TestSuite suite() {
- TestSuite result = new TestSuite();
- result.addTest(MetaTestGraph.suite(TestReifier.class, GraphMemFast.class));
- result.setName(TestReifier.class.getSimpleName());
- return result;
- }
-
}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestTriple.java b/jena-core/src/test/java/org/apache/jena/graph/TestTriple.java
index 1ac3d42dfa..7129878013 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestTriple.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestTriple.java
@@ -21,10 +21,12 @@
package org.apache.jena.graph;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import java.util.function.Function;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.jena.graph.impl.LiteralLabel;
import org.apache.jena.graph.impl.LiteralLabelFactory;
@@ -32,20 +34,13 @@ import org.apache.jena.junit.NodeCreateUtils;
import org.apache.jena.shared.PrefixMapping;
import org.apache.jena.test.JenaTestLib;
-public class TestTriple extends TestCase {
-
- public TestTriple(String name) {
- super(name);
- }
-
- public static TestSuite suite() {
- return new TestSuite(TestTriple.class);
- }
+public class TestTriple {
private static final String U = "http://some.domain.name/magic/spells.incant";
private static final String N = "Alice";
private static final LiteralLabel L = LiteralLabelFactory.createLang("ashes are burning", "en");
+ @Test
public void testTripleEquals() {
// create some nodes to test
String id = BlankNodeId.createFreshId();
@@ -89,14 +84,14 @@ public class TestTriple extends TestCase {
}
}
- assertEquals("triple, null", triples[0].equals(null), false);
+ assertEquals(triples[0].equals(null), false, "triple, null");
JenaTestLib.assertDiffer("triple, string", triples[0], "string");
// now compare each triple with each other triple
for ( int i = 0 ; i < triples.length ; i++ ) {
for ( int j = 0 ; j < triples.length ; j++ ) {
if ( expected[i][j] ) {
- assertEquals("triples " + i + ", " + j, triples[i], triples[j]);
+ assertEquals(triples[i], triples[j], "triples " + i + ", " + j);
} else {
JenaTestLib.assertDiffer("triples" + i + ", " + j, triples[i], triples[j]);
}
@@ -104,11 +99,13 @@ public class TestTriple extends TestCase {
}
}
+ @Test
public void testTripleCreate() {
Node S = NodeCreateUtils.create("s"), P = NodeCreateUtils.create("p"), O = NodeCreateUtils.create("o");
assertEquals(Triple.create(S, P, O), Triple.create(S, P, O));
}
+ @Test
public void testTripleCreateFromString() {
Node S = NodeCreateUtils.create("a"), P = NodeCreateUtils.create("_P"), O = NodeCreateUtils.create("?c");
assertEquals(Triple.create(S, P, O), NodeCreateUtils.createTriple("a _P ?c"));
@@ -117,6 +114,7 @@ public class TestTriple extends TestCase {
/**
* Test that triple-creation respects prefixes, assuming that node creation does.
*/
+ @Test
public void testTriplePrefixes() {
Node S = NodeCreateUtils.create("rdf:alpha"), P = NodeCreateUtils.create("dc:creator");
Node O = NodeCreateUtils.create("spoo:notmapped");
@@ -124,6 +122,7 @@ public class TestTriple extends TestCase {
assertEquals(Triple.create(S, P, O), t);
}
+ @Test
public void testTripleCreationMapped() {
PrefixMapping pm = PrefixMapping.Factory.create().setNsPrefix("a", "ftp://foo/").setNsPrefix("b", "http://spoo/");
Triple wanted = NodeCreateUtils.createTriple("ftp://foo/x http://spoo/y c:z");
@@ -131,12 +130,14 @@ public class TestTriple extends TestCase {
assertEquals(wanted, got);
}
+ @Test
public void testPlainTripleMatches() {
testMatches("S P O");
testMatches("_S _P _O");
testMatches("1 2 3");
}
+ @Test
public void testAnyTripleMatches() {
testMatches("?? P O", "Z P O");
testMatches("S ?? O", "S Q O");
@@ -155,12 +156,14 @@ public class TestTriple extends TestCase {
assertTrue(NodeCreateUtils.createTriple(pattern).matches(NodeCreateUtils.createTriple(triple)));
}
+ @Test
public void testPlainTripleDoesntMatch() {
testMatchFails("S P O", "Z P O");
testMatchFails("S P O", "S Q O");
testMatchFails("S P O", "S P oh");
}
+ @Test
public void testAnyTripleDoesntMatch() {
testMatchFails("?? P O", "S P oh");
testMatchFails("S ?? O", "Z R O");
@@ -171,6 +174,7 @@ public class TestTriple extends TestCase {
assertFalse(NodeCreateUtils.createTriple(pattern).matches(NodeCreateUtils.createTriple(triple)));
}
+ @Test
public void testMatchesNodes() {
assertTrue(NodeCreateUtils.createTriple("S P O").matches(GraphTestLib.node("S"), GraphTestLib.node("P"), GraphTestLib.node("O")));
assertTrue(NodeCreateUtils.createTriple("?? P O").matches(GraphTestLib.node("Z"), GraphTestLib.node("P"), GraphTestLib.node("O")));
@@ -182,6 +186,7 @@ public class TestTriple extends TestCase {
assertFalse(NodeCreateUtils.createTriple("S P O").matches(GraphTestLib.node("Z"), GraphTestLib.node("P"), GraphTestLib.node("I")));
}
+ @Test
public void testConcrete() {
assertTrue(NodeCreateUtils.createTriple("S P O").isConcrete());
assertTrue(NodeCreateUtils.createTriple("S P 11").isConcrete());
@@ -202,26 +207,30 @@ public class TestTriple extends TestCase {
* Primarily to make sure that literals get quoted and stuff comes out in some
* kind of coherent order.
*/
+ @Test
public void testTripleToStringOrdering() {
Triple t1 = NodeCreateUtils.createTriple("subject predicate object");
- assertTrue("subject must be present", t1.toString().contains("subject"));
- assertTrue("subject must preceed predicate", t1.toString().indexOf("subject") < t1.toString().indexOf("predicate"));
- assertTrue("predicate must preceed object", t1.toString().indexOf("predicate") < t1.toString().indexOf("object"));
+ assertTrue(t1.toString().contains("subject"), "subject must be present");
+ assertTrue(t1.toString().indexOf("subject") < t1.toString().indexOf("predicate"), "subject must preceed predicate");
+ assertTrue(t1.toString().indexOf("predicate") < t1.toString().indexOf("object"), "predicate must preceed object");
}
+ @Test
public void testTripleToStringQuoting() {
Triple t1 = NodeCreateUtils.createTriple("subject predicate 'object'");
assertTrue(t1.toString().indexOf("object") > 0);
}
+ @Test
public void testTripleToStringWithPrefixing() {
PrefixMapping pm = PrefixMapping.Factory.create();
pm.setNsPrefix("spoo", "eg://domain.dom/spoo#");
Triple t1 = NodeCreateUtils.createTriple("eg://domain.dom/spoo#a b c");
- // assertEquals( "spoo:a <eh:/b> <eh:/c>", t1.toString( pm ) );
+ // assertEquals("spoo:a <eh:/b> <eh:/c>", t1.toString( pm ) );
assertEquals("spoo:a eh:/b eh:/c", t1.toString(pm));
}
+ @Test
public void testTripleMaps() {
assertEquals(GraphTestLib.node("x"), getSubject.apply(NodeCreateUtils.createTriple("x P z")));
assertEquals(GraphTestLib.node("P"), getPredicate.apply(NodeCreateUtils.createTriple("x P z")));
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestTripleField.java b/jena-core/src/test/java/org/apache/jena/graph/TestTripleField.java
index 678ac316fc..9af0ffe59e 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestTripleField.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestTripleField.java
@@ -21,68 +21,74 @@
package org.apache.jena.graph;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.graph.Triple.*;
import org.apache.jena.test.JenaTestLib;
-public class TestTripleField extends TestCase {
- public TestTripleField(String name) {
- super(name);
- }
-
- public static TestSuite suite() {
- return new TestSuite(TestTripleField.class);
- }
+public class TestTripleField {
+ @Test
public void testFieldsExistAndAreTyped() {
JenaTestLib.assertInstanceOf(Triple.Field.class, Triple.Field.fieldSubject);
JenaTestLib.assertInstanceOf(Triple.Field.class, Triple.Field.fieldObject);
JenaTestLib.assertInstanceOf(Triple.Field.class, Triple.Field.fieldPredicate);
}
+ @Test
public void testGetSubject() {
assertEquals(GraphTestLib.node("s"), Field.fieldSubject.getField(GraphTestLib.triple("s p o")));
}
+ @Test
public void testGetObject() {
assertEquals(GraphTestLib.node("o"), Field.fieldObject.getField(GraphTestLib.triple("s p o")));
}
+ @Test
public void testGetPredicate() {
assertEquals(GraphTestLib.node("p"), Field.fieldPredicate.getField(GraphTestLib.triple("s p o")));
}
+ @Test
public void testFilterSubject() {
assertTrue(Field.fieldSubject.filterOn(GraphTestLib.node("a")).test(GraphTestLib.triple("a P b")));
assertFalse(Field.fieldSubject.filterOn(GraphTestLib.node("x")).test(GraphTestLib.triple("a P b")));
}
+ @Test
public void testFilterObject() {
assertTrue(Field.fieldObject.filterOn(GraphTestLib.node("b")).test(GraphTestLib.triple("a P b")));
assertFalse(Field.fieldObject.filterOn(GraphTestLib.node("c")).test(GraphTestLib.triple("a P b")));
}
+ @Test
public void testFilterPredicate() {
assertTrue(Field.fieldPredicate.filterOn(GraphTestLib.node("P")).test(GraphTestLib.triple("a P b")));
assertFalse(Field.fieldPredicate.filterOn(GraphTestLib.node("Q")).test(GraphTestLib.triple("a P b")));
}
+ @Test
public void testFilterOnConcreteSubject() {
assertTrue(Field.fieldSubject.filterOnConcrete(GraphTestLib.node("a")).test(GraphTestLib.triple("a P b")));
assertFalse(Field.fieldSubject.filterOnConcrete(GraphTestLib.node("x")).test(GraphTestLib.triple("a P b")));
}
+ @Test
public void testFilterOnConcreteObject() {
assertTrue(Field.fieldObject.filterOnConcrete(GraphTestLib.node("b")).test(GraphTestLib.triple("a P b")));
assertFalse(Field.fieldObject.filterOnConcrete(GraphTestLib.node("c")).test(GraphTestLib.triple("a P b")));
}
+ @Test
public void testFilterOnConcretePredicate() {
assertTrue(Field.fieldPredicate.filterOnConcrete(GraphTestLib.node("P")).test(GraphTestLib.triple("a P b")));
assertFalse(Field.fieldPredicate.filterOnConcrete(GraphTestLib.node("Q")).test(GraphTestLib.triple("a P b")));
}
+ @Test
public void testFilterByTriple() {
assertTrue(Field.fieldSubject.filterOn(GraphTestLib.triple("s P o")).test(GraphTestLib.triple("s Q p")));
assertFalse(Field.fieldSubject.filterOn(GraphTestLib.triple("s P o")).test(GraphTestLib.triple("x Q p")));
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TestTypedLiterals.java b/jena-core/src/test/java/org/apache/jena/graph/TestTypedLiterals.java
index 35e2868ead..f9b8100332 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TestTypedLiterals.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TestTypedLiterals.java
@@ -21,13 +21,15 @@
package org.apache.jena.graph;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.*;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.commons.codec.binary.Hex;
import org.apache.jena.datatypes.BaseDatatype;
import org.apache.jena.datatypes.DatatypeFormatException;
@@ -41,13 +43,12 @@ import org.apache.jena.rdf.model.*;
import org.apache.jena.shared.impl.JenaParameters;
import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.XSD;
-import org.junit.Assert;
/**
* Unit test for the typed literal machinery - including RDFDatatype, TypeMapper and
* LiteralLabel. See also TestLiteralLabelSameValueAs
*/
-public class TestTypedLiterals extends TestCase {
+public class TestTypedLiterals {
/** dummy model used as a literal factory */
private Model m = ModelFactory.createDefaultModel();
@@ -56,20 +57,14 @@ public class TestTypedLiterals extends TestCase {
/* static { Locale.setDefault(Locale.ITALY);
* TimeZone.setDefault(TimeZone.getTimeZone("CEST")); } */
- public TestTypedLiterals(String name) {
- super(name);
- }
-
/**
* This is its own test suite
*/
- public static TestSuite suite() {
- return new TestSuite(TestTypedLiterals.class);
- }
/**
* Test the base functioning of unknown datatypes
*/
+ @Test
public void testUnknownDatatype() {
String typeURI = "urn:jena-dt:unknown";
String typeURI2 = "urn:jena-dt:unknown2";
@@ -95,9 +90,9 @@ public class TestTypedLiterals extends TestCase {
// Check typed accessors
try {
l3.getInt();
- assertTrue("Allowed int conversion", false);
+ assertTrue(false, "Allowed int conversion");
} catch (DatatypeFormatException e) {}
- assertEquals("Extract value", l1.getValue(), new BaseDatatype.TypedValue("foo", typeURI));
+ assertEquals(l1.getValue(), new BaseDatatype.TypedValue("foo", typeURI), "Extract value");
JenaParameters.enableSilentAcceptanceOfUnknownDatatypes = false;
boolean foundException = false;
@@ -107,7 +102,7 @@ public class TestTypedLiterals extends TestCase {
foundException = true;
}
JenaParameters.enableSilentAcceptanceOfUnknownDatatypes = originalFlag;
- assertTrue("Detected unknown datatype", foundException);
+ assertTrue(foundException, "Detected unknown datatype");
// Check we can create a literal of an unregistered java type without
// anything blowing up
@@ -119,6 +114,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Tests the base functioning of a user defined datatype
*/
+ @Test
public void testUserDef() {
// Register the user defined type for rationals
RDFDatatype rtype = RationalType.theRationalType;
@@ -135,18 +131,19 @@ public class TestTypedLiterals extends TestCase {
assertDiffer("values should be tested!", l1, l3);
// Check typed accessors
- assertSame("Datatype incorrect", l1.getDatatype(), rtype);
- assertEquals("Datatype uri incorrect", l1.getDatatypeURI(), RationalType.theTypeURI);
+ assertSame(l1.getDatatype(), rtype, "Datatype incorrect");
+ assertEquals(l1.getDatatypeURI(), RationalType.theTypeURI, "Datatype uri incorrect");
Object val = l1.getValue();
- assertTrue("Value space check", val instanceof Rational);
- assertTrue("Value check", ((Rational)val).getNumerator() == 3);
- assertTrue("Value check", ((Rational)val).getDenominator() == 5);
+ assertTrue(val instanceof Rational, "Value space check");
+ assertTrue(((Rational)val).getNumerator() == 3, "Value check");
+ assertTrue(((Rational)val).getDenominator() == 5, "Value check");
try {
l1.getInt();
- assertTrue("Allowed int conversion", false);
+ assertTrue(false, "Allowed int conversion");
} catch (DatatypeFormatException e) {}
}
+ @Test
public void testRDFLangString_1() {
// Registration
RDFDatatype dt = TypeMapper.getInstance().getTypeByName(RDF.langString.getURI());
@@ -154,6 +151,7 @@ public class TestTypedLiterals extends TestCase {
assertTrue(RDF.dtLangString == dt);
}
+ @Test
public void testRDFLangString_2() {
// "abc"^^rdf:langString (no language tag)
Literal ll1 = m.createTypedLiteral("abc", RDFLangString.rdfLangString);
@@ -165,6 +163,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Tests basic XSD integer types()
*/
+ @Test
public void testXSDbasics() {
String xsdIntURI = "http://www.w3.org/2001/XMLSchema#int";
@@ -174,11 +173,11 @@ public class TestTypedLiterals extends TestCase {
Literal l4 = m.createTypedLiteral("63"); // default map
assertSameValueAs("Default map failed", l1, l2);
- assertEquals("Value wrong", l1.getValue(), Integer.valueOf(42));
- assertEquals("class wrong", l1.getValue().getClass(), Integer.class);
- assertEquals("Value accessor problem", l1.getInt(), 42);
- assertEquals("wrong type name", l2.getDatatypeURI(), xsdIntURI);
- assertEquals("wrong type", l2.getDatatype(), XSDDatatype.XSDint);
+ assertEquals(l1.getValue(), Integer.valueOf(42), "Value wrong");
+ assertEquals(l1.getValue().getClass(), Integer.class, "class wrong");
+ assertEquals(l1.getInt(), 42, "Value accessor problem");
+ assertEquals(l2.getDatatypeURI(), xsdIntURI, "wrong type name");
+ assertEquals(l2.getDatatype(), XSDDatatype.XSDint, "wrong type");
assertDiffer("Not value sensitive", l1, l4);
checkIllegalLiteral("zap", XSDDatatype.XSDint);
checkIllegalLiteral("42.1", XSDDatatype.XSDint);
@@ -191,12 +190,12 @@ public class TestTypedLiterals extends TestCase {
l2 = m.createTypedLiteral("42.42", XSDDatatype.XSDfloat);
Literal l3 = m.createTypedLiteral("42.42", XSDDatatype.XSDdouble);
- assertEquals("class wrong", l1.getValue().getClass(), Double.class);
+ assertEquals(l1.getValue().getClass(), Double.class, "class wrong");
assertFloatEquals("value wrong", ((Double)(l1.getValue())).floatValue(), 42.42);
- assertEquals("class wrong", l2.getValue().getClass(), Float.class);
+ assertEquals(l2.getValue().getClass(), Float.class, "class wrong");
assertFloatEquals("value wrong", ((Float)(l2.getValue())).floatValue(), 42.42);
assertFloatEquals("Value accessor problem", l1.getFloat(), 42.42);
- assertEquals("wrong type", l2.getDatatype(), XSDDatatype.XSDfloat);
+ assertEquals(l2.getDatatype(), XSDDatatype.XSDfloat, "wrong type");
assertSameValueAs("equality fn", l1, l3);
// Minimal check on long, short, byte
@@ -276,18 +275,19 @@ public class TestTypedLiterals extends TestCase {
checkLegalLiteral("true", XSDDatatype.XSDboolean, Boolean.class, true);
checkLegalLiteral("false", XSDDatatype.XSDboolean, Boolean.class, false);
l1 = m.createTypedLiteral(true);
- assertEquals("boolean mapping", XSDDatatype.XSDboolean, l1.getDatatype());
+ assertEquals(XSDDatatype.XSDboolean, l1.getDatatype(), "boolean mapping");
// String types
checkLegalLiteral("hello world", XSDDatatype.XSDstring, String.class, "hello world");
l1 = m.createTypedLiteral("foo bar");
- assertEquals("string mapping", XSDDatatype.XSDstring, l1.getDatatype());
+ assertEquals(XSDDatatype.XSDstring, l1.getDatatype(), "string mapping");
}
/**
* Some selected equality tests which caused problems in WG tests
*/
+ @Test
public void testMiscEquality() {
Literal l1 = m.createTypedLiteral("10", "http://www.w3.org/2001/XMLSchema#integer");
Literal l3 = m.createTypedLiteral("010", "http://www.w3.org/2001/XMLSchema#integer");
@@ -303,6 +303,7 @@ public class TestTypedLiterals extends TestCase {
* Check that creating a typed literal from an object traps the interesting
* special cases of String and Calendar.
*/
+ @Test
public void testOverloads() {
// First case string overloads an explicit type
boolean old = JenaParameters.enableEagerLiteralValidation;
@@ -316,7 +317,7 @@ public class TestTypedLiterals extends TestCase {
} catch (DatatypeFormatException e1) {
test1 = true;
}
- assertTrue("detected illegal string, direct", test1);
+ assertTrue(test1, "detected illegal string, direct");
boolean test2 = false;
try {
@@ -325,7 +326,7 @@ public class TestTypedLiterals extends TestCase {
} catch (DatatypeFormatException e2) {
test2 = true;
}
- assertTrue("detected illegal string, overloaded", test2);
+ assertTrue(test2, "detected illegal string, overloaded");
// Overloading of calendar convenience functions
Calendar testCal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
@@ -333,7 +334,7 @@ public class TestTypedLiterals extends TestCase {
testCal.set(Calendar.MILLISECOND, 0); // ms field can be undefined on
// Linux
Literal lc = m.createTypedLiteral((Object)testCal);
- assertEquals("calendar overloading test", m.createTypedLiteral("1999-05-30T15:09:32Z", XSDDatatype.XSDdateTime), lc);
+ assertEquals(m.createTypedLiteral("1999-05-30T15:09:32Z", XSDDatatype.XSDdateTime), lc, "calendar overloading test");
} finally {
JenaParameters.enableEagerLiteralValidation = old;
@@ -343,6 +344,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Test plain literal/xsd:string/xsd:int equality operations
*/
+ @Test
public void testPlainSameValueAs() {
Literal lString = m.createTypedLiteral("10", XSDDatatype.XSDstring);
Literal lPlain = m.createTypedLiteral("10", (RDFDatatype)null);
@@ -353,7 +355,7 @@ public class TestTypedLiterals extends TestCase {
assertSameValueAs("Null type = plain literal", lPlain, lPlain2);
assertSameValueAs("Null type = plain literal", lPlain, lPlain3);
assertSameValueAs("Null type = plain literal", lPlain2, lPlain3);
- assertEquals("null type mean xsd:string", XSDDatatype.XSDstring, lPlain3.getDatatype());
+ assertEquals(XSDDatatype.XSDstring, lPlain3.getDatatype(), "null type mean xsd:string");
assertDiffer("String != int", lString, lInt);
assertDiffer("Plain != int", lPlain, lInt);
assertDiffer("Plain != int", lPlain2, lInt);
@@ -365,6 +367,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Test cases of numeric comparison.
*/
+ @Test
public void testNumberSameValueAs() {
Literal lDouble = m.createTypedLiteral("5", XSDDatatype.XSDdouble);
Literal lDouble2 = m.createTypedLiteral("5.5", XSDDatatype.XSDdouble);
@@ -403,6 +406,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Check basic handling of big integers and decimals
*/
+ @Test
public void testBigNums() {
Literal l1 = m.createTypedLiteral("12345678901234567890", XSDDatatype.XSDinteger);
Literal l2 = m.createTypedLiteral("12345678901234567891", XSDDatatype.XSDinteger);
@@ -436,6 +440,7 @@ public class TestTypedLiterals extends TestCase {
* Test case for retrieving a value like 3.00 from a probe like 3.0. This test is
* value sensitive.
*/
+ @Test
public void testDecimalFind() {
Graph graph = GraphMemFactory.createDefaultGraphSameValue();
RDFDatatype dt = XSDDatatype.XSDdecimal;
@@ -451,6 +456,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Test the internal machinery of decimal normalization directly
*/
+ @Test
public void testDecimalCanonicalize() {
doTestDecimalCanonicalize("0.500", "0.5", BigDecimal.class);
doTestDecimalCanonicalize("0.50", "0.5", BigDecimal.class);
@@ -474,67 +480,73 @@ public class TestTypedLiterals extends TestCase {
/**
* Test data/time wrappers
*/
+ @Test
public void testDateTime_1() {
// Duration
Literal l1 = m.createTypedLiteral("P1Y2M3DT5H6M7.50S", XSDDatatype.XSDduration);
- assertEquals("duration data type", XSDDatatype.XSDduration, l1.getDatatype());
- assertEquals("duration java type", XSDDuration.class, l1.getValue().getClass());
- assertEquals("duration value", 1, ((XSDDuration)l1.getValue()).getYears());
- assertEquals("duration value", 2, ((XSDDuration)l1.getValue()).getMonths());
- assertEquals("duration value", 3, ((XSDDuration)l1.getValue()).getDays());
- assertEquals("duration value", 5, ((XSDDuration)l1.getValue()).getHours());
- assertEquals("duration value", 6, ((XSDDuration)l1.getValue()).getMinutes());
- assertEquals("duration value", 7, ((XSDDuration)l1.getValue()).getFullSeconds());
- assertEquals("duration value", BigDecimal.valueOf(75, 1), ((XSDDuration)l1.getValue()).getBigSeconds());
+ assertEquals(XSDDatatype.XSDduration, l1.getDatatype(), "duration data type");
+ assertEquals(XSDDuration.class, l1.getValue().getClass(), "duration java type");
+ assertEquals(1, ((XSDDuration)l1.getValue()).getYears(), "duration value");
+ assertEquals(2, ((XSDDuration)l1.getValue()).getMonths(), "duration value");
+ assertEquals(3, ((XSDDuration)l1.getValue()).getDays(), "duration value");
+ assertEquals(5, ((XSDDuration)l1.getValue()).getHours(), "duration value");
+ assertEquals(6, ((XSDDuration)l1.getValue()).getMinutes(), "duration value");
+ assertEquals(7, ((XSDDuration)l1.getValue()).getFullSeconds(), "duration value");
+ assertEquals(BigDecimal.valueOf(75, 1), ((XSDDuration)l1.getValue()).getBigSeconds(), "duration value");
assertFloatEquals("duration value", 18367.5, ((XSDDuration)l1.getValue()).getTimePart());
- assertEquals("serialization", "P1Y2M3DT5H6M7.5S", l1.getValue().toString());
- assertTrue("equality test", l1.sameValueAs(m.createTypedLiteral("P1Y2M3DT5H6M7.5S", XSDDatatype.XSDduration)));
- assertTrue("inequality test", l1 != m.createTypedLiteral("P1Y2M2DT5H6M7.5S", XSDDatatype.XSDduration));
+ assertEquals("P1Y2M3DT5H6M7.5S", l1.getValue().toString(), "serialization");
+ assertTrue(l1.sameValueAs(m.createTypedLiteral("P1Y2M3DT5H6M7.5S", XSDDatatype.XSDduration)), "equality test");
+ assertTrue(l1 != m.createTypedLiteral("P1Y2M2DT5H6M7.5S", XSDDatatype.XSDduration), "inequality test");
}
+ @Test
public void testDateTime_2() {
Literal l1 = m.createTypedLiteral("P1Y2M3DT5H0M", XSDDatatype.XSDduration);
- assertEquals("serialization", "P1Y2M3DT5H", l1.getValue().toString());
+ assertEquals("P1Y2M3DT5H", l1.getValue().toString(), "serialization");
}
+ @Test
public void testDateTime_3() {
Literal l1 = m.createTypedLiteral("P1Y", XSDDatatype.XSDduration);
- assertEquals("duration data type", XSDDatatype.XSDduration, l1.getDatatype());
- assertEquals("duration java type", XSDDuration.class, l1.getValue().getClass());
- assertEquals("duration value", 1, ((XSDDuration)l1.getValue()).getYears());
- assertEquals("serialization", "P1Y", l1.getValue().toString());
- assertTrue("equality test", l1.sameValueAs(m.createTypedLiteral("P1Y", XSDDatatype.XSDduration)));
- assertTrue("inequality test", l1 != m.createTypedLiteral("P1Y", XSDDatatype.XSDduration));
+ assertEquals(XSDDatatype.XSDduration, l1.getDatatype(), "duration data type");
+ assertEquals(XSDDuration.class, l1.getValue().getClass(), "duration java type");
+ assertEquals(1, ((XSDDuration)l1.getValue()).getYears(), "duration value");
+ assertEquals("P1Y", l1.getValue().toString(), "serialization");
+ assertTrue(l1.sameValueAs(m.createTypedLiteral("P1Y", XSDDatatype.XSDduration)), "equality test");
+ assertTrue(l1 != m.createTypedLiteral("P1Y", XSDDatatype.XSDduration), "inequality test");
}
+ @Test
public void testDateTime_4() {
Literal l1 = m.createTypedLiteral("-P120D", XSDDatatype.XSDduration);
Literal l2 = m.createTypedLiteral(l1.getValue());
assertEquals("-P120D", l2.getLexicalForm());
}
+ @Test
public void testDateTime_5() {
Literal d1 = m.createTypedLiteral("PT1H1M1S", XSDDatatype.XSDduration);
Literal d2 = m.createTypedLiteral("PT1H1M1.1S", XSDDatatype.XSDduration);
- assertTrue("duration compare", !d1.sameValueAs(d2));
+ assertTrue(!d1.sameValueAs(d2), "duration compare");
XSDDuration dur1 = (XSDDuration)d1.getValue();
XSDDuration dur2 = (XSDDuration)d2.getValue();
- assertEquals("duration compare order", 1, dur2.compare(dur1));
+ assertEquals(1, dur2.compare(dur1), "duration compare order");
}
+ @Test
public void testDateTime_6() {
// dateTime
Literal l1 = m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime);
XSDDateTime xdt = (XSDDateTime)l1.getValue();
- assertEquals("dateTime data type", XSDDatatype.XSDdateTime, l1.getDatatype());
- assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
- assertEquals("dateTime value", 1999, xdt.getYears());
- assertEquals("dateTime value", 5, xdt.getMonths());
- assertEquals("dateTime value", 31, xdt.getDays());
- assertEquals("dateTime value", 2, xdt.getHours());
- assertEquals("dateTime value", 9, xdt.getMinutes());
- assertEquals("dateTime value", 32, xdt.getFullSeconds());
- assertEquals("serialization", "1999-05-31T02:09:32Z", l1.getValue().toString());
+ assertEquals(XSDDatatype.XSDdateTime, l1.getDatatype(), "dateTime data type");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "dateTime java type");
+ assertEquals(1999, xdt.getYears(), "dateTime value");
+ assertEquals(5, xdt.getMonths(), "dateTime value");
+ assertEquals(31, xdt.getDays(), "dateTime value");
+ assertEquals(2, xdt.getHours(), "dateTime value");
+ assertEquals(9, xdt.getMinutes(), "dateTime value");
+ assertEquals(32, xdt.getFullSeconds(), "dateTime value");
+ assertEquals("1999-05-31T02:09:32Z", l1.getValue().toString(), "serialization");
Calendar cal = xdt.asCalendar();
Calendar testCal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
testCal.set(1999, 4, 31, 2, 9, 32);
@@ -548,21 +560,22 @@ public class TestTypedLiterals extends TestCase {
* testCal.get(Calendar.MINUTE) ); assertEquals("calendar value",
* cal.get(Calendar.SECOND), testCal.get(Calendar.SECOND) ); */
testCal.set(Calendar.MILLISECOND, 0); // ms field can be undefined on Linux
- assertEquals("calendar value", cal, testCal);
- assertEquals("equality test", l1, m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime));
- assertTrue("inequality test", l1 != m.createTypedLiteral("1999-04-31T02:09:32Z", XSDDatatype.XSDdateTime));
+ assertEquals(cal, testCal, "calendar value");
+ assertEquals(l1, m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime), "equality test");
+ assertTrue(l1 != m.createTypedLiteral("1999-04-31T02:09:32Z", XSDDatatype.XSDdateTime), "inequality test");
Calendar testCal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
testCal2.set(1999, 4, 30, 15, 9, 32);
testCal2.set(Calendar.MILLISECOND, 0); // ms field can be undefined on
// Linux
Literal lc = m.createTypedLiteral(testCal2);
- assertEquals("calendar 24 hour test", m.createTypedLiteral("1999-05-30T15:09:32Z", XSDDatatype.XSDdateTime), lc);
+ assertEquals(m.createTypedLiteral("1999-05-30T15:09:32Z", XSDDatatype.XSDdateTime), lc, "calendar 24 hour test");
- assertEquals("calendar value", cal, testCal);
- assertEquals("equality test", l1, m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime));
+ assertEquals(cal, testCal, "calendar value");
+ assertEquals(l1, m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime), "equality test");
}
+ @Test
public void testDateTime_7() {
Calendar testCal3 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
testCal3.clear();
@@ -579,9 +592,10 @@ public class TestTypedLiterals extends TestCase {
Resource r1 = m.getResource(uri1);
Property p = m.getProperty(urip);
XSDDateTime returnedDateTime = (XSDDateTime)r1.getProperty(p).getLiteral().getValue();
- assertEquals("deserialized calendar value", testCal3, returnedDateTime.asCalendar());
+ assertEquals(testCal3, returnedDateTime.asCalendar(), "deserialized calendar value");
}
+ @Test
public void testDateTime_8() {
// dateTime to calendar with milliseconds
Calendar testCal4 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
@@ -597,13 +611,14 @@ public class TestTypedLiterals extends TestCase {
// Internal helper
private void doDateTimeTest(Calendar cal, String lex, double time) {
Literal lc4 = m.createTypedLiteral(cal);
- assertEquals("serialization", lex, lc4.getValue().toString());
- assertEquals("calendar ms test", m.createTypedLiteral(lex, XSDDatatype.XSDdateTime), lc4);
+ assertEquals(lex, lc4.getValue().toString(), "serialization");
+ assertEquals(m.createTypedLiteral(lex, XSDDatatype.XSDdateTime), lc4, "calendar ms test");
XSDDateTime dt4 = (XSDDateTime)lc4.getValue();
- assertTrue("Fraction time check", Math.abs(dt4.getSeconds() - time) < 0.0001);
+ assertTrue(Math.abs(dt4.getSeconds() - time) < 0.0001, "Fraction time check");
assertEquals(dt4.asCalendar(), cal);
}
+ @Test
public void testDateTime_9() {
// Years before 1000 : xsd:dateTime requires at least a four digit year.
// GregorianCalendar does not handle negative years. (.get(YEAR) triggers
@@ -617,8 +632,8 @@ public class TestTypedLiterals extends TestCase {
XSDDateTime xdtM = new XSDDateTime(calM1);
LiteralLabel xdtM_ll = LiteralLabelFactory.createByValue(xdtM, XSDDatatype.XSDdateTime);
- assertTrue("Pre-1000 calendar value", xdtM_ll.isWellFormed());
- assertTrue("Pre-1000 calendar value", xdtM_ll.getLexicalForm().matches("^[0-9]{4}-.*"));
+ assertTrue(xdtM_ll.isWellFormed(), "Pre-1000 calendar value");
+ assertTrue(xdtM_ll.getLexicalForm().matches("^[0-9]{4}-.*"), "Pre-1000 calendar value");
}
// Illegal dateTimes
boolean ok = false;
@@ -631,126 +646,135 @@ public class TestTypedLiterals extends TestCase {
} finally {
JenaParameters.enableEagerLiteralValidation = old;
}
- assertTrue("Early detection of invalid literals", ok);
+ assertTrue(ok, "Early detection of invalid literals");
}
// date
+ @Test
public void testDateTime_10() {
Literal l1 = m.createTypedLiteral("1999-05-31", XSDDatatype.XSDdate);
- assertEquals("dateTime data type", XSDDatatype.XSDdate, l1.getDatatype());
- assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
+ assertEquals(XSDDatatype.XSDdate, l1.getDatatype(), "dateTime data type");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "dateTime java type");
XSDDateTime xdt = (XSDDateTime)l1.getValue();
- assertEquals("dateTime value", 1999, xdt.getYears());
- assertEquals("dateTime value", 5, xdt.getMonths());
- assertEquals("dateTime value", 31, xdt.getDays());
+ assertEquals(1999, xdt.getYears(), "dateTime value");
+ assertEquals(5, xdt.getMonths(), "dateTime value");
+ assertEquals(31, xdt.getDays(), "dateTime value");
try {
xdt.getHours();
- assertTrue("Failed to prevent illegal access", false);
+ assertTrue(false, "Failed to prevent illegal access");
} catch (IllegalDateTimeFieldException e) {}
}
// time
+ @Test
public void testDateTime_11() {
Literal l1 = m.createTypedLiteral("12:56:32", XSDDatatype.XSDtime);
- assertEquals("dateTime data type", XSDDatatype.XSDtime, l1.getDatatype());
- assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
+ assertEquals(XSDDatatype.XSDtime, l1.getDatatype(), "dateTime data type");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "dateTime java type");
XSDDateTime xdt = (XSDDateTime)l1.getValue();
- assertEquals("dateTime value", 12, xdt.getHours());
- assertEquals("dateTime value", 56, xdt.getMinutes());
- assertEquals("dateTime value", 32, xdt.getFullSeconds());
+ assertEquals(12, xdt.getHours(), "dateTime value");
+ assertEquals(56, xdt.getMinutes(), "dateTime value");
+ assertEquals(32, xdt.getFullSeconds(), "dateTime value");
try {
xdt.getDays();
- assertTrue("Failed to prevent illegal access", false);
+ assertTrue(false, "Failed to prevent illegal access");
} catch (IllegalDateTimeFieldException e) {}
}
// gYearMonth
+ @Test
public void testDateTime_12() {
Literal l1 = m.createTypedLiteral("1999-05", XSDDatatype.XSDgYearMonth);
- assertEquals("dateTime data type", XSDDatatype.XSDgYearMonth, l1.getDatatype());
- assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
+ assertEquals(XSDDatatype.XSDgYearMonth, l1.getDatatype(), "dateTime data type");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "dateTime java type");
XSDDateTime xdt = (XSDDateTime)l1.getValue();
- assertEquals("dateTime value", 1999, xdt.getYears());
- assertEquals("dateTime value", 5, xdt.getMonths());
+ assertEquals(1999, xdt.getYears(), "dateTime value");
+ assertEquals(5, xdt.getMonths(), "dateTime value");
try {
xdt.getDays();
- assertTrue("Failed to prevent illegal access", false);
+ assertTrue(false, "Failed to prevent illegal access");
} catch (IllegalDateTimeFieldException e) {}
// gYear
}
+ @Test
public void testDateTime_13() {
Literal l1 = m.createTypedLiteral("1999", XSDDatatype.XSDgYear);
- assertEquals("dateTime data type", XSDDatatype.XSDgYear, l1.getDatatype());
- assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
+ assertEquals(XSDDatatype.XSDgYear, l1.getDatatype(), "dateTime data type");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "dateTime java type");
XSDDateTime xdt = (XSDDateTime)l1.getValue();
- assertEquals("dateTime value", 1999, xdt.getYears());
+ assertEquals(1999, xdt.getYears(), "dateTime value");
try {
xdt.getMonths();
- assertTrue("Failed to prevent illegal access", false);
+ assertTrue(false, "Failed to prevent illegal access");
} catch (IllegalDateTimeFieldException e) {}
// gMonth
}
+ @Test
public void testDateTime_14() {
Literal l1 = m.createTypedLiteral("--05--", XSDDatatype.XSDgMonth);
- assertEquals("dateTime data type", XSDDatatype.XSDgMonth, l1.getDatatype());
- assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
+ assertEquals(XSDDatatype.XSDgMonth, l1.getDatatype(), "dateTime data type");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "dateTime java type");
XSDDateTime xdt = (XSDDateTime)l1.getValue();
- assertEquals("dateTime value", 5, xdt.getMonths());
+ assertEquals(5, xdt.getMonths(), "dateTime value");
try {
xdt.getYears();
- assertTrue("Failed to prevent illegal access", false);
+ assertTrue(false, "Failed to prevent illegal access");
} catch (IllegalDateTimeFieldException e) {}
}
// gMonthDay
+ @Test
public void testDateTime_15() {
Literal l1 = m.createTypedLiteral("--05-25", XSDDatatype.XSDgMonthDay);
- assertEquals("dateTime data type", XSDDatatype.XSDgMonthDay, l1.getDatatype());
- assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
+ assertEquals(XSDDatatype.XSDgMonthDay, l1.getDatatype(), "dateTime data type");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "dateTime java type");
XSDDateTime xdt = (XSDDateTime)l1.getValue();
- assertEquals("dateTime value", 5, xdt.getMonths());
- assertEquals("dateTime value", 25, xdt.getDays());
+ assertEquals(5, xdt.getMonths(), "dateTime value");
+ assertEquals(25, xdt.getDays(), "dateTime value");
try {
xdt.getYears();
- assertTrue("Failed to prevent illegal access", false);
+ assertTrue(false, "Failed to prevent illegal access");
} catch (IllegalDateTimeFieldException e) {}
}
// gDay
+ @Test
public void testDateTime_16() {
Literal l1 = m.createTypedLiteral("---25", XSDDatatype.XSDgDay);
- assertEquals("dateTime data type", XSDDatatype.XSDgDay, l1.getDatatype());
- assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
+ assertEquals(XSDDatatype.XSDgDay, l1.getDatatype(), "dateTime data type");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "dateTime java type");
XSDDateTime xdt = (XSDDateTime)l1.getValue();
- assertEquals("dateTime value", 25, xdt.getDays());
+ assertEquals(25, xdt.getDays(), "dateTime value");
try {
xdt.getMonths();
- assertTrue("Failed to prevent illegal access", false);
+ assertTrue(false, "Failed to prevent illegal access");
} catch (IllegalDateTimeFieldException e) {}
}
+ @Test
public void testDateTime_17() {
// Creation of datetime from a date object
Calendar ncal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
ncal.set(2003, 11, 8, 10, 50, 42);
ncal.set(Calendar.MILLISECOND, 0);
Literal l1 = m.createTypedLiteral(ncal);
- assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype());
- assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass());
- assertEquals("DateTime from date", "2003-12-08T10:50:42Z", l1.getValue().toString());
+ assertEquals(XSDDatatype.XSDdateTime, l1.getDatatype(), "DateTime from date");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "DateTime from date");
+ assertEquals("2003-12-08T10:50:42Z", l1.getValue().toString(), "DateTime from date");
}
// Thanks to Greg Shueler for DST patch and test case
////// some of below code from java.util.GregorianCalendar javadoc///////
// create a Pacific Standard Time time zone
+ @Test
public void testDateTime_18() {
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "America/Los_Angeles");
@@ -763,24 +787,25 @@ public class TestTypedLiterals extends TestCase {
ncal.set(Calendar.MILLISECOND, 0);
// System.err.println("cal is: "+ncal);
Literal l1 = m.createTypedLiteral(ncal);
- assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype());
- assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass());
- assertEquals("DateTime from date", "2004-03-21T20:50:42Z", l1.getValue().toString());
+ assertEquals(XSDDatatype.XSDdateTime, l1.getDatatype(), "DateTime from date");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "DateTime from date");
+ assertEquals("2004-03-21T20:50:42Z", l1.getValue().toString(), "DateTime from date");
// System.err.println("date is: "+ncal.getTime());
ncal = new GregorianCalendar(pdt);
ncal.set(2004, 03, 21, 12, 50, 42);// within daylight savings time
ncal.set(Calendar.MILLISECOND, 0);
// System.err.println("cal is: "+ncal);
l1 = m.createTypedLiteral(ncal);
- assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype());
- assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass());
- assertEquals("DateTime from date", "2004-04-21T19:50:42Z", l1.getValue().toString());
+ assertEquals(XSDDatatype.XSDdateTime, l1.getDatatype(), "DateTime from date");
+ assertEquals(XSDDateTime.class, l1.getValue().getClass(), "DateTime from date");
+ assertEquals("2004-04-21T19:50:42Z", l1.getValue().toString(), "DateTime from date");
// System.err.println("date is: "+ncal.getTime());
}
/**
* Test query applied to graphs containing typed values
*/
+ @Test
public void testTypedContains() {
Model model = ModelFactory.createModelSameValue();
Property p = model.createProperty("urn:x-eg/p");
@@ -798,6 +823,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Test the isValidLiteral machinery
*/
+ @Test
public void testIsValidLiteral() {
Literal l = m.createTypedLiteral("1000", XSDDatatype.XSDinteger);
LiteralLabel ll = l.asNode().getLiteral();
@@ -863,11 +889,13 @@ public class TestTypedLiterals extends TestCase {
}
// These should not be used in data but we test they don't crash anything.
+ @Test
public void testIsValidLiteral1() {
Literal lit = m.createTypedLiteral("100", XSDDatatype.XSD + "#anyType");
assertFalse(XSDDatatype.XSDinteger.isValidLiteral(lit.asNode().getLiteral()));
}
+ @Test
public void testIsValidLiteral2() {
Literal lit = m.createTypedLiteral("100", XSDDatatype.XSD + "#anySimpleType");
assertFalse(XSDDatatype.XSDinteger.isValidLiteral(lit.asNode().getLiteral()));
@@ -878,96 +906,103 @@ public class TestTypedLiterals extends TestCase {
/**
* Test binary types base64 and hexbinary
*/
+ @Test
public void testBinary1() {
// Check byte[] maps onto a binary type - specifically base64Binary.
byte[] data = new byte[]{12, 42, 99};
Literal l = m.createTypedLiteral(data);
LiteralLabel ll = l.asNode().getLiteral();
- assertTrue("binary test 1", ll.getDatatype() instanceof XSDbinary);
+ assertTrue(ll.getDatatype() instanceof XSDbinary, "binary test 1");
// base64 is registered for byte[]
// hexBinary is not registered as a type for byte[]
- assertTrue("binary test 1a", ll.getDatatype() instanceof XSDbase64Binary);
- assertEquals("binary test 1b", "DCpj", ll.getLexicalForm());
+ assertTrue(ll.getDatatype() instanceof XSDbase64Binary, "binary test 1a");
+ assertEquals("DCpj", ll.getLexicalForm(), "binary test 1b");
}
+ @Test
public void testBinary2() {
// Check round tripping from value
LiteralLabel l2 = m.createTypedLiteral("DCpj", XSDDatatype.XSDbase64Binary).asNode().getLiteral();
Object data2 = l2.getValue();
- assertTrue("binary test 3", data2 instanceof byte[]);
+ assertTrue(data2 instanceof byte[], "binary test 3");
byte[] data2b = (byte[])data2;
- assertEquals("binary test 4", data2b[0], data[0]);
- assertEquals("binary test 5", data2b[1], data[1]);
- assertEquals("binary test 6", data2b[2], data[2]);
+ assertEquals(data2b[0], data[0], "binary test 4");
+ assertEquals(data2b[1], data[1], "binary test 5");
+ assertEquals(data2b[2], data[2], "binary test 6");
}
+ @Test
public void testBinary3() {
// Check hexBinary
Literal l = m.createTypedLiteral(data, XSDDatatype.XSDhexBinary);
LiteralLabel ll = l.asNode().getLiteral();
- assertEquals("binary test 1b", ll.getDatatype(), XSDDatatype.XSDhexBinary);
- assertEquals("binary test 2b", Hex.encodeHexString(data, false), ll.getLexicalForm());
+ assertEquals(ll.getDatatype(), XSDDatatype.XSDhexBinary, "binary test 1b");
+ assertEquals(Hex.encodeHexString(data, false), ll.getLexicalForm(), "binary test 2b");
// Check round tripping from value
LiteralLabel l2 = m.createTypedLiteral(ll.getLexicalForm(), XSDDatatype.XSDhexBinary).asNode().getLiteral();
Object data2 = l2.getValue();
- assertTrue("binary test 3b", data2 instanceof byte[]);
+ assertTrue(data2 instanceof byte[], "binary test 3b");
byte[] data2b = ((byte[])data2);
- assertEquals("binary test 4b", data2b[0], data[0]);
- assertEquals("binary test 5b", data2b[1], data[1]);
- assertEquals("binary test 6b", data2b[2], data[2]);
+ assertEquals(data2b[0], data[0], "binary test 4b");
+ assertEquals(data2b[1], data[1], "binary test 5b");
+ assertEquals(data2b[2], data[2], "binary test 6b");
assertEquals(l2, ll);
}
+ @Test
public void testBinary4() {
Literal la = m.createTypedLiteral("GpM7", XSDDatatype.XSDbase64Binary);
Literal lb = m.createTypedLiteral("GpM7", XSDDatatype.XSDbase64Binary);
la.sameValueAs(lb);
- assertTrue("equality test", la.sameValueAs(lb));
+ assertTrue(la.sameValueAs(lb), "equality test");
data = new byte[]{15, (byte)0xB7};
Literal l = m.createTypedLiteral(data, XSDDatatype.XSDhexBinary);
- assertEquals("hexBinary encoding", "0FB7", l.getLexicalForm());
+ assertEquals("0FB7", l.getLexicalForm(), "hexBinary encoding");
}
+ @Test
public void testBinaryIndexing1() {
Literal x1 = m.createTypedLiteral("", XSDDatatype.XSDbase64Binary);
Literal x2 = m.createTypedLiteral("", XSDDatatype.XSDbase64Binary);
- assertEquals("base64Binary indexing hashCode", x1.asNode().getIndexingValue().hashCode(),
- x2.asNode().getIndexingValue().hashCode());
- assertEquals("base64Binary indexing", x1.asNode().getIndexingValue(), x2.asNode().getIndexingValue());
+ assertEquals(x1.asNode().getIndexingValue().hashCode(), x2.asNode().getIndexingValue().hashCode(), "base64Binary indexing hashCode");
+ assertEquals(x1.asNode().getIndexingValue(), x2.asNode().getIndexingValue(), "base64Binary indexing");
}
+ @Test
public void testBinaryIndexing2() {
Literal x1 = m.createTypedLiteral("GpM7", XSDDatatype.XSDbase64Binary);
Literal x2 = m.createTypedLiteral("GpM7", XSDDatatype.XSDbase64Binary);
- assertEquals("base64Binary indexing hashCode", x1.asNode().getIndexingValue().hashCode(),
- x2.asNode().getIndexingValue().hashCode());
- assertEquals("base64Binary indexing", x1.asNode().getIndexingValue(), x2.asNode().getIndexingValue());
+ assertEquals(x1.asNode().getIndexingValue().hashCode(), x2.asNode().getIndexingValue().hashCode(), "base64Binary indexing hashCode");
+ assertEquals(x1.asNode().getIndexingValue(), x2.asNode().getIndexingValue(), "base64Binary indexing");
}
+ @Test
public void testBinaryIndexing3() {
Literal x1 = m.createTypedLiteral("", XSDDatatype.XSDhexBinary);
Literal x2 = m.createTypedLiteral("", XSDDatatype.XSDhexBinary);
- assertEquals("hexBinary indexing hashCode", x1.asNode().getIndexingValue().hashCode(), x2.asNode().getIndexingValue().hashCode());
- assertEquals("hexBinary indexing", x1.asNode().getIndexingValue(), x2.asNode().getIndexingValue());
+ assertEquals(x1.asNode().getIndexingValue().hashCode(), x2.asNode().getIndexingValue().hashCode(), "hexBinary indexing hashCode");
+ assertEquals(x1.asNode().getIndexingValue(), x2.asNode().getIndexingValue(), "hexBinary indexing");
}
+ @Test
public void testBinaryIndexing4() {
Literal x1 = m.createTypedLiteral("AABB", XSDDatatype.XSDhexBinary);
Literal x2 = m.createTypedLiteral("AABB", XSDDatatype.XSDhexBinary);
- assertEquals("hexBinary indexing hashCode", x1.asNode().getIndexingValue().hashCode(), x2.asNode().getIndexingValue().hashCode());
- assertEquals("hexBinary indexing", x1.asNode().getIndexingValue(), x2.asNode().getIndexingValue());
+ assertEquals(x1.asNode().getIndexingValue().hashCode(), x2.asNode().getIndexingValue().hashCode(), "hexBinary indexing hashCode");
+ assertEquals(x1.asNode().getIndexingValue(), x2.asNode().getIndexingValue(), "hexBinary indexing");
}
/**
* Test that XSD anyURI is not sameValueAs XSD string (Xerces returns a string as
* the value for both)
*/
+ @Test
public void testXSDanyURI() {
Node node1 = NodeFactory.createLiteralDT("http://example/", XSDDatatype.XSDanyURI);
Node node2 = NodeFactory.createLiteralDT("http://example/", XSDDatatype.XSDstring);
@@ -977,15 +1012,17 @@ public class TestTypedLiterals extends TestCase {
/**
* Test a user error report concerning date/time literals from JENA-1503
*/
+ @Test
public void testDateTimeBug3() {
final String testLex = "-0001-02-03T04:05:06";
Node n = NodeFactory.createLiteralDT(testLex, XSDDatatype.XSDdateTime);
- assertEquals("Got wrong XSDDateTime representation!", testLex, n.getLiteralValue().toString());
+ assertEquals(testLex, n.getLiteralValue().toString(), "Got wrong XSDDateTime representation!");
}
/**
* Test a user error report concerning date/time literals
*/
+ @Test
public void testDateTimeBug() {
// Bug in serialization
String XSDDateURI = XSD.date.getURI();
@@ -1030,6 +1067,7 @@ public class TestTypedLiterals extends TestCase {
return date;
}
+ @Test
public void testDateTimeBug2() throws Exception {
String[] timezonelist = {"GMT", "America/New_York", "America/Chicago",};
@@ -1056,7 +1094,7 @@ public class TestTypedLiterals extends TestCase {
int xhr = xdt.getHours();
int dhr = cal.get(Calendar.HOUR_OF_DAY);
int dif = (xhr - dhr + offset) % 24;
- Assert.assertEquals("Difference between cal and xdt", 0, dif);
+ assertEquals(0, dif, "Difference between cal and xdt");
// //System.out.println("xhr="+xhr+",dhr="+dhr+",dif="+dif);
// System.out.println(""
@@ -1073,6 +1111,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Test global parameter flags.
*/
+ @Test
public void testFlags() {
boolean originalFlag = JenaParameters.enableEagerLiteralValidation;
JenaParameters.enableEagerLiteralValidation = true;
@@ -1083,7 +1122,7 @@ public class TestTypedLiterals extends TestCase {
foundException = true;
}
JenaParameters.enableEagerLiteralValidation = originalFlag;
- assertTrue("Early datatype format exception", foundException);
+ assertTrue(foundException, "Early datatype format exception");
JenaParameters.enableEagerLiteralValidation = false;
foundException = false;
@@ -1092,7 +1131,7 @@ public class TestTypedLiterals extends TestCase {
l = m.createTypedLiteral("fool", XSDDatatype.XSDint);
} catch (DatatypeFormatException e1) {
JenaParameters.enableEagerLiteralValidation = originalFlag;
- assertTrue("Delayed datatype format validation", false);
+ assertTrue(false, "Delayed datatype format validation");
}
try {
l.getValue();
@@ -1100,20 +1139,21 @@ public class TestTypedLiterals extends TestCase {
foundException = true;
}
JenaParameters.enableEagerLiteralValidation = originalFlag;
- assertTrue("Early datatype format exception", foundException);
+ assertTrue(foundException, "Early datatype format exception");
}
/**
* Test that equality function takes lexical distinction into account.
*/
+ @Test
public void testLexicalDistinction() {
Literal l1 = m.createTypedLiteral("3.0", XSDDatatype.XSDdecimal);
Literal l2 = m.createTypedLiteral("3.00", XSDDatatype.XSDdecimal);
Literal l3 = m.createTypedLiteral("3.0", XSDDatatype.XSDdecimal);
assertSameValueAs("lexical form does not affect value", l1, l2);
assertSameValueAs("lexical form does not affect value", l3, l2);
- assertTrue("lexical form affects equality", !l1.equals(l2));
- assertTrue("lexical form affects equality", l1.equals(l3));
+ assertTrue(!l1.equals(l2), "lexical form affects equality");
+ assertTrue(l1.equals(l3), "lexical form affects equality");
// This version will become illegal in the future and will be removed then
l1 = m.createTypedLiteral("3", XSDDatatype.XSDint);
@@ -1121,13 +1161,14 @@ public class TestTypedLiterals extends TestCase {
l3 = m.createTypedLiteral("3", XSDDatatype.XSDint);
assertSameValueAs("lexical form does not affect value", l1, l2);
assertSameValueAs("lexical form does not affect value", l3, l2);
- assertTrue("lexical form affects equality", !l1.equals(l2));
- assertTrue("lexical form affects equality", l1.equals(l3));
+ assertTrue(!l1.equals(l2), "lexical form affects equality");
+ assertTrue(l1.equals(l3), "lexical form affects equality");
}
/**
* Test parse/unparse pairing for problem datatypes
*/
+ @Test
public void testRoundTrip() {
// Prior problem cases with unparsing
doTestRoundTrip("13:20:00.000", XSDDatatype.XSDtime, false);
@@ -1161,17 +1202,18 @@ public class TestTypedLiterals extends TestCase {
Literal l1 = m.createTypedLiteral(lex, dt);
Object o1 = l1.getValue();
Literal l2 = m.createTypedLiteral(o1);
- assertTrue("value round trip", l1.sameValueAs(l2));
+ assertTrue(l1.sameValueAs(l2), "value round trip");
Object o2 = l2.getValue();
- assertTrue("value round trip2", o1.equals(o2));
+ assertTrue(o1.equals(o2), "value round trip2");
if ( testType ) {
- assertEquals("Datatype round trip", dt, l2.getDatatype());
+ assertEquals(dt, l2.getDatatype(), "Datatype round trip");
}
}
/**
* Test ability to override an apparent DateTime to be just a date
*/
+ @Test
public void testDateOverride() {
Calendar date = new GregorianCalendar(2007, 3, 4);
date.setTimeZone(TimeZone.getTimeZone("GMT+0"));
@@ -1186,21 +1228,21 @@ public class TestTypedLiterals extends TestCase {
* Test that two objects are not semantically the same
*/
private void assertDiffer(String title, Literal x, Literal y) {
- assertTrue(title, !x.sameValueAs(y));
+ assertTrue(!x.sameValueAs(y), title);
}
/**
* Test that two objects are semantically the same
*/
private void assertSameValueAs(String title, Literal x, Literal y) {
- assertTrue(title, x.sameValueAs(y));
+ assertTrue(x.sameValueAs(y), title);
}
/**
* Test two doubles are equal to within 0.001
*/
private void assertFloatEquals(String title, double x, double y) {
- assertTrue(title, Math.abs(x - y) < 0.001);
+ assertTrue(Math.abs(x - y) < 0.001, title);
}
/**
@@ -1210,7 +1252,7 @@ public class TestTypedLiterals extends TestCase {
try {
Literal l = m.createTypedLiteral(lex, dtype);
l.getValue();
- assertTrue("Failed to catch '" + lex + "' as an illegal " + dtype, false);
+ assertTrue(false, "Failed to catch '" + lex + "' as an illegal " + dtype);
} catch (DatatypeFormatException e1) {
// OK this is what we expected
}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/AbstractTestPrefixMapping.java b/jena-core/src/test/java/org/apache/jena/graph/compose/AbstractTestPrefixMapping.java
index 32d874b061..23238ed71c 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/compose/AbstractTestPrefixMapping.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/AbstractTestPrefixMapping.java
@@ -21,11 +21,14 @@
package org.apache.jena.graph.compose;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
import org.apache.jena.shared.PrefixMapping;
import org.apache.jena.test.JenaTestLib;
@@ -34,10 +37,7 @@ import org.apache.jena.test.JenaTestLib;
* prefixMapping to be tested.
*/
-public abstract class AbstractTestPrefixMapping extends TestCase {
- public AbstractTestPrefixMapping(String name) {
- super(name);
- }
+public abstract class AbstractTestPrefixMapping {
/**
* Subclasses implement to return a new, empty prefixMapping of their preferred
@@ -52,14 +52,17 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
/**
* The empty prefix is specifically allowed [for the default namespace].
*/
+ @Test
public void testEmptyPrefix() {
addGetTest("", crispURI);
}
+ @Test
public void testStrPrefix1() {
addGetTest("abc", "http://example/");
}
+ @Test
public void testStrPrefix2() {
// U+1F607 - smiling face with halo
String prefix = new String(Character.toChars(0x1F607));
@@ -77,6 +80,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
/**
* Test that various illegal names are trapped.
*/
+ @Test
public void testCheckNames() {
PrefixMapping ns = getMapping();
for ( String bad : badNames ) {
@@ -89,6 +93,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
}
}
+ @Test
public void testNullURITrapped() {
try {
getMapping().setNsPrefix("xy", null);
@@ -102,24 +107,25 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
* test that a PrefixMapping maps names to URIs. The names and URIs are all fully
* distinct - overlapping names/uris are dealt with in other tests.
*/
+ @Test
public void testPrefixMappingMapping() {
String toast = "ftp://ftp.nowhere.not/";
JenaTestLib.assertDiffer("crisp and toast must differ", crispURI, toast);
/* */
PrefixMapping ns = getMapping();
- assertEquals("crisp should be unset", null, ns.getNsPrefixURI("crisp"));
- assertEquals("toast should be unset", null, ns.getNsPrefixURI("toast"));
- assertEquals("butter should be unset", null, ns.getNsPrefixURI("butter"));
+ assertEquals(null, ns.getNsPrefixURI("crisp"), "crisp should be unset");
+ assertEquals(null, ns.getNsPrefixURI("toast"), "toast should be unset");
+ assertEquals(null, ns.getNsPrefixURI("butter"), "butter should be unset");
/* */
ns.setNsPrefix("crisp", crispURI);
- assertEquals("crisp should be set", crispURI, ns.getNsPrefixURI("crisp"));
- assertEquals("toast should still be unset", null, ns.getNsPrefixURI("toast"));
- assertEquals("butter should still be unset", null, ns.getNsPrefixURI("butter"));
+ assertEquals(crispURI, ns.getNsPrefixURI("crisp"), "crisp should be set");
+ assertEquals(null, ns.getNsPrefixURI("toast"), "toast should still be unset");
+ assertEquals(null, ns.getNsPrefixURI("butter"), "butter should still be unset");
/* */
ns.setNsPrefix("toast", toast);
- assertEquals("crisp should be set", crispURI, ns.getNsPrefixURI("crisp"));
- assertEquals("toast should be set", toast, ns.getNsPrefixURI("toast"));
- assertEquals("butter should still be unset", null, ns.getNsPrefixURI("butter"));
+ assertEquals(crispURI, ns.getNsPrefixURI("crisp"), "crisp should be set");
+ assertEquals(toast, ns.getNsPrefixURI("toast"), "toast should be set");
+ assertEquals(null, ns.getNsPrefixURI("butter"), "butter should still be unset");
}
/**
@@ -127,6 +133,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
* uriB is a prefix of uriA to try and ensure that the ordering of the map
* doesn't matter.
*/
+ @Test
public void testReversePrefixMapping() {
PrefixMapping ns = getMapping();
String uriA = "http://jena.hpl.hp.com/A#", uriB = "http://jena.hpl.hp.com/";
@@ -141,10 +148,11 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
/**
* test that we can extract a proper Map from a PrefixMapping
*/
+ @Test
public void testPrefixMappingMap() {
PrefixMapping ns = getCrispyRope();
Map<String, String> map = ns.getNsPrefixMap();
- assertEquals("map should have two elements", 2, map.size());
+ assertEquals(2, map.size(), "map should have two elements");
assertEquals(crispURI, map.get("crisp"));
assertEquals("scheme:rope/string#", map.get("rope"));
}
@@ -153,6 +161,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
* test that the Map returned by getNsPrefixMap does not alias (parts of) the
* secret internal map of the PrefixMapping
*/
+ @Test
public void testPrefixMappingSecret() {
PrefixMapping ns = getCrispyRope();
Map<String, String> map = ns.getNsPrefixMap();
@@ -190,20 +199,22 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
static final String[][] expansions = {{"crisp:pathPart", crispURI + "pathPart"}, {"rope:partPath", ropeURI + "partPath"},
{"crisp:path:part", crispURI + "path:part"},};
+ @Test
public void testExpandPrefix() {
PrefixMapping ns = getMapping();
ns.setNsPrefix("crisp", crispURI);
ns.setNsPrefix("rope", ropeURI);
/* */
for ( String aDontChange : dontChange ) {
- assertEquals("should be unchanged", aDontChange, ns.expandPrefix(aDontChange));
+ assertEquals(aDontChange, ns.expandPrefix(aDontChange), "should be unchanged");
}
/* */
for ( String[] expansion : expansions ) {
- assertEquals("should expand correctly", expansion[1], ns.expandPrefix(expansion[0]));
+ assertEquals(expansion[1], ns.expandPrefix(expansion[0]), "should expand correctly");
}
}
+ @Test
public void testUseEasyPrefix() {
testUseEasyPrefix("prefix mapping impl", getMapping());
testShortForm("prefix mapping impl", getMapping());
@@ -216,12 +227,13 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
public static void testShortForm(String title, PrefixMapping ns) {
ns.setNsPrefix("crisp", crispURI);
ns.setNsPrefix("butter", butterURI);
- assertEquals(title, "", ns.shortForm(""));
- assertEquals(title, ropeURI, ns.shortForm(ropeURI));
- assertEquals(title, "crisp:tail", ns.shortForm(crispURI + "tail"));
- assertEquals(title, "butter:here:we:are", ns.shortForm(butterURI + "here:we:are"));
+ assertEquals("", ns.shortForm(""), title);
+ assertEquals(ropeURI, ns.shortForm(ropeURI), title);
+ assertEquals("crisp:tail", ns.shortForm(crispURI + "tail"), title);
+ assertEquals("butter:here:we:are", ns.shortForm(butterURI + "here:we:are"), title);
}
+ @Test
public void testEasyQName() {
PrefixMapping ns = getMapping();
String alphaURI = "http://seasonal.song/preamble/";
@@ -229,6 +241,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals("alpha:rowboat", ns.qnameFor(alphaURI + "rowboat"));
}
+ @Test
public void testNoQNameNoPrefix() {
PrefixMapping ns = getMapping();
String alphaURI = "http://seasonal.song/preamble/";
@@ -236,6 +249,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals(null, ns.qnameFor("eg:rowboat"));
}
+ @Test
public void testNoQNameBadLocal() {
PrefixMapping ns = getMapping();
String alphaURI = "http://seasonal.song/preamble/";
@@ -247,6 +261,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
* The tests implied by the email where Chris suggested adding qnameFor;
* shortForm generates illegal qnames but qnameFor does not.
*/
+ @Test
public void testQnameFromEmail() {
String uri = "http://some.long.uri/for/a/namespace#";
PrefixMapping ns = getMapping();
@@ -259,10 +274,11 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
* test that we can add the maplets from another PrefixMapping without losing our
* own.
*/
+ @Test
public void testAddOtherPrefixMapping() {
PrefixMapping a = getMapping();
PrefixMapping b = getMapping();
- assertFalse("must have two diffferent maps", a == b);
+ assertFalse(a == b, "must have two diffferent maps");
a.setNsPrefix("crisp", crispURI);
a.setNsPrefix("rope", ropeURI);
b.setNsPrefix("butter", butterURI);
@@ -281,6 +297,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
/**
* as for testAddOtherPrefixMapping, except that it's a plain Map we're adding.
*/
+ @Test
public void testAddMap() {
PrefixMapping b = getMapping();
Map<String, String> map = new HashMap<>();
@@ -291,6 +308,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
checkContainsMapping(b);
}
+ @Test
public void testAddDefaultMap() {
PrefixMapping pm = getMapping();
PrefixMapping root = PrefixMapping.Factory.create();
@@ -306,6 +324,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals("cootle:", pm.getNsPrefixURI("c"));
}
+ @Test
public void testSecondPrefixRetainsExistingMap() {
PrefixMapping A = getMapping();
A.setNsPrefix("a", crispURI);
@@ -314,6 +333,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals(crispURI, A.getNsPrefixURI("b"));
}
+ @Test
public void testSecondPrefixReplacesReverseMap() {
PrefixMapping A = getMapping();
A.setNsPrefix("a", crispURI);
@@ -321,6 +341,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals("b", A.getNsURIPrefix(crispURI));
}
+ @Test
public void testSecondPrefixDeletedUncoversPreviousMap() {
PrefixMapping A = getMapping();
A.setNsPrefix("x", crispURI);
@@ -332,6 +353,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
/**
* Test that the empty prefix does not wipe an existing prefix for the same URI.
*/
+ @Test
public void testEmptyDoesNotWipeURI() {
PrefixMapping pm = getMapping();
pm.setNsPrefix("frodo", ropeURI);
@@ -343,6 +365,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
* Test that adding a new prefix mapping for U does not throw away a default
* mapping for U.
*/
+ @Test
public void testSameURIKeepsDefault() {
PrefixMapping A = getMapping();
A.setNsPrefix("", crispURI);
@@ -350,6 +373,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals(crispURI, A.getNsPrefixURI(""));
}
+ @Test
public void testReturnsSelf() {
PrefixMapping A = getMapping();
assertSame(A, A.setNsPrefix("crisp", crispURI));
@@ -358,6 +382,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertSame(A, A.removeNsPrefix("rhubarb"));
}
+ @Test
public void testRemovePrefix() {
String hURI = "http://test.remove.prefixes/prefix#";
String bURI = "http://other.test.remove.prefixes/prefix#";
@@ -369,6 +394,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals(bURI, A.getNsPrefixURI("br"));
}
+ @Test
public void testClear() {
String hURI = "http://test.remove.prefixes/prefix#";
String bURI = "http://other.test.remove.prefixes/prefix#";
@@ -384,6 +410,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals(null, A.getNsURIPrefix(bURI));
}
+ @Test
public void testNoMapping() {
String hURI = "http://test.prefixes/prefix#";
PrefixMapping A = getMapping();
@@ -392,6 +419,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertFalse(A.hasNoMappings());
}
+ @Test
public void testNumPrefixes() {
String hURI = "http://test.prefixes/prefix#";
PrefixMapping A = getMapping();
@@ -400,6 +428,7 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
assertEquals(1, A.numPrefixes());
}
+ @Test
public void testEquality() {
testEquals("");
testEquals("", "x=a", false);
@@ -427,8 +456,8 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
fill(A, S);
fill(B, T);
String title = "usual: '" + S + "', testing: '" + T + "', should be " + (expected ? "equal" : "different");
- assertEquals(title, expected, A.samePrefixMappingAs(B));
- assertEquals(title, expected, B.samePrefixMappingAs(A));
+ assertEquals(expected, A.samePrefixMappingAs(B), title);
+ assertEquals(expected, B.samePrefixMappingAs(A), title);
}
protected void fill(PrefixMapping pm, String settings) {
@@ -440,10 +469,12 @@ public abstract class AbstractTestPrefixMapping extends TestCase {
}
// we now allow namespaces to end with non-punctuational characters
+ @Test
public void testAllowNastyNamespace() {
getMapping().setNsPrefix("abc", "def");
}
+ @Test
public void testLock() {
PrefixMapping A = getMapping();
assertSame(A, A.lock());
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/AbstractTestPrefixMapping_JU6.java b/jena-core/src/test/java/org/apache/jena/graph/compose/AbstractTestPrefixMapping_JU6.java
deleted file mode 100644
index 243b1093ea..0000000000
--- a/jena-core/src/test/java/org/apache/jena/graph/compose/AbstractTestPrefixMapping_JU6.java
+++ /dev/null
@@ -1,510 +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.graph.compose;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.jena.shared.PrefixMapping;
-import org.apache.jena.test.JenaTestLib;
-
-/**
- * Test prefix mappings - subclass this test and override getMapping() to deliver the
- * prefixMapping to be tested.
- */
-
-public abstract class AbstractTestPrefixMapping_JU6 {
-
- /**
- * Subclasses implement to return a new, empty prefixMapping of their preferred
- * kind.
- */
- abstract protected PrefixMapping getMapping();
-
- static final String crispURI = "http://crisp.nosuch.net/";
- static final String ropeURI = "scheme:rope/string#";
- static final String butterURI = "ftp://ftp.nowhere.at.all/cream#";
-
- /**
- * The empty prefix is specifically allowed [for the default namespace].
- */
- @Test
- public void testEmptyPrefix() {
- addGetTest("", crispURI);
- }
-
- @Test
- public void testStrPrefix1() {
- addGetTest("abc", "http://example/");
- }
-
- @Test
- public void testStrPrefix2() {
- // U+1F607 - smiling face with halo
- String prefix = new String(Character.toChars(0x1F607));
- addGetTest(prefix, "http://example/");
- }
-
- private void addGetTest(String prefix, String uri) {
- PrefixMapping pmap = getMapping();
- pmap.setNsPrefix(prefix, uri);
- assertEquals(uri, pmap.getNsPrefixURI(prefix));
- }
-
- static final String[] badNames = {"<hello>", "foo:bar", "with a space", "-argument"};
-
- /**
- * Test that various illegal names are trapped.
- */
- @Test
- public void testCheckNames() {
- PrefixMapping ns = getMapping();
- for ( String bad : badNames ) {
- try {
- ns.setNsPrefix(bad, crispURI);
- fail("'" + bad + "' is an illegal prefix and should be trapped");
- } catch (PrefixMapping.IllegalPrefixException e) {
- JenaTestLib.pass();
- }
- }
- }
-
- @Test
- public void testNullURITrapped() {
- try {
- getMapping().setNsPrefix("xy", null);
- fail("should trap null URI in setNsPrefix");
- } catch (NullPointerException e) {
- JenaTestLib.pass();
- }
- }
-
- /**
- * test that a PrefixMapping maps names to URIs. The names and URIs are all fully
- * distinct - overlapping names/uris are dealt with in other tests.
- */
- @Test
- public void testPrefixMappingMapping() {
- String toast = "ftp://ftp.nowhere.not/";
- JenaTestLib.assertDiffer("crisp and toast must differ", crispURI, toast);
- /* */
- PrefixMapping ns = getMapping();
- assertEquals(null, ns.getNsPrefixURI("crisp"), "crisp should be unset");
- assertEquals(null, ns.getNsPrefixURI("toast"), "toast should be unset");
- assertEquals(null, ns.getNsPrefixURI("butter"), "butter should be unset");
- /* */
- ns.setNsPrefix("crisp", crispURI);
- assertEquals(crispURI, ns.getNsPrefixURI("crisp"), "crisp should be set");
- assertEquals(null, ns.getNsPrefixURI("toast"), "toast should still be unset");
- assertEquals(null, ns.getNsPrefixURI("butter"), "butter should still be unset");
- /* */
- ns.setNsPrefix("toast", toast);
- assertEquals(crispURI, ns.getNsPrefixURI("crisp"), "crisp should be set");
- assertEquals(toast, ns.getNsPrefixURI("toast"), "toast should be set");
- assertEquals(null, ns.getNsPrefixURI("butter"), "butter should still be unset");
- }
-
- /**
- * Test that we can run the prefix mapping in reverse - from URIs to prefixes.
- * uriB is a prefix of uriA to try and ensure that the ordering of the map
- * doesn't matter.
- */
- @Test
- public void testReversePrefixMapping() {
- PrefixMapping ns = getMapping();
- String uriA = "http://jena.hpl.hp.com/A#", uriB = "http://jena.hpl.hp.com/";
- String uriC = "http://jena.hpl.hp.com/Csharp/";
- String prefixA = "aa", prefixB = "bb";
- ns.setNsPrefix(prefixA, uriA).setNsPrefix(prefixB, uriB);
- assertEquals(null, ns.getNsURIPrefix(uriC));
- assertEquals(prefixA, ns.getNsURIPrefix(uriA));
- assertEquals(prefixB, ns.getNsURIPrefix(uriB));
- }
-
- /**
- * test that we can extract a proper Map from a PrefixMapping
- */
- @Test
- public void testPrefixMappingMap() {
- PrefixMapping ns = getCrispyRope();
- Map<String, String> map = ns.getNsPrefixMap();
- assertEquals(2, map.size(), "map should have two elements");
- assertEquals(crispURI, map.get("crisp"));
- assertEquals("scheme:rope/string#", map.get("rope"));
- }
-
- /**
- * test that the Map returned by getNsPrefixMap does not alias (parts of) the
- * secret internal map of the PrefixMapping
- */
- @Test
- public void testPrefixMappingSecret() {
- PrefixMapping ns = getCrispyRope();
- Map<String, String> map = ns.getNsPrefixMap();
- // The map may be unmodifiable in which case put throws
- // UnsupportedOperationException
- try {
- map.put("crisp", "with/onions");
- map.put("sandwich", "with/cheese");
- } catch (UnsupportedOperationException ex) {}
-
- assertEquals(crispURI, ns.getNsPrefixURI("crisp"));
- assertEquals(ropeURI, ns.getNsPrefixURI("rope"));
- assertEquals(null, ns.getNsPrefixURI("sandwich"));
- }
-
- private PrefixMapping getCrispyRope() {
- PrefixMapping ns = getMapping();
- ns.setNsPrefix("crisp", crispURI);
- ns.setNsPrefix("rope", ropeURI);
- return ns;
- }
-
- /**
- * these are strings that should not change when they are prefix-expanded with
- * crisp and rope as legal prefixes.
- */
- static final String[] dontChange = {"", "http://www.somedomain.something/whatever#", "crispy:cabbage", "cris:isOnInfiniteEarths",
- "rop:tangled/web", "roped:abseiling"};
-
- /**
- * these are the required mappings which the test cases below should satisfy: an
- * array of 2-arrays, where element 0 is the string to expand and element 1 is
- * the string it should expand to.
- */
- static final String[][] expansions = {{"crisp:pathPart", crispURI + "pathPart"}, {"rope:partPath", ropeURI + "partPath"},
- {"crisp:path:part", crispURI + "path:part"},};
-
- @Test
- public void testExpandPrefix() {
- PrefixMapping ns = getMapping();
- ns.setNsPrefix("crisp", crispURI);
- ns.setNsPrefix("rope", ropeURI);
- /* */
- for ( String aDontChange : dontChange ) {
- assertEquals(aDontChange, ns.expandPrefix(aDontChange), "should be unchanged");
- }
- /* */
- for ( String[] expansion : expansions ) {
- assertEquals(expansion[1], ns.expandPrefix(expansion[0]), "should expand correctly");
- }
- }
-
- @Test
- public void testUseEasyPrefix() {
- testUseEasyPrefix("prefix mapping impl", getMapping());
- testShortForm("prefix mapping impl", getMapping());
- }
-
- public static void testUseEasyPrefix(String title, PrefixMapping ns) {
- testShortForm(title, ns);
- }
-
- public static void testShortForm(String title, PrefixMapping ns) {
- ns.setNsPrefix("crisp", crispURI);
- ns.setNsPrefix("butter", butterURI);
- assertEquals("", ns.shortForm(""), title);
- assertEquals(ropeURI, ns.shortForm(ropeURI), title);
- assertEquals("crisp:tail", ns.shortForm(crispURI + "tail"), title);
- assertEquals("butter:here:we:are", ns.shortForm(butterURI + "here:we:are"), title);
- }
-
- @Test
- public void testEasyQName() {
- PrefixMapping ns = getMapping();
- String alphaURI = "http://seasonal.song/preamble/";
- ns.setNsPrefix("alpha", alphaURI);
- assertEquals("alpha:rowboat", ns.qnameFor(alphaURI + "rowboat"));
- }
-
- @Test
- public void testNoQNameNoPrefix() {
- PrefixMapping ns = getMapping();
- String alphaURI = "http://seasonal.song/preamble/";
- ns.setNsPrefix("alpha", alphaURI);
- assertEquals(null, ns.qnameFor("eg:rowboat"));
- }
-
- @Test
- public void testNoQNameBadLocal() {
- PrefixMapping ns = getMapping();
- String alphaURI = "http://seasonal.song/preamble/";
- ns.setNsPrefix("alpha", alphaURI);
- assertEquals(null, ns.qnameFor(alphaURI + "12345"));
- }
-
- /**
- * The tests implied by the email where Chris suggested adding qnameFor;
- * shortForm generates illegal qnames but qnameFor does not.
- */
- @Test
- public void testQnameFromEmail() {
- String uri = "http://some.long.uri/for/a/namespace#";
- PrefixMapping ns = getMapping();
- ns.setNsPrefix("x", uri);
- assertEquals(null, ns.qnameFor(uri));
- assertEquals(null, ns.qnameFor(uri + "non/fiction"));
- }
-
- /**
- * test that we can add the maplets from another PrefixMapping without losing our
- * own.
- */
- @Test
- public void testAddOtherPrefixMapping() {
- PrefixMapping a = getMapping();
- PrefixMapping b = getMapping();
- assertFalse(a == b, "must have two diffferent maps");
- a.setNsPrefix("crisp", crispURI);
- a.setNsPrefix("rope", ropeURI);
- b.setNsPrefix("butter", butterURI);
- assertEquals(null, b.getNsPrefixURI("crisp"));
- assertEquals(null, b.getNsPrefixURI("rope"));
- b.setNsPrefixes(a);
- checkContainsMapping(b);
- }
-
- private void checkContainsMapping(PrefixMapping b) {
- assertEquals(crispURI, b.getNsPrefixURI("crisp"));
- assertEquals(ropeURI, b.getNsPrefixURI("rope"));
- assertEquals(butterURI, b.getNsPrefixURI("butter"));
- }
-
- /**
- * as for testAddOtherPrefixMapping, except that it's a plain Map we're adding.
- */
- @Test
- public void testAddMap() {
- PrefixMapping b = getMapping();
- Map<String, String> map = new HashMap<>();
- map.put("crisp", crispURI);
- map.put("rope", ropeURI);
- b.setNsPrefix("butter", butterURI);
- b.setNsPrefixes(map);
- checkContainsMapping(b);
- }
-
- @Test
- public void testAddDefaultMap() {
- PrefixMapping pm = getMapping();
- PrefixMapping root = PrefixMapping.Factory.create();
- pm.setNsPrefix("a", "aPrefix:");
- pm.setNsPrefix("b", "bPrefix:");
- root.setNsPrefix("a", "pootle:");
- root.setNsPrefix("z", "bPrefix:");
- root.setNsPrefix("c", "cootle:");
- assertSame(pm, pm.withDefaultMappings(root));
- assertEquals("aPrefix:", pm.getNsPrefixURI("a"));
- assertEquals(null, pm.getNsPrefixURI("z"));
- assertEquals("bPrefix:", pm.getNsPrefixURI("b"));
- assertEquals("cootle:", pm.getNsPrefixURI("c"));
- }
-
- @Test
- public void testSecondPrefixRetainsExistingMap() {
- PrefixMapping A = getMapping();
- A.setNsPrefix("a", crispURI);
- A.setNsPrefix("b", crispURI);
- assertEquals(crispURI, A.getNsPrefixURI("a"));
- assertEquals(crispURI, A.getNsPrefixURI("b"));
- }
-
- @Test
- public void testSecondPrefixReplacesReverseMap() {
- PrefixMapping A = getMapping();
- A.setNsPrefix("a", crispURI);
- A.setNsPrefix("b", crispURI);
- assertEquals("b", A.getNsURIPrefix(crispURI));
- }
-
- @Test
- public void testSecondPrefixDeletedUncoversPreviousMap() {
- PrefixMapping A = getMapping();
- A.setNsPrefix("x", crispURI);
- A.setNsPrefix("y", crispURI);
- A.removeNsPrefix("y");
- assertEquals("x", A.getNsURIPrefix(crispURI));
- }
-
- /**
- * Test that the empty prefix does not wipe an existing prefix for the same URI.
- */
- @Test
- public void testEmptyDoesNotWipeURI() {
- PrefixMapping pm = getMapping();
- pm.setNsPrefix("frodo", ropeURI);
- pm.setNsPrefix("", ropeURI);
- assertEquals(ropeURI, pm.getNsPrefixURI("frodo"));
- }
-
- /**
- * Test that adding a new prefix mapping for U does not throw away a default
- * mapping for U.
- */
- @Test
- public void testSameURIKeepsDefault() {
- PrefixMapping A = getMapping();
- A.setNsPrefix("", crispURI);
- A.setNsPrefix("crisp", crispURI);
- assertEquals(crispURI, A.getNsPrefixURI(""));
- }
-
- @Test
- public void testReturnsSelf() {
- PrefixMapping A = getMapping();
- assertSame(A, A.setNsPrefix("crisp", crispURI));
- assertSame(A, A.setNsPrefixes(A));
- assertSame(A, A.setNsPrefixes(new HashMap<String, String>()));
- assertSame(A, A.removeNsPrefix("rhubarb"));
- }
-
- @Test
- public void testRemovePrefix() {
- String hURI = "http://test.remove.prefixes/prefix#";
- String bURI = "http://other.test.remove.prefixes/prefix#";
- PrefixMapping A = getMapping();
- A.setNsPrefix("hr", hURI);
- A.setNsPrefix("br", bURI);
- A.removeNsPrefix("hr");
- assertEquals(null, A.getNsPrefixURI("hr"));
- assertEquals(bURI, A.getNsPrefixURI("br"));
- }
-
- @Test
- public void testClear() {
- String hURI = "http://test.remove.prefixes/prefix#";
- String bURI = "http://other.test.remove.prefixes/prefix#";
- PrefixMapping A = getMapping();
- A.setNsPrefix("hr", hURI);
- A.setNsPrefix("br", bURI);
- A.clearNsPrefixMap();
-
- assertEquals(null, A.getNsPrefixURI("hr"));
- assertEquals(null, A.getNsPrefixURI("br"));
-
- assertEquals(null, A.getNsURIPrefix(hURI));
- assertEquals(null, A.getNsURIPrefix(bURI));
- }
-
- @Test
- public void testNoMapping() {
- String hURI = "http://test.prefixes/prefix#";
- PrefixMapping A = getMapping();
- assertTrue(A.hasNoMappings());
- A.setNsPrefix("hr", hURI);
- assertFalse(A.hasNoMappings());
- }
-
- @Test
- public void testNumPrefixes() {
- String hURI = "http://test.prefixes/prefix#";
- PrefixMapping A = getMapping();
- assertEquals(0, A.numPrefixes());
- A.setNsPrefix("hr", hURI);
- assertEquals(1, A.numPrefixes());
- }
-
- @Test
- public void testEquality() {
- testEquals("");
- testEquals("", "x=a", false);
- testEquals("x=a", "", false);
- testEquals("x=a");
- testEquals("x=a y=b", "y=b x=a", true);
- testEquals("x=a x=b", "x=b x=a", false);
- }
-
- protected void testEquals(String S) {
- testEquals(S, S, true);
- }
-
- protected void testEquals(String S, String T, boolean expected) {
- testEqualsBase(S, T, expected);
- testEqualsBase(T, S, expected);
- }
-
- public void testEqualsBase(String S, String T, boolean expected) {
- testEquals(S, T, expected, getMapping(), getMapping());
- testEquals(S, T, expected, PrefixMapping.Factory.create(), getMapping());
- }
-
- protected void testEquals(String S, String T, boolean expected, PrefixMapping A, PrefixMapping B) {
- fill(A, S);
- fill(B, T);
- String title = "usual: '" + S + "', testing: '" + T + "', should be " + (expected ? "equal" : "different");
- assertEquals(expected, A.samePrefixMappingAs(B), title);
- assertEquals(expected, B.samePrefixMappingAs(A), title);
- }
-
- protected void fill(PrefixMapping pm, String settings) {
- List<String> L = JenaTestLib.listOfStrings(settings);
- for ( String setting : L ) {
- int eq = setting.indexOf('=');
- pm.setNsPrefix(setting.substring(0, eq), setting.substring(eq + 1));
- }
- }
-
- // we now allow namespaces to end with non-punctuational characters
- @Test
- public void testAllowNastyNamespace() {
- getMapping().setNsPrefix("abc", "def");
- }
-
- @Test
- public void testLock() {
- PrefixMapping A = getMapping();
- assertSame(A, A.lock());
- /* */
- try {
- A.setNsPrefix("crisp", crispURI);
- fail("mapping should be frozen");
- } catch (PrefixMapping.JenaLockedException e) {
- JenaTestLib.pass();
- }
- /* */
- try {
- A.setNsPrefixes(A);
- fail("mapping should be frozen");
- } catch (PrefixMapping.JenaLockedException e) {
- JenaTestLib.pass();
- }
- /* */
- try {
- A.setNsPrefixes(new HashMap<String, String>());
- fail("mapping should be frozen");
- } catch (PrefixMapping.JenaLockedException e) {
- JenaTestLib.pass();
- }
- /* */
- try {
- A.removeNsPrefix("toast");
- fail("mapping should be frozen");
- } catch (PrefixMapping.JenaLockedException e) {
- JenaTestLib.pass();
- }
- }
-}
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/TestDelta.java b/jena-core/src/test/java/org/apache/jena/graph/compose/TestDelta.java
index 8220654077..003770df04 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/compose/TestDelta.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/TestDelta.java
@@ -25,12 +25,12 @@ import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
-import org.apache.jena.graph.BaseTestGraph_JU6;
+import org.apache.jena.graph.BaseTestGraph;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.GraphTestLib;
import org.apache.jena.graph.Triple;
-public class TestDelta extends BaseTestGraph_JU6 {
+public class TestDelta extends BaseTestGraph {
private static final String DEFAULT_TRIPLES = "x R y; p S q";
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/TestDyadic.java b/jena-core/src/test/java/org/apache/jena/graph/compose/TestDyadic.java
index cd0fd3e695..881637c30a 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/compose/TestDyadic.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/TestDyadic.java
@@ -27,14 +27,14 @@ import org.junit.jupiter.api.Test;
import java.util.StringTokenizer;
-import org.apache.jena.graph.BaseTestGraph_JU6;
+import org.apache.jena.graph.BaseTestGraph;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.GraphMemFactory;
import org.apache.jena.graph.Triple;
import org.apache.jena.util.iterator.ExtendedIterator;
import org.apache.jena.util.iterator.NiceIterator;
-public abstract class TestDyadic extends BaseTestGraph_JU6 {
+public abstract class TestDyadic extends BaseTestGraph {
static private ExtendedIterator<String> things(final String x) {
return new NiceIterator<String>() {
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/TestMultiUnion.java b/jena-core/src/test/java/org/apache/jena/graph/compose/TestMultiUnion.java
index 27acadc03c..3346618cee 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/compose/TestMultiUnion.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/TestMultiUnion.java
@@ -34,7 +34,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.apache.jena.graph.BaseTestGraph_JU6;
+import org.apache.jena.graph.BaseTestGraph;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.GraphTestLib;
import org.apache.jena.rdf.model.Model;
@@ -45,7 +45,7 @@ import org.apache.jena.rdf.model.ModelFactory;
* Unit tests for multi-union graph.
* </p>
*/
-public class TestMultiUnion extends BaseTestGraph_JU6
+public class TestMultiUnion extends BaseTestGraph
{
// External signature methods
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/TestPolyadicPrefixMapping.java b/jena-core/src/test/java/org/apache/jena/graph/compose/TestPolyadicPrefixMapping.java
index 3ab3187818..7728ff7236 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/compose/TestPolyadicPrefixMapping.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/TestPolyadicPrefixMapping.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
import org.apache.jena.graph.*;
import org.apache.jena.shared.PrefixMapping;
-public class TestPolyadicPrefixMapping extends AbstractTestPrefixMapping_JU6 {
+public class TestPolyadicPrefixMapping extends AbstractTestPrefixMapping {
Graph gBase;
Graph g1, g2;
diff --git a/jena-core/src/test/java/org/apache/jena/memvalue/TestGraphMemModel.java b/jena-core/src/test/java/org/apache/jena/memvalue/TestGraphMemModel.java
index 5297a009ac..7f8602507b 100644
--- a/jena-core/src/test/java/org/apache/jena/memvalue/TestGraphMemModel.java
+++ b/jena-core/src/test/java/org/apache/jena/memvalue/TestGraphMemModel.java
@@ -48,7 +48,7 @@ import org.apache.jena.util.iterator.ExtendedIterator;
* Jena5+ : Only {@link GraphMemValue} supports this. Other graph are "same term", not
* "same value" and language tags are held in canonical form.
*/
-public class TestGraphMemModel extends BaseTestGraph_JU6 {
+public class TestGraphMemModel extends BaseTestGraph {
@Override
public Graph getNewGraph() {
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntGraph.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntGraph.java
index 7fa8c8aaba..5c4b05b801 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntGraph.java
@@ -21,7 +21,7 @@
package org.apache.jena.ontology.impl;
-import org.apache.jena.graph.BaseTestGraph_JU6;
+import org.apache.jena.graph.BaseTestGraph;
import org.apache.jena.graph.Graph;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.test.JenaTestLib;
@@ -31,7 +31,7 @@ import org.apache.jena.test.JenaTestLib;
via OntModel - there doesn't appear to be an OntGraph class.
*/
-public class TestOntGraph extends BaseTestGraph_JU6
+public class TestOntGraph extends BaseTestGraph
{
static { JenaTestLib.setup(); }
diff --git a/jena-core/src/test/java/org/apache/jena/graph/AbstractTestGraph.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/AbstractTestGraph.java
similarity index 97%
rename from jena-core/src/test/java/org/apache/jena/graph/AbstractTestGraph.java
rename to jena-core/src/test/java/org/apache/jena/reasoner/test/AbstractTestGraph.java
index 3fcb6600a0..934122bd6b 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/AbstractTestGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/AbstractTestGraph.java
@@ -19,12 +19,23 @@
* SPDX-License-Identifier: Apache-2.0
*/
-package org.apache.jena.graph;
+package org.apache.jena.reasoner.test;
import java.io.InputStream;
import java.util.*;
import junit.framework.TestCase;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphEventManager;
+import org.apache.jena.graph.GraphEvents;
+import org.apache.jena.graph.GraphListener;
+import org.apache.jena.graph.GraphMemFactory;
+import org.apache.jena.graph.GraphTestLib;
+import org.apache.jena.graph.GraphUtil;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.RecordingListener;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.TransactionHandler;
import org.apache.jena.junit.NodeCreateUtils;
import org.apache.jena.memvalue.TrackingTripleIterator;
import org.apache.jena.rdf.model.Model;
@@ -37,11 +48,14 @@ import org.apache.jena.util.iterator.ClosableIterator;
import org.apache.jena.util.iterator.ExtendedIterator;
/**
+ * A copy of {@code org.apache.jena.graph.AbstractTestGraph}, kept package-scope here so
+ * that {@link TestInfGraph} does not hold the JUnit 3 original in place.
+ * <p>
* AbstractTestGraph provides a bunch of basic tests for something that purports to
* be a Graph. The abstract method getGraph must be overridden in subclasses to
* deliver a Graph of interest.
*/
-public abstract class AbstractTestGraph extends TestCase {
+abstract class AbstractTestGraph extends TestCase {
public AbstractTestGraph(String name) {
super(name);
}
diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java
index 4c9f8427e1..8dece4ecd5 100644
--- a/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/TestInfGraph.java
@@ -22,7 +22,6 @@
package org.apache.jena.reasoner.test;
import junit.framework.TestSuite;
-import org.apache.jena.graph.AbstractTestGraph;
import org.apache.jena.graph.Graph;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.reasoner.InfGraph;
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
index 3db97c36e4..fb179f47b4 100644
--- 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
@@ -45,7 +45,7 @@ public class JenaCoreTestAll_JU4 extends TestCase {
// ** COMPLEX
// Generates tests.
//JU6 addTest(ts, "Enhanced", org.apache.jena.enhanced.TS3_enh.suite());
- addTest(ts, "Graph", adaptJUnit4(org.apache.jena.graph.TS3_graph.class));
+//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));
diff --git a/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU6.java b/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU6.java
index 92020ee5ff..13a9c8132c 100644
--- a/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU6.java
+++ b/jena-core/src/test/java/org/apache/jena/test/JenaCoreTestAll_JU6.java
@@ -27,6 +27,7 @@ import org.junit.platform.suite.api.Suite;
import org.apache.jena.core_ttl.tests.TS6_TestTurtle;
import org.apache.jena.datatypes.TS6_dt;
+import org.apache.jena.graph.TS6_graph;
import org.apache.jena.graph.compose.TS6_compose;
import org.apache.jena.enhanced.TS6_enh;
import org.apache.jena.irix.TS6_IRIx2;
@@ -54,6 +55,8 @@ import org.apache.jena.vocabulary.TS6_Vocabularies;
TS6_enh.class,
+ TS6_graph.class,
+
TS6_GraphMem.class,
TS6_GraphMemValue.class,