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/08/30 19:40:28 UTC
(jena) 02/02: GH-3236: Convert jena-core ontology testing to JUnit6
This is an automated email from the ASF dual-hosted git repository.
afs pushed a commit to branch convert-junit
in repository https://gitbox.apache.org/repos/asf/jena.git
commit 9531e42144f3d50cce5688b8c7553b73fb684ec8
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Sun Aug 30 16:55:45 2026 +0100
GH-3236: Convert jena-core ontology testing to JUnit6
---
.../org/apache/jena/ontology/impl/OntTestBase.java | 74 +-
.../org/apache/jena/ontology/impl/OntTestUtil.java | 129 +++
.../ontology/impl/{TS3_ont.java => TS6_ont.java} | 18 +-
.../jena/ontology/impl/TestAllDifferent.java | 44 +-
.../jena/ontology/impl/TestClassExpression.java | 866 ++++++++++-----------
.../jena/ontology/impl/TestCreateInOntModel.java | 61 +-
.../apache/jena/ontology/impl/TestFrameView.java | 138 ++--
.../apache/jena/ontology/impl/TestIndividual.java | 65 +-
.../ontology/impl/TestListSyntaxCategories.java | 62 +-
.../apache/jena/ontology/impl/TestOntClass.java | 119 +--
.../jena/ontology/impl/TestOntDocumentManager.java | 220 +++---
.../apache/jena/ontology/impl/TestOntGraph.java | 12 +-
.../apache/jena/ontology/impl/TestOntModel.java | 339 ++++----
.../jena/ontology/impl/TestOntModelSpec.java | 14 +-
.../jena/ontology/impl/TestOntReasoning.java | 85 +-
.../apache/jena/ontology/impl/TestOntResource.java | 413 +++++-----
.../apache/jena/ontology/impl/TestOntTools.java | 51 +-
.../apache/jena/ontology/impl/TestOntology.java | 80 +-
.../apache/jena/ontology/impl/TestProperty.java | 358 +++++----
.../{TS3_ModelMakers.java => TS6_ModelMakers.java} | 19 +-
.../jena/ontology/makers/TestGraphMaker.java | 83 +-
.../jena/ontology/makers/TestModelMakerImpl.java | 46 +-
.../org/apache/jena/test/JenaCoreTestAll_JU4.java | 4 +-
.../org/apache/jena/test/JenaCoreTestAll_JU6.java | 5 +
24 files changed, 1801 insertions(+), 1504 deletions(-)
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestBase.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestBase.java
index 694fe1d40b..98c7f5b3ad 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestBase.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestBase.java
@@ -19,29 +19,35 @@
* SPDX-License-Identifier: Apache-2.0
*/
-// Package
-///////////////
package org.apache.jena.ontology.impl;
+import static org.junit.jupiter.api.Assertions.*;
-// Imports
-///////////////
import java.util.*;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
-import junit.framework.*;
import org.apache.jena.ontology.*;
import org.apache.jena.rdf.model.*;
-import org.apache.jena.reasoner.test.TestUtil;
-
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
- * Generic test case for ontology unit testing
+ * Generic test case for ontology unit testing.
+ * </p>
+ * <p>
+ * JUnit6 counterpart of {@link OntTestBase}. The JUnit3 original was a
+ * {@code TestSuite} that built one {@code TestCase} per entry of
+ * {@link #getTests}; here the same array becomes one {@link DynamicTest} per
+ * entry, so the test count is unchanged. {@code OntTestCase} keeps the
+ * constructor and {@code ontTest} contract of the original, so sub-classes
+ * carry over unaltered.
* </p>
*/
@SuppressWarnings("removal")
public abstract class OntTestBase
- extends TestSuite
{
// Constants
//////////////////////////////////
@@ -49,30 +55,24 @@ public abstract class OntTestBase
public static final String BASE = "http://jena.hpl.hp.com/testing/ontology";
public static final String NS = BASE + "#";
-
- // Static variables
- //////////////////////////////////
-
- // Instance variables
- //////////////////////////////////
-
-
- // Constructors
- //////////////////////////////////
-
- public OntTestBase( String name ) {
- super( name );
- TestCase[] tc = getTests();
-
- for ( TestCase aTc : tc )
- {
- addTest( aTc );
- }
- }
+ static { JenaTestLib.setup(); }
// External signature methods
//////////////////////////////////
+ /**
+ * One dynamic test per entry of {@link #getTests}. Each entry runs the three
+ * language profiles internally, exactly as {@code OntTestCase.runTest()} did
+ * under JUnit3, so one entry remains one test.
+ */
+ @TestFactory
+ public Stream<DynamicTest> ontTests() {
+ OntTestCase[] tc = getTests();
+ if (tc == null)
+ return Stream.empty();
+ return Arrays.stream( tc )
+ .map( t -> DynamicTest.dynamicTest( t.getName(), () -> { t.setUp(); t.runTest(); } ) );
+ }
// Internal implementation methods
//////////////////////////////////
@@ -82,31 +82,34 @@ public abstract class OntTestBase
return null;
}
-
//==============================================================================
// Inner class definitions
//==============================================================================
protected abstract class OntTestCase
- extends TestCase
{
protected boolean m_inOWL;
protected boolean m_inOWLLite;
protected boolean m_inRDFS;
protected String m_langElement;
+ protected String m_name;
protected boolean m_owlLang = true;
protected boolean m_owlLiteLang = false;
protected boolean m_rdfsLang = false;
public OntTestCase( String langElement , boolean inOWL , boolean inOWLLite , boolean inRDFS ) {
- super( "Ontology API test " + langElement );
+ m_name = "Ontology API test " + langElement;
m_langElement = langElement;
m_inOWL = inOWL;
m_inOWLLite = inOWLLite;
m_inRDFS = inRDFS;
}
- @Override
+ /** The name this case ran under in the JUnit3 suite. */
+ public String getName() {
+ return m_name;
+ }
+
public void runTest()
throws Exception
{
@@ -136,7 +139,7 @@ public abstract class OntTestBase
profileEx = true;
}
- assertEquals( "language element " + m_langElement + " was " + (inModel ? "" : "not") + " expected in model " + m.getProfile().getLabel(), inModel, !profileEx );
+ assertEquals( inModel, !profileEx, "language element " + m_langElement + " was " + (inModel ? "" : "not") + " expected in model " + m.getProfile().getLabel() );
}
/** Does the work in the test sub-class */
@@ -144,10 +147,9 @@ public abstract class OntTestBase
/** Test that an iterator delivers the expected values */
protected void iteratorTest( Iterator<?> i, Object[] expected ) {
- TestUtil.assertIteratorValues( this, i, expected );
+ OntTestUtil.assertIteratorValues( i, expected );
}
- @Override
public void setUp() {
// ensure the ont doc manager is in a consistent state
OntDocumentManager.getInstance().reset( true );
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestUtil.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestUtil.java
new file mode 100644
index 0000000000..999de2ae11
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/OntTestUtil.java
@@ -0,0 +1,129 @@
+/*
+ * 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.ontology.impl;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.Iterator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement;
+
+/**
+ * Collection of utilities to assist with unit testing.
+ * <p>
+ * The {@code assertIterator*} methods are derived from
+ * {@link org.apache.jena.reasoner.test.TestUtil} so that this package can be
+ * migrated to JUnit6 independently. The {@code junit.framework.TestCase}
+ * argument of the originals has been dropped: it served only to label failure
+ * messages and to name the logger, both of which JUnit6 reports for itself.
+ */
+class OntTestUtil {
+
+ private static final Logger LOG = LoggerFactory.getLogger( OntTestUtil.class );
+
+ /**
+ * Helper method to test an iterator against a list of objects - order independent
+ * @param it The iterator to test
+ * @param vals The expected values of the iterator
+ */
+ static void assertIteratorValues(Iterator<?> it, Object[] vals) {
+ assertIteratorValues( it, vals, 0 );
+ }
+
+ /**
+ * Helper method to test an iterator against a list of objects - order independent, and
+ * can optionally check the count of anonymous resources. This allows us to test a
+ * iterator of resource values which includes both URI nodes and bNodes.
+ * @param it The iterator to test
+ * @param vals The expected values of the iterator
+ * @param countAnon If non zero, count the number of anonymous resources returned by <code>it</code>,
+ * and don't check these resources against the expected <code>vals</code>.
+ */
+ static void assertIteratorValues(Iterator<?> it, Object[] vals, int countAnon ) {
+ boolean[] found = new boolean[vals.length];
+ int anonFound = 0;
+
+ for (int i = 0; i < vals.length; i++) found[i] = false;
+
+ while (it.hasNext()) {
+ Object n = it.next();
+ boolean gotit = false;
+
+ // do bNodes separately
+ if (countAnon > 0 && isAnonValue( n )) {
+ anonFound++;
+ continue;
+ }
+
+ for (int i = 0; i < vals.length; i++) {
+ if (n.equals(vals[i])) {
+ gotit = true;
+ found[i] = true;
+ }
+ }
+ if (!gotit) {
+ LOG.debug( "found unexpected iterator value: " + n);
+ }
+ assertTrue( gotit, "found unexpected iterator value: " + n);
+ }
+
+ // check that no expected values were unfound
+ for (int i = 0; i < vals.length; i++) {
+ if (!found[i]) {
+ LOG.debug( "failed to find expected iterator value: " + vals[i]);
+ }
+ assertTrue( found[i], "failed to find expected iterator value: " + vals[i]);
+ }
+
+ // check we got the right no. of anons
+ assertEquals( countAnon, anonFound, "iterator test did not find the right number of anon. nodes" );
+ }
+
+ /**
+ * Check the length of an iterator.
+ */
+ static void assertIteratorLength(Iterator<?> it, int expectedLength) {
+ int length = 0;
+ while (it.hasNext()) {
+ it.next();
+ length++;
+ }
+ assertEquals(expectedLength, length);
+ }
+
+ /**
+ * For the purposes of counting, a value is anonymous if (a) it is an anonymous resource,
+ * or (b) it is a statement with a bNode subject or (c) it is a statement with a bNode
+ * object. This is because we cannot check bNode identity against fixed expected data values.
+ * @param n A value
+ * @return True if n is anonymous
+ */
+ static boolean isAnonValue( Object n ) {
+ return ((n instanceof Resource) && ((Resource) n).isAnon()) ||
+ ((n instanceof Statement) && ((Statement) n).getSubject().isAnon()) ||
+ ((n instanceof Statement) && isAnonValue( ((Statement) n).getObject() ));
+ }
+}
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TS3_ont.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TS6_ont.java
similarity index 80%
rename from jena-core/src/test/java/org/apache/jena/ontology/impl/TS3_ont.java
rename to jena-core/src/test/java/org/apache/jena/ontology/impl/TS6_ont.java
index 37b5072315..bc7cbc8f9f 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TS3_ont.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TS6_ont.java
@@ -21,12 +21,14 @@
package org.apache.jena.ontology.impl;
-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;
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
+@Suite
+@SelectClasses({
TestOntGraph.class,
TestOntResource.class,
TestClassExpression.class,
@@ -44,4 +46,10 @@ import org.junit.runners.Suite;
TestFrameView.class,
TestOntTools.class,
})
-public class TS3_ont {}
+
+public class TS6_ont {
+ @BeforeSuite
+ public static void beforeSuite() {
+ JenaTestLib.setup();
+ }
+}
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestAllDifferent.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestAllDifferent.java
index 5b14e9d472..16280673a5 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestAllDifferent.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestAllDifferent.java
@@ -25,19 +25,24 @@ package org.apache.jena.ontology.impl;
// Imports
///////////////
-import junit.framework.*;
import org.apache.jena.ontology.*;
import org.apache.jena.rdf.model.RDFNode;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.apache.jena.test.JenaTestLib;
+
/**
* <p>
* Unit tests for the AllDifferent declaration.
* </p>
*/
@SuppressWarnings("removal")
-public class TestAllDifferent
- extends OntTestBase
+public class TestAllDifferent extends OntTestBase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
@@ -50,15 +55,6 @@ public class TestAllDifferent
// Constructors
//////////////////////////////////
- static public TestSuite suite() {
- return new TestAllDifferent( "TestAllDifferent" );
- }
-
- public TestAllDifferent( String name ) {
- super( name );
- }
-
-
// External signature methods
//////////////////////////////////
@@ -74,26 +70,26 @@ public class TestAllDifferent
OntResource c = m.getResource( NS + "c" ).as( OntResource.class );
a.addDistinctMember( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.DISTINCT_MEMBERS() ) );
- assertEquals( "List size should be 1", 1, a.getDistinctMembers().size() );
- assertTrue( "a should have b as distinct", a.hasDistinctMember( b ) );
+ assertEquals( 1, a.getCardinality( prof.DISTINCT_MEMBERS() ), "Cardinality should be 1" );
+ assertEquals( 1, a.getDistinctMembers().size(), "List size should be 1" );
+ assertTrue( a.hasDistinctMember( b ), "a should have b as distinct" );
a.addDistinctMember( c );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.DISTINCT_MEMBERS() ) );
- assertEquals( "List size should be 2", 2, a.getDistinctMembers().size() );
+ assertEquals( 1, a.getCardinality( prof.DISTINCT_MEMBERS() ), "Cardinality should be 1" );
+ assertEquals( 2, a.getDistinctMembers().size(), "List size should be 2" );
iteratorTest( a.listDistinctMembers(), new Object[] {b, c} );
- assertTrue( "a should have b as distinct", a.hasDistinctMember( b ) );
- assertTrue( "a should have c as distinct", a.hasDistinctMember( c ) );
+ assertTrue( a.hasDistinctMember( b ), "a should have b as distinct" );
+ assertTrue( a.hasDistinctMember( c ), "a should have c as distinct" );
a.setDistinctMembers( m.createList( new RDFNode[] {b} ) );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.DISTINCT_MEMBERS() ) );
- assertEquals( "List size should be 1", 1, a.getDistinctMembers().size() );
- assertTrue( "a should have b as distinct", a.hasDistinctMember( b ) );
- assertTrue( "a should not have c as distinct", !a.hasDistinctMember( c ) );
+ assertEquals( 1, a.getCardinality( prof.DISTINCT_MEMBERS() ), "Cardinality should be 1" );
+ assertEquals( 1, a.getDistinctMembers().size(), "List size should be 1" );
+ assertTrue( a.hasDistinctMember( b ), "a should have b as distinct" );
+ assertTrue( !a.hasDistinctMember( c ), "a should not have c as distinct" );
a.removeDistinctMember( b );
- assertTrue( "a should have not b as distinct", !a.hasDistinctMember( b ) );
+ assertTrue( !a.hasDistinctMember( b ), "a should have not b as distinct" );
}
},
};
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestClassExpression.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestClassExpression.java
index f750bc761a..df61e02089 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestClassExpression.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestClassExpression.java
@@ -23,17 +23,17 @@
///////////////
package org.apache.jena.ontology.impl;
-
-
// Imports
///////////////
-import junit.framework.*;
import org.apache.jena.ontology.*;
import org.apache.jena.rdf.model.*;
import org.apache.jena.util.iterator.ClosableIterator;
import org.apache.jena.util.iterator.NullIterator;
import org.apache.jena.vocabulary.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -41,9 +41,11 @@ import org.apache.jena.vocabulary.*;
* </p>
*/
@SuppressWarnings("removal")
-public class TestClassExpression
- extends OntTestBase
+public class TestClassExpression extends OntTestBase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
@@ -56,15 +58,6 @@ public class TestClassExpression
// Constructors
//////////////////////////////////
- static public TestSuite suite() {
- return new TestClassExpression( "TestClassExpression" );
- }
-
- public TestClassExpression( String name ) {
- super( name );
- }
-
-
// External signature methods
//////////////////////////////////
@@ -80,22 +73,22 @@ public class TestClassExpression
OntClass C = m.createClass( NS + "C" );
A.addSuperClass( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.SUB_CLASS_OF() ) );
- assertEquals( "A should have super-class B", B, A.getSuperClass() );
+ assertEquals( 1, A.getCardinality( prof.SUB_CLASS_OF() ), "Cardinality should be 1" );
+ assertEquals( B, A.getSuperClass(), "A should have super-class B" );
A.addSuperClass( C );
- assertEquals( "Cardinality should be 2", 2, A.getCardinality( prof.SUB_CLASS_OF() ) );
+ assertEquals( 2, A.getCardinality( prof.SUB_CLASS_OF() ), "Cardinality should be 2" );
iteratorTest( A.listSuperClasses(), new Object[] {C, B} );
A.setSuperClass( C );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.SUB_CLASS_OF() ) );
- assertEquals( "A shuold have super-class C", C, A.getSuperClass() );
- assertTrue( "A shuold not have super-class B", !A.hasSuperClass( B, false ) );
+ assertEquals( 1, A.getCardinality( prof.SUB_CLASS_OF() ), "Cardinality should be 1" );
+ assertEquals( C, A.getSuperClass(), "A shuold have super-class C" );
+ assertTrue( !A.hasSuperClass( B, false ), "A shuold not have super-class B" );
A.removeSuperClass( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.SUB_CLASS_OF() ) );
+ assertEquals( 1, A.getCardinality( prof.SUB_CLASS_OF() ), "Cardinality should be 1" );
A.removeSuperClass( C );
- assertEquals( "Cardinality should be 0", 0, A.getCardinality( prof.SUB_CLASS_OF() ) );
+ assertEquals( 0, A.getCardinality( prof.SUB_CLASS_OF() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntClass.sub-class", true, true, true ) {
@@ -107,22 +100,22 @@ public class TestClassExpression
OntClass C = m.createClass( NS + "C" );
A.addSubClass( B );
- assertEquals( "Cardinality should be 1", 1, B.getCardinality( prof.SUB_CLASS_OF() ) );
- assertEquals( "A should have sub-class B", B, A.getSubClass() );
+ assertEquals( 1, B.getCardinality( prof.SUB_CLASS_OF() ), "Cardinality should be 1" );
+ assertEquals( B, A.getSubClass(), "A should have sub-class B" );
A.addSubClass( C );
- assertEquals( "Cardinality should be 2", 2, B.getCardinality( prof.SUB_CLASS_OF() ) + C.getCardinality( prof.SUB_CLASS_OF() ) );
+ assertEquals( 2, B.getCardinality( prof.SUB_CLASS_OF() ) + C.getCardinality( prof.SUB_CLASS_OF() ), "Cardinality should be 2" );
iteratorTest( A.listSubClasses(), new Object[] {C, B} );
A.setSubClass( C );
- assertEquals( "Cardinality should be 1", 1, B.getCardinality( prof.SUB_CLASS_OF() ) + C.getCardinality( prof.SUB_CLASS_OF() ) );
- assertEquals( "A shuold have sub-class C", C, A.getSubClass() );
- assertTrue( "A shuold not have sub-class B", !A.hasSubClass( B, false ) );
+ assertEquals( 1, B.getCardinality( prof.SUB_CLASS_OF() ) + C.getCardinality( prof.SUB_CLASS_OF() ), "Cardinality should be 1" );
+ assertEquals( C, A.getSubClass(), "A shuold have sub-class C" );
+ assertTrue( !A.hasSubClass( B, false ), "A shuold not have sub-class B" );
A.removeSubClass( B );
- assertTrue( "A should have sub-class C", A.hasSubClass( C, false ) );
+ assertTrue( A.hasSubClass( C, false ), "A should have sub-class C" );
A.removeSubClass( C );
- assertTrue( "A should not have sub-class C", !A.hasSubClass( C, false ) );
+ assertTrue( !A.hasSubClass( C, false ), "A should not have sub-class C" );
}
},
new OntTestCase( "OntClass.equivalentClass", true, true, false ) {
@@ -134,22 +127,22 @@ public class TestClassExpression
OntClass C = m.createClass( NS + "C" );
A.addEquivalentClass( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.EQUIVALENT_CLASS() ) );
- assertEquals( "A have equivalentClass B", B, A.getEquivalentClass() );
+ assertEquals( 1, A.getCardinality( prof.EQUIVALENT_CLASS() ), "Cardinality should be 1" );
+ assertEquals( B, A.getEquivalentClass(), "A have equivalentClass B" );
A.addEquivalentClass( C );
- assertEquals( "Cardinality should be 2", 2, A.getCardinality( prof.EQUIVALENT_CLASS() ) );
+ assertEquals( 2, A.getCardinality( prof.EQUIVALENT_CLASS() ), "Cardinality should be 2" );
iteratorTest( A.listEquivalentClasses(), new Object[] {C, B} );
A.setEquivalentClass( C );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.EQUIVALENT_CLASS() ) );
- assertEquals( "A should have equivalentClass C", C, A.getEquivalentClass() );
- assertTrue( "A should not have equivalentClass B", !A.hasEquivalentClass( B ) );
+ assertEquals( 1, A.getCardinality( prof.EQUIVALENT_CLASS() ), "Cardinality should be 1" );
+ assertEquals( C, A.getEquivalentClass(), "A should have equivalentClass C" );
+ assertTrue( !A.hasEquivalentClass( B ), "A should not have equivalentClass B" );
A.removeEquivalentClass( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.EQUIVALENT_CLASS() ) );
+ assertEquals( 1, A.getCardinality( prof.EQUIVALENT_CLASS() ), "Cardinality should be 1" );
A.removeEquivalentClass( C );
- assertEquals( "Cardinality should be 0", 0, A.getCardinality( prof.EQUIVALENT_CLASS() ) );
+ assertEquals( 0, A.getCardinality( prof.EQUIVALENT_CLASS() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntClass.disjointWith", true, false, false ) {
@@ -161,22 +154,22 @@ public class TestClassExpression
OntClass C = m.createClass( NS + "C" );
A.addDisjointWith( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.DISJOINT_WITH() ) );
- assertEquals( "A have be disjoint with B", B, A.getDisjointWith() );
+ assertEquals( 1, A.getCardinality( prof.DISJOINT_WITH() ), "Cardinality should be 1" );
+ assertEquals( B, A.getDisjointWith(), "A have be disjoint with B" );
A.addDisjointWith( C );
- assertEquals( "Cardinality should be 2", 2, A.getCardinality( prof.DISJOINT_WITH() ) );
+ assertEquals( 2, A.getCardinality( prof.DISJOINT_WITH() ), "Cardinality should be 2" );
iteratorTest( A.listDisjointWith(), new Object[] {C,B} );
A.setDisjointWith( C );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.DISJOINT_WITH() ) );
- assertEquals( "A should be disjoint with C", C, A.getDisjointWith() );
- assertTrue( "A should not be disjoint with B", !A.isDisjointWith( B ) );
+ assertEquals( 1, A.getCardinality( prof.DISJOINT_WITH() ), "Cardinality should be 1" );
+ assertEquals( C, A.getDisjointWith(), "A should be disjoint with C" );
+ assertTrue( !A.isDisjointWith( B ), "A should not be disjoint with B" );
A.removeDisjointWith( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.DISJOINT_WITH() ) );
+ assertEquals( 1, A.getCardinality( prof.DISJOINT_WITH() ), "Cardinality should be 1" );
A.removeDisjointWith( C );
- assertEquals( "Cardinality should be 0", 0, A.getCardinality( prof.DISJOINT_WITH() ) );
+ assertEquals( 0, A.getCardinality( prof.DISJOINT_WITH() ), "Cardinality should be 0" );
}
},
new OntTestCase( "EnumeratedClass.oneOf", true, false, false ) {
@@ -188,25 +181,25 @@ public class TestClassExpression
OntResource b = m.getResource( NS + "b" ).as( OntResource.class );
A.addOneOf( a );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.ONE_OF() ) );
- assertEquals( "Size should be 1", 1, A.getOneOf().size() );
- assertTrue( "A should have a as enumerated member", A.getOneOf().contains( a ) );
+ assertEquals( 1, A.getCardinality( prof.ONE_OF() ), "Cardinality should be 1" );
+ assertEquals( 1, A.getOneOf().size(), "Size should be 1" );
+ assertTrue( A.getOneOf().contains( a ), "A should have a as enumerated member" );
A.addOneOf( b );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.ONE_OF() ) );
- assertEquals( "Size should be 2", 2, A.getOneOf().size() );
+ assertEquals( 1, A.getCardinality( prof.ONE_OF() ), "Cardinality should be 1" );
+ assertEquals( 2, A.getOneOf().size(), "Size should be 2" );
iteratorTest( A.listOneOf(), new Object[] {a,b} );
A.setOneOf( m.createList( new RDFNode[] {b} ) );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.ONE_OF() ) );
- assertEquals( "Size should be 1", 1, A.getOneOf().size() );
- assertTrue( "A should have b in the enum", A.hasOneOf( b ) );
- assertTrue( "A should not have a in the enum", !A.hasOneOf( a ) );
+ assertEquals( 1, A.getCardinality( prof.ONE_OF() ), "Cardinality should be 1" );
+ assertEquals( 1, A.getOneOf().size(), "Size should be 1" );
+ assertTrue( A.hasOneOf( b ), "A should have b in the enum" );
+ assertTrue( !A.hasOneOf( a ), "A should not have a in the enum" );
A.removeOneOf( a );
- assertTrue( "Should have b as an enum value", A.hasOneOf( b ) );
+ assertTrue( A.hasOneOf( b ), "Should have b as an enum value" );
A.removeOneOf( b );
- assertTrue( "Should not have b as an enum value", !A.hasOneOf( b ) );
+ assertTrue( !A.hasOneOf( b ), "Should not have b as an enum value" );
}
},
new OntTestCase( "IntersectionClass.intersectionOf", true, true, false ) {
@@ -218,29 +211,29 @@ public class TestClassExpression
OntClass C = m.createClass( NS + "C" );
A.addOperand( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.INTERSECTION_OF() ) );
- assertEquals( "Size should be 1", 1, A.getOperands().size() );
- assertTrue( "A should have a as intersection member", A.getOperands().contains( B ) );
+ assertEquals( 1, A.getCardinality( prof.INTERSECTION_OF() ), "Cardinality should be 1" );
+ assertEquals( 1, A.getOperands().size(), "Size should be 1" );
+ assertTrue( A.getOperands().contains( B ), "A should have a as intersection member" );
A.addOperand( C );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.INTERSECTION_OF() ) );
- assertEquals( "Size should be 2", 2, A.getOperands().size() );
+ assertEquals( 1, A.getCardinality( prof.INTERSECTION_OF() ), "Cardinality should be 1" );
+ assertEquals( 2, A.getOperands().size(), "Size should be 2" );
iteratorTest( A.listOperands(), new Object[] {B,C} );
ClosableIterator<? extends Resource> i = A.listOperands();
- assertTrue( "Argument should be an OntClass", i.next() instanceof OntClass );
+ assertTrue( i.next() instanceof OntClass, "Argument should be an OntClass" );
i.close();
A.setOperands( m.createList( new RDFNode[] {C} ) );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.INTERSECTION_OF() ) );
- assertEquals( "Size should be 1", 1, A.getOperands().size() );
- assertTrue( "A should have C in the intersection", A.hasOperand( C ) );
- assertTrue( "A should not have B in the intersection", !A.hasOperand( B ) );
+ assertEquals( 1, A.getCardinality( prof.INTERSECTION_OF() ), "Cardinality should be 1" );
+ assertEquals( 1, A.getOperands().size(), "Size should be 1" );
+ assertTrue( A.hasOperand( C ), "A should have C in the intersection" );
+ assertTrue( !A.hasOperand( B ), "A should not have B in the intersection" );
A.removeOperand( B );
- assertTrue( "Should have C as an operand", A.hasOperand( C ) );
+ assertTrue( A.hasOperand( C ), "Should have C as an operand" );
A.removeOperand( C );
- assertTrue( "Should not have C as an operand", !A.hasOperand( C ) );
+ assertTrue( !A.hasOperand( C ), "Should not have C as an operand" );
}
},
new OntTestCase( "UnionClass.unionOf", true, false, false ) {
@@ -252,29 +245,29 @@ public class TestClassExpression
OntClass C = m.createClass( NS + "C" );
A.addOperand( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) );
- assertEquals( "Size should be 1", 1, A.getOperands().size() );
- assertTrue( "A should have a as union member", A.getOperands().contains( B ) );
+ assertEquals( 1, A.getCardinality( prof.UNION_OF() ), "Cardinality should be 1" );
+ assertEquals( 1, A.getOperands().size(), "Size should be 1" );
+ assertTrue( A.getOperands().contains( B ), "A should have a as union member" );
A.addOperand( C );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) );
- assertEquals( "Size should be 2", 2, A.getOperands().size() );
+ assertEquals( 1, A.getCardinality( prof.UNION_OF() ), "Cardinality should be 1" );
+ assertEquals( 2, A.getOperands().size(), "Size should be 2" );
iteratorTest( A.listOperands(), new Object[] {B,C} );
ClosableIterator<? extends Resource> i = A.listOperands();
- assertTrue( "Argument should be an OntClass", i.next() instanceof OntClass );
+ assertTrue( i.next() instanceof OntClass, "Argument should be an OntClass" );
i.close();
A.setOperands( m.createList( new RDFNode[] {C} ) );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) );
- assertEquals( "Size should be 1", 1, A.getOperands().size() );
- assertTrue( "A should have C in the union", A.hasOperand( C ) );
- assertTrue( "A should not have B in the union", !A.hasOperand( B ) );
+ assertEquals( 1, A.getCardinality( prof.UNION_OF() ), "Cardinality should be 1" );
+ assertEquals( 1, A.getOperands().size(), "Size should be 1" );
+ assertTrue( A.hasOperand( C ), "A should have C in the union" );
+ assertTrue( !A.hasOperand( B ), "A should not have B in the union" );
A.removeOperand( B );
- assertTrue( "Should have C as an operand", A.hasOperand( C ) );
+ assertTrue( A.hasOperand( C ), "Should have C as an operand" );
A.removeOperand( C );
- assertTrue( "Should not have C as an operand", !A.hasOperand( C ) );
+ assertTrue( !A.hasOperand( C ), "Should not have C as an operand" );
}
},
new OntTestCase( "ComplementClass.complementOf", true, false, false ) {
@@ -287,30 +280,30 @@ public class TestClassExpression
boolean ex = false;
try { A.addOperand( B ); } catch (UnsupportedOperationException e) {ex = true;}
- assertTrue( "Should fail to add to a complement", ex );
+ assertTrue( ex, "Should fail to add to a complement" );
ex = false;
try { A.addOperands( new NullIterator<Resource>() ); } catch (UnsupportedOperationException e) {ex = true;}
- assertTrue( "Should fail to add to a complement", ex );
+ assertTrue( ex, "Should fail to add to a complement" );
ex = false;
try { A.setOperands( m.createList( new RDFNode[] {C} ) ); } catch (UnsupportedOperationException e) {ex = true;}
- assertTrue( "Should fail to set a list to a complement", ex );
+ assertTrue( ex, "Should fail to set a list to a complement" );
A.setOperand( B );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.COMPLEMENT_OF() ) );
- assertEquals( "Complement should be B", B, A.getOperand() );
+ assertEquals( 1, A.getCardinality( prof.COMPLEMENT_OF() ), "Cardinality should be 1" );
+ assertEquals( B, A.getOperand(), "Complement should be B" );
iteratorTest( A.listOperands(), new Object[] {B} );
A.setOperand( C );
- assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.COMPLEMENT_OF() ) );
- assertTrue( "A should have C in the complement", A.hasOperand( C ) );
- assertTrue( "A should not have B in the complement", !A.hasOperand( B ) );
+ assertEquals( 1, A.getCardinality( prof.COMPLEMENT_OF() ), "Cardinality should be 1" );
+ assertTrue( A.hasOperand( C ), "A should have C in the complement" );
+ assertTrue( !A.hasOperand( B ), "A should not have B in the complement" );
A.removeOperand( B );
- assertTrue( "Should have C as an operand", A.hasOperand( C ) );
+ assertTrue( A.hasOperand( C ), "Should have C as an operand" );
A.removeOperand( C );
- assertTrue( "Should not have C as an operand", !A.hasOperand( C ) );
+ assertTrue( !A.hasOperand( C ), "Should not have C as an operand" );
}
},
new OntTestCase( "Restriction.onProperty", true, true, false ) {
@@ -323,22 +316,22 @@ public class TestClassExpression
Restriction A = m.createAllValuesFromRestriction( NS + "A", p, B );
- assertEquals( "Restriction should be on property p", p, A.getOnProperty() );
- assertTrue( "Restriction should be on property p", A.onProperty( p ) );
- assertTrue( "Restriction should not be on property q", !A.onProperty( q ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ON_PROPERTY() ));
+ assertEquals( p, A.getOnProperty(), "Restriction should be on property p" );
+ assertTrue( A.onProperty( p ), "Restriction should be on property p" );
+ assertTrue( !A.onProperty( q ), "Restriction should not be on property q" );
+ assertEquals( 1, A.getCardinality( prof.ON_PROPERTY() ), "cardinality should be 1 ");
A.setOnProperty( q );
- assertEquals( "Restriction should be on property q", q, A.getOnProperty() );
- assertTrue( "Restriction should not be on property p", !A.onProperty( p ) );
- assertTrue( "Restriction should not on property q", A.onProperty( q ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ON_PROPERTY() ));
+ assertEquals( q, A.getOnProperty(), "Restriction should be on property q" );
+ assertTrue( !A.onProperty( p ), "Restriction should not be on property p" );
+ assertTrue( A.onProperty( q ), "Restriction should not on property q" );
+ assertEquals( 1, A.getCardinality( prof.ON_PROPERTY() ), "cardinality should be 1 ");
A.removeOnProperty( p );
- assertTrue( "Should have q as on property", A.onProperty( q ) );
+ assertTrue( A.onProperty( q ), "Should have q as on property" );
A.removeOnProperty( q );
- assertTrue( "Should not have q as on property", !A.onProperty( q ) );
+ assertTrue( !A.onProperty( q ), "Should not have q as on property" );
}
},
new OntTestCase( "AllValuesFromRestriction.allValuesFrom", true, true, false ) {
@@ -351,22 +344,22 @@ public class TestClassExpression
AllValuesFromRestriction A = m.createAllValuesFromRestriction( NS + "A", p, B );
- assertEquals( "Restriction should be all values from B", B, A.getAllValuesFrom() );
- assertTrue( "Restriction should be all values from B", A.hasAllValuesFrom( B ) );
- assertTrue( "Restriction should not be all values from C", !A.hasAllValuesFrom( C ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertEquals( B, A.getAllValuesFrom(), "Restriction should be all values from B" );
+ assertTrue( A.hasAllValuesFrom( B ), "Restriction should be all values from B" );
+ assertTrue( !A.hasAllValuesFrom( C ), "Restriction should not be all values from C" );
+ assertEquals( 1, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 1 ");
A.setAllValuesFrom( C );
- assertEquals( "Restriction should be all values from C", C, A.getAllValuesFrom() );
- assertTrue( "Restriction should not be all values from B", !A.hasAllValuesFrom( B ) );
- assertTrue( "Restriction should be all values from C", A.hasAllValuesFrom( C ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertEquals( C, A.getAllValuesFrom(), "Restriction should be all values from C" );
+ assertTrue( !A.hasAllValuesFrom( B ), "Restriction should not be all values from B" );
+ assertTrue( A.hasAllValuesFrom( C ), "Restriction should be all values from C" );
+ assertEquals( 1, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 1 ");
A.removeAllValuesFrom( C );
- assertTrue( "Restriction should not be some values from C", !A.hasAllValuesFrom( C ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertTrue( !A.hasAllValuesFrom( C ), "Restriction should not be some values from C" );
+ assertEquals( 0, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 0 ");
}
},
new OntTestCase( "AllValuesFromRestriction.allValuesFrom.datatype", true, true, false ) {
@@ -377,22 +370,22 @@ public class TestClassExpression
AllValuesFromRestriction A = m.createAllValuesFromRestriction( NS + "A", p, XSD.gDay );
- assertEquals( "Restriction should be all values from gDay", XSD.gDay, A.getAllValuesFrom() );
- assertTrue( "Restriction should be all values from gDay", A.hasAllValuesFrom( XSD.gDay ) );
- assertTrue( "Restriction should not be all values from decimal", !A.hasAllValuesFrom( XSD.decimal ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertEquals( XSD.gDay, A.getAllValuesFrom(), "Restriction should be all values from gDay" );
+ assertTrue( A.hasAllValuesFrom( XSD.gDay ), "Restriction should be all values from gDay" );
+ assertTrue( !A.hasAllValuesFrom( XSD.decimal ), "Restriction should not be all values from decimal" );
+ assertEquals( 1, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 1 ");
A.setAllValuesFrom( XSD.gMonth );
- assertEquals( "Restriction should be all values from gMonth", XSD.gMonth, A.getAllValuesFrom() );
- assertTrue( "Restriction should not be all values from gDay", !A.hasAllValuesFrom( XSD.gDay ) );
- assertTrue( "Restriction should be all values from gMonth", A.hasAllValuesFrom( XSD.gMonth ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertEquals( XSD.gMonth, A.getAllValuesFrom(), "Restriction should be all values from gMonth" );
+ assertTrue( !A.hasAllValuesFrom( XSD.gDay ), "Restriction should not be all values from gDay" );
+ assertTrue( A.hasAllValuesFrom( XSD.gMonth ), "Restriction should be all values from gMonth" );
+ assertEquals( 1, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 1 ");
A.removeAllValuesFrom( XSD.gMonth );
- assertTrue( "Restriction should not be some values from gMonth", !A.hasAllValuesFrom( XSD.gMonth ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertTrue( !A.hasAllValuesFrom( XSD.gMonth ), "Restriction should not be some values from gMonth" );
+ assertEquals( 0, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 0 ");
}
},
new OntTestCase( "AllValuesFromRestriction.allValuesFrom.literal", true, true, false ) {
@@ -403,10 +396,10 @@ public class TestClassExpression
AllValuesFromRestriction A = m.createAllValuesFromRestriction( NS + "A", p, RDFS.Literal );
- assertEquals( "Restriction should be all values from literal", RDFS.Literal, A.getAllValuesFrom() );
- assertTrue( "Restriction should be all values from literal", A.hasAllValuesFrom( RDFS.Literal ) );
- assertTrue( "Restriction should not be all values from decimal", !A.hasAllValuesFrom( XSD.decimal ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertEquals( RDFS.Literal, A.getAllValuesFrom(), "Restriction should be all values from literal" );
+ assertTrue( A.hasAllValuesFrom( RDFS.Literal ), "Restriction should be all values from literal" );
+ assertTrue( !A.hasAllValuesFrom( XSD.decimal ), "Restriction should not be all values from decimal" );
+ assertEquals( 1, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 1 ");
}
},
new OntTestCase( "AllValuesFromRestriction.allValuesFrom.datarange", true, false, false ) {
@@ -420,16 +413,16 @@ public class TestClassExpression
AllValuesFromRestriction A = m.createAllValuesFromRestriction( NS + "A", p, dr );
- assertEquals( "Restriction should be all values from dr", dr, A.getAllValuesFrom() );
- assertTrue( "value should be a datarange", A.getAllValuesFrom() instanceof DataRange );
- assertTrue( "Restriction should be all values from dr", A.hasAllValuesFrom( dr ) );
- assertTrue( "Restriction should not be all values from decimal", !A.hasAllValuesFrom( XSD.decimal ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertEquals( dr, A.getAllValuesFrom(), "Restriction should be all values from dr" );
+ assertTrue( A.getAllValuesFrom() instanceof DataRange, "value should be a datarange" );
+ assertTrue( A.hasAllValuesFrom( dr ), "Restriction should be all values from dr" );
+ assertTrue( !A.hasAllValuesFrom( XSD.decimal ), "Restriction should not be all values from decimal" );
+ assertEquals( 1, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 1 ");
A.removeAllValuesFrom( dr );
- assertTrue( "Restriction should not be some values from gMonth", !A.hasAllValuesFrom( dr ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.ALL_VALUES_FROM() ));
+ assertTrue( !A.hasAllValuesFrom( dr ), "Restriction should not be some values from gMonth" );
+ assertEquals( 0, A.getCardinality( prof.ALL_VALUES_FROM() ), "cardinality should be 0 ");
}
},
new OntTestCase( "HasValueRestriction.hasValue", true, false, false ) {
@@ -444,24 +437,24 @@ public class TestClassExpression
HasValueRestriction A = m.createHasValueRestriction( NS + "A", p, b );
- assertEquals( "Restriction should be has value b", b, A.getHasValue() );
+ assertEquals( b, A.getHasValue(), "Restriction should be has value b" );
assertTrue( A.getHasValue() instanceof Individual );
- assertTrue( "Restriction should be to have value b", A.hasValue( b ) );
- assertTrue( "Restriction should not be have value c", !A.hasValue( c ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.HAS_VALUE() ));
+ assertTrue( A.hasValue( b ), "Restriction should be to have value b" );
+ assertTrue( !A.hasValue( c ), "Restriction should not be have value c" );
+ assertEquals( 1, A.getCardinality( prof.HAS_VALUE() ), "cardinality should be 1 ");
A.setHasValue( c );
- assertEquals( "Restriction should be has value c", c, A.getHasValue() );
- assertTrue( "Restriction should not be to have value b", !A.hasValue( b ) );
- assertTrue( "Restriction should not be have value c", A.hasValue( c ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.HAS_VALUE() ));
+ assertEquals( c, A.getHasValue(), "Restriction should be has value c" );
+ assertTrue( !A.hasValue( b ), "Restriction should not be to have value b" );
+ assertTrue( A.hasValue( c ), "Restriction should not be have value c" );
+ assertEquals( 1, A.getCardinality( prof.HAS_VALUE() ), "cardinality should be 1 ");
A.removeHasValue( c );
- assertTrue( "Restriction should not be to have value b", !A.hasValue( b ) );
- assertTrue( "Restriction should not be have value c", !A.hasValue( c ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.HAS_VALUE() ));
+ assertTrue( !A.hasValue( b ), "Restriction should not be to have value b" );
+ assertTrue( !A.hasValue( c ), "Restriction should not be have value c" );
+ assertEquals( 0, A.getCardinality( prof.HAS_VALUE() ), "cardinality should be 0 ");
}
},
new OntTestCase( "SomeValuesFromRestriction.someValuesFrom", true, true, false ) {
@@ -474,22 +467,22 @@ public class TestClassExpression
SomeValuesFromRestriction A = m.createSomeValuesFromRestriction( NS + "A", p, B );
- assertEquals( "Restriction should be some values from B", B, A.getSomeValuesFrom() );
- assertTrue( "Restriction should be some values from B", A.hasSomeValuesFrom( B ) );
- assertTrue( "Restriction should not be some values from C", !A.hasSomeValuesFrom( C ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertEquals( B, A.getSomeValuesFrom(), "Restriction should be some values from B" );
+ assertTrue( A.hasSomeValuesFrom( B ), "Restriction should be some values from B" );
+ assertTrue( !A.hasSomeValuesFrom( C ), "Restriction should not be some values from C" );
+ assertEquals( 1, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 1 ");
A.setSomeValuesFrom( C );
- assertEquals( "Restriction should be some values from C", C, A.getSomeValuesFrom() );
- assertTrue( "Restriction should not be some values from B", !A.hasSomeValuesFrom( B ) );
- assertTrue( "Restriction should be some values from C", A.hasSomeValuesFrom( C ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertEquals( C, A.getSomeValuesFrom(), "Restriction should be some values from C" );
+ assertTrue( !A.hasSomeValuesFrom( B ), "Restriction should not be some values from B" );
+ assertTrue( A.hasSomeValuesFrom( C ), "Restriction should be some values from C" );
+ assertEquals( 1, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 1 ");
A.removeSomeValuesFrom( C );
- assertTrue( "Restriction should not be some values from C", !A.hasSomeValuesFrom( C ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertTrue( !A.hasSomeValuesFrom( C ), "Restriction should not be some values from C" );
+ assertEquals( 0, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 0 ");
}
},
new OntTestCase( "SomeValuesFromRestriction.SomeValuesFrom.datatype", true, true, false ) {
@@ -500,22 +493,22 @@ public class TestClassExpression
SomeValuesFromRestriction A = m.createSomeValuesFromRestriction( NS + "A", p, XSD.gDay );
- assertEquals( "Restriction should be some values from gDay", XSD.gDay, A.getSomeValuesFrom() );
- assertTrue( "Restriction should be some values from gDay", A.hasSomeValuesFrom( XSD.gDay ) );
- assertTrue( "Restriction should not be some values from decimal", !A.hasSomeValuesFrom( XSD.decimal ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertEquals( XSD.gDay, A.getSomeValuesFrom(), "Restriction should be some values from gDay" );
+ assertTrue( A.hasSomeValuesFrom( XSD.gDay ), "Restriction should be some values from gDay" );
+ assertTrue( !A.hasSomeValuesFrom( XSD.decimal ), "Restriction should not be some values from decimal" );
+ assertEquals( 1, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 1 ");
A.setSomeValuesFrom( XSD.gMonth );
- assertEquals( "Restriction should be some values from gMonth", XSD.gMonth, A.getSomeValuesFrom() );
- assertTrue( "Restriction should not be some values from gDay", !A.hasSomeValuesFrom( XSD.gDay ) );
- assertTrue( "Restriction should be some values from gMonth", A.hasSomeValuesFrom( XSD.gMonth ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertEquals( XSD.gMonth, A.getSomeValuesFrom(), "Restriction should be some values from gMonth" );
+ assertTrue( !A.hasSomeValuesFrom( XSD.gDay ), "Restriction should not be some values from gDay" );
+ assertTrue( A.hasSomeValuesFrom( XSD.gMonth ), "Restriction should be some values from gMonth" );
+ assertEquals( 1, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 1 ");
A.removeSomeValuesFrom( XSD.gMonth );
- assertTrue( "Restriction should not be some values from gMonth", !A.hasSomeValuesFrom( XSD.gMonth ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertTrue( !A.hasSomeValuesFrom( XSD.gMonth ), "Restriction should not be some values from gMonth" );
+ assertEquals( 0, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 0 ");
}
},
new OntTestCase( "SomeValuesFromRestriction.SomeValuesFrom.literal", true, true, false ) {
@@ -526,10 +519,10 @@ public class TestClassExpression
SomeValuesFromRestriction A = m.createSomeValuesFromRestriction( NS + "A", p, RDFS.Literal );
- assertEquals( "Restriction should be some values from literal", RDFS.Literal, A.getSomeValuesFrom() );
- assertTrue( "Restriction should be some values from literal", A.hasSomeValuesFrom( RDFS.Literal ) );
- assertTrue( "Restriction should not be some values from decimal", !A.hasSomeValuesFrom( XSD.decimal ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertEquals( RDFS.Literal, A.getSomeValuesFrom(), "Restriction should be some values from literal" );
+ assertTrue( A.hasSomeValuesFrom( RDFS.Literal ), "Restriction should be some values from literal" );
+ assertTrue( !A.hasSomeValuesFrom( XSD.decimal ), "Restriction should not be some values from decimal" );
+ assertEquals( 1, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 1 ");
}
},
new OntTestCase( "SomeValuesFromRestriction.SomeValuesFrom.datarange", true, false, false ) {
@@ -543,16 +536,16 @@ public class TestClassExpression
SomeValuesFromRestriction A = m.createSomeValuesFromRestriction( NS + "A", p, dr );
- assertEquals( "Restriction should be some values from dr", dr, A.getSomeValuesFrom() );
- assertTrue( "value should be a datarange", A.getSomeValuesFrom() instanceof DataRange );
- assertTrue( "Restriction should be some values from dr", A.hasSomeValuesFrom( dr ) );
- assertTrue( "Restriction should not be some values from decimal", !A.hasSomeValuesFrom( XSD.decimal ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertEquals( dr, A.getSomeValuesFrom(), "Restriction should be some values from dr" );
+ assertTrue( A.getSomeValuesFrom() instanceof DataRange, "value should be a datarange" );
+ assertTrue( A.hasSomeValuesFrom( dr ), "Restriction should be some values from dr" );
+ assertTrue( !A.hasSomeValuesFrom( XSD.decimal ), "Restriction should not be some values from decimal" );
+ assertEquals( 1, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 1 ");
A.removeSomeValuesFrom( dr );
- assertTrue( "Restriction should not be some values from gMonth", !A.hasSomeValuesFrom( dr ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.SOME_VALUES_FROM() ));
+ assertTrue( !A.hasSomeValuesFrom( dr ), "Restriction should not be some values from gMonth" );
+ assertEquals( 0, A.getCardinality( prof.SOME_VALUES_FROM() ), "cardinality should be 0 ");
}
},
new OntTestCase( "CardinalityRestriction.cardinality", true, true, false ) {
@@ -563,23 +556,23 @@ public class TestClassExpression
CardinalityRestriction A = m.createCardinalityRestriction( NS + "A", p, 3 );
- assertEquals( "Restriction should be cardinality 3", 3, A.getCardinality() );
- assertTrue( "Restriction should be cardinality 3", A.hasCardinality( 3 ) );
- assertTrue( "Restriction should not be cardinality 2", !A.hasCardinality( 2 ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.CARDINALITY() ));
+ assertEquals( 3, A.getCardinality(), "Restriction should be cardinality 3" );
+ assertTrue( A.hasCardinality( 3 ), "Restriction should be cardinality 3" );
+ assertTrue( !A.hasCardinality( 2 ), "Restriction should not be cardinality 2" );
+ assertEquals( 1, A.getCardinality( prof.CARDINALITY() ), "cardinality should be 1 ");
A.setCardinality( 2 );
- assertEquals( "Restriction should be cardinality 2", 2, A.getCardinality() );
- assertTrue( "Restriction should not be cardinality 3", !A.hasCardinality( 3 ) );
- assertTrue( "Restriction should be cardinality 2", A.hasCardinality( 2 ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.CARDINALITY() ));
+ assertEquals( 2, A.getCardinality(), "Restriction should be cardinality 2" );
+ assertTrue( !A.hasCardinality( 3 ), "Restriction should not be cardinality 3" );
+ assertTrue( A.hasCardinality( 2 ), "Restriction should be cardinality 2" );
+ assertEquals( 1, A.getCardinality( prof.CARDINALITY() ), "cardinality should be 1 ");
A.removeCardinality( 2 );
- assertTrue( "Restriction should not be cardinality 3", !A.hasCardinality( 3 ) );
- assertTrue( "Restriction should not be cardinality 2", !A.hasCardinality( 2 ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.CARDINALITY() ));
+ assertTrue( !A.hasCardinality( 3 ), "Restriction should not be cardinality 3" );
+ assertTrue( !A.hasCardinality( 2 ), "Restriction should not be cardinality 2" );
+ assertEquals( 0, A.getCardinality( prof.CARDINALITY() ), "cardinality should be 0 ");
}
},
new OntTestCase( "MinCardinalityRestriction.minCardinality", true, true, false ) {
@@ -590,23 +583,23 @@ public class TestClassExpression
MinCardinalityRestriction A = m.createMinCardinalityRestriction( NS + "A", p, 3 );
- assertEquals( "Restriction should be min cardinality 3", 3, A.getMinCardinality() );
- assertTrue( "Restriction should be min cardinality 3", A.hasMinCardinality( 3 ) );
- assertTrue( "Restriction should not be min cardinality 2", !A.hasMinCardinality( 2 ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.MIN_CARDINALITY() ));
+ assertEquals( 3, A.getMinCardinality(), "Restriction should be min cardinality 3" );
+ assertTrue( A.hasMinCardinality( 3 ), "Restriction should be min cardinality 3" );
+ assertTrue( !A.hasMinCardinality( 2 ), "Restriction should not be min cardinality 2" );
+ assertEquals( 1, A.getCardinality( prof.MIN_CARDINALITY() ), "cardinality should be 1 ");
A.setMinCardinality( 2 );
- assertEquals( "Restriction should be min cardinality 2", 2, A.getMinCardinality() );
- assertTrue( "Restriction should not be min cardinality 3", !A.hasMinCardinality( 3 ) );
- assertTrue( "Restriction should be min cardinality 2", A.hasMinCardinality( 2 ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.MIN_CARDINALITY() ));
+ assertEquals( 2, A.getMinCardinality(), "Restriction should be min cardinality 2" );
+ assertTrue( !A.hasMinCardinality( 3 ), "Restriction should not be min cardinality 3" );
+ assertTrue( A.hasMinCardinality( 2 ), "Restriction should be min cardinality 2" );
+ assertEquals( 1, A.getCardinality( prof.MIN_CARDINALITY() ), "cardinality should be 1 ");
A.removeMinCardinality( 2 );
- assertTrue( "Restriction should not be cardinality 3", !A.hasMinCardinality( 3 ) );
- assertTrue( "Restriction should not be cardinality 2", !A.hasMinCardinality( 2 ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.MIN_CARDINALITY() ));
+ assertTrue( !A.hasMinCardinality( 3 ), "Restriction should not be cardinality 3" );
+ assertTrue( !A.hasMinCardinality( 2 ), "Restriction should not be cardinality 2" );
+ assertEquals( 0, A.getCardinality( prof.MIN_CARDINALITY() ), "cardinality should be 0 ");
}
},
new OntTestCase( "MaxCardinalityRestriction.maxCardinality", true, true, false ) {
@@ -617,23 +610,23 @@ public class TestClassExpression
MaxCardinalityRestriction A = m.createMaxCardinalityRestriction( NS + "A", p, 3 );
- assertEquals( "Restriction should be max cardinality 3", 3, A.getMaxCardinality() );
- assertTrue( "Restriction should be max cardinality 3", A.hasMaxCardinality( 3 ) );
- assertTrue( "Restriction should not be max cardinality 2", !A.hasMaxCardinality( 2 ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.MAX_CARDINALITY() ));
+ assertEquals( 3, A.getMaxCardinality(), "Restriction should be max cardinality 3" );
+ assertTrue( A.hasMaxCardinality( 3 ), "Restriction should be max cardinality 3" );
+ assertTrue( !A.hasMaxCardinality( 2 ), "Restriction should not be max cardinality 2" );
+ assertEquals( 1, A.getCardinality( prof.MAX_CARDINALITY() ), "cardinality should be 1 ");
A.setMaxCardinality( 2 );
- assertEquals( "Restriction should be max cardinality 2", 2, A.getMaxCardinality() );
- assertTrue( "Restriction should not be max cardinality 3", !A.hasMaxCardinality( 3 ) );
- assertTrue( "Restriction should be max cardinality 2", A.hasMaxCardinality( 2 ) );
- assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.MAX_CARDINALITY() ));
+ assertEquals( 2, A.getMaxCardinality(), "Restriction should be max cardinality 2" );
+ assertTrue( !A.hasMaxCardinality( 3 ), "Restriction should not be max cardinality 3" );
+ assertTrue( A.hasMaxCardinality( 2 ), "Restriction should be max cardinality 2" );
+ assertEquals( 1, A.getCardinality( prof.MAX_CARDINALITY() ), "cardinality should be 1 ");
A.removeMaxCardinality( 2 );
- assertTrue( "Restriction should not be cardinality 3", !A.hasMaxCardinality( 3 ) );
- assertTrue( "Restriction should not be cardinality 2", !A.hasMaxCardinality( 2 ) );
- assertEquals( "cardinality should be 0 ", 0, A.getCardinality( prof.MAX_CARDINALITY() ));
+ assertTrue( !A.hasMaxCardinality( 3 ), "Restriction should not be cardinality 3" );
+ assertTrue( !A.hasMaxCardinality( 2 ), "Restriction should not be cardinality 2" );
+ assertEquals( 0, A.getCardinality( prof.MAX_CARDINALITY() ), "cardinality should be 0 ");
}
},
new OntTestCase( "QualifiedRestriction.hasClassQ", false, false, false ) {
@@ -646,19 +639,19 @@ public class TestClassExpression
String nameA = "ABCBA";
QualifiedRestriction A = m.createMaxCardinalityQRestriction( NS + nameA, p, 3, c );
- assertEquals( "Restriction should hasClassQ c", c, A.getHasClassQ() );
- assertTrue( "Restriction should be hasClassQ c", A.hasHasClassQ( c ) );
- assertFalse( "Restriction should not be hasClassQ d", A.hasHasClassQ( d ) );
+ assertEquals( c, A.getHasClassQ(), "Restriction should hasClassQ c" );
+ assertTrue( A.hasHasClassQ( c ), "Restriction should be hasClassQ c" );
+ assertFalse( A.hasHasClassQ( d ), "Restriction should not be hasClassQ d" );
A.setHasClassQ( d );
- assertEquals( "Restriction should hasClassQ d", d, A.getHasClassQ() );
- assertTrue( "Restriction should be hasClassQ d", A.hasHasClassQ( d ) );
- assertFalse( "Restriction should not be hasClassQ c", A.hasHasClassQ( c ) );
+ assertEquals( d, A.getHasClassQ(), "Restriction should hasClassQ d" );
+ assertTrue( A.hasHasClassQ( d ), "Restriction should be hasClassQ d" );
+ assertFalse( A.hasHasClassQ( c ), "Restriction should not be hasClassQ c" );
- assertTrue( "Should be a qualified restriction", m.getResource( NS + nameA ).canAs( QualifiedRestriction.class ) );
+ assertTrue( m.getResource( NS + nameA ).canAs( QualifiedRestriction.class ), "Should be a qualified restriction" );
A.removeHasClassQ( d );
- assertFalse( "Should not be a qualified restriction", m.getResource( NS + nameA ).canAs( QualifiedRestriction.class ) );
+ assertFalse( m.getResource( NS + nameA ).canAs( QualifiedRestriction.class ), "Should not be a qualified restriction" );
}
},
new OntTestCase( "CardinalityQRestriction.cardinality", false, false, false ) {
@@ -669,19 +662,19 @@ public class TestClassExpression
CardinalityQRestriction A = m.createCardinalityQRestriction( NS + "A", p, 3, c );
- assertEquals( "Restriction should cardinality 3", 3, A.getCardinalityQ() );
- assertTrue( "Restriction should be cardinality 3", A.hasCardinalityQ( 3 ) );
- assertFalse( "Restriction should not be cardinality 1", A.hasCardinalityQ( 1 ) );
+ assertEquals( 3, A.getCardinalityQ(), "Restriction should cardinality 3" );
+ assertTrue( A.hasCardinalityQ( 3 ), "Restriction should be cardinality 3" );
+ assertFalse( A.hasCardinalityQ( 1 ), "Restriction should not be cardinality 1" );
A.setCardinalityQ( 1 );
- assertEquals( "Restriction should cardinality 1", 1, A.getCardinalityQ() );
- assertFalse( "Restriction should not be cardinality 3", A.hasCardinalityQ( 3 ) );
- assertTrue( "Restriction should be cardinality 1", A.hasCardinalityQ( 1 ) );
+ assertEquals( 1, A.getCardinalityQ(), "Restriction should cardinality 1" );
+ assertFalse( A.hasCardinalityQ( 3 ), "Restriction should not be cardinality 3" );
+ assertTrue( A.hasCardinalityQ( 1 ), "Restriction should be cardinality 1" );
- assertTrue( "Should be a qualified cardinality restriction", m.getResource( NS + "A" ).canAs( CardinalityQRestriction.class ) );
+ assertTrue( m.getResource( NS + "A" ).canAs( CardinalityQRestriction.class ), "Should be a qualified cardinality restriction" );
A.removeCardinalityQ( 1 );
- assertFalse( "Should not be a qualified cardinality restriction", m.getResource( NS + "A" ).canAs( CardinalityQRestriction.class ) );
+ assertFalse( m.getResource( NS + "A" ).canAs( CardinalityQRestriction.class ), "Should not be a qualified cardinality restriction" );
}
},
new OntTestCase( "MinCardinalityQRestriction.minCardinality", false, false, false ) {
@@ -692,19 +685,19 @@ public class TestClassExpression
MinCardinalityQRestriction A = m.createMinCardinalityQRestriction( NS + "A", p, 3, c );
- assertEquals( "Restriction should min cardinality 3", 3, A.getMinCardinalityQ() );
- assertTrue( "Restriction should be min cardinality 3", A.hasMinCardinalityQ( 3 ) );
- assertFalse( "Restriction should not be min cardinality 1", A.hasMinCardinalityQ( 1 ) );
+ assertEquals( 3, A.getMinCardinalityQ(), "Restriction should min cardinality 3" );
+ assertTrue( A.hasMinCardinalityQ( 3 ), "Restriction should be min cardinality 3" );
+ assertFalse( A.hasMinCardinalityQ( 1 ), "Restriction should not be min cardinality 1" );
A.setMinCardinalityQ( 1 );
- assertEquals( "Restriction should min cardinality 1", 1, A.getMinCardinalityQ() );
- assertFalse( "Restriction should not be min cardinality 3", A.hasMinCardinalityQ( 3 ) );
- assertTrue( "Restriction should be min cardinality 1", A.hasMinCardinalityQ( 1 ) );
+ assertEquals( 1, A.getMinCardinalityQ(), "Restriction should min cardinality 1" );
+ assertFalse( A.hasMinCardinalityQ( 3 ), "Restriction should not be min cardinality 3" );
+ assertTrue( A.hasMinCardinalityQ( 1 ), "Restriction should be min cardinality 1" );
- assertTrue( "Should be a qualified min cardinality restriction", m.getResource( NS + "A" ).canAs( MinCardinalityQRestriction.class ) );
+ assertTrue( m.getResource( NS + "A" ).canAs( MinCardinalityQRestriction.class ), "Should be a qualified min cardinality restriction" );
A.removeMinCardinalityQ( 1 );
- assertFalse( "Should not be a qualified min cardinality restriction", m.getResource( NS + "A" ).canAs( MinCardinalityQRestriction.class ) );
+ assertFalse( m.getResource( NS + "A" ).canAs( MinCardinalityQRestriction.class ), "Should not be a qualified min cardinality restriction" );
}
},
new OntTestCase( "MaxCardinalityQRestriction.maxCardinality", false, false, false ) {
@@ -715,19 +708,19 @@ public class TestClassExpression
MaxCardinalityQRestriction A = m.createMaxCardinalityQRestriction( NS + "A", p, 3, c );
- assertEquals( "Restriction should max cardinality 3", 3, A.getMaxCardinalityQ() );
- assertTrue( "Restriction should be max cardinality 3", A.hasMaxCardinalityQ( 3 ) );
- assertFalse( "Restriction should not be max cardinality 1", A.hasMaxCardinalityQ( 1 ) );
+ assertEquals( 3, A.getMaxCardinalityQ(), "Restriction should max cardinality 3" );
+ assertTrue( A.hasMaxCardinalityQ( 3 ), "Restriction should be max cardinality 3" );
+ assertFalse( A.hasMaxCardinalityQ( 1 ), "Restriction should not be max cardinality 1" );
A.setMaxCardinalityQ( 1 );
- assertEquals( "Restriction should max cardinality 1", 1, A.getMaxCardinalityQ() );
- assertFalse( "Restriction should not be max cardinality 3", A.hasMaxCardinalityQ( 3 ) );
- assertTrue( "Restriction should be max cardinality 1", A.hasMaxCardinalityQ( 1 ) );
+ assertEquals( 1, A.getMaxCardinalityQ(), "Restriction should max cardinality 1" );
+ assertFalse( A.hasMaxCardinalityQ( 3 ), "Restriction should not be max cardinality 3" );
+ assertTrue( A.hasMaxCardinalityQ( 1 ), "Restriction should be max cardinality 1" );
- assertTrue( "Should be a qualified max cardinality restriction", m.getResource( NS + "A" ).canAs( MaxCardinalityQRestriction.class ) );
+ assertTrue( m.getResource( NS + "A" ).canAs( MaxCardinalityQRestriction.class ), "Should be a qualified max cardinality restriction" );
A.removeMaxCardinalityQ( 1 );
- assertFalse( "Should not be a qualified max cardinality restriction", m.getResource( NS + "A" ).canAs( MaxCardinalityQRestriction.class ) );
+ assertFalse( m.getResource( NS + "A" ).canAs( MaxCardinalityQRestriction.class ), "Should not be a qualified max cardinality restriction" );
}
},
@@ -756,7 +749,7 @@ public class TestClassExpression
OntClass A = m.createClass( NS + "ClassA" );
OntClass C = m.createClass( NS + "ClassC" );
- assertTrue( "A should be equiv to C", A.hasEquivalentClass( C ) );
+ assertTrue( A.hasEquivalentClass( C ), "A should be equiv to C" );
}
},
new OntTestCase( "OntClass.disjoint.fromFile", true, false, false ) {
@@ -769,7 +762,7 @@ public class TestClassExpression
OntClass A = m.createClass( NS + "ClassA" );
OntClass D = m.createClass( NS + "ClassD" );
- assertTrue( "A should be disjoint with D", A.isDisjointWith( D ) );
+ assertTrue( A.isDisjointWith( D ), "A should be disjoint with D" );
}
},
@@ -782,11 +775,11 @@ public class TestClassExpression
Individual y = m.createIndividual( NS + "y", b );
OntClass a = m.createEnumeratedClass( NS + "A", m.createList( new RDFNode[] {x, y} ) );
- assertTrue( "enumerated class test not correct", a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", !a.isUnionClass() );
- assertTrue( "complement class test not correct", !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( !a.isUnionClass(), "union class test not correct" );
+ assertTrue( !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
}
},
new OntTestCase( "OntClass.isIntersectionClass", true, true, false ) {
@@ -796,11 +789,11 @@ public class TestClassExpression
OntClass c = m.createClass( NS + "C" );
OntClass a = m.createIntersectionClass( NS + "A", m.createList( new RDFNode[] {b,c} ) );
- assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", a.isIntersectionClass() );
- assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
- assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( m_owlLiteLang || !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isUnionClass(), "union class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
}
},
new OntTestCase( "OntClass.isUnionClass", true, false, false ) {
@@ -810,11 +803,11 @@ public class TestClassExpression
OntClass c = m.createClass( NS + "C" );
OntClass a = m.createUnionClass( NS + "A", m.createList( new RDFNode[] {b,c} ) );
- assertTrue( "enumerated class test not correct", !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", a.isUnionClass() );
- assertTrue( "complement class test not correct", !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( a.isUnionClass(), "union class test not correct" );
+ assertTrue( !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
}
},
new OntTestCase( "OntClass.isComplementClass", true, false, false ) {
@@ -823,11 +816,11 @@ public class TestClassExpression
OntClass b = m.createClass( NS + "B" );
OntClass a = m.createComplementClass( NS + "A", b );
- assertTrue( "enumerated class test not correct", !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", !a.isUnionClass() );
- assertTrue( "complement class test not correct", a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( !a.isUnionClass(), "union class test not correct" );
+ assertTrue( a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
}
},
new OntTestCase( "OntClass.isRestriction", true, true, false ) {
@@ -835,11 +828,11 @@ public class TestClassExpression
public void ontTest( OntModel m ) {
OntClass a = m.createRestriction( null );
- assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
- assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
- assertTrue( "restriction test not correct", a.isRestriction() );
+ assertTrue( m_owlLiteLang || !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isUnionClass(), "union class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( a.isRestriction(), "restriction test not correct" );
}
},
@@ -849,22 +842,22 @@ public class TestClassExpression
public void ontTest( OntModel m ) {
OntClass a = m.createClass( NS + "A" );
- assertTrue( "enumerated class test not correct", !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", !a.isUnionClass() );
- assertTrue( "complement class test not correct", !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( !a.isUnionClass(), "union class test not correct" );
+ assertTrue( !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
OntClass b = m.createClass( NS + "B" );
Individual x = m.createIndividual( NS + "x", b );
Individual y = m.createIndividual( NS + "y", b );
a = a.convertToEnumeratedClass( m.createList( new RDFNode[] {x, y} ) );
- assertTrue( "enumerated class test not correct", a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", !a.isUnionClass() );
- assertTrue( "complement class test not correct", !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( !a.isUnionClass(), "union class test not correct" );
+ assertTrue( !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
}
},
new OntTestCase( "OntClass.toIntersectionClass", true, true, false ) {
@@ -872,21 +865,21 @@ public class TestClassExpression
public void ontTest( OntModel m ) {
OntClass a = m.createClass( NS + "A" );
- assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
- assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( m_owlLiteLang || !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isUnionClass(), "union class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
OntClass b = m.createClass( NS + "B" );
OntClass c = m.createClass( NS + "C" );
a = a.convertToIntersectionClass( m.createList( new RDFNode[] {b,c} ) );
- assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", a.isIntersectionClass() );
- assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
- assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( m_owlLiteLang || !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isUnionClass(), "union class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
}
},
new OntTestCase( "OntClass.toUnionClass", true, false, false ) {
@@ -894,21 +887,21 @@ public class TestClassExpression
public void ontTest( OntModel m ) {
OntClass a = m.createClass( NS + "A" );
- assertTrue( "enumerated class test not correct", !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", !a.isUnionClass() );
- assertTrue( "complement class test not correct", !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( !a.isUnionClass(), "union class test not correct" );
+ assertTrue( !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
OntClass b = m.createClass( NS + "B" );
OntClass c = m.createClass( NS + "C" );
a = a.convertToUnionClass( m.createList( new RDFNode[] {b,c} ) );
- assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", m_owlLiteLang || a.isUnionClass() );
- assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( m_owlLiteLang || !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( m_owlLiteLang || a.isUnionClass(), "union class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
}
},
new OntTestCase( "OntClass.toComplementClass", true, false, false ) {
@@ -916,20 +909,20 @@ public class TestClassExpression
public void ontTest( OntModel m ) {
OntClass a = m.createClass( NS + "A" );
- assertTrue( "enumerated class test not correct", !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", !a.isUnionClass() );
- assertTrue( "complement class test not correct", !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( !a.isUnionClass(), "union class test not correct" );
+ assertTrue( !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
OntClass b = m.createClass( NS + "B" );
a = a.convertToComplementClass( b );
- assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
- assertTrue( "complement class test not correct", m_owlLiteLang || a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( m_owlLiteLang || !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isUnionClass(), "union class test not correct" );
+ assertTrue( m_owlLiteLang || a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
}
},
new OntTestCase( "OntClass.toRestriction", true, true, false ) {
@@ -937,24 +930,23 @@ public class TestClassExpression
public void ontTest( OntModel m ) {
OntClass a = m.createClass( NS + "A" );
- assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
- assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
- assertTrue( "restriction test not correct", !a.isRestriction() );
+ assertTrue( m_owlLiteLang || !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isUnionClass(), "union class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( !a.isRestriction(), "restriction test not correct" );
ObjectProperty p = m.createObjectProperty( NS + "p" );
a = a.convertToRestriction( p );
- assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
- assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
- assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
- assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
- assertTrue( "restriction test not correct", a.isRestriction() );
+ assertTrue( m_owlLiteLang || !a.isEnumeratedClass(), "enumerated class test not correct" );
+ assertTrue( !a.isIntersectionClass(), "intersection class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isUnionClass(), "union class test not correct" );
+ assertTrue( m_owlLiteLang || !a.isComplementClass(), "complement class test not correct" );
+ assertTrue( a.isRestriction(), "restriction test not correct" );
}
},
-
// restriction type testing
new OntTestCase( "Restriction.isAllValuesFrom", true, true, false ) {
@Override
@@ -963,12 +955,12 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createAllValuesFromRestriction( null, p, b );
- assertTrue( "all values from test not correct", a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.isSomeValuesFrom", true, true, false ) {
@@ -978,12 +970,12 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createSomeValuesFromRestriction( null, p, b );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.isHasValue", true, false, false ) {
@@ -994,12 +986,12 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createHasValueRestriction( null, p, x );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.isCardinality", true, true, false ) {
@@ -1008,12 +1000,12 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createCardinalityRestriction( null, p, 3 );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.isMinCardinality", true, true, false ) {
@@ -1022,12 +1014,12 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createMinCardinalityRestriction( null, p, 1 );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.isMaxCardinality", true, true, false ) {
@@ -1036,12 +1028,12 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createMaxCardinalityRestriction( null, p, 5 );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
@@ -1052,22 +1044,22 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createRestriction( p );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
OntClass b = m.createClass( NS + "B" );
a = a.convertToAllValuesFromRestriction( b );
- assertTrue( "all values from test not correct", a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.convertToSomeValuesFrom", true, true, false ) {
@@ -1076,22 +1068,22 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createRestriction( p );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
OntClass b = m.createClass( NS + "B" );
a = a.convertToSomeValuesFromRestriction( b );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.convertToHasValue", true, false, false ) {
@@ -1100,23 +1092,23 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createRestriction( p );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
OntClass b = m.createClass( NS + "B" );
Individual x = m.createIndividual( b );
a = a.convertToHasValueRestriction( x );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.convertCardinality", true, true, false ) {
@@ -1125,21 +1117,21 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createRestriction( p );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
a = a.convertToCardinalityRestriction( 3 );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.convertMinCardinality", true, true, false ) {
@@ -1148,21 +1140,21 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createRestriction( p );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
a = a.convertToMinCardinalityRestriction( 3 );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "Restriction.convertMaxCardinality", true, true, false ) {
@@ -1171,21 +1163,21 @@ public class TestClassExpression
ObjectProperty p = m.createObjectProperty( NS + "p" );
Restriction a = m.createRestriction( p );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", !a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( !a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
a = a.convertToMaxCardinalityRestriction( 3 );
- assertTrue( "all values from test not correct", !a.isAllValuesFromRestriction() );
- assertTrue( "some values from test not correct", !a.isSomeValuesFromRestriction() );
- assertTrue( "has value test not correct", m_owlLiteLang || !a.isHasValueRestriction() );
- assertTrue( "cardinality test not correct", !a.isCardinalityRestriction() );
- assertTrue( "min cardinality test not correct", !a.isMinCardinalityRestriction() );
- assertTrue( "max cardinality test not correct", a.isMaxCardinalityRestriction() );
+ assertTrue( !a.isAllValuesFromRestriction(), "all values from test not correct" );
+ assertTrue( !a.isSomeValuesFromRestriction(), "some values from test not correct" );
+ assertTrue( m_owlLiteLang || !a.isHasValueRestriction(), "has value test not correct" );
+ assertTrue( !a.isCardinalityRestriction(), "cardinality test not correct" );
+ assertTrue( !a.isMinCardinalityRestriction(), "min cardinality test not correct" );
+ assertTrue( a.isMaxCardinalityRestriction(), "max cardinality test not correct" );
}
},
new OntTestCase( "OntClass.listInstances", true, true, true ) {
@@ -1252,8 +1244,8 @@ public class TestClassExpression
iteratorTest( C.listDeclaredProperties( false ), new Object[] { p, q, s} );
iteratorTest( C.listDeclaredProperties( true ), new Object[] {s} );
- assertNotNull( "declared property should be an ont prop", C.listDeclaredProperties( true ).next() );
- assertNotNull( "declared property should be an ont prop", C.listDeclaredProperties( false ).next() );
+ assertNotNull( C.listDeclaredProperties( true ).next(), "declared property should be an ont prop" );
+ assertNotNull( C.listDeclaredProperties( false ).next(), "declared property should be an ont prop" );
}
},
new OntTestCase( "DataRange.oneOf", true, false, false ) {
@@ -1266,22 +1258,22 @@ public class TestClassExpression
DataRange d0 = m.createDataRange( lits );
- assertTrue( "datarange should contain x", d0.hasOneOf( x ) );
- assertTrue( "datarange should contain y", d0.hasOneOf( y ) );
- assertFalse( "datarange should not contain z", d0.hasOneOf( z ) );
+ assertTrue( d0.hasOneOf( x ), "datarange should contain x" );
+ assertTrue( d0.hasOneOf( y ), "datarange should contain y" );
+ assertFalse( d0.hasOneOf( z ), "datarange should not contain z" );
d0.removeOneOf( z );
- assertTrue( "datarange should contain x", d0.hasOneOf( x ) );
- assertTrue( "datarange should contain y", d0.hasOneOf( y ) );
- assertFalse( "datarange should not contain z", d0.hasOneOf( z ) );
+ assertTrue( d0.hasOneOf( x ), "datarange should contain x" );
+ assertTrue( d0.hasOneOf( y ), "datarange should contain y" );
+ assertFalse( d0.hasOneOf( z ), "datarange should not contain z" );
d0.removeOneOf( x );
- assertFalse( "datarange should not contain x", d0.hasOneOf( x ) );
- assertTrue( "datarange should contain y", d0.hasOneOf( y ) );
- assertFalse( "datarange should not contain z", d0.hasOneOf( z ) );
+ assertFalse( d0.hasOneOf( x ), "datarange should not contain x" );
+ assertTrue( d0.hasOneOf( y ), "datarange should contain y" );
+ assertFalse( d0.hasOneOf( z ), "datarange should not contain z" );
d0.addOneOf( z );
- assertEquals( "datarange should be size 2", 2, d0.getOneOf().size() );
+ assertEquals( 2, d0.getOneOf().size(), "datarange should be size 2" );
iteratorTest( d0.listOneOf(), new Object[] {y,z} );
d0.setOneOf( m.createList( new RDFNode[] {x} ) );
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestCreateInOntModel.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestCreateInOntModel.java
index 72d56a3b76..72b23ff73c 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestCreateInOntModel.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestCreateInOntModel.java
@@ -23,12 +23,17 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+
+import org.apache.jena.test.JenaTestLib;
import org.apache.jena.ontology.AllDifferent;
import org.apache.jena.ontology.AllValuesFromRestriction;
import org.apache.jena.ontology.AnnotationProperty;
@@ -62,8 +67,6 @@ import org.apache.jena.rdf.model.RDFList;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.vocabulary.OWL;
-
-
/**
* <p>
* Unit test cases for creating values in ontology models
@@ -71,8 +74,9 @@ import org.apache.jena.vocabulary.OWL;
*/
@SuppressWarnings("removal")
public class TestCreateInOntModel
- extends TestCase
{
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
public static final String BASE = "http://jena.hpl.hp.com/testing/ontology";
@@ -402,11 +406,6 @@ public class TestCreateInOntModel
// Constructors
//////////////////////////////////
- public TestCreateInOntModel( String name ) {
- super( name );
- }
-
-
// External signature methods
//////////////////////////////////
@@ -414,19 +413,17 @@ public class TestCreateInOntModel
return "TestCreate";
}
- public static TestSuite suite() {
- TestSuite s = new TestSuite( "TestCreate" );
-
- for ( CreateTestCase testCase : testCases )
- {
- s.addTest( testCase );
- }
-
- return s;
+ /**
+ * One dynamic test per entry of the {@code testCases} table. The JUnit3
+ * original added each {@code CreateTestCase} to a {@code TestSuite}, so one
+ * entry remains one test.
+ */
+ @TestFactory
+ public Stream<DynamicTest> createInOntModelTests() {
+ return Stream.of( testCases )
+ .map( tc -> DynamicTest.dynamicTest( tc.getName(), () -> { tc.setUp(); tc.runTest(); } ) );
}
-
-
// Internal implementation methods
//////////////////////////////////
@@ -435,42 +432,44 @@ public class TestCreateInOntModel
//==============================================================================
protected static class CreateTestCase
- extends TestCase
{
+ protected String m_name;
protected String m_lang;
protected String m_uri;
public CreateTestCase( String name, String lang, String uri ) {
- super( name );
+ m_name = name;
m_lang = lang;
m_uri = uri;
}
- @Override
+ /** The name this case ran under in the JUnit3 suite. */
+ public String getName() {
+ return m_name;
+ }
+
public void runTest() {
OntModel m = ModelFactory.createOntologyModel( m_lang );
// do the creation step
OntResource r = doCreate( m );
- assertNotNull( "Result of creation step should not be null", r );
+ assertNotNull( r, "Result of creation step should not be null" );
if (m_uri == null) {
- assertTrue( "Created resource should be anonymous", r.isAnon() );
+ assertTrue( r.isAnon(), "Created resource should be anonymous" );
}
else {
- assertEquals( "Created resource has wrong uri", m_uri, r.getURI() );
+ assertEquals( m_uri, r.getURI(), "Created resource has wrong uri" );
}
- assertTrue( "Result test failed", test( r ));
+ assertTrue( test( r ), "Result test failed");
}
- @Override
public void setUp() {
// ensure the ont doc manager is in a consistent state
OntDocumentManager.getInstance().reset( true );
}
-
/* get the resource */
public OntResource doCreate( OntModel m ) {
// to be overridden in sub-classes
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestFrameView.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestFrameView.java
index 9584d58bcc..03cee8e545 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestFrameView.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestFrameView.java
@@ -25,13 +25,16 @@ package org.apache.jena.ontology.impl;
// Imports
///////////////
-import junit.framework.TestCase;
import org.apache.jena.ontology.*;
import org.apache.jena.rdf.model.*;
-import org.apache.jena.reasoner.test.TestUtil;
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -40,8 +43,10 @@ import org.apache.jena.reasoner.test.TestUtil;
*/
@SuppressWarnings("removal")
public class TestFrameView
- extends TestCase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
@@ -107,7 +112,7 @@ public class TestFrameView
// External signature methods
//////////////////////////////////
- @Override
+ @BeforeEach
public void setUp() {
OntDocumentManager.getInstance().reset();
OntDocumentManager.getInstance().clearCache();
@@ -121,7 +126,6 @@ public class TestFrameView
infB = mInf.getOntClass( NS + "B" );
infC = mInf.getOntClass( NS + "C" );
-
noinfA = mNoInf.getOntClass( NS + "A" );
noinfB = mNoInf.getOntClass( NS + "B" );
noinfC = mNoInf.getOntClass( NS + "C" );
@@ -163,13 +167,13 @@ public class TestFrameView
noinfPintersect = mNoInf.getObjectProperty( NS + "intersectP" );
}
- @Override
+ @AfterEach
public void tearDown() {
/* assistance with monitoring space leak
System.gc();
System.gc();
Runtime r = Runtime.getRuntime();
- System.out.println( getName() +
+ System.out.println( getClass().getSimpleName() +
" memory = " + r.freeMemory() +
", alloc = " + r.totalMemory() +
", % = " + Math.round( 100.0 * (double) r.freeMemory() / (double) r.totalMemory() ));
@@ -182,11 +186,13 @@ public class TestFrameView
// OntClass.listDeclaredProperties() tests ...
+ @Test
public void testLDP_noinfA_nodirect() {
- TestUtil.assertIteratorValues( this, noinfA.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(noinfA.listDeclaredProperties( false ),
new Object[] {noinfPa, noinfQa, noinfG, noinfQb} );
}
+ @Test
public void testHasDP_noinfA_nodirect() {
// we only need a small number of tests on hasDP because it's the
// main componenet of listDP
@@ -194,196 +200,228 @@ public class TestFrameView
assertFalse( noinfA.hasDeclaredProperty( noinfPb, false ) );
}
+ @Test
public void testLDP_noinfA_direct() {
- TestUtil.assertIteratorValues( this, noinfA.listDeclaredProperties( true ),
+ OntTestUtil.assertIteratorValues(noinfA.listDeclaredProperties( true ),
new Object[] {noinfPa, noinfQa, noinfG, noinfQb} );
}
+ @Test
public void testLDP_infA_nodirect() {
- TestUtil.assertIteratorValues( this, infA.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(infA.listDeclaredProperties( false ),
new Object[] {infPa, infQa, infQb, noinfG} );
}
+ @Test
public void testLDP_infA_direct() {
- TestUtil.assertIteratorValues( this, infA.listDeclaredProperties( true ),
+ OntTestUtil.assertIteratorValues(infA.listDeclaredProperties( true ),
new Object[] {infPa, infQa, infQb, noinfG} );
}
+ @Test
public void testLDP_noinfB_nodirect() {
- TestUtil.assertIteratorValues( this, noinfB.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(noinfB.listDeclaredProperties( false ),
new Object[] {noinfPa, noinfPb, noinfQa, noinfG, noinfQb} );
}
+ @Test
public void testLDP_noinfB_direct() {
- TestUtil.assertIteratorValues( this, noinfB.listDeclaredProperties( true ),
+ OntTestUtil.assertIteratorValues(noinfB.listDeclaredProperties( true ),
new Object[] {noinfPb} );
}
+ @Test
public void testLDP_infB_nodirect() {
- TestUtil.assertIteratorValues( this, infB.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(infB.listDeclaredProperties( false ),
new Object[] {infPa, infPb, infQa, infQb, infG} );
}
+ @Test
public void testLDP_infB_direct() {
- TestUtil.assertIteratorValues( this, infB.listDeclaredProperties( true ),
+ OntTestUtil.assertIteratorValues(infB.listDeclaredProperties( true ),
new Object[] {infPb} );
}
+ @Test
public void testLDP_noinfC_nodirect() {
// note that qB appears in the results because without inference it looks like a global
- TestUtil.assertIteratorValues( this, noinfC.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(noinfC.listDeclaredProperties( false ),
new Object[] {noinfPa, noinfPb, noinfPc, noinfQa, noinfG, noinfQb} );
}
+ @Test
public void testLDP_noinfC_direct() {
- TestUtil.assertIteratorValues( this, noinfC.listDeclaredProperties( true ),
+ OntTestUtil.assertIteratorValues(noinfC.listDeclaredProperties( true ),
new Object[] {noinfPc} );
}
+ @Test
public void testLDP_infC_nodirect() {
- TestUtil.assertIteratorValues( this, infC.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(infC.listDeclaredProperties( false ),
new Object[] {infPa, infPb, infPc, infQa, infQb, infG} );
}
+ @Test
public void testLDP_infC_direct() {
- TestUtil.assertIteratorValues( this, infC.listDeclaredProperties( true ),
+ OntTestUtil.assertIteratorValues(infC.listDeclaredProperties( true ),
new Object[] {infPc} );
}
-
+ @Test
public void testLDP_noinfAnn_nodirect() {
// note that qB appears in the results because without inference it looks like a global
- TestUtil.assertIteratorValues( this, noinfAnn.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(noinfAnn.listDeclaredProperties( false ),
new Object[] {noinfPann, noinfG, noinfQb} );
}
+ @Test
public void testLDP_noinfAnn_direct() {
- TestUtil.assertIteratorValues( this, noinfAnn.listDeclaredProperties( true ),
+ OntTestUtil.assertIteratorValues(noinfAnn.listDeclaredProperties( true ),
new Object[] {noinfPann, noinfG, noinfQb} );
}
+ @Test
public void testLDP_infAnn_nodirect() {
- TestUtil.assertIteratorValues( this, infAnn.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(infAnn.listDeclaredProperties( false ),
new Object[] {noinfPann, noinfG} );
}
+ @Test
public void testLDP_infAnn_direct() {
- TestUtil.assertIteratorValues( this, infAnn.listDeclaredProperties( true ),
+ OntTestUtil.assertIteratorValues(infAnn.listDeclaredProperties( true ),
new Object[] {noinfPann, noinfG} );
}
-
+ @Test
public void testLDP_noinfUnion_nodirect() {
- TestUtil.assertIteratorValues( this, noinfUnion1.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(noinfUnion1.listDeclaredProperties( false ),
new Object[] {noinfG, noinfQb} );
- TestUtil.assertIteratorValues( this, noinfUnion2.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(noinfUnion2.listDeclaredProperties( false ),
new Object[] {noinfG, noinfQb} );
}
+ @Test
public void testLDP_infUnion_nodirect() {
- TestUtil.assertIteratorValues( this, infUnion1.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(infUnion1.listDeclaredProperties( false ),
new Object[] {infPunion, infG} );
- TestUtil.assertIteratorValues( this, infUnion2.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(infUnion2.listDeclaredProperties( false ),
new Object[] {infPunion, infG} );
}
+ @Test
public void testLDP_noinfIntersect_nodirect() {
- TestUtil.assertIteratorValues( this, noinfIntersect1.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(noinfIntersect1.listDeclaredProperties( false ),
new Object[] {noinfG, noinfQb} );
- TestUtil.assertIteratorValues( this, noinfIntersect2.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(noinfIntersect2.listDeclaredProperties( false ),
new Object[] {noinfG, noinfQb} );
}
+ @Test
public void testLDP_infIntersect_nodirect() {
- TestUtil.assertIteratorValues( this, infIntersect1.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(infIntersect1.listDeclaredProperties( false ),
new Object[] {infG} );
- TestUtil.assertIteratorValues( this, infIntersect2.listDeclaredProperties( false ),
+ OntTestUtil.assertIteratorValues(infIntersect2.listDeclaredProperties( false ),
new Object[] {infG} );
}
// OntProperty.listDeclaringProperties() tests ...
+ @Test
public void testLDC_noinfPa_nodirect() {
- TestUtil.assertIteratorValues( this, noinfPa.listDeclaringClasses( false ),
+ OntTestUtil.assertIteratorValues(noinfPa.listDeclaringClasses( false ),
new Object[] {noinfA, noinfB, noinfC} );
}
+ @Test
public void testLDC_infPa_nodirect() {
- TestUtil.assertIteratorValues( this, infPa.listDeclaringClasses( false ),
+ OntTestUtil.assertIteratorValues(infPa.listDeclaringClasses( false ),
new Object[] {infA, infB, infC} );
}
+ @Test
public void testLDC_noinfPb_nodirect() {
- TestUtil.assertIteratorValues( this, noinfPb.listDeclaringClasses( false ),
+ OntTestUtil.assertIteratorValues(noinfPb.listDeclaringClasses( false ),
new Object[] {noinfB, noinfC} );
}
+ @Test
public void testLDC_infPb_nodirect() {
- TestUtil.assertIteratorValues( this, infPb.listDeclaringClasses( false ),
+ OntTestUtil.assertIteratorValues(infPb.listDeclaringClasses( false ),
new Object[] {infC, infB} );
}
+ @Test
public void testLDC_noinfPc_nodirect() {
- TestUtil.assertIteratorValues( this, noinfPc.listDeclaringClasses( false ),
+ OntTestUtil.assertIteratorValues(noinfPc.listDeclaringClasses( false ),
new Object[] {noinfC} );
}
+ @Test
public void testLDC_infPc_nodirect() {
- TestUtil.assertIteratorValues( this, infPc.listDeclaringClasses( false ),
+ OntTestUtil.assertIteratorValues(infPc.listDeclaringClasses( false ),
new Object[] {infC} );
}
+ @Test
public void testLDC_noinfPa_direct() {
- TestUtil.assertIteratorValues( this, noinfPa.listDeclaringClasses( true ),
+ OntTestUtil.assertIteratorValues(noinfPa.listDeclaringClasses( true ),
new Object[] {noinfA} );
}
+ @Test
public void testLDC_infPa_direct() {
- TestUtil.assertIteratorValues( this, infPa.listDeclaringClasses( true ),
+ OntTestUtil.assertIteratorValues(infPa.listDeclaringClasses( true ),
new Object[] {infA} );
}
+ @Test
public void testLDC_noinfPb_direct() {
- TestUtil.assertIteratorValues( this, noinfPb.listDeclaringClasses( true ),
+ OntTestUtil.assertIteratorValues(noinfPb.listDeclaringClasses( true ),
new Object[] {noinfB} );
}
+ @Test
public void testLDC_infPb_direct() {
- TestUtil.assertIteratorValues( this, infPb.listDeclaringClasses( true ),
+ OntTestUtil.assertIteratorValues(infPb.listDeclaringClasses( true ),
new Object[] {infB} );
}
+ @Test
public void testLDC_noinfPc_direct() {
- TestUtil.assertIteratorValues( this, noinfPc.listDeclaringClasses( true ),
+ OntTestUtil.assertIteratorValues(noinfPc.listDeclaringClasses( true ),
new Object[] {noinfC} );
}
+ @Test
public void testLDC_infPc_direct() {
- TestUtil.assertIteratorValues( this, infPc.listDeclaringClasses( true ),
+ OntTestUtil.assertIteratorValues(infPc.listDeclaringClasses( true ),
new Object[] {infC} );
}
+ @Test
public void testLDC_noinfG_direct() {
- TestUtil.assertIteratorValues( this, noinfG.listDeclaringClasses( true ),
+ OntTestUtil.assertIteratorValues(noinfG.listDeclaringClasses( true ),
new Object[] {noinfA, noinfAnn, noinfUnion1, noinfUnion2, mNoInf.getOntClass(NS+"Joint"),noinfIntersect1,noinfIntersect2}, 2 );
}
+ @Test
public void testLDC_infG_direct() {
- TestUtil.assertIteratorValues( this, infG.listDeclaringClasses( true ),
+ OntTestUtil.assertIteratorValues(infG.listDeclaringClasses( true ),
new Object[] {infA, infAnn, mNoInf.getOntClass(NS+"Joint"),noinfIntersect1,noinfIntersect2}, 1 );
}
+ @Test
public void testLDC_noinfG_nodirect() {
- TestUtil.assertIteratorValues( this, noinfG.listDeclaringClasses( false ),
+ OntTestUtil.assertIteratorValues(noinfG.listDeclaringClasses( false ),
new Object[] {noinfA, noinfB, noinfC, noinfUnion1, noinfUnion2, noinfAnn, mNoInf.getOntClass(NS+"Joint"),noinfIntersect1,noinfIntersect2}, 2 );
}
+ @Test
public void testLDC_infG_nodirect() {
- TestUtil.assertIteratorValues( this, infG.listDeclaringClasses( false ),
+ OntTestUtil.assertIteratorValues(infG.listDeclaringClasses( false ),
new Object[] {infA, infB, infC, infAnn, noinfUnion1, noinfUnion2, mNoInf.getOntClass(NS+"Joint"),noinfIntersect1,noinfIntersect2}, 2 );
}
-
// Internal implementation methods
//////////////////////////////////
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestIndividual.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestIndividual.java
index 4eb2c3cd93..d5ea25169c 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestIndividual.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestIndividual.java
@@ -23,11 +23,9 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
-import junit.framework.TestSuite;
import org.apache.jena.ontology.Individual;
import org.apache.jena.ontology.OntClass;
import org.apache.jena.ontology.OntModel;
@@ -43,6 +41,9 @@ import org.apache.jena.vocabulary.RDFS;
import java.io.StringReader;
import java.util.Iterator;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -50,32 +51,23 @@ import java.util.Iterator;
* </p>
*/
@SuppressWarnings("removal")
-public class TestIndividual
- extends OntTestBase
+public class TestIndividual extends OntTestBase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
// Static variables
//////////////////////////////////
-
-
// Instance variables
//////////////////////////////////
// Constructors
//////////////////////////////////
- static public TestSuite suite() {
- return new TestIndividual( "TestIndividual" );
- }
-
- public TestIndividual( String name ) {
- super( name );
- }
-
-
// External signature methods
//////////////////////////////////
@@ -93,22 +85,22 @@ public class TestIndividual
Individual z = m.createIndividual( A );
x.addSameAs( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.SAME_AS() ) );
- assertEquals( "x should be the same as y", y, x.getSameAs() );
- assertTrue( "x should be the same as y", x.isSameAs( y ) );
+ assertEquals( 1, x.getCardinality( prof.SAME_AS() ), "Cardinality should be 1" );
+ assertEquals( y, x.getSameAs(), "x should be the same as y" );
+ assertTrue( x.isSameAs( y ), "x should be the same as y" );
x.addSameAs( z );
- assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.SAME_AS() ) );
+ assertEquals( 2, x.getCardinality( prof.SAME_AS() ), "Cardinality should be 2" );
iteratorTest( x.listSameAs(), new Object[] {z,y} );
x.setSameAs( z );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.SAME_AS() ) );
- assertEquals( "x should be same indiv. as z", z, x.getSameAs() );
+ assertEquals( 1, x.getCardinality( prof.SAME_AS() ), "Cardinality should be 1" );
+ assertEquals( z, x.getSameAs(), "x should be same indiv. as z" );
x.removeSameAs( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.SAME_AS() ) );
+ assertEquals( 1, x.getCardinality( prof.SAME_AS() ), "Cardinality should be 1" );
x.removeSameAs( z );
- assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.SAME_AS() ) );
+ assertEquals( 0, x.getCardinality( prof.SAME_AS() ), "Cardinality should be 0" );
}
},
@@ -323,9 +315,9 @@ public class TestIndividual
"</rdf:RDF>";
m.read( new StringReader( SOURCE ), null );
Individual x = m.getIndividual( "http://jena.hpl.hp.com/test#x" );
- assertEquals( "Label on resource x", "a_label", x.getLabel( null) );
- assertEquals( "Label on resource x", "a_label", x.getLabel( "" ) );
- assertSame( "fr label on resource x", null, x.getLabel( "fr" ) );
+ assertEquals( "a_label", x.getLabel( null), "Label on resource x" );
+ assertEquals( "a_label", x.getLabel( "" ), "Label on resource x" );
+ assertSame( null, x.getLabel( "fr" ), "fr label on resource x" );
}
},
@@ -335,7 +327,7 @@ public class TestIndividual
OntModel defModel = ModelFactory.createOntologyModel();
OntClass c = defModel.createClass( "http://example.com/test#A" );
Individual i = c.createIndividual();
- assertTrue( "i should be an individual", i.isIndividual() );
+ assertTrue( i.isIndividual(), "i should be an individual" );
}
},
/** User report of builtin classes showing up as individuals */
@@ -349,7 +341,7 @@ public class TestIndividual
for (Iterator<OntClass> it = m.listClasses(); it.hasNext(); ) {
OntClass ontClass = it.next();
- assertFalse( ontClass.getLocalName() + "should not be an individual", ontClass.isIndividual() );
+ assertFalse( ontClass.isIndividual(), ontClass.getLocalName() + "should not be an individual" );
}
}
},
@@ -364,7 +356,7 @@ public class TestIndividual
for (Iterator<OntClass> it=m.listClasses(); it.hasNext(); ) {
OntClass ontClass = it.next();
- assertFalse( ontClass.getLocalName() + "should not be an individual", ontClass.isIndividual() );
+ assertFalse( ontClass.isIndividual(), ontClass.getLocalName() + "should not be an individual" );
}
}
},
@@ -381,7 +373,7 @@ public class TestIndividual
for (Iterator<OntClass> it = m.listClasses(); it.hasNext(); ) {
OntClass ontClass = it.next();
- assertFalse( ontClass.getLocalName() + " should not be an individual", ontClass.isIndividual() );
+ assertFalse( ontClass.isIndividual(), ontClass.getLocalName() + " should not be an individual" );
}
}
},
@@ -397,7 +389,7 @@ public class TestIndividual
for (Iterator<OntClass> it = m.listClasses(); it.hasNext(); ) {
OntClass ontClass = it.next();
- assertFalse( ontClass.getLocalName() + " should not be an individual", ontClass.isIndividual() );
+ assertFalse( ontClass.isIndividual(), ontClass.getLocalName() + " should not be an individual" );
}
}
},
@@ -413,7 +405,7 @@ public class TestIndividual
for (Iterator<OntClass> it = m.listClasses(); it.hasNext(); ) {
OntClass ontClass = it.next();
- assertFalse( ontClass.getLocalName() + " should not be an individual", ontClass.isIndividual() );
+ assertFalse( ontClass.isIndividual(), ontClass.getLocalName() + " should not be an individual" );
}
}
},
@@ -429,8 +421,8 @@ public class TestIndividual
OntClass c2 = m.createClass(NS + "C2");
m.add( punned, RDF.type, c2 ); // punned is a class and and instance of c2
- assertFalse( "should not be an individual", c2.isIndividual() );
- assertTrue( "should be an individual", punned.isIndividual() );
+ assertFalse( c2.isIndividual(), "should not be an individual" );
+ assertTrue( punned.isIndividual(), "should be an individual" );
}
},
@@ -444,12 +436,11 @@ public class TestIndividual
OntClass c2 = m.createClass(NS + "C2");
m.add( punned, RDF.type, c2 ); // punned is a class and and instance of c2
- assertFalse( "should not be an individual", c2.isIndividual() );
- assertTrue( "should be an individual", punned.isIndividual() );
+ assertFalse( c2.isIndividual(), "should not be an individual" );
+ assertTrue( punned.isIndividual(), "should be an individual" );
}
}
-
};
}
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestListSyntaxCategories.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestListSyntaxCategories.java
index 592e1cf5bb..6da65e69d2 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestListSyntaxCategories.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestListSyntaxCategories.java
@@ -26,8 +26,14 @@ package org.apache.jena.ontology.impl;
// Imports
///////////////
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+
+import org.apache.jena.test.JenaTestLib;
import org.apache.jena.ontology.AllDifferent;
import org.apache.jena.ontology.AnnotationProperty;
import org.apache.jena.ontology.FunctionalProperty;
@@ -64,13 +70,13 @@ import java.util.List;
*/
@SuppressWarnings("removal")
public class TestListSyntaxCategories
- extends TestCase
{
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
public static final String NS = "http://jena.hpl.hp.com/testing/ontology#";
-
// Static variables
//////////////////////////////////
@@ -668,34 +674,26 @@ public class TestListSyntaxCategories
},
};
-
// Instance variables
//////////////////////////////////
// Constructors
//////////////////////////////////
- public TestListSyntaxCategories( String name ) {
- super( name );
- }
-
-
-
// External signature methods
//////////////////////////////////
- public static TestSuite suite() {
- TestSuite s = new TestSuite( "TestListSyntaxCategories" );
-
- for ( DoListTest testCase : testCases )
- {
- s.addTest( testCase );
- }
-
- return s;
+ /**
+ * One dynamic test per entry of the {@code testCases} table. The JUnit3
+ * original added each {@code DoListTest} to a {@code TestSuite}, so one
+ * entry remains one test.
+ */
+ @TestFactory
+ public Stream<DynamicTest> listSyntaxCategoryTests() {
+ return Stream.of( testCases )
+ .map( tc -> DynamicTest.dynamicTest( tc.getName(), () -> { tc.setUp(); tc.runTest(); } ) );
}
-
// Internal implementation methods
//////////////////////////////////
@@ -704,8 +702,8 @@ public class TestListSyntaxCategories
//==============================================================================
protected static class DoListTest
- extends TestCase
{
+ protected String m_name;
protected String m_fileName;
protected OntModelSpec m_spec;
protected int m_count;
@@ -717,7 +715,7 @@ public class TestListSyntaxCategories
}
protected DoListTest( String name, String fileName, OntModelSpec spec, int count, String[] expected, boolean exExpected ) {
- super( name );
+ m_name = name;
m_fileName = fileName;
m_spec = spec;
m_count = count;
@@ -725,14 +723,16 @@ public class TestListSyntaxCategories
m_exExpected = exExpected;
}
- @Override
+ /** The name this case ran under in the JUnit3 suite. */
+ public String getName() {
+ return m_name;
+ }
+
public void setUp() {
// ensure the ont doc manager is in a consistent state
OntDocumentManager.getInstance().reset( true );
}
-
- @Override
public void runTest() {
Logger logger = LoggerFactory.getLogger( getClass() );
OntModel m = ModelFactory.createOntologyModel( m_spec, null );
@@ -754,7 +754,7 @@ public class TestListSyntaxCategories
exOccurred = true;
}
- assertEquals( "Ontology exception" + (m_exExpected ? " was " : " was not ") + "expected", m_exExpected, exOccurred );
+ assertEquals( m_exExpected, exOccurred, "Ontology exception" + (m_exExpected ? " was " : " was not ") + "expected" );
if (!exOccurred) {
List<Resource> expected = expected( m );
@@ -764,7 +764,7 @@ public class TestListSyntaxCategories
// now we walk the iterator
while (i.hasNext()) {
Resource res = i.next();
- assertTrue( "Should not fail node test on " + res, test( res ));
+ assertTrue( test( res ), "Should not fail node test on " + res);
actual.add( res );
if (expected != null) {
@@ -796,10 +796,10 @@ public class TestListSyntaxCategories
}
}
- assertEquals( getName() + ": wrong number of results returned", m_count, actual.size() );
+ assertEquals( m_count, actual.size(), getName() + ": wrong number of results returned" );
if (expected != null) {
- assertTrue( "Did not find all expected resources in iterator", expected.isEmpty() );
- assertEquals( "Found extraneous results, not in expected list", 0, extraneous );
+ assertTrue( expected.isEmpty(), "Did not find all expected resources in iterator" );
+ assertEquals( 0, extraneous, "Found extraneous results, not in expected list" );
}
}
}
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntClass.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntClass.java
index 3c0582e4f8..ced9e29f8d 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntClass.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntClass.java
@@ -23,6 +23,9 @@
///////////////
package org.apache.jena.ontology.impl;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
// Imports
///////////////
@@ -33,13 +36,11 @@ import org.apache.jena.ontology.OntModel;
import org.apache.jena.ontology.OntModelSpec;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.reasoner.test.TestUtil;
-import org.apache.jena.test.JenaTestBase;
+import org.apache.jena.test.JenaTestLib;
import org.apache.jena.vocabulary.OWL;
import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.RDFS;
-
/**
* <p>
* Misc. tests for OntClass, over and above those in
@@ -48,8 +49,10 @@ import org.apache.jena.vocabulary.RDFS;
*/
@SuppressWarnings("removal")
public class TestOntClass
- extends JenaTestBase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
@@ -64,13 +67,10 @@ public class TestOntClass
// Constructors
//////////////////////////////////
- public TestOntClass( String name ) {
- super( name );
- }
-
// External signature methods
//////////////////////////////////
+ @Test
public void testSuperClassNE() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
OntClass a = m.createClass( NS + "A" );
@@ -79,6 +79,7 @@ public class TestOntClass
assertFalse( a.hasSuperClass() );
}
+ @Test
public void testSubClassNE() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
OntClass a = m.createClass( NS + "A" );
@@ -87,6 +88,7 @@ public class TestOntClass
assertFalse( a.hasSubClass() );
}
+ @Test
public void testCreateIndividual() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
OntClass a = m.createClass( NS + "A" );
@@ -97,6 +99,7 @@ public class TestOntClass
assertTrue( j.hasRDFType(a) );
}
+ @Test
public void testIsHierarchyRoot0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
OntClass a = m.createClass( NS + "A" );
@@ -106,6 +109,7 @@ public class TestOntClass
assertFalse( b.isHierarchyRoot() );
}
+ @Test
public void testIsHierarchyRoot1() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RULE_INF );
OntClass a = m.createClass( NS + "A" );
@@ -115,6 +119,7 @@ public class TestOntClass
assertFalse( b.isHierarchyRoot() );
}
+ @Test
public void testIsHierarchyRoot2() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RDFS_INF );
OntClass a = m.createClass( NS + "A" );
@@ -124,6 +129,7 @@ public class TestOntClass
assertFalse( b.isHierarchyRoot() );
}
+ @Test
public void testIsHierarchyRoot3() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_TRANS_INF );
OntClass a = m.createClass( NS + "A" );
@@ -133,6 +139,7 @@ public class TestOntClass
assertFalse( b.isHierarchyRoot() );
}
+ @Test
public void testIsHierarchyRoot4() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_DL_MEM );
OntClass a = m.createClass( NS + "A" );
@@ -142,6 +149,7 @@ public class TestOntClass
assertFalse( b.isHierarchyRoot() );
}
+ @Test
public void testIsHierarchyRoot5() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM );
OntClass a = m.createClass( NS + "A" );
@@ -151,6 +159,7 @@ public class TestOntClass
assertFalse( b.isHierarchyRoot() );
}
+ @Test
public void testIsHierarchyRoot8() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM );
OntClass a = m.createClass( NS + "A" );
@@ -160,6 +169,7 @@ public class TestOntClass
assertFalse( b.isHierarchyRoot() );
}
+ @Test
public void testIsHierarchyRoot9() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM_RDFS_INF );
OntClass a = m.createClass( NS + "A" );
@@ -169,6 +179,7 @@ public class TestOntClass
assertFalse( b.isHierarchyRoot() );
}
+ @Test
public void testListSubClasses0() {
// no inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM );
@@ -178,12 +189,13 @@ public class TestOntClass
OntClass d = m.getOntClass( NS + "D" );
OntClass e = m.getOntClass( NS + "E" );
- TestUtil.assertIteratorValues( this, a.listSubClasses(), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, a.listSubClasses( false ), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, a.listSubClasses( true ), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, b.listSubClasses( true ), new Object[] {d,e} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses(), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses( false ), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses( true ), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(b.listSubClasses( true ), new Object[] {d,e} );
}
+ @Test
public void testListSubClasses1() {
// rule inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM_RULE_INF );
@@ -194,12 +206,13 @@ public class TestOntClass
OntClass e = m.getOntClass( NS + "E" );
OntClass f = m.getOntClass( NS + "F" );
- TestUtil.assertIteratorValues( this, a.listSubClasses(), new Object[] {b,c,d,e,f} );
- TestUtil.assertIteratorValues( this, a.listSubClasses( false ), new Object[] {b,c,d,e,f} );
- TestUtil.assertIteratorValues( this, a.listSubClasses( true ), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, b.listSubClasses( true ), new Object[] {d,e} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses(), new Object[] {b,c,d,e,f} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses( false ), new Object[] {b,c,d,e,f} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses( true ), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(b.listSubClasses( true ), new Object[] {d,e} );
}
+ @Test
public void testListSubClasses2() {
// micro rule inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF );
@@ -210,12 +223,13 @@ public class TestOntClass
OntClass e = m.getOntClass( NS + "E" );
OntClass f = m.getOntClass( NS + "F" );
- TestUtil.assertIteratorValues( this, a.listSubClasses(), new Object[] {b,c,d,e,f, OWL.Nothing} );
- TestUtil.assertIteratorValues( this, a.listSubClasses( false ), new Object[] {b,c,d,e,f, OWL.Nothing} );
- TestUtil.assertIteratorValues( this, a.listSubClasses( true ), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, b.listSubClasses( true ), new Object[] {d,e} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses(), new Object[] {b,c,d,e,f, OWL.Nothing} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses( false ), new Object[] {b,c,d,e,f, OWL.Nothing} );
+ OntTestUtil.assertIteratorValues(a.listSubClasses( true ), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(b.listSubClasses( true ), new Object[] {d,e} );
}
+ @Test
public void testListSuperClasses0() {
// no inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM );
@@ -224,12 +238,13 @@ public class TestOntClass
OntClass c = m.getOntClass( NS + "C" );
OntClass e = m.getOntClass( NS + "E" );
- TestUtil.assertIteratorValues( this, e.listSuperClasses(), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, e.listSuperClasses( false ), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, e.listSuperClasses( true ), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, b.listSuperClasses( true ), new Object[] {a} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses(), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses( false ), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses( true ), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(b.listSuperClasses( true ), new Object[] {a} );
}
+ @Test
public void testListSuperClasses1() {
// rule inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM_RULE_INF );
@@ -238,12 +253,13 @@ public class TestOntClass
OntClass c = m.getOntClass( NS + "C" );
OntClass e = m.getOntClass( NS + "E" );
- TestUtil.assertIteratorValues( this, e.listSuperClasses(), new Object[] {b,c,a,RDFS.Resource, OWL.Thing} );
- TestUtil.assertIteratorValues( this, e.listSuperClasses( false ), new Object[] {b,c,a,RDFS.Resource, OWL.Thing} );
- TestUtil.assertIteratorValues( this, e.listSuperClasses( true ), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, b.listSuperClasses( true ), new Object[] {a} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses(), new Object[] {b,c,a,RDFS.Resource, OWL.Thing} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses( false ), new Object[] {b,c,a,RDFS.Resource, OWL.Thing} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses( true ), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(b.listSuperClasses( true ), new Object[] {a} );
}
+ @Test
public void testListSuperClasses2() {
// micro rule inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF);
@@ -252,12 +268,13 @@ public class TestOntClass
OntClass c = m.getOntClass( NS + "C" );
OntClass e = m.getOntClass( NS + "E" );
- TestUtil.assertIteratorValues( this, e.listSuperClasses(), new Object[] {b,c,a, OWL.Thing} );
- TestUtil.assertIteratorValues( this, e.listSuperClasses( false ), new Object[] {b,c,a, OWL.Thing} );
- TestUtil.assertIteratorValues( this, e.listSuperClasses( true ), new Object[] {b,c} );
- TestUtil.assertIteratorValues( this, b.listSuperClasses( true ), new Object[] {a} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses(), new Object[] {b,c,a, OWL.Thing} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses( false ), new Object[] {b,c,a, OWL.Thing} );
+ OntTestUtil.assertIteratorValues(e.listSuperClasses( true ), new Object[] {b,c} );
+ OntTestUtil.assertIteratorValues(b.listSuperClasses( true ), new Object[] {a} );
}
+ @Test
public void testListSuperClasses3() {
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
OntClass A = m.createClass( NS +"A");
@@ -268,11 +285,10 @@ public class TestOntClass
B.addSuperClass(C);
C.addSuperClass(B);
- TestUtil.assertIteratorValues( this, A.listSuperClasses( true ), new Object[] {B,C} );
+ OntTestUtil.assertIteratorValues(A.listSuperClasses( true ), new Object[] {B,C} );
}
-
-
+ @Test
public void testListInstances0() {
// no inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM );
@@ -282,13 +298,14 @@ public class TestOntClass
Individual ia = a.createIndividual();
Individual ib = b.createIndividual();
- TestUtil.assertIteratorValues( this, a.listInstances(), new Object[] {ia} );
- TestUtil.assertIteratorValues( this, b.listInstances(), new Object[] {ib} );
+ OntTestUtil.assertIteratorValues(a.listInstances(), new Object[] {ia} );
+ OntTestUtil.assertIteratorValues(b.listInstances(), new Object[] {ib} );
- TestUtil.assertIteratorValues( this, a.listInstances(true), new Object[] {ia} );
- TestUtil.assertIteratorValues( this, b.listInstances(true), new Object[] {ib} );
+ OntTestUtil.assertIteratorValues(a.listInstances(true), new Object[] {ia} );
+ OntTestUtil.assertIteratorValues(b.listInstances(true), new Object[] {ib} );
}
+ @Test
public void testListInstances1() {
// no inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM_RULE_INF );
@@ -304,13 +321,14 @@ public class TestOntClass
Individual id = d.createIndividual(NS + "iD");
Individual ie = e.createIndividual(NS + "iE");
- TestUtil.assertIteratorValues( this, a.listInstances(), new Object[] {ia,ib,ic,id,ie} );
- TestUtil.assertIteratorValues( this, b.listInstances(), new Object[] {ib,id,ie} );
+ OntTestUtil.assertIteratorValues(a.listInstances(), new Object[] {ia,ib,ic,id,ie} );
+ OntTestUtil.assertIteratorValues(b.listInstances(), new Object[] {ib,id,ie} );
- TestUtil.assertIteratorValues( this, a.listInstances(true), new Object[] {ia} );
- TestUtil.assertIteratorValues( this, b.listInstances(true), new Object[] {ib} );
+ OntTestUtil.assertIteratorValues(a.listInstances(true), new Object[] {ia} );
+ OntTestUtil.assertIteratorValues(b.listInstances(true), new Object[] {ib} );
}
+ @Test
public void testListInstances2() {
// no inference
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF );
@@ -326,13 +344,14 @@ public class TestOntClass
Individual id = d.createIndividual(NS + "iD");
Individual ie = e.createIndividual(NS + "iE");
- TestUtil.assertIteratorValues( this, a.listInstances(), new Object[] {ia,ib,ic,id,ie} );
- TestUtil.assertIteratorValues( this, b.listInstances(), new Object[] {ib,id,ie} );
+ OntTestUtil.assertIteratorValues(a.listInstances(), new Object[] {ia,ib,ic,id,ie} );
+ OntTestUtil.assertIteratorValues(b.listInstances(), new Object[] {ib,id,ie} );
- TestUtil.assertIteratorValues( this, a.listInstances(true), new Object[] {ia} );
- TestUtil.assertIteratorValues( this, b.listInstances(true), new Object[] {ib} );
+ OntTestUtil.assertIteratorValues(a.listInstances(true), new Object[] {ia} );
+ OntTestUtil.assertIteratorValues(b.listInstances(true), new Object[] {ib} );
}
+ @Test
public void testDropIndividual() {
OntModel m = createABCDEFModel( OntModelSpec.OWL_MEM );
OntClass a = m.getOntClass( NS + "A" );
@@ -362,6 +381,7 @@ public class TestOntClass
assertFalse( ia.hasOntClass( b ) );
}
+ @Test
public void testDatatypeIsClassOwlFull() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
Resource c = m.createResource();
@@ -369,6 +389,7 @@ public class TestOntClass
assertTrue( c.canAs( OntClass.class ));
}
+ @Test
public void testDatatypeIsClassOwlDL() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_DL_MEM );
Resource c = m.createResource();
@@ -376,6 +397,7 @@ public class TestOntClass
assertTrue( c.canAs( OntClass.class ));
}
+ @Test
public void testDatatypeIsClassOwlLite() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM );
Resource c = m.createResource();
@@ -383,6 +405,7 @@ public class TestOntClass
assertTrue( c.canAs( OntClass.class ));
}
+ @Test
public void testDatatypeIsClassOwlRDFS() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM );
Resource c = m.createResource();
@@ -390,6 +413,7 @@ public class TestOntClass
assertTrue( c.canAs( OntClass.class ));
}
+ @Test
public void testOwlThingNothingClass() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
@@ -437,7 +461,6 @@ public class TestOntClass
return m;
}
-
//==============================================================================
// Inner class definitions
//==============================================================================
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntDocumentManager.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntDocumentManager.java
index f911fe20ce..cef4fe7a35 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntDocumentManager.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntDocumentManager.java
@@ -23,12 +23,9 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.jena.ontology.OntClass;
import org.apache.jena.ontology.OntDocumentManager;
import org.apache.jena.ontology.OntDocumentManager.ReadFailureHandler;
@@ -43,7 +40,6 @@ import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.StmtIterator;
import org.apache.jena.rdf.model.impl.RDFReaderFImpl;
-import org.apache.jena.reasoner.test.TestUtil;
import org.apache.jena.test.X_RDFReaderF;
import org.apache.jena.vocabulary.OWL;
import org.apache.jena.vocabulary.OntDocManagerVocab;
@@ -58,7 +54,17 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -67,9 +73,10 @@ import java.util.Set;
*/
@SuppressWarnings("removal")
public class TestOntDocumentManager
- extends TestCase
{
+ static { JenaTestLib.setup(); }
+
static { RDFReaderFImpl.alternative(new X_RDFReaderF()); }
// Constants
@@ -97,39 +104,16 @@ public class TestOntDocumentManager
{ "testing/ontology/testImport5", cnt(2), T, "file:testing/ontology/testImport5/ont-policy.rdf" }
};
-
// Instance variables
//////////////////////////////////
-
// Constructors
//////////////////////////////////
- public TestOntDocumentManager( String s ) {
- super( s );
- }
-
- public static TestSuite suite() {
- TestSuite suite = new TestSuite( "TestOntDocumentManager" );
-
- // add the fixed test cases
- suite.addTestSuite( TestOntDocumentManager.class );
-
- // add the data-driven test cases
- for ( Object[] aS_testData : s_testData )
- {
- suite.addTest( new DocManagerImportTest( (String) aS_testData[0], ( (Integer) aS_testData[1] ).intValue(),
- ( (Boolean) aS_testData[2] ).booleanValue(),
- (String) aS_testData[3] ) );
- }
- return suite;
- }
-
-
// External signature methods
//////////////////////////////////
- @Override
+ @BeforeEach
public void setUp() {
// ensure the ont doc manager is in a consistent state
OntDocumentManager.getInstance().reset( true );
@@ -148,23 +132,27 @@ public class TestOntDocumentManager
}
}
+ @Test
public void testConstruct0() {
OntDocumentManager m = new OntDocumentManager();
assertNotNull( m );
assertEquals( m.getMetadataSearchPath(), OntDocumentManager.DEFAULT_METADATA_PATH );
}
+ @Test
public void testConstruct1() {
OntDocumentManager mgr = new OntDocumentManager( "" );
- assertTrue( "Should be no specification loaded", !mgr.listDocuments().hasNext() );
+ assertTrue( !mgr.listDocuments().hasNext(), "Should be no specification loaded" );
}
+ @Test
public void testConstruct2() {
// make sure we don't fail on null
OntDocumentManager mgr = new OntDocumentManager( (String) null );
- assertTrue( "Should be no specification loaded", !mgr.listDocuments().hasNext() );
+ assertTrue( !mgr.listDocuments().hasNext(), "Should be no specification loaded" );
}
+ @Test
public void testConstruct3() {
Model m = ModelFactory.createDefaultModel();
Resource r = m.createResource();
@@ -173,17 +161,19 @@ public class TestOntDocumentManager
r.addProperty( OntDocManagerVocab.altURL, m.createResource("file:local.rdf") );
OntDocumentManager mgr = new OntDocumentManager( m );
- assertEquals( "cache URL not correct", "file:local.rdf", mgr.doAltURLMapping( "http://example.com/foo" ));
+ assertEquals( "file:local.rdf", mgr.doAltURLMapping( "http://example.com/foo" ), "cache URL not correct");
}
+ @Test
public void testInitialisation() {
OntDocumentManager mgr = new OntDocumentManager( "ont-policy-test.rdf" );
- assertTrue( "Should be at least one specification loaded", mgr.listDocuments().hasNext() );
- assertNotNull( "cache URL for owl should not be null", mgr.doAltURLMapping( "http://www.w3.org/2002/07/owl" ));
- assertEquals( "cache URL for owl not correct", "file:vocabularies/owl.owl", mgr.doAltURLMapping( "http://www.w3.org/2002/07/owl" ));
+ assertTrue( mgr.listDocuments().hasNext(), "Should be at least one specification loaded" );
+ assertNotNull( mgr.doAltURLMapping( "http://www.w3.org/2002/07/owl" ), "cache URL for owl should not be null");
+ assertEquals( "file:vocabularies/owl.owl", mgr.doAltURLMapping( "http://www.w3.org/2002/07/owl" ), "cache URL for owl not correct");
}
+ @Test
public void testGetInstance() {
OntDocumentManager odm = OntDocumentManager.getInstance();
assertNotNull( odm );
@@ -192,6 +182,7 @@ public class TestOntDocumentManager
assertSame( odm, odm2 );
}
+ @Test
public void testSetMetadataSearchPath() {
OntDocumentManager odm = new OntDocumentManager( "ont-policy-test.rdf" );
assertEquals( "ont-policy-test.rdf", odm.getMetadataSearchPath() );
@@ -211,6 +202,7 @@ public class TestOntDocumentManager
assertEquals( "ont-policy-test.rdf", odm.getLoadedPolicyURL() );
}
+ @Test
public void testConfigure0() {
Model m = ModelFactory.createDefaultModel();
Resource r = m.createResource();
@@ -219,12 +211,13 @@ public class TestOntDocumentManager
r.addProperty( OntDocManagerVocab.altURL, m.createResource("file:local.rdf") );
OntDocumentManager odm = new OntDocumentManager( "ont-policy-test.rdf" );
- TestUtil.assertIteratorLength( odm.listDocuments(), 3 );
+ OntTestUtil.assertIteratorLength( odm.listDocuments(), 3 );
odm.configure( m, false );
- TestUtil.assertIteratorLength( odm.listDocuments(), 4 );
+ OntTestUtil.assertIteratorLength( odm.listDocuments(), 4 );
}
+ @Test
public void testConfigure1() {
Model m = ModelFactory.createDefaultModel();
Resource r = m.createResource();
@@ -233,12 +226,13 @@ public class TestOntDocumentManager
r.addProperty( OntDocManagerVocab.altURL, m.createResource("file:local.rdf") );
OntDocumentManager odm = new OntDocumentManager( "ont-policy-test.rdf" );
- TestUtil.assertIteratorLength( odm.listDocuments(), 3 );
+ OntTestUtil.assertIteratorLength( odm.listDocuments(), 3 );
odm.configure( m );
- TestUtil.assertIteratorLength( odm.listDocuments(), 1 );
+ OntTestUtil.assertIteratorLength( odm.listDocuments(), 1 );
}
+ @Test
public void testConfigure2() {
// create a simple policy
Model m = ModelFactory.createDefaultModel();
@@ -249,10 +243,10 @@ public class TestOntDocumentManager
OntDocumentManager mgr = new OntDocumentManager( (String) null );
assertTrue( mgr.getCacheModels() );
mgr.configure( m );
- assertFalse( "Docmgr configure() should have updated cache models flag", mgr.getCacheModels() );
+ assertFalse( mgr.getCacheModels(), "Docmgr configure() should have updated cache models flag" );
}
-
+ @Test
public void testReset() {
OntDocumentManager mgr = new OntDocumentManager( (String) null );
@@ -274,12 +268,14 @@ public class TestOntDocumentManager
assertTrue( mgr.getCacheModels() );
}
+ @Test
public void testDoAltMapping() {
OntDocumentManager odm = new OntDocumentManager( "ont-policy-test.rdf" );
assertEquals( "file:vocabularies/owl.owl", odm.doAltURLMapping( "http://www.w3.org/2002/07/owl" ));
assertEquals( "http://example.com/nocache", odm.doAltURLMapping( "http://example.com/nocache" ));
}
+ @Test
public void testAddModel0() {
OntDocumentManager odm = OntDocumentManager.getInstance();
Model m = ModelFactory.createDefaultModel();
@@ -289,6 +285,7 @@ public class TestOntDocumentManager
assertSame( m, odm.getModel(uri));
}
+ @Test
public void testAddModel1() {
OntDocumentManager odm = OntDocumentManager.getInstance();
Model m0 = ModelFactory.createDefaultModel();
@@ -306,6 +303,7 @@ public class TestOntDocumentManager
assertSame( m1, odm.getModel(uri));
}
+ @Test
public void testClearCache0() {
OntDocumentManager odm = OntDocumentManager.getInstance();
Model m = ModelFactory.createDefaultModel();
@@ -319,6 +317,7 @@ public class TestOntDocumentManager
/**
* Ensure that sub-model imports are not re-used after clearing the cache.
*/
+ @Test
public void testClearCache1() {
OntModelSpec spec = new OntModelSpec(OntModelSpec.OWL_MEM);
spec.getDocumentManager().reset();
@@ -350,6 +349,7 @@ public class TestOntDocumentManager
assertEquals( count0, subModel1.size() );
}
+ @Test
public void testForget() {
OntDocumentManager odm = new OntDocumentManager( "ont-policy-test.rdf" );
assertEquals( "file:vocabularies/owl.owl", odm.doAltURLMapping( "http://www.w3.org/2002/07/owl" ) );
@@ -364,6 +364,7 @@ public class TestOntDocumentManager
assertNull( odm.getModel( "http://www.w3.org/2002/07/owl#" ));
}
+ @Test
public void testGetOntology() {
OntDocumentManager odm = new OntDocumentManager( "ont-policy-test.rdf" );
OntModel m = odm.getOntology( "http://www.w3.org/2002/07/owl", OntModelSpec.OWL_MEM );
@@ -373,6 +374,7 @@ public class TestOntDocumentManager
assertSame( m, m1 );
}
+ @Test
public void testProcessImports() {
OntDocumentManager odm = new OntDocumentManager( "ont-policy-test.rdf" );
assertTrue( odm.getProcessImports() );
@@ -380,6 +382,7 @@ public class TestOntDocumentManager
assertFalse( odm.getProcessImports() );
}
+ @Test
public void testCacheModels() {
OntDocumentManager odm = new OntDocumentManager( "ont-policy-test.rdf" );
assertTrue( odm.getCacheModels() );
@@ -387,13 +390,15 @@ public class TestOntDocumentManager
assertFalse( odm.getCacheModels() );
}
+ @Test
public void testManualAssociation() {
OntDocumentManager odm = new OntDocumentManager( (String) null );
odm.addAltEntry( "http://www.w3.org/2002/07/owl", "file:foo.bar" );
- assertEquals( "Failed to retrieve cache location", "file:foo.bar", odm.doAltURLMapping( "http://www.w3.org/2002/07/owl" ) );
+ assertEquals( "file:foo.bar", odm.doAltURLMapping( "http://www.w3.org/2002/07/owl" ), "Failed to retrieve cache location" );
}
+ @Test
public void testRelativeNames() {
OntModel m = ModelFactory.createOntologyModel();
m.getDocumentManager().addAltEntry(
@@ -405,71 +410,74 @@ public class TestOntDocumentManager
assertFalse( m.getResource("file:testing/ontology/relativenames.rdf#A").canAs(OntClass.class));
}
-
-
+ @Test
public void testIgnoreImport() {
OntDocumentManager odm = new OntDocumentManager();
- TestUtil.assertIteratorLength( odm.listIgnoredImports(), 0 );
+ OntTestUtil.assertIteratorLength( odm.listIgnoredImports(), 0 );
odm.addIgnoreImport( "file:testing/ontology/testImport3/c.owl" );
- TestUtil.assertIteratorLength( odm.listIgnoredImports(), 1 );
+ OntTestUtil.assertIteratorLength( odm.listIgnoredImports(), 1 );
assertTrue( odm.ignoringImport( "file:testing/ontology/testImport3/c.owl"));
assertFalse( odm.ignoringImport( "file:testing/ontology/foo.owl"));
OntModelSpec spec = new OntModelSpec( null, odm, null, ProfileRegistry.OWL_LANG );
OntModel m = ModelFactory.createOntologyModel( spec, null );
- assertNotNull( "Ontology model should not be null", m );
+ assertNotNull( m, "Ontology model should not be null" );
m.read( "file:testing/ontology/testImport3/a.owl" );
- assertEquals( "Marker count not correct", 2, countMarkers( m ));
+ assertEquals( 2, countMarkers( m ), "Marker count not correct");
odm.removeIgnoreImport( "file:testing/ontology/testImport3/c.owl" );
- TestUtil.assertIteratorLength( odm.listIgnoredImports(), 0 );
+ OntTestUtil.assertIteratorLength( odm.listIgnoredImports(), 0 );
assertFalse( odm.ignoringImport( "file:testing/ontology/testImport3/c.owl"));
}
/** Simple case: a imports b, b imports c, remove c */
+ @Test
public void testUnloadImport1() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport3/a.owl" );
- assertEquals( "Marker count not correct", 3, countMarkers( m ) );
+ assertEquals( 3, countMarkers( m ), "Marker count not correct" );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should be imported" );
m.getDocumentManager().unloadImport( m, "file:testing/ontology/testImport3/c.owl" );
- assertEquals( "Marker count not correct", 2, countMarkers( m ) );
- assertFalse( "c should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
+ assertEquals( 2, countMarkers( m ), "Marker count not correct" );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should not be imported" );
}
/** case 2: a imports b, b imports c, remove b */
+ @Test
public void testUnloadImport2() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport3/a.owl" );
- assertEquals( "Marker count not correct", 3, countMarkers( m ) );
+ assertEquals( 3, countMarkers( m ), "Marker count not correct" );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertTrue( "b should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should be imported" );
m.getDocumentManager().unloadImport( m, "file:testing/ontology/testImport3/b.owl" );
- assertEquals( "Marker count not correct", 1, countMarkers( m ) );
- assertFalse( "c should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertFalse( "b should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertEquals( 1, countMarkers( m ), "Marker count not correct" );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should not be imported" );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should not be imported" );
}
/** case 3: a imports b, b imports c, a imports d, d imports c, remove b */
+ @Test
public void testUnloadImport3() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport6/a.owl" );
- assertEquals( "Marker count not correct", 4, countMarkers( m ) );
+ assertEquals( 4, countMarkers( m ), "Marker count not correct" );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport6/c.owl" ) );
- assertTrue( "b should be imported", m.hasLoadedImport( "file:testing/ontology/testImport6/b.owl" ) );
- assertTrue( "d should be imported", m.hasLoadedImport( "file:testing/ontology/testImport6/d.owl" ) );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport6/c.owl" ), "c should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport6/b.owl" ), "b should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport6/d.owl" ), "d should be imported" );
m.getDocumentManager().unloadImport( m, "file:testing/ontology/testImport6/b.owl" );
- assertEquals( "Marker count not correct", 3, countMarkers( m ) );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport6/c.owl" ) );
- assertTrue( "d should be imported", m.hasLoadedImport( "file:testing/ontology/testImport6/d.owl" ) );
- assertFalse( "b should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport6/b.owl" ) );
+ assertEquals( 3, countMarkers( m ), "Marker count not correct" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport6/c.owl" ), "c should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport6/d.owl" ), "d should be imported" );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport6/b.owl" ), "b should not be imported" );
}
+ @Test
public void testDynamicImports1() {
OntModel m = ModelFactory.createOntologyModel();
Resource a = m.getResource( "file:testing/ontology/testImport3/a.owl" );
@@ -477,12 +485,13 @@ public class TestOntDocumentManager
m.add( a, m.getProfile().IMPORTS(), b );
// not dymamically imported by default
- assertEquals( "Marker count not correct", 0, countMarkers( m ) );
+ assertEquals( 0, countMarkers( m ), "Marker count not correct" );
- assertFalse( "c should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertFalse( "b should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should not be imported" );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should not be imported" );
}
+ @Test
public void testDynamicImports2() {
OntModel m = ModelFactory.createOntologyModel();
Resource a = m.getResource( "file:testing/ontology/testImport3/a.owl" );
@@ -493,19 +502,20 @@ public class TestOntDocumentManager
m.add( a, m.getProfile().IMPORTS(), b );
// dynamically imported
- assertEquals( "Marker count not correct", 2, countMarkers( m ) );
+ assertEquals( 2, countMarkers( m ), "Marker count not correct" );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertTrue( "b should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should be imported" );
}
+ @Test
public void testDynamicImports3() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport3/a.owl" );
- assertEquals( "Marker count not correct", 3, countMarkers( m ) );
+ assertEquals( 3, countMarkers( m ), "Marker count not correct" );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertTrue( "b should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should be imported" );
m.setDynamicImports( true );
@@ -513,28 +523,30 @@ public class TestOntDocumentManager
Resource b = m.getResource( OntResolve.resolve("file:testing/ontology/testImport3/b.owl") );
m.remove( m.createStatement( a, m.getProfile().IMPORTS(), b ) );
- assertEquals( "Marker count not correct", 1, countMarkers( m ) );
- assertFalse( "c should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertFalse( "b should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertEquals( 1, countMarkers( m ), "Marker count not correct" );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should not be imported" );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should not be imported" );
}
+ @Test
public void testSearchPath() {
OntDocumentManager o1 = new OntDocumentManager( "ont-policy-test.rdf" );
- assertEquals( "Did not return correct loaded search path", "ont-policy-test.rdf", o1.getLoadedPolicyURL() );
+ assertEquals( "ont-policy-test.rdf", o1.getLoadedPolicyURL(), "Did not return correct loaded search path" );
OntDocumentManager o2 = new OntDocumentManager( "ont-policy-test.notexist.rdf;ont-policy-test.rdf" );
- assertEquals( "Did not return correct loaded search path", "ont-policy-test.rdf", o2.getLoadedPolicyURL() );
+ assertEquals( "ont-policy-test.rdf", o2.getLoadedPolicyURL(), "Did not return correct loaded search path" );
OntDocumentManager o3 = new OntDocumentManager( (String) null );
- assertNull( "Most recent policy should be null", o3.getLoadedPolicyURL() );
+ assertNull( o3.getLoadedPolicyURL(), "Most recent policy should be null" );
o3.setMetadataSearchPath( "ont-policy-test.rdf", true );
- assertEquals( "Did not return correct loaded search path", "ont-policy-test.rdf", o2.getLoadedPolicyURL() );
+ assertEquals( "ont-policy-test.rdf", o2.getLoadedPolicyURL(), "Did not return correct loaded search path" );
o3.setMetadataSearchPath( "ont-policy-test.notexist.rdf", true );
- assertNull( "Most recent policy should be null", o3.getLoadedPolicyURL() );
+ assertNull( o3.getLoadedPolicyURL(), "Most recent policy should be null" );
}
+ @Test
public void testReadFailHandler0() {
OntDocumentManager o1 = new OntDocumentManager( "ont-policy-test.rdf" );
assertNull( o1.getReadFailureHandler() );
@@ -553,6 +565,7 @@ public class TestOntDocumentManager
* is designed for domain names that are sure to be invalid. See
* <a href="http://tools.ietf.org/html/rfc2606#section-2">tools.ietf.org/html/rfc2606#section-2</a>
*/
+ @Test
public void testReadFailHandler1() {
OntDocumentManager o1 = new OntDocumentManager( "ont-policy-test.rdf" );
@@ -569,6 +582,7 @@ public class TestOntDocumentManager
assertTrue( rfh.m_seen );
}
+ @Test
public void testReadHook0() {
TestReadHook rh = new TestReadHook( false );
OntDocumentManager o1 = new OntDocumentManager( "ont-policy-test.rdf" );
@@ -585,10 +599,11 @@ public class TestOntDocumentManager
OntModel m = ModelFactory.createOntologyModel( spec );
m.read( new StringReader( source ), "http://example.com/foo#", "N3" );
- assertEquals( "Wrong number of calls to before load hook", 3, rh.m_before );
- assertEquals( "Wrong number of calls to after load hook", 3, rh.m_after );
+ assertEquals( 3, rh.m_before, "Wrong number of calls to before load hook" );
+ assertEquals( 3, rh.m_after, "Wrong number of calls to after load hook" );
}
+ @Test
public void testReadHook1() {
TestReadHook rh = new TestReadHook( true );
OntDocumentManager o1 = new OntDocumentManager( "ont-policy-test.rdf" );
@@ -602,11 +617,10 @@ public class TestOntDocumentManager
OntModel m = ModelFactory.createOntologyModel( spec );
m.read( new StringReader( source ), "http://example.com/foo#", "N3" );
- assertEquals( "Wrong number of calls to before load hook", 1, rh.m_before );
- assertEquals( "Wrong number of calls to after load hook", 1, rh.m_after );
+ assertEquals( 1, rh.m_before, "Wrong number of calls to before load hook" );
+ assertEquals( 1, rh.m_after, "Wrong number of calls to after load hook" );
}
-
/* count the number of marker statements in the combined model */
public static int countMarkers( Model m ) {
int count = 0;
@@ -620,10 +634,22 @@ public class TestOntDocumentManager
return count;
}
+ /**
+ * One dynamic test per row of {@code s_testData}. The JUnit3 suite() added
+ * the fixed test cases (now ordinary @Test methods) plus one
+ * DocManagerImportTest per row, so one row remains one test.
+ */
+ @TestFactory
+ public Stream<DynamicTest> docManagerImportTests() {
+ return Stream.of( s_testData )
+ .map( row -> new DocManagerImportTest( (String) row[0], ((Integer) row[1]).intValue(),
+ ((Boolean) row[2]).booleanValue(), (String) row[3] ) )
+ .map( tc -> DynamicTest.dynamicTest( tc.getName(), tc::runTest ) );
+ }
+
// Internal implementation methods
//////////////////////////////////
-
//==============================================================================
// Inner class definitions
//==============================================================================
@@ -640,8 +666,8 @@ public class TestOntDocumentManager
* total.
*/
static class DocManagerImportTest
- extends TestCase
{
+ String m_name;
String m_dir;
int m_count;
String m_path;
@@ -649,7 +675,7 @@ public class TestOntDocumentManager
/* constuctor */
DocManagerImportTest( String dir, int count, boolean processImports, String path ) {
- super( dir );
+ m_name = dir;
m_dir = dir;
m_count = count;
m_path = path;
@@ -658,7 +684,11 @@ public class TestOntDocumentManager
// external contract methods
- @Override
+ /** The name this case ran under in the JUnit3 suite. */
+ public String getName() {
+ return m_name;
+ }
+
public void runTest() {
OntDocumentManager dm = new OntDocumentManager();
@@ -671,7 +701,7 @@ public class TestOntDocumentManager
// now load the model - we always start from a.owl in the given directory
OntModelSpec spec = new OntModelSpec( null, dm, null, ProfileRegistry.OWL_LANG );
OntModel m = ModelFactory.createOntologyModel( spec, null );
- assertNotNull( "Ontology model should not be null", m );
+ assertNotNull( m, "Ontology model should not be null" );
String filename = "file:" + m_dir + "/a.owl";
@@ -680,7 +710,7 @@ public class TestOntDocumentManager
} catch (Throwable ex) {
m.read(filename);
}
- assertEquals( "Marker count not correct: "+filename, m_count, countMarkers( m ));
+ assertEquals( m_count, countMarkers( m ), "Marker count not correct: "+filename);
}
}
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 de77911a8b..7fa8c8aaba 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,23 +21,19 @@
package org.apache.jena.ontology.impl;
-import junit.framework.TestSuite;
-import org.apache.jena.graph.AbstractTestGraph;
+import org.apache.jena.graph.BaseTestGraph_JU6;
import org.apache.jena.graph.Graph;
import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.test.JenaTestLib;
/**
Ensure that an OntGraph passes the graph tests. Clunky because it has to go
via OntModel - there doesn't appear to be an OntGraph class.
*/
-public class TestOntGraph extends AbstractTestGraph
+public class TestOntGraph extends BaseTestGraph_JU6
{
- public TestOntGraph( String name )
- { super( name ); }
-
- public static TestSuite suite()
- { return new TestSuite( TestOntGraph.class ); }
+ static { JenaTestLib.setup(); }
@Override
@SuppressWarnings("removal")
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModel.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModel.java
index e4e6d6e1af..c48ef75bd5 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModel.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModel.java
@@ -23,7 +23,6 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
@@ -43,8 +42,6 @@ import org.apache.jena.ontology.Ontology;
import org.apache.jena.ontology.impl.OWLProfile.SupportsCheck;
import org.apache.jena.rdf.model.*;
import org.apache.jena.reasoner.rulesys.test.TestRuleSystemBugs;
-import org.apache.jena.reasoner.test.TestUtil;
-import org.apache.jena.test.JenaTestBase;
import org.apache.jena.test.JenaTestLib;
import org.apache.jena.vocabulary.OWL;
import org.apache.jena.vocabulary.RDF;
@@ -61,7 +58,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* <p>
@@ -71,8 +71,10 @@ import java.util.Map;
*/
@SuppressWarnings("removal")
public class TestOntModel
- extends JenaTestBase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
@@ -111,21 +113,17 @@ public class TestOntModel
// Constructors
//////////////////////////////////
- public TestOntModel( String name ) {
- super( name );
- }
-
// External signature methods
//////////////////////////////////
- @Override
+ @BeforeEach
public void setUp() {
// ensure the ont doc manager is in a consistent state
OntDocumentManager.getInstance().reset( true );
}
-
/** Test writing the base model to an output stream */
+ @Test
public void testWriteOutputStream() {
OntModel m = ModelFactory.createOntologyModel();
@@ -160,10 +158,11 @@ public class TestOntModel
mIn2.read( new ByteArrayInputStream( DOC.getBytes() ), BASE );
// should be the same
- assertTrue( "InputStream write/read cycle failed (1)", mIn1.isIsomorphicWith( m.getBaseModel() ) );
- assertTrue( "InputStream write/read cycle failed (2)", mIn2.isIsomorphicWith( m.getBaseModel() ) );
+ assertTrue( mIn1.isIsomorphicWith( m.getBaseModel() ), "InputStream write/read cycle failed (1)" );
+ assertTrue( mIn2.isIsomorphicWith( m.getBaseModel() ), "InputStream write/read cycle failed (2)" );
}
+ @Test
public void testGetBaseModelPrefixes() {
OntModel om = ModelFactory.createOntologyModel();
om.setNsPrefix( "bill", "http://bill.and.ben/flowerpot#" );
@@ -175,6 +174,7 @@ public class TestOntModel
* The default namespace pefix of a non-base-model should not manifest as
* the default namespace prefix of the base model or the Ont model.
*/
+ @Test
public void testPolyadicPrefixMapping() {
final String IMPORTED_NAMESPACE = "http://imported#";
final String LOCAL_NAMESPACE = "http://local#";
@@ -186,6 +186,7 @@ public class TestOntModel
assertNull( ontModel.getNsURIPrefix( IMPORTED_NAMESPACE ) );
}
+ @Test
public void testWritesPrefixes() {
OntModel om = ModelFactory.createOntologyModel();
om.setNsPrefix( "spoo", "http://spoo.spoo.com/spoo#" );
@@ -199,6 +200,7 @@ public class TestOntModel
}
/** Test writing the base model to an output stream */
+ @Test
public void testWriteWriter() {
OntModel m = ModelFactory.createOntologyModel();
@@ -232,32 +234,34 @@ public class TestOntModel
mIn2.read( new StringReader( DOC ), BASE );
// should be the same
- assertTrue( "Writer write/read cycle failed (1)", mIn1.isIsomorphicWith( m.getBaseModel() ) );
- assertTrue( "Writer write/read cycle failed (2)", mIn2.isIsomorphicWith( m.getBaseModel() ) );
+ assertTrue( mIn1.isIsomorphicWith( m.getBaseModel() ), "Writer write/read cycle failed (1)" );
+ assertTrue( mIn2.isIsomorphicWith( m.getBaseModel() ), "Writer write/read cycle failed (2)" );
}
+ @Test
public void testGetOntology() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createOntology( NS + "s" );
- assertEquals( "Result of get s", s, m.getOntology( NS + "s" ) );
- assertNull( "result of get q", m.getOntology( NS+"q") );
- assertNull( "result of get r", m.getOntology( NS+"r"));
+ assertEquals( s, m.getOntology( NS + "s" ), "Result of get s" );
+ assertNull( m.getOntology( NS+"q"), "result of get q" );
+ assertNull( m.getOntology( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetIndividual() {
OntModel m = ModelFactory.createOntologyModel();
OntClass c = m.createClass( NS +"c" );
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createIndividual( NS + "s", c );
- assertEquals( "Result of get s", s, m.getIndividual( NS + "s" ) );
- assertNull( "result of get q", m.getIndividual( NS+"q") );
+ assertEquals( s, m.getIndividual( NS + "s" ), "Result of get s" );
+ assertNull( m.getIndividual( NS+"q"), "result of get q" );
}
/** User requested: allow null arguments when creating individuals */
+ @Test
public void testCreateIndividual() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
Resource i0 = m.createIndividual( OWL.Thing );
@@ -275,82 +279,84 @@ public class TestOntModel
assertNotNull( i5 );
}
+ @Test
public void testGetOntProperty() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createOntProperty( NS + "s" );
- assertEquals( "Result of get s", s, m.getOntProperty( NS + "s" ) );
- assertNull( "result of get q", m.getOntProperty( NS+"q") );
- assertNull( "result of get r", m.getOntProperty( NS+"r"));
+ assertEquals( s, m.getOntProperty( NS + "s" ), "Result of get s" );
+ assertNull( m.getOntProperty( NS+"q"), "result of get q" );
+ assertNull( m.getOntProperty( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetObjectProperty() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createObjectProperty( NS + "s" );
- assertEquals( "Result of get s", s, m.getObjectProperty( NS + "s" ) );
- assertNull( "result of get q", m.getObjectProperty( NS+"q") );
- assertNull( "result of get r", m.getObjectProperty( NS+"r"));
+ assertEquals( s, m.getObjectProperty( NS + "s" ), "Result of get s" );
+ assertNull( m.getObjectProperty( NS+"q"), "result of get q" );
+ assertNull( m.getObjectProperty( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetTransitiveProperty() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createTransitiveProperty( NS + "s" );
- assertEquals( "Result of get s", s, m.getTransitiveProperty( NS + "s" ) );
- assertNull( "result of get q", m.getTransitiveProperty( NS+"q") );
- assertNull( "result of get r", m.getTransitiveProperty( NS+"r"));
+ assertEquals( s, m.getTransitiveProperty( NS + "s" ), "Result of get s" );
+ assertNull( m.getTransitiveProperty( NS+"q"), "result of get q" );
+ assertNull( m.getTransitiveProperty( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetSymmetricProperty() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createSymmetricProperty( NS + "s" );
- assertEquals( "Result of get s", s, m.getSymmetricProperty( NS + "s" ) );
- assertNull( "result of get q", m.getSymmetricProperty( NS+"q") );
- assertNull( "result of get r", m.getSymmetricProperty( NS+"r"));
+ assertEquals( s, m.getSymmetricProperty( NS + "s" ), "Result of get s" );
+ assertNull( m.getSymmetricProperty( NS+"q"), "result of get q" );
+ assertNull( m.getSymmetricProperty( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetInverseFunctionalProperty() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createInverseFunctionalProperty( NS + "s" );
- assertEquals( "Result of get s", s, m.getInverseFunctionalProperty( NS + "s" ) );
- assertNull( "result of get q", m.getInverseFunctionalProperty( NS+"q") );
- assertNull( "result of get r", m.getInverseFunctionalProperty( NS+"r"));
+ assertEquals( s, m.getInverseFunctionalProperty( NS + "s" ), "Result of get s" );
+ assertNull( m.getInverseFunctionalProperty( NS+"q"), "result of get q" );
+ assertNull( m.getInverseFunctionalProperty( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetDatatypeProperty() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createDatatypeProperty( NS + "s" );
- assertEquals( "Result of get s", s, m.getDatatypeProperty( NS + "s" ) );
- assertNull( "result of get q", m.getDatatypeProperty( NS+"q") );
- assertNull( "result of get r", m.getDatatypeProperty( NS+"r"));
+ assertEquals( s, m.getDatatypeProperty( NS + "s" ), "Result of get s" );
+ assertNull( m.getDatatypeProperty( NS+"q"), "result of get q" );
+ assertNull( m.getDatatypeProperty( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetAnnotationProperty() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createAnnotationProperty( NS + "s" );
- assertEquals( "Result of get s", s, m.getAnnotationProperty( NS + "s" ) );
- assertNull( "result of get q", m.getAnnotationProperty( NS+"q") );
- assertNull( "result of get r", m.getAnnotationProperty( NS+"r"));
+ assertEquals( s, m.getAnnotationProperty( NS + "s" ), "Result of get s" );
+ assertNull( m.getAnnotationProperty( NS+"q"), "result of get q" );
+ assertNull( m.getAnnotationProperty( NS+"r"), "result of get r");
}
+ @Test
public void testGetOntResource() {
OntModel m = ModelFactory.createOntologyModel();
OntResource r0 = m.getOntResource( NS + "a" );
@@ -367,78 +373,79 @@ public class TestOntModel
JenaTestLib.assertInstanceOf( OntResource.class, r3 );
}
+ @Test
public void testGetOntClass() {
OntModel m = ModelFactory.createOntologyModel();
Resource r = m.getResource( NS + "r" );
Resource r0 = m.getResource( NS + "r0" );
m.add( r, RDF.type, r0 );
Resource s = m.createClass( NS + "s" );
- assertEquals( "Result of get s", s, m.getOntClass( NS + "s" ) );
- assertNull( "result of get q", m.getOntClass( NS+"q") );
- assertNull( "result of get r", m.getOntClass( NS+"r"));
+ assertEquals( s, m.getOntClass( NS + "s" ), "Result of get s" );
+ assertNull( m.getOntClass( NS+"q"), "result of get q" );
+ assertNull( m.getOntClass( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetComplementClass() {
OntModel m = ModelFactory.createOntologyModel();
OntClass c = m.createClass( NS +"c" );
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createComplementClass( NS + "s", c );
- assertEquals( "Result of get s", s, m.getComplementClass( NS + "s" ) );
- assertNull( "result of get q", m.getComplementClass( NS+"q") );
- assertNull( "result of get r", m.getComplementClass( NS+"r"));
+ assertEquals( s, m.getComplementClass( NS + "s" ), "Result of get s" );
+ assertNull( m.getComplementClass( NS+"q"), "result of get q" );
+ assertNull( m.getComplementClass( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetEnumeratedClass() {
OntModel m = ModelFactory.createOntologyModel();
RDFList l = m.createList();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createEnumeratedClass( NS + "s", l );
- assertEquals( "Result of get s", s, m.getEnumeratedClass( NS + "s" ) );
- assertNull( "result of get q", m.getEnumeratedClass( NS+"q") );
- assertNull( "result of get r", m.getEnumeratedClass( NS+"r"));
+ assertEquals( s, m.getEnumeratedClass( NS + "s" ), "Result of get s" );
+ assertNull( m.getEnumeratedClass( NS+"q"), "result of get q" );
+ assertNull( m.getEnumeratedClass( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetUnionClass() {
OntModel m = ModelFactory.createOntologyModel();
RDFList l = m.createList();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createUnionClass( NS + "s", l );
- assertEquals( "Result of get s", s, m.getUnionClass( NS + "s" ) );
- assertNull( "result of get q", m.getUnionClass( NS+"q") );
- assertNull( "result of get r", m.getUnionClass( NS+"r"));
+ assertEquals( s, m.getUnionClass( NS + "s" ), "Result of get s" );
+ assertNull( m.getUnionClass( NS+"q"), "result of get q" );
+ assertNull( m.getUnionClass( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetIntersectionClass() {
OntModel m = ModelFactory.createOntologyModel();
RDFList l = m.createList();
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createIntersectionClass( NS + "s", l );
- assertEquals( "Result of get s", s, m.getIntersectionClass( NS + "s" ) );
- assertNull( "result of get q", m.getIntersectionClass( NS+"q") );
- assertNull( "result of get r", m.getIntersectionClass( NS+"r"));
+ assertEquals( s, m.getIntersectionClass( NS + "s" ), "Result of get s" );
+ assertNull( m.getIntersectionClass( NS+"q"), "result of get q" );
+ assertNull( m.getIntersectionClass( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetRestriction() {
OntModel m = ModelFactory.createOntologyModel();
Property p = m.createProperty( NS + "p" );
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createRestriction( NS + "s", p );
- assertEquals( "Result of get s", s, m.getRestriction( NS + "s" ) );
- assertNull( "result of get q", m.getRestriction( NS+"q") );
- assertNull( "result of get r", m.getRestriction( NS+"r"));
+ assertEquals( s, m.getRestriction( NS + "s" ), "Result of get s" );
+ assertNull( m.getRestriction( NS+"q"), "result of get q" );
+ assertNull( m.getRestriction( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetHasValueRestriction() {
OntModel m = ModelFactory.createOntologyModel();
Property p = m.createProperty( NS + "p" );
@@ -446,12 +453,12 @@ public class TestOntModel
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createHasValueRestriction( NS + "s", p, c );
- assertEquals( "Result of get s", s, m.getHasValueRestriction( NS + "s" ) );
- assertNull( "result of get q", m.getHasValueRestriction( NS+"q") );
- assertNull( "result of get r", m.getHasValueRestriction( NS+"r"));
+ assertEquals( s, m.getHasValueRestriction( NS + "s" ), "Result of get s" );
+ assertNull( m.getHasValueRestriction( NS+"q"), "result of get q" );
+ assertNull( m.getHasValueRestriction( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetSomeValuesFromRestriction() {
OntModel m = ModelFactory.createOntologyModel();
Property p = m.createProperty( NS + "p" );
@@ -459,12 +466,12 @@ public class TestOntModel
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createSomeValuesFromRestriction( NS + "s", p, c );
- assertEquals( "Result of get s", s, m.getSomeValuesFromRestriction( NS + "s" ) );
- assertNull( "result of get q", m.getSomeValuesFromRestriction( NS+"q") );
- assertNull( "result of get r", m.getSomeValuesFromRestriction( NS+"r"));
+ assertEquals( s, m.getSomeValuesFromRestriction( NS + "s" ), "Result of get s" );
+ assertNull( m.getSomeValuesFromRestriction( NS+"q"), "result of get q" );
+ assertNull( m.getSomeValuesFromRestriction( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetAllValuesFromRestriction() {
OntModel m = ModelFactory.createOntologyModel();
Property p = m.createProperty( NS + "p" );
@@ -472,55 +479,56 @@ public class TestOntModel
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createAllValuesFromRestriction( NS + "s", p, c );
- assertEquals( "Result of get s", s, m.getAllValuesFromRestriction( NS + "s" ) );
- assertNull( "result of get q", m.getAllValuesFromRestriction( NS+"q") );
- assertNull( "result of get r", m.getAllValuesFromRestriction( NS+"r"));
+ assertEquals( s, m.getAllValuesFromRestriction( NS + "s" ), "Result of get s" );
+ assertNull( m.getAllValuesFromRestriction( NS+"q"), "result of get q" );
+ assertNull( m.getAllValuesFromRestriction( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetCardinalityRestriction() {
OntModel m = ModelFactory.createOntologyModel();
Property p = m.createProperty( NS + "p" );
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createCardinalityRestriction( NS + "s", p, 1 );
- assertEquals( "Result of get s", s, m.getCardinalityRestriction( NS + "s" ) );
- assertNull( "result of get q", m.getCardinalityRestriction( NS+"q") );
- assertNull( "result of get r", m.getCardinalityRestriction( NS+"r"));
+ assertEquals( s, m.getCardinalityRestriction( NS + "s" ), "Result of get s" );
+ assertNull( m.getCardinalityRestriction( NS+"q"), "result of get q" );
+ assertNull( m.getCardinalityRestriction( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetMinCardinalityRestriction() {
OntModel m = ModelFactory.createOntologyModel();
Property p = m.createProperty( NS + "p" );
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createMinCardinalityRestriction( NS + "s", p, 1 );
- assertEquals( "Result of get s", s, m.getMinCardinalityRestriction( NS + "s" ) );
- assertNull( "result of get q", m.getMinCardinalityRestriction( NS+"q") );
- assertNull( "result of get r", m.getMinCardinalityRestriction( NS+"r"));
+ assertEquals( s, m.getMinCardinalityRestriction( NS + "s" ), "Result of get s" );
+ assertNull( m.getMinCardinalityRestriction( NS+"q"), "result of get q" );
+ assertNull( m.getMinCardinalityRestriction( NS+"r"), "result of get r");
}
-
+ @Test
public void testGetMaxCardinalityRestriction() {
OntModel m = ModelFactory.createOntologyModel();
Property p = m.createProperty( NS + "p" );
Resource r = m.getResource( NS + "r" );
m.add( r, RDF.type, r );
Resource s = m.createMaxCardinalityRestriction( NS + "s", p, 1 );
- assertEquals( "Result of get s", s, m.getMaxCardinalityRestriction( NS + "s" ) );
- assertNull( "result of get q", m.getMaxCardinalityRestriction( NS+"q") );
- assertNull( "result of get r", m.getMaxCardinalityRestriction( NS+"r"));
+ assertEquals( s, m.getMaxCardinalityRestriction( NS + "s" ), "Result of get s" );
+ assertNull( m.getMaxCardinalityRestriction( NS+"q"), "result of get q" );
+ assertNull( m.getMaxCardinalityRestriction( NS+"r"), "result of get r");
}
+ @Test
public void testGetSubgraphs() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport6/a.owl" );
- assertEquals( "Marker count not correct", 4, TestOntDocumentManager.countMarkers( m ) );
+ assertEquals( 4, TestOntDocumentManager.countMarkers( m ), "Marker count not correct" );
List<Graph> subs = m.getSubGraphs();
- assertEquals( "n subgraphs should be ", 3, subs.size() );
+ assertEquals( 3, subs.size(), "n subgraphs should be " );
}
private static boolean hasImport(Collection<String> c, String x) {
@@ -528,27 +536,28 @@ public class TestOntModel
return c.stream().anyMatch(elt->elt.endsWith(x2));
}
-
+ @Test
public void testListImportURIs() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport6/a.owl" );
Collection<String> c = m.listImportedOntologyURIs();
- assertEquals( "Should be two non-closed import URI's", 2, c.size() );
- assertTrue( "b should be imported ", hasImport(c, "file:testing/ontology/testImport6/b.owl"));
- assertFalse( "c should not be imported ", hasImport(c, "file:testing/ontology/testImport6/c.owl"));
- assertTrue( "d should be imported ", hasImport(c, "file:testing/ontology/testImport6/d.owl"));
+ assertEquals( 2, c.size(), "Should be two non-closed import URI's" );
+ assertTrue( hasImport(c, "file:testing/ontology/testImport6/b.owl"), "b should be imported ");
+ assertFalse( hasImport(c, "file:testing/ontology/testImport6/c.owl"), "c should not be imported ");
+ assertTrue( hasImport(c, "file:testing/ontology/testImport6/d.owl"), "d should be imported ");
c = m.listImportedOntologyURIs( true );
- assertEquals( "Should be two non-closed import URI's", 3, c.size() );
- assertTrue( "b should be imported ", hasImport(c, "file:testing/ontology/testImport6/b.owl" ));
- assertTrue( "c should be imported ", hasImport(c, "file:testing/ontology/testImport6/c.owl" ));
- assertTrue( "d should be imported ", hasImport(c, "file:testing/ontology/testImport6/d.owl" ));
+ assertEquals( 3, c.size(), "Should be two non-closed import URI's" );
+ assertTrue( hasImport(c, "file:testing/ontology/testImport6/b.owl" ), "b should be imported ");
+ assertTrue( hasImport(c, "file:testing/ontology/testImport6/c.owl" ), "c should be imported ");
+ assertTrue( hasImport(c, "file:testing/ontology/testImport6/d.owl" ), "d should be imported ");
}
/** Some tests for listing properties. See also {@link TestListSyntaxCategories} */
+ @Test
public void testListOntProperties0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
ObjectProperty op = m.createObjectProperty( NS + "op" );
@@ -567,6 +576,7 @@ public class TestOntModel
assertTrue( iteratorContains( m.listOntProperties(), rdfp ) );
}
+ @Test
public void testListOntProperties1() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF);
ObjectProperty op = m.createObjectProperty( NS + "op" );
@@ -585,6 +595,7 @@ public class TestOntModel
assertTrue( iteratorContains( m.listOntProperties(), rdfp ) );
}
+ @Test
public void testListOntProperties2() {
OntModelSpec owlDLReasoner = new OntModelSpec( OntModelSpec.OWL_DL_MEM );
owlDLReasoner.setReasoner( OntModelSpec.OWL_MEM_MICRO_RULE_INF.getReasoner() );
@@ -605,7 +616,7 @@ public class TestOntModel
assertTrue( iteratorContains( m.listOntProperties(), rdfp ) );
}
-
+ @Test
public void testListAllOntProperties0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
ObjectProperty op = m.createObjectProperty( NS + "op" );
@@ -624,6 +635,7 @@ public class TestOntModel
assertTrue( iteratorContains( m.listAllOntProperties(), rdfp ) );
}
+ @Test
public void testListObjectProperties0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
ObjectProperty op = m.createObjectProperty( NS + "op" );
@@ -642,6 +654,7 @@ public class TestOntModel
assertFalse( iteratorContains( m.listObjectProperties(), rdfp ) );
}
+ @Test
public void testListDatatypeProperties0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
ObjectProperty op = m.createObjectProperty( NS + "op" );
@@ -660,6 +673,7 @@ public class TestOntModel
assertFalse( iteratorContains( m.listDatatypeProperties(), rdfp ) );
}
+ @Test
public void testListAnnotationProperties0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
ObjectProperty op = m.createObjectProperty( NS + "op" );
@@ -678,17 +692,18 @@ public class TestOntModel
assertFalse( iteratorContains( m.listAnnotationProperties(), rdfp ) );
}
+ @Test
public void testListSubModels0() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport6/a.owl" );
- assertEquals( "Marker count not correct", 4, TestOntDocumentManager.countMarkers( m ) );
+ assertEquals( 4, TestOntDocumentManager.countMarkers( m ), "Marker count not correct" );
List<OntModel> importModels = new ArrayList<>();
for (Iterator<OntModel> j = m.listSubModels(); j.hasNext(); ) {
importModels.add( j.next() );
}
- assertEquals( "n import models should be ", 3, importModels.size() );
+ assertEquals( 3, importModels.size(), "n import models should be " );
int nImports = 0;
@@ -698,20 +713,21 @@ public class TestOntModel
nImports += x.countSubModels();
}
// listSubModels' default behaviour is *not* to include imports of sub-models
- assertEquals( "Wrong number of sub-model imports", 0, nImports );
+ assertEquals( 0, nImports, "Wrong number of sub-model imports" );
}
+ @Test
public void testListSubModels1() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport6/a.owl" );
- assertEquals( "Marker count not correct", 4, TestOntDocumentManager.countMarkers( m ) );
+ assertEquals( 4, TestOntDocumentManager.countMarkers( m ), "Marker count not correct" );
List<OntModel> importModels = new ArrayList<>();
for (Iterator<OntModel> j = m.listSubModels( true ); j.hasNext(); ) {
importModels.add( j.next() );
}
- assertEquals( "n import models should be ", 3, importModels.size() );
+ assertEquals( 3, importModels.size(), "n import models should be " );
int nImports = 0;
@@ -720,9 +736,10 @@ public class TestOntModel
// count the number of imports of each sub-model
nImports += x.countSubModels();
}
- assertEquals( "Wrong number of sub-model imports", 2, nImports );
+ assertEquals( 2, nImports, "Wrong number of sub-model imports" );
}
+ @Test
public void testGetImportedModel() {
OntModel m = ModelFactory.createOntologyModel();
m.read( "file:testing/ontology/testImport6/a.owl" );
@@ -734,17 +751,18 @@ public class TestOntModel
.getImportedModel( "file:testing/ontology/testImport6/c.owl" );
OntModel m4 = m.getImportedModel( "file:testing/ontology/testImport6/a.owl" );
- assertNotNull( "Import model b should not be null", m0 );
- assertNotNull( "Import model c should not be null", m1 );
- assertNotNull( "Import model d should not be null", m2 );
- assertNotNull( "Import model b-c should not be null", m3 );
- assertNull( "Import model a should be null", m4 );
+ assertNotNull( m0, "Import model b should not be null" );
+ assertNotNull( m1, "Import model c should not be null" );
+ assertNotNull( m2, "Import model d should not be null" );
+ assertNotNull( m3, "Import model b-c should not be null" );
+ assertNull( m4, "Import model a should be null" );
}
/**
* Test that the supports checks that are defined in the OWL full profile are not
* missing in the DL and Lite profiles, unless by design.
* Not strictly a model test, but it has to go somewhere */
+ @Test
public void testProfiles() {
List<Class<?>> notInDL = Arrays.asList( new Class<?>[] {} );
List<Class<?>> notInLite = Arrays.asList( new Class<?>[] {DataRange.class, HasValueRestriction.class} );
@@ -756,14 +774,11 @@ public class TestOntModel
for ( Map.Entry<Class<?>, SupportsCheck> entry : fullProfileMap.entrySet() )
{
Class<?> c = entry.getKey();
- assertTrue( "Key in OWL DL profile: " + c.getName(),
- dlProfileMap.containsKey( c ) || notInDL.contains( c ) );
- assertTrue( "Key in OWL lite profile: " + c.getName(),
- liteProfileMap.containsKey( c ) || notInLite.contains( c ) );
+ assertTrue( dlProfileMap.containsKey( c ) || notInDL.contains( c ), "Key in OWL DL profile: " + c.getName() );
+ assertTrue( liteProfileMap.containsKey( c ) || notInLite.contains( c ), "Key in OWL lite profile: " + c.getName() );
}
}
-
/**
Added by kers to ensure that bulk update works; should really be a test
of the ontology Graph using AbstractTestGraph, but that fails because there
@@ -771,6 +786,7 @@ public class TestOntModel
<p>
<b>Yet</b>.
*/
+ @Test
public void testBulkAddWorks()
{
OntModel om1= ModelFactory.createOntologyModel();
@@ -778,6 +794,7 @@ public class TestOntModel
om1.add( om2 );
}
+ @Test
public void testRead() {
String base0 = "http://example.com/test0";
String ns0 = base0 + "#";
@@ -788,17 +805,18 @@ public class TestOntModel
m.getDocumentManager().reset();
m.getDocumentManager().addAltEntry( base0, "file:testing/ontology/relativenames.rdf" );
m.read( base0, "RDF/XML" );
- assertNotNull( "Should be a class ns0:A", m.getOntClass( ns0 + "A" ) );
- assertNull( "Should not be a class ns1:A", m.getOntClass( ns1 + "A" ) );
+ assertNotNull( m.getOntClass( ns0 + "A" ), "Should be a class ns0:A" );
+ assertNull( m.getOntClass( ns1 + "A" ), "Should not be a class ns1:A" );
m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
m.getDocumentManager().reset();
m.getDocumentManager().addAltEntry( base0, "file:testing/ontology/relativenames.rdf" );
m.read( base0, base1, "RDF/XML" );
- assertNull( "Should not be a class ns0:A", m.getOntClass( ns0 + "A" ) );
- assertNotNull( "Should be a class ns1:A", m.getOntClass( ns1 + "A" ) );
+ assertNull( m.getOntClass( ns0 + "A" ), "Should not be a class ns0:A" );
+ assertNotNull( m.getOntClass( ns1 + "A" ), "Should be a class ns1:A" );
}
+ @Test
public void testListDataRange() {
String base = "http://jena.hpl.hp.com/test#";
String doc =
@@ -828,14 +846,13 @@ public class TestOntModel
m.read(new StringReader(doc), base);
Iterator<DataRange> i = m.listDataRanges();
- assertTrue( "Should be at least one DataRange", i.hasNext() );
+ assertTrue( i.hasNext(), "Should be at least one DataRange" );
Object dr = i.next();
JenaTestLib.assertInstanceOf( DataRange.class, dr );
- assertFalse( "Should no more DataRange", i.hasNext() );
+ assertFalse( i.hasNext(), "Should no more DataRange" );
}
-
-
+ @Test
public void testListHierarchyRoots0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
assertFalse( m.listHierarchyRootClasses().hasNext() );
@@ -843,6 +860,7 @@ public class TestOntModel
assertFalse( m.listHierarchyRootClasses().hasNext() );
}
+ @Test
public void testListHierarchyRoots1() {
String doc =
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. "
@@ -857,11 +875,11 @@ public class TestOntModel
m.read( new StringReader(doc), NS, "N3" );
OntClass a = m.getOntClass(NS+"A");
- TestUtil.assertIteratorValues( this, m.listHierarchyRootClasses(),
+ OntTestUtil.assertIteratorValues(m.listHierarchyRootClasses(),
new Object[] {a} );
}
-
+ @Test
public void testListHierarchyRoots2() {
String doc =
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. "
@@ -876,11 +894,11 @@ public class TestOntModel
m.read( new StringReader(doc), NS, "N3" );
OntClass a = m.getOntClass(NS+"A");
- TestUtil.assertIteratorValues( this, m.listHierarchyRootClasses(),
+ OntTestUtil.assertIteratorValues(m.listHierarchyRootClasses(),
new Object[] {a} );
}
-
+ @Test
public void testListHierarchyRoots3() {
String doc =
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. "
@@ -896,10 +914,11 @@ public class TestOntModel
m.read( new StringReader(doc), NS, "N3" );
OntClass a = m.getOntClass(NS+"A");
- TestUtil.assertIteratorValues( this, m.listHierarchyRootClasses(),
+ OntTestUtil.assertIteratorValues(m.listHierarchyRootClasses(),
new Object[] {a} );
}
+ @Test
public void testListHierarchyRoots4() {
String doc =
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. "
@@ -917,11 +936,12 @@ public class TestOntModel
OntClass a = m.getOntClass(NS+"A");
OntClass c = m.getOntClass(NS+"C");
- TestUtil.assertIteratorValues( this, m.listHierarchyRootClasses(),
+ OntTestUtil.assertIteratorValues(m.listHierarchyRootClasses(),
new Object[] {a,c} );
}
/* Auto-loading of imports is off by default */
+ @Test
public void testLoadImports0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
Resource a = m.getResource( "file:testing/ontology/testImport3/a.owl" );
@@ -929,21 +949,21 @@ public class TestOntModel
m.add( a, m.getProfile().IMPORTS(), b );
// not dymamically imported by default
- assertEquals( "Marker count not correct", 0, TestOntDocumentManager.countMarkers( m ) );
+ assertEquals( 0, TestOntDocumentManager.countMarkers( m ), "Marker count not correct" );
- assertFalse( "c should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertFalse( "b should not be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should not be imported" );
+ assertFalse( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should not be imported" );
m.loadImports();
- assertEquals( "Marker count not correct", 2, TestOntDocumentManager.countMarkers( m ) );
+ assertEquals( 2, TestOntDocumentManager.countMarkers( m ), "Marker count not correct" );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertTrue( "b should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should be imported" );
}
-
/* Auto-loading of imports = on */
+ @Test
public void testLoadImports1() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
Resource a = m.getResource( "file:testing/ontology/testImport3/a.owl" );
@@ -952,21 +972,22 @@ public class TestOntModel
m.setDynamicImports( true );
m.add( a, m.getProfile().IMPORTS(), b );
- assertEquals( "Marker count not correct", 2, TestOntDocumentManager.countMarkers( m ) );
+ assertEquals( 2, TestOntDocumentManager.countMarkers( m ), "Marker count not correct" );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertTrue( "b should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should be imported" );
// this should have no effect
m.loadImports();
- assertEquals( "Marker count not correct", 2, TestOntDocumentManager.countMarkers( m ) );
+ assertEquals( 2, TestOntDocumentManager.countMarkers( m ), "Marker count not correct" );
- assertTrue( "c should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ) );
- assertTrue( "b should be imported", m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ) );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/c.owl" ), "c should be imported" );
+ assertTrue( m.hasLoadedImport( "file:testing/ontology/testImport3/b.owl" ), "b should be imported" );
}
/** Test that resources are attached to the right sub-models when importing */
+ @Test
public void testLoadImports2() {
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
ontModel.read("file:testing/ontology/testImport8/a.owl");
@@ -986,6 +1007,7 @@ public class TestOntModel
}
/** Test getting conclusions after loading imports */
+ @Test
public void testAddImports0() {
OntModel base = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
@@ -1008,6 +1030,7 @@ public class TestOntModel
assertTrue( a.hasSubClass( b ) );
}
+ @Test
public void testAddImports1() {
String ns = "http://jena.hpl.hp.com/2003/03/testont";
OntModel base = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
@@ -1015,7 +1038,6 @@ public class TestOntModel
OntDocumentManager odm = OntDocumentManager.getInstance();
odm.addAltEntry( ns + "#a", "file:testing/ontology/testImport7/a.owl" );
-
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF, base );
Ontology oo = base.createOntology( ns );
@@ -1034,6 +1056,7 @@ public class TestOntModel
/**
* AddSubModel variant 2: base = no inf, import = no inf
*/
+ @Test
public void testaddSubModel0() {
OntModel m0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
OntModel m1 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
@@ -1052,6 +1075,7 @@ public class TestOntModel
/**
* AddSubModel variant 2: base = inf, import = no inf
*/
+ @Test
public void testaddSubModel1() {
OntDocumentManager.getInstance().setProcessImports( false );
OntDocumentManager.getInstance().addAltEntry( "http://www.w3.org/TR/2003/CR-owl-guide-20030818/wine",
@@ -1074,6 +1098,7 @@ public class TestOntModel
/**
* Variant 3: base = no inf, import = inf
*/
+ @Test
public void testaddSubModel3() {
OntModel m0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
OntModel m1 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RDFS_INF );
@@ -1092,6 +1117,7 @@ public class TestOntModel
/**
* Variant 4: base = inf, import = inf
*/
+ @Test
public void testaddSubModel4() {
OntModel m0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RDFS_INF );
OntModel m1 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RDFS_INF );
@@ -1108,6 +1134,7 @@ public class TestOntModel
}
/** Remove a sub model (imported model) */
+ @Test
public void testremoveSubModel0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null );
m.read( "file:testing/ontology/testImport3/a.owl" );
@@ -1121,7 +1148,6 @@ public class TestOntModel
assertEquals( 0, m.getSubGraphs().size() );
}
-
/** Getting the deductions model of an OntModel
* see also {@link TestRuleSystemBugs#testOntModelGetDeductions()}
* <p>ijd: Feb 6th, 2008 - this test has been disabled for
@@ -1156,6 +1182,7 @@ public class TestOntModel
/**
* Test that using closed models in imports does not raise an exception
*/
+ @Test
public void testImportClosedModel() {
String SOURCEA=
"<rdf:RDF" +
@@ -1182,12 +1209,13 @@ public class TestOntModel
a1.read( new StringReader( SOURCEA ), null );
// for completeness, check that we have read the same contents
- assertEquals( "Models should be same size", a0count, a1.size() );
+ assertEquals( a0count, a1.size(), "Models should be same size" );
}
/**
* OntModel read should do content negotiation if no base URI is given
*/
+ @Test
public void testReadConneg0() {
final boolean[] acceptHeaderSet = new boolean[] {false};
@@ -1214,6 +1242,7 @@ public class TestOntModel
}
/** No conneg for file: uri's normally */
+ @Test
public void testReadConneg1() {
final boolean[] acceptHeaderSet = new boolean[] {false};
@@ -1234,6 +1263,7 @@ public class TestOntModel
}
/** With RDF/XML syntax specified, conneg */
+ @Test
public void testReadConneg2() {
final boolean[] acceptHeaderSet = new boolean[] {false};
@@ -1260,6 +1290,7 @@ public class TestOntModel
}
/** With a base URI, no conneg */
+ @Test
public void testReadConneg3() {
final boolean[] acceptHeaderSet = new boolean[] {false};
@@ -1285,9 +1316,6 @@ public class TestOntModel
}
-
-
-
// Internal implementation methods
//////////////////////////////////
@@ -1302,7 +1330,6 @@ public class TestOntModel
return found;
}
-
//==============================================================================
// Inner class definitions
//==============================================================================
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModelSpec.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModelSpec.java
index b34507411b..a5f7a9df47 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModelSpec.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModelSpec.java
@@ -21,15 +21,19 @@
package org.apache.jena.ontology.impl;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.ontology.OntModelSpec;
-import org.apache.jena.test.JenaTestBase;
+import org.apache.jena.test.JenaTestLib;
@SuppressWarnings("removal")
-public class TestOntModelSpec extends JenaTestBase
+public class TestOntModelSpec
{
- public TestOntModelSpec( String name )
- { super( name ); }
+ static { JenaTestLib.setup(); }
+ @Test
public void testEqualityAndDifference()
{
testEqualityAndDifference( OntModelSpec.OWL_MEM );
@@ -56,11 +60,13 @@ public class TestOntModelSpec extends JenaTestBase
assertEquals( os, new OntModelSpec( os ) );
}
+ @Test
public void testAssembleRoot()
{
// TODO OntModelSpec.assemble( Resource root )
}
+ @Test
public void testAssembleModel()
{
// TODO OntModelSpec.assemble( Model model )
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntReasoning.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntReasoning.java
index 4a5fbeac00..10d55fb33a 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntReasoning.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntReasoning.java
@@ -23,7 +23,6 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
import java.io.ByteArrayInputStream;
@@ -34,11 +33,15 @@ import org.apache.jena.ontology.*;
import org.apache.jena.rdf.model.*;
import org.apache.jena.reasoner.Reasoner;
import org.apache.jena.reasoner.ReasonerRegistry;
-import org.apache.jena.reasoner.test.TestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import junit.framework.TestCase;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -47,8 +50,10 @@ import junit.framework.TestCase;
*/
@SuppressWarnings("removal")
public class TestOntReasoning
- extends TestCase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
public static final String BASE = "http://jena.hpl.hp.com/testing/ontology";
@@ -63,20 +68,16 @@ public class TestOntReasoning
// Constructors
//////////////////////////////////
- public TestOntReasoning( String name ) {
- super( name );
- }
-
// External signature methods
//////////////////////////////////
- @Override
+ @BeforeEach
public void setUp() {
// ensure the ont doc manager is in a consistent state
OntDocumentManager.getInstance().reset( true );
}
-
+ @Test
public void testSubClassDirectTransInf1a() {
OntModel m = ModelFactory.createOntologyModel( ProfileRegistry.OWL_LITE_LANG );
@@ -93,6 +94,7 @@ public class TestOntReasoning
iteratorTest( A.listSubClasses( true ), new Object[] {B, C} );
}
+ @Test
public void testSubClassDirectTransInf1b() {
OntModel m = ModelFactory.createOntologyModel( ProfileRegistry.OWL_LITE_LANG );
@@ -110,6 +112,7 @@ public class TestOntReasoning
iteratorTest( A.listSubClasses( true ), new Object[] {B, C} );
}
+ @Test
public void testSubClassDirectTransInf2a() {
// test the code path for generating direct sc with no reasoner
OntModelSpec spec = new OntModelSpec( OntModelSpec.OWL_LITE_MEM );
@@ -129,6 +132,7 @@ public class TestOntReasoning
iteratorTest( A.listSubClasses( true ), new Object[] {B, C} );
}
+ @Test
public void testSubClassDirectTransInf2b() {
// test the code path for generating direct sc with no reasoner
OntModelSpec spec = new OntModelSpec( OntModelSpec.OWL_LITE_MEM );
@@ -149,6 +153,7 @@ public class TestOntReasoning
iteratorTest( A.listSubClasses( true ), new Object[] {B, C} );
}
+ @Test
public void testListSuperClassesDirect() {
String ns = "http://example.org/test#";
OntModel m0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
@@ -162,10 +167,10 @@ public class TestOntReasoning
c2.addEquivalentClass( c3 );
// now c1 is the direct super-class of c2, even allowing for the equiv with c3
- assertFalse( "pass 1: c0 should not be a direct super of c2", c2.hasSuperClass( c0, true ) );
- assertFalse( "pass 1: c3 should not be a direct super of c2", c2.hasSuperClass( c3, true ) );
- assertFalse( "pass 1: c2 should not be a direct super of c2", c2.hasSuperClass( c2, true ) );
- assertTrue( "pass 1: c1 should be a direct super of c2", c2.hasSuperClass( c1, true ) );
+ assertFalse( c2.hasSuperClass( c0, true ), "pass 1: c0 should not be a direct super of c2" );
+ assertFalse( c2.hasSuperClass( c3, true ), "pass 1: c3 should not be a direct super of c2" );
+ assertFalse( c2.hasSuperClass( c2, true ), "pass 1: c2 should not be a direct super of c2" );
+ assertTrue( c2.hasSuperClass( c1, true ), "pass 1: c1 should be a direct super of c2" );
// second pass - with inference
m0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RULE_INF );
@@ -179,12 +184,13 @@ public class TestOntReasoning
c2.addEquivalentClass( c3 );
// now c1 is the direct super-class of c2, even allowing for the equiv with c3
- assertFalse( "pass 2: c0 should not be a direct super of c2", c2.hasSuperClass( c0, true ) );
- assertFalse( "pass 2: c3 should not be a direct super of c2", c2.hasSuperClass( c3, true ) );
- assertFalse( "pass 2: c2 should not be a direct super of c2", c2.hasSuperClass( c2, true ) );
- assertTrue( "pass 2: c1 should be a direct super of c2", c2.hasSuperClass( c1, true ) );
+ assertFalse( c2.hasSuperClass( c0, true ), "pass 2: c0 should not be a direct super of c2" );
+ assertFalse( c2.hasSuperClass( c3, true ), "pass 2: c3 should not be a direct super of c2" );
+ assertFalse( c2.hasSuperClass( c2, true ), "pass 2: c2 should not be a direct super of c2" );
+ assertTrue( c2.hasSuperClass( c1, true ), "pass 2: c1 should be a direct super of c2" );
}
+ @Test
public void testSubPropertyDirectTransInf1a() {
OntModel m = ModelFactory.createOntologyModel( ProfileRegistry.OWL_LITE_LANG );
@@ -201,6 +207,7 @@ public class TestOntReasoning
iteratorTest( p.listSubProperties( true ), new Object[] {q,r} );
}
+ @Test
public void testSubPropertyDirectTransInf1b() {
OntModel m = ModelFactory.createOntologyModel( ProfileRegistry.OWL_LITE_LANG );
@@ -218,6 +225,7 @@ public class TestOntReasoning
iteratorTest( p.listSubProperties( true ), new Object[] {q,r} );
}
+ @Test
public void testSubPropertyDirectTransInf2a() {
// test the code path for generating direct sc with no reasoner
OntModelSpec spec = new OntModelSpec( OntModelSpec.OWL_LITE_MEM );
@@ -237,6 +245,7 @@ public class TestOntReasoning
iteratorTest( p.listSubProperties( true ), new Object[] {q,r} );
}
+ @Test
public void testSubPropertyDirectTransInf2b() {
// test the code path for generating direct sc with no reasoner
OntModelSpec spec = new OntModelSpec( OntModelSpec.OWL_LITE_MEM );
@@ -257,6 +266,7 @@ public class TestOntReasoning
iteratorTest( p.listSubProperties( true ), new Object[] {q,r} );
}
+ @Test
public void testListDeclaredProperties0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RULE_INF, null );
@@ -310,6 +320,7 @@ public class TestOntReasoning
/**
* Test LDP with anonymous classes
*/
+ @Test
public void testListDeclaredProperties1() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
OntProperty p = m.createOntProperty( NS + "p" );
@@ -317,10 +328,11 @@ public class TestOntReasoning
Restriction r = m.createMinCardinalityRestriction( null, p, 1 );
r.addSubClass( a );
Iterator<OntProperty> i = a.listDeclaredProperties();
- TestUtil.assertIteratorLength( a.listDeclaredProperties(), 1 );
+ OntTestUtil.assertIteratorLength( a.listDeclaredProperties(), 1 );
}
/** Test LDP with resources in different sub-models */
+ @Test
public void testListDeclaredProperties2() {
OntModel m0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
@@ -341,15 +353,16 @@ public class TestOntReasoning
OntClass cc0 = m1.getOntClass( NS + "c0" );
assertNotNull( cc0 );
- TestUtil.assertIteratorValues( this, c1.listDeclaredProperties(), new Object[] {p0} );
- TestUtil.assertIteratorValues( this, c0.listDeclaredProperties(false), new Object[] {p0} );
- TestUtil.assertIteratorValues( this, cc0.listDeclaredProperties(false), new Object[] {p0} );
+ OntTestUtil.assertIteratorValues(c1.listDeclaredProperties(), new Object[] {p0} );
+ OntTestUtil.assertIteratorValues(c0.listDeclaredProperties(false), new Object[] {p0} );
+ OntTestUtil.assertIteratorValues(cc0.listDeclaredProperties(false), new Object[] {p0} );
}
/**
* Problem reported by Andy Seaborne - combine abox and tbox in RDFS with
* ontmodel
*/
+ @Test
public void testRDFSAbox() {
String sourceT =
"<rdf:RDF "
@@ -389,10 +402,11 @@ public class TestOntReasoning
inds.add(i.next());
}
- assertTrue("x should be an individual", inds.contains(m.getResource("http://example.org/foo#x")));
+ assertTrue(inds.contains(m.getResource("http://example.org/foo#x")), "x should be an individual");
}
+ @Test
public void testInvokeDirectClassReasoning() {
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_TRANS_INF, null);
Resource a = m.createResource("http://example.org#A");
@@ -408,18 +422,20 @@ public class TestOntReasoning
A.hasSuperClass(b, true);
}
+ @Test
public void testListIndividualsWithReasoner() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RDFS_INF );
OntClass C = m.createClass( NS + "C" );
Resource a = m.createResource( NS + "a", C );
- TestUtil.assertIteratorValues( this, m.listIndividuals(), new Object[] {a} );
+ OntTestUtil.assertIteratorValues(m.listIndividuals(), new Object[] {a} );
}
/**
* Bug report by kers - maximal lower elements calculation not correct in models
* with no reasoner. Manifests as direct sub-class bug.
*/
+ @Test
public void testListSubClassesDirectNoReasoner() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM );
OntClass r = m.createClass( NS + "r" );
@@ -447,10 +463,10 @@ public class TestOntReasoning
r.addSubClass( f );
r.addSubClass( g );
- TestUtil.assertIteratorValues( this, r.listSubClasses( true ), new Object[] {a} );
+ OntTestUtil.assertIteratorValues(r.listSubClasses( true ), new Object[] {a} );
}
-
+ @Test
public void testOwlLiteClasses() {
OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM_TRANS_INF );
@@ -464,20 +480,20 @@ public class TestOntReasoning
model.setStrictMode( true );
for (OntResource r: new OntResource[] {b,p0,p1,p2}) {
- assertFalse( r + " should not be an individual", r.canAs( Individual.class ));
+ assertFalse( r.canAs( Individual.class ), r + " should not be an individual");
}
}
/** Bugrep from Benson Margulies: see
* <a href="https://issues.apache.org/jira/browse/JENA-21">JENA-21</a>
*/
+ @Test
public void testBM0() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RDFS_INF );
// should not throw NPE:
m.listStatements( null, null, (RDFNode) null, null );
}
-
// Internal implementation methods
//////////////////////////////////
@@ -495,24 +511,23 @@ public class TestOntReasoning
// debugging
if (!expList.contains( next )) {
- logger.debug( getName() + " - Unexpected iterator result: " + next );
+ logger.debug( getClass().getSimpleName() + " - Unexpected iterator result: " + next );
}
- assertTrue( "Value " + next + " was not expected as a result from this iterator ", expList.contains( next ) );
- assertTrue( "Value " + next + " was not removed from the list ", expList.remove( next ) );
+ assertTrue( expList.contains( next ), "Value " + next + " was not expected as a result from this iterator " );
+ assertTrue( expList.remove( next ), "Value " + next + " was not removed from the list " );
}
if (!(expList.size() == 0)) {
- logger.debug( getName() + " Expected iterator results not found" );
+ logger.debug( getClass().getSimpleName() + " Expected iterator results not found" );
for ( Object anExpList : expList )
{
- logger.debug( getName() + " - missing: " + anExpList );
+ logger.debug( getClass().getSimpleName() + " - missing: " + anExpList );
}
}
- assertEquals( "There were expected elements from the iterator that were not found", 0, expList.size() );
+ assertEquals( 0, expList.size(), "There were expected elements from the iterator that were not found" );
}
-
//==============================================================================
// Inner class definitions
//==============================================================================
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntResource.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntResource.java
index a04ffe0d40..264b411b30 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntResource.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntResource.java
@@ -23,10 +23,8 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
-import junit.framework.TestSuite;
import org.apache.jena.ontology.*;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.NodeIterator;
@@ -34,7 +32,9 @@ import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.vocabulary.RDF;
+import static org.junit.jupiter.api.Assertions.*;
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -44,28 +44,21 @@ import org.apache.jena.vocabulary.RDF;
@SuppressWarnings("removal")
public class TestOntResource extends OntTestBase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
// Static variables
//////////////////////////////////
-
// Instance variables
//////////////////////////////////
// Constructors
//////////////////////////////////
- static public TestSuite suite() {
- return new TestOntResource( "TestResource" );
- }
-
- public TestOntResource( String name ) {
- super( name );
- }
-
-
// External signature methods
//////////////////////////////////
@@ -84,24 +77,24 @@ public class TestOntResource extends OntTestBase
OntResource c = m.getResource( NS + "c" ).as( OntResource.class );
a.addSameAs( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.SAME_AS() ) );
- assertEquals( "a should be sameAs b", b, a.getSameAs() );
+ assertEquals( 1, a.getCardinality( prof.SAME_AS() ), "Cardinality should be 1" );
+ assertEquals( b, a.getSameAs(), "a should be sameAs b" );
a.addSameAs( c );
- assertEquals( "Cardinality should be 2", 2, a.getCardinality( prof.SAME_AS() ) );
+ assertEquals( 2, a.getCardinality( prof.SAME_AS() ), "Cardinality should be 2" );
iteratorTest( a.listSameAs(), new Object[] {b, c} );
- assertTrue( "a should be the same as b", a.isSameAs( b ) );
- assertTrue( "a should be the same as c", a.isSameAs( c ) );
+ assertTrue( a.isSameAs( b ), "a should be the same as b" );
+ assertTrue( a.isSameAs( c ), "a should be the same as c" );
a.setSameAs( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.SAME_AS() ) );
- assertEquals( "a should be sameAs b", b, a.getSameAs() );
+ assertEquals( 1, a.getCardinality( prof.SAME_AS() ), "Cardinality should be 1" );
+ assertEquals( b, a.getSameAs(), "a should be sameAs b" );
a.removeSameAs( c );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.SAME_AS() ) );
+ assertEquals( 1, a.getCardinality( prof.SAME_AS() ), "Cardinality should be 1" );
a.removeSameAs( b );
- assertEquals( "Cardinality should be 0", 0, a.getCardinality( prof.SAME_AS() ) );
+ assertEquals( 0, a.getCardinality( prof.SAME_AS() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntResource.differentFrom", true, true, false ) {
@@ -113,24 +106,24 @@ public class TestOntResource extends OntTestBase
OntResource c = m.getResource( NS + "c" ).as( OntResource.class );
a.addDifferentFrom( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.DIFFERENT_FROM() ) );
- assertEquals( "a should be differentFrom b", b, a.getDifferentFrom() );
+ assertEquals( 1, a.getCardinality( prof.DIFFERENT_FROM() ), "Cardinality should be 1" );
+ assertEquals( b, a.getDifferentFrom(), "a should be differentFrom b" );
a.addDifferentFrom( c );
- assertEquals( "Cardinality should be 2", 2, a.getCardinality( prof.DIFFERENT_FROM() ) );
+ assertEquals( 2, a.getCardinality( prof.DIFFERENT_FROM() ), "Cardinality should be 2" );
iteratorTest( a.listDifferentFrom(), new Object[] {b, c} );
- assertTrue( "a should be diff from b", a.isDifferentFrom( b ) );
- assertTrue( "a should be diff from c", a.isDifferentFrom( c ) );
+ assertTrue( a.isDifferentFrom( b ), "a should be diff from b" );
+ assertTrue( a.isDifferentFrom( c ), "a should be diff from c" );
a.setDifferentFrom( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.DIFFERENT_FROM() ) );
- assertEquals( "a should be differentFrom b", b, a.getDifferentFrom() );
+ assertEquals( 1, a.getCardinality( prof.DIFFERENT_FROM() ), "Cardinality should be 1" );
+ assertEquals( b, a.getDifferentFrom(), "a should be differentFrom b" );
a.removeDifferentFrom( c );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.DIFFERENT_FROM() ) );
+ assertEquals( 1, a.getCardinality( prof.DIFFERENT_FROM() ), "Cardinality should be 1" );
a.removeDifferentFrom( b );
- assertEquals( "Cardinality should be 0", 0, a.getCardinality( prof.DIFFERENT_FROM() ) );
+ assertEquals( 0, a.getCardinality( prof.DIFFERENT_FROM() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntResource.seeAlso", true, true, true ) {
@@ -142,24 +135,24 @@ public class TestOntResource extends OntTestBase
OntResource c = m.getResource( NS + "c" ).as( OntResource.class );
a.addSeeAlso( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.SEE_ALSO() ) );
- assertEquals( "a should be seeAlso b", b, a.getSeeAlso() );
+ assertEquals( 1, a.getCardinality( prof.SEE_ALSO() ), "Cardinality should be 1" );
+ assertEquals( b, a.getSeeAlso(), "a should be seeAlso b" );
a.addSeeAlso( c );
- assertEquals( "Cardinality should be 2", 2, a.getCardinality( prof.SEE_ALSO() ) );
+ assertEquals( 2, a.getCardinality( prof.SEE_ALSO() ), "Cardinality should be 2" );
iteratorTest( a.listSeeAlso(), new Object[] {b, c} );
- assertTrue( "a should have seeAlso b", a.hasSeeAlso( b ) );
- assertTrue( "a should have seeAlso c", a.hasSeeAlso( c ) );
+ assertTrue( a.hasSeeAlso( b ), "a should have seeAlso b" );
+ assertTrue( a.hasSeeAlso( c ), "a should have seeAlso c" );
a.setSeeAlso( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.SEE_ALSO() ) );
- assertEquals( "a should be seeAlso b", b, a.getSeeAlso() );
+ assertEquals( 1, a.getCardinality( prof.SEE_ALSO() ), "Cardinality should be 1" );
+ assertEquals( b, a.getSeeAlso(), "a should be seeAlso b" );
a.removeSeeAlso( c );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.SEE_ALSO() ) );
+ assertEquals( 1, a.getCardinality( prof.SEE_ALSO() ), "Cardinality should be 1" );
a.removeSeeAlso( b );
- assertEquals( "Cardinality should be 0", 0, a.getCardinality( prof.SEE_ALSO() ) );
+ assertEquals( 0, a.getCardinality( prof.SEE_ALSO() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntResource.isDefinedBy", true, true, true ) {
@@ -171,24 +164,24 @@ public class TestOntResource extends OntTestBase
OntResource c = m.getResource( NS + "c" ).as( OntResource.class );
a.addIsDefinedBy( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.IS_DEFINED_BY() ) );
- assertEquals( "a should be isDefinedBy b", b, a.getIsDefinedBy() );
+ assertEquals( 1, a.getCardinality( prof.IS_DEFINED_BY() ), "Cardinality should be 1" );
+ assertEquals( b, a.getIsDefinedBy(), "a should be isDefinedBy b" );
a.addIsDefinedBy( c );
- assertEquals( "Cardinality should be 2", 2, a.getCardinality( prof.IS_DEFINED_BY() ) );
+ assertEquals( 2, a.getCardinality( prof.IS_DEFINED_BY() ), "Cardinality should be 2" );
iteratorTest( a.listIsDefinedBy(), new Object[] {b, c} );
- assertTrue( "a should be defined by b", a.isDefinedBy( b ) );
- assertTrue( "a should be defined by c", a.isDefinedBy( c ) );
+ assertTrue( a.isDefinedBy( b ), "a should be defined by b" );
+ assertTrue( a.isDefinedBy( c ), "a should be defined by c" );
a.setIsDefinedBy( b );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.IS_DEFINED_BY() ) );
- assertEquals( "a should be isDefinedBy b", b, a.getIsDefinedBy() );
+ assertEquals( 1, a.getCardinality( prof.IS_DEFINED_BY() ), "Cardinality should be 1" );
+ assertEquals( b, a.getIsDefinedBy(), "a should be isDefinedBy b" );
a.removeDefinedBy( c );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.IS_DEFINED_BY() ) );
+ assertEquals( 1, a.getCardinality( prof.IS_DEFINED_BY() ), "Cardinality should be 1" );
a.removeDefinedBy( b );
- assertEquals( "Cardinality should be 0", 0, a.getCardinality( prof.IS_DEFINED_BY() ) );
+ assertEquals( 0, a.getCardinality( prof.IS_DEFINED_BY() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntResource.versionInfo", true, true, false ) {
@@ -198,24 +191,24 @@ public class TestOntResource extends OntTestBase
OntResource a = m.getResource( NS + "a" ).as( OntResource.class );
a.addVersionInfo( "some info" );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.VERSION_INFO() ) );
- assertEquals( "a has wrong version info", "some info", a.getVersionInfo() );
+ assertEquals( 1, a.getCardinality( prof.VERSION_INFO() ), "Cardinality should be 1" );
+ assertEquals( "some info", a.getVersionInfo(), "a has wrong version info" );
a.addVersionInfo( "more info" );
- assertEquals( "Cardinality should be 2", 2, a.getCardinality( prof.VERSION_INFO() ) );
+ assertEquals( 2, a.getCardinality( prof.VERSION_INFO() ), "Cardinality should be 2" );
iteratorTest( a.listVersionInfo(), new Object[] {"some info", "more info"} );
- assertTrue( "a should have some info", a.hasVersionInfo( "some info" ) );
- assertTrue( "a should have more info", a.hasVersionInfo( "more info" ) );
+ assertTrue( a.hasVersionInfo( "some info" ), "a should have some info" );
+ assertTrue( a.hasVersionInfo( "more info" ), "a should have more info" );
a.setVersionInfo( "new info" );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.VERSION_INFO() ) );
- assertEquals( "a has wrong version info", "new info", a.getVersionInfo() );
+ assertEquals( 1, a.getCardinality( prof.VERSION_INFO() ), "Cardinality should be 1" );
+ assertEquals( "new info", a.getVersionInfo(), "a has wrong version info" );
a.removeVersionInfo( "old info" );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.VERSION_INFO() ) );
+ assertEquals( 1, a.getCardinality( prof.VERSION_INFO() ), "Cardinality should be 1" );
a.removeVersionInfo( "new info" );
- assertEquals( "Cardinality should be 0", 0, a.getCardinality( prof.VERSION_INFO() ) );
+ assertEquals( 0, a.getCardinality( prof.VERSION_INFO() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntResource.label.nolang", true, true, true ) {
@@ -225,24 +218,24 @@ public class TestOntResource extends OntTestBase
OntResource a = m.getResource( NS + "a" ).as( OntResource.class );
a.addLabel( "some info", null );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.LABEL() ) );
- assertEquals( "a has wrong label", "some info", a.getLabel( null ) );
+ assertEquals( 1, a.getCardinality( prof.LABEL() ), "Cardinality should be 1" );
+ assertEquals( "some info", a.getLabel( null ), "a has wrong label" );
a.addLabel( "more info", null );
- assertEquals( "Cardinality should be 2", 2, a.getCardinality( prof.LABEL() ) );
+ assertEquals( 2, a.getCardinality( prof.LABEL() ), "Cardinality should be 2" );
iteratorTest( a.listLabels( null ), new Object[] {m.createLiteral( "some info" ), m.createLiteral( "more info" )} );
- assertTrue( "a should have label some info", a.hasLabel( "some info", null ) );
- assertTrue( "a should have label more info", a.hasLabel( "more info", null ) );
+ assertTrue( a.hasLabel( "some info", null ), "a should have label some info" );
+ assertTrue( a.hasLabel( "more info", null ), "a should have label more info" );
a.setLabel( "new info", null );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.LABEL() ) );
- assertEquals( "a has wrong label", "new info", a.getLabel( null ) );
+ assertEquals( 1, a.getCardinality( prof.LABEL() ), "Cardinality should be 1" );
+ assertEquals( "new info", a.getLabel( null ), "a has wrong label" );
a.removeLabel( "foo", null );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.LABEL() ) );
+ assertEquals( 1, a.getCardinality( prof.LABEL() ), "Cardinality should be 1" );
a.removeLabel( "new info", null );
- assertEquals( "Cardinality should be 0", 0, a.getCardinality( prof.LABEL() ) );
+ assertEquals( 0, a.getCardinality( prof.LABEL() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntResource.label.lang", true, true, true ) {
@@ -251,33 +244,33 @@ public class TestOntResource extends OntTestBase
OntResource a = m.getResource( NS + "a" ).as( OntResource.class );
a.addLabel( "good", "EN" );
- assertEquals( "wrong label", "good", a.getLabel( null ) );
+ assertEquals( "good", a.getLabel( null ), "wrong label" );
a.addLabel( "bon", "FR" );
- assertEquals( "wrong label", "good", a.getLabel( "EN" ) );
- assertEquals( "wrong label", null, a.getLabel( "EN-GB" ) ); // no literal with a specific enough language
- assertEquals( "wrong label", "bon", a.getLabel( "FR" ) );
+ assertEquals( "good", a.getLabel( "EN" ), "wrong label" );
+ assertEquals( null, a.getLabel( "EN-GB" ), "wrong label" ); // no literal with a specific enough language
+ assertEquals( "bon", a.getLabel( "FR" ), "wrong label" );
- assertTrue( "a should have label good", a.hasLabel( "good", "EN" ) );
- assertTrue( "a should have label bon", a.hasLabel( "bon", "FR" ) );
- assertTrue( "a should note have label good (DE)", !a.hasLabel( "good", "DE" ) );
+ assertTrue( a.hasLabel( "good", "EN" ), "a should have label good" );
+ assertTrue( a.hasLabel( "bon", "FR" ), "a should have label bon" );
+ assertTrue( !a.hasLabel( "good", "DE" ), "a should note have label good (DE)" );
a.addLabel( "spiffing", "EN-GB" );
a.addLabel( "duude", "EN-US" );
- assertEquals( "wrong label", "spiffing", a.getLabel( "EN-GB" ) );
- assertEquals( "wrong label", "duude", a.getLabel( "EN-US" ) );
- assertEquals( "wrong label", null, a.getLabel( "DE" ) );
+ assertEquals( "spiffing", a.getLabel( "EN-GB" ), "wrong label" );
+ assertEquals( "duude", a.getLabel( "EN-US" ), "wrong label" );
+ assertEquals( null, a.getLabel( "DE" ), "wrong label" );
a.addLabel( "abcdef", "AB-CD" );
- assertEquals( "wrong label", "abcdef", a.getLabel( "AB" ) );
- assertEquals( "wrong label", null, a.getLabel( "AB-XY" ) );
+ assertEquals( "abcdef", a.getLabel( "AB" ), "wrong label" );
+ assertEquals( null, a.getLabel( "AB-XY" ), "wrong label" );
a.removeLabel( "abcde", "AB-CD" );
- assertEquals( "Cardinality should be 5", 5, a.getCardinality( a.getProfile().LABEL() ) );
+ assertEquals( 5, a.getCardinality( a.getProfile().LABEL() ), "Cardinality should be 5" );
a.removeLabel( "abcdef", "AB-CD" );
- assertEquals( "Cardinality should be 4", 4, a.getCardinality( a.getProfile().LABEL() ) );
+ assertEquals( 4, a.getCardinality( a.getProfile().LABEL() ), "Cardinality should be 4" );
}
},
new OntTestCase( "OntResource.comment.nolang", true, true, true ) {
@@ -287,24 +280,24 @@ public class TestOntResource extends OntTestBase
OntResource a = m.getResource( NS + "a" ).as( OntResource.class );
a.addComment( "some info", null );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.COMMENT() ) );
- assertEquals( "a has wrong comment", "some info", a.getComment( null ) );
+ assertEquals( 1, a.getCardinality( prof.COMMENT() ), "Cardinality should be 1" );
+ assertEquals( "some info", a.getComment( null ), "a has wrong comment" );
a.addComment( "more info", null );
- assertEquals( "Cardinality should be 2", 2, a.getCardinality( prof.COMMENT() ) );
+ assertEquals( 2, a.getCardinality( prof.COMMENT() ), "Cardinality should be 2" );
iteratorTest( a.listComments( null ), new Object[] {m.createLiteral( "some info" ), m.createLiteral( "more info" )} );
- assertTrue( "a should have comment some info", a.hasComment( "some info", null ) );
- assertTrue( "a should have comment more info", a.hasComment( "more info", null ) );
+ assertTrue( a.hasComment( "some info", null ), "a should have comment some info" );
+ assertTrue( a.hasComment( "more info", null ), "a should have comment more info" );
a.setComment( "new info", null );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.COMMENT() ) );
- assertEquals( "a has wrong comment", "new info", a.getComment( null ) );
+ assertEquals( 1, a.getCardinality( prof.COMMENT() ), "Cardinality should be 1" );
+ assertEquals( "new info", a.getComment( null ), "a has wrong comment" );
a.removeComment( "foo", null );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( prof.COMMENT() ) );
+ assertEquals( 1, a.getCardinality( prof.COMMENT() ), "Cardinality should be 1" );
a.removeComment( "new info", null );
- assertEquals( "Cardinality should be 0", 0, a.getCardinality( prof.COMMENT() ) );
+ assertEquals( 0, a.getCardinality( prof.COMMENT() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntResource.comment.lang", true, true, true ) {
@@ -313,33 +306,33 @@ public class TestOntResource extends OntTestBase
OntResource a = m.getResource( NS + "a" ).as( OntResource.class );
a.addComment( "good", "EN" );
- assertEquals( "wrong comment", "good", a.getComment( null ) );
+ assertEquals( "good", a.getComment( null ), "wrong comment" );
a.addComment( "bon", "FR" );
- assertEquals( "wrong comment", "good", a.getComment( "EN" ) );
- assertEquals( "wrong comment", null, a.getComment( "EN-GB" ) ); // no literal with a specific enough language
- assertEquals( "wrong comment", "bon", a.getComment( "FR" ) );
+ assertEquals( "good", a.getComment( "EN" ), "wrong comment" );
+ assertEquals( null, a.getComment( "EN-GB" ), "wrong comment" ); // no literal with a specific enough language
+ assertEquals( "bon", a.getComment( "FR" ), "wrong comment" );
- assertTrue( "a should have label good", a.hasComment( "good", "EN" ) );
- assertTrue( "a should have label bon", a.hasComment( "bon", "FR" ) );
- assertTrue( "a should note have label good (DE)", !a.hasComment( "good", "DE" ) );
+ assertTrue( a.hasComment( "good", "EN" ), "a should have label good" );
+ assertTrue( a.hasComment( "bon", "FR" ), "a should have label bon" );
+ assertTrue( !a.hasComment( "good", "DE" ), "a should note have label good (DE)" );
a.addComment( "spiffing", "EN-GB" );
a.addComment( "duude", "EN-US" );
- assertEquals( "wrong comment", "spiffing", a.getComment( "EN-GB" ) );
- assertEquals( "wrong comment", "duude", a.getComment( "EN-US" ) );
- assertEquals( "wrong comment", null, a.getComment( "DE" ) );
+ assertEquals( "spiffing", a.getComment( "EN-GB" ), "wrong comment" );
+ assertEquals( "duude", a.getComment( "EN-US" ), "wrong comment" );
+ assertEquals( null, a.getComment( "DE" ), "wrong comment" );
a.addComment( "abcdef", "AB-CD" );
- assertEquals( "wrong comment", "abcdef", a.getComment( "AB" ) );
- assertEquals( "wrong comment", null, a.getComment( "AB-XY" ) );
+ assertEquals( "abcdef", a.getComment( "AB" ), "wrong comment" );
+ assertEquals( null, a.getComment( "AB-XY" ), "wrong comment" );
a.removeComment( "abcde", "AB-CD" );
- assertEquals( "Cardinality should be 5", 5, a.getCardinality( a.getProfile().COMMENT() ) );
+ assertEquals( 5, a.getCardinality( a.getProfile().COMMENT() ), "Cardinality should be 5" );
a.removeComment( "abcdef", "AB-CD" );
- assertEquals( "Cardinality should be 4", 4, a.getCardinality( a.getProfile().COMMENT() ) );
+ assertEquals( 4, a.getCardinality( a.getProfile().COMMENT() ), "Cardinality should be 4" );
}
},
new OntTestCase( "OntResource.type (no inference)", true, true, true ) {
@@ -350,11 +343,11 @@ public class TestOntResource extends OntTestBase
A.addSubClass( B );
OntResource a = m.getResource( NS + "a" ).as( OntResource.class );
- assertEquals( "Cardinality of rdf:type is wrong", 0, a.getCardinality( RDF.type ) );
+ assertEquals( 0, a.getCardinality( RDF.type ), "Cardinality of rdf:type is wrong" );
a.addRDFType( B );
- assertEquals( "rdf:type of a is wrong", B, a.getRDFType() );
- assertEquals( "rdf:type of a is wrong", B, a.getRDFType( false ) );
+ assertEquals( B, a.getRDFType(), "rdf:type of a is wrong" );
+ assertEquals( B, a.getRDFType( false ), "rdf:type of a is wrong" );
iteratorTest( a.listRDFTypes( false ), new Object[] {B} ); // only B since we're not using an inference model
iteratorTest( a.listRDFTypes( true ), new Object[] {B} );
@@ -363,19 +356,19 @@ public class TestOntResource extends OntTestBase
iteratorTest( a.listRDFTypes( false ), new Object[] {A,B} );
iteratorTest( a.listRDFTypes( true ), new Object[] {B} );
- assertTrue( "a should not be of class A direct", !a.hasRDFType( A, true ));
- assertTrue( "a should not be of class B direct", a.hasRDFType( B, true ));
+ assertTrue( !a.hasRDFType( A, true ), "a should not be of class A direct");
+ assertTrue( a.hasRDFType( B, true ), "a should not be of class B direct");
OntClass C = m.createClass( NS + "C" );
a.setRDFType( C );
- assertTrue( "a should be of class C", a.hasRDFType( C, false ));
- assertTrue( "a should not be of class A", !a.hasRDFType( A, false ));
- assertTrue( "a should not be of class B", !a.hasRDFType( B, false ));
+ assertTrue( a.hasRDFType( C, false ), "a should be of class C");
+ assertTrue( !a.hasRDFType( A, false ), "a should not be of class A");
+ assertTrue( !a.hasRDFType( B, false ), "a should not be of class B");
a.removeRDFType( B );
- assertEquals( "Cardinality should be 1", 1, a.getCardinality( RDF.type ) );
+ assertEquals( 1, a.getCardinality( RDF.type ), "Cardinality should be 1" );
a.removeRDFType( C );
- assertEquals( "Cardinality should be 0", 0, a.getCardinality( RDF.type ) );
+ assertEquals( 0, a.getCardinality( RDF.type ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntResource.remove", true, true, true ) {
@@ -391,13 +384,13 @@ public class TestOntResource extends OntTestBase
C.addSubClass( D );
C.addSubClass( E );
- assertTrue( "super-class of E", E.hasSuperClass( C, false ) );
+ assertTrue( E.hasSuperClass( C, false ), "super-class of E" );
iteratorTest( A.listSubClasses(), new Object[] {B,C} );
C.remove();
- assertTrue( "super-class of D", !D.hasSuperClass( C, false ) );
- assertTrue( "super-class of E", !E.hasSuperClass( C, false ) );
+ assertTrue( !D.hasSuperClass( C, false ), "super-class of D" );
+ assertTrue( !E.hasSuperClass( C, false ), "super-class of E" );
iteratorTest( A.listSubClasses(), new Object[] {B} );
}
},
@@ -407,18 +400,18 @@ public class TestOntResource extends OntTestBase
Resource r = m.createResource();
r.addProperty( RDF.type, m.getProfile().CLASS() );
OntResource or = r.as( OntResource.class );
- assertFalse( "should not be annotation prop", or.isAnnotationProperty() );
- assertFalse( "should not be all different", or.isAllDifferent() );
- assertTrue( "should be class", or.isClass() );
- assertFalse( "should not be property", or.isProperty() );
- assertFalse( "should not be object property", or.isObjectProperty() );
- assertFalse( "should not be datatype property", or.isDatatypeProperty() );
- assertTrue( "should not be individual", owlFull() || !or.isIndividual() );
- assertFalse( "should not be data range", or.isDataRange() );
- assertFalse( "should not be ontology", or.isOntology() );
+ assertFalse( or.isAnnotationProperty(), "should not be annotation prop" );
+ assertFalse( or.isAllDifferent(), "should not be all different" );
+ assertTrue( or.isClass(), "should be class" );
+ assertFalse( or.isProperty(), "should not be property" );
+ assertFalse( or.isObjectProperty(), "should not be object property" );
+ assertFalse( or.isDatatypeProperty(), "should not be datatype property" );
+ assertTrue( owlFull() || !or.isIndividual(), "should not be individual" );
+ assertFalse( or.isDataRange(), "should not be data range" );
+ assertFalse( or.isOntology(), "should not be ontology" );
RDFNode n = or.asClass();
- assertTrue( "Should be OntClass", n instanceof OntClass );
+ assertTrue( n instanceof OntClass, "Should be OntClass" );
}
},
new OntTestCase( "OntResource.asAnnotationProperty", true, true, false) {
@@ -431,18 +424,18 @@ public class TestOntResource extends OntTestBase
r.addProperty( RDF.type, m.getProfile().ANNOTATION_PROPERTY() );
OntResource or = r.as( OntResource.class );
- assertTrue( "should be annotation prop", or.isAnnotationProperty() );
- assertFalse( "should not be all different", or.isAllDifferent() );
- assertFalse( "should not be class", or.isClass() );
- assertTrue( "should be property", or.isProperty() );
- assertFalse( "should not be object property", or.isObjectProperty() );
- assertFalse( "should not be datatype property", or.isDatatypeProperty() );
- assertFalse( "should not be individual", or.isIndividual() );
- assertFalse( "should not be data range", or.isDataRange() );
- assertFalse( "should not be ontology", or.isOntology() );
+ assertTrue( or.isAnnotationProperty(), "should be annotation prop" );
+ assertFalse( or.isAllDifferent(), "should not be all different" );
+ assertFalse( or.isClass(), "should not be class" );
+ assertTrue( or.isProperty(), "should be property" );
+ assertFalse( or.isObjectProperty(), "should not be object property" );
+ assertFalse( or.isDatatypeProperty(), "should not be datatype property" );
+ assertFalse( or.isIndividual(), "should not be individual" );
+ assertFalse( or.isDataRange(), "should not be data range" );
+ assertFalse( or.isOntology(), "should not be ontology" );
RDFNode n = or.asAnnotationProperty();
- assertTrue( "Should be AnnotationProperty", n instanceof AnnotationProperty);
+ assertTrue( n instanceof AnnotationProperty, "Should be AnnotationProperty");
}
},
new OntTestCase( "OntResource.asObjectProperty", true, true, false) {
@@ -455,18 +448,18 @@ public class TestOntResource extends OntTestBase
r.addProperty( RDF.type, m.getProfile().OBJECT_PROPERTY() );
OntResource or = r.as( OntResource.class );
- assertFalse( "should not be annotation prop", or.isAnnotationProperty() );
- assertFalse( "should not be all different", or.isAllDifferent() );
- assertFalse( "should not be class", or.isClass() );
- assertTrue( "should be property", or.isProperty() );
- assertTrue( "should be object property", or.isObjectProperty() );
- assertFalse( "should not be datatype property", or.isDatatypeProperty() );
- assertFalse( "should not be individual", or.isIndividual() );
- assertFalse( "should not be data range", or.isDataRange() );
- assertFalse( "should not be ontology", or.isOntology() );
+ assertFalse( or.isAnnotationProperty(), "should not be annotation prop" );
+ assertFalse( or.isAllDifferent(), "should not be all different" );
+ assertFalse( or.isClass(), "should not be class" );
+ assertTrue( or.isProperty(), "should be property" );
+ assertTrue( or.isObjectProperty(), "should be object property" );
+ assertFalse( or.isDatatypeProperty(), "should not be datatype property" );
+ assertFalse( or.isIndividual(), "should not be individual" );
+ assertFalse( or.isDataRange(), "should not be data range" );
+ assertFalse( or.isOntology(), "should not be ontology" );
RDFNode n = or.asObjectProperty();
- assertTrue( "Should be ObjectProperty", n instanceof ObjectProperty);
+ assertTrue( n instanceof ObjectProperty, "Should be ObjectProperty");
}
},
new OntTestCase( "OntResource.asDatatypeProperty", true, true, false) {
@@ -479,18 +472,18 @@ public class TestOntResource extends OntTestBase
r.addProperty( RDF.type, m.getProfile().DATATYPE_PROPERTY() );
OntResource or = r.as( OntResource.class );
- assertFalse( "should not be annotation prop", or.isAnnotationProperty() );
- assertFalse( "should not be all different", or.isAllDifferent() );
- assertFalse( "should not be class", or.isClass() );
- assertTrue( "should be property", or.isProperty() );
- assertFalse( "should not be object property", or.isObjectProperty() );
- assertTrue( "should be datatype property", or.isDatatypeProperty() );
- assertFalse( "should not be individual", or.isIndividual() );
- assertFalse( "should not be data range", or.isDataRange() );
- assertFalse( "should not be ontology", or.isOntology() );
+ assertFalse( or.isAnnotationProperty(), "should not be annotation prop" );
+ assertFalse( or.isAllDifferent(), "should not be all different" );
+ assertFalse( or.isClass(), "should not be class" );
+ assertTrue( or.isProperty(), "should be property" );
+ assertFalse( or.isObjectProperty(), "should not be object property" );
+ assertTrue( or.isDatatypeProperty(), "should be datatype property" );
+ assertFalse( or.isIndividual(), "should not be individual" );
+ assertFalse( or.isDataRange(), "should not be data range" );
+ assertFalse( or.isOntology(), "should not be ontology" );
RDFNode n = or.asDatatypeProperty();
- assertTrue( "Should be DatatypeProperty", n instanceof DatatypeProperty);
+ assertTrue( n instanceof DatatypeProperty, "Should be DatatypeProperty");
}
},
new OntTestCase( "OntResource.asAllDifferent", true, true, false) {
@@ -503,18 +496,18 @@ public class TestOntResource extends OntTestBase
r.addProperty( RDF.type, m.getProfile().ALL_DIFFERENT() );
OntResource or = r.as( OntResource.class );
- assertFalse( "should not be annotation prop", or.isAnnotationProperty() );
- assertTrue( "should be all different", or.isAllDifferent() );
- assertFalse( "should not be class", or.isClass() );
- assertFalse( "should not be property", or.isProperty() );
- assertFalse( "should not be object property", or.isObjectProperty() );
- assertFalse( "should not be datatype property", or.isDatatypeProperty() );
- assertFalse( "should not be individual", or.isIndividual() );
- assertFalse( "should not be data range", or.isDataRange() );
- assertFalse( "should not be ontology", or.isOntology() );
+ assertFalse( or.isAnnotationProperty(), "should not be annotation prop" );
+ assertTrue( or.isAllDifferent(), "should be all different" );
+ assertFalse( or.isClass(), "should not be class" );
+ assertFalse( or.isProperty(), "should not be property" );
+ assertFalse( or.isObjectProperty(), "should not be object property" );
+ assertFalse( or.isDatatypeProperty(), "should not be datatype property" );
+ assertFalse( or.isIndividual(), "should not be individual" );
+ assertFalse( or.isDataRange(), "should not be data range" );
+ assertFalse( or.isOntology(), "should not be ontology" );
RDFNode n = or.asAllDifferent();
- assertTrue( "Should be AnnotationProperty", n instanceof AllDifferent);
+ assertTrue( n instanceof AllDifferent, "Should be AnnotationProperty");
}
},
new OntTestCase( "OntResource.asProperty", true, true, true ) {
@@ -524,18 +517,18 @@ public class TestOntResource extends OntTestBase
r.addProperty( RDF.type, m.getProfile().PROPERTY() );
OntResource or = r.as( OntResource.class );
- assertFalse( "should not be annotation prop", or.isAnnotationProperty() );
- assertFalse( "should not be all different", or.isAllDifferent() );
- assertFalse( "should not be class", or.isClass() );
- assertTrue( "should be property", or.isProperty() );
- assertFalse( "should not be object property", or.isObjectProperty() );
- assertFalse( "should not be datatype property", or.isDatatypeProperty() );
- assertFalse( "should not be individual", or.isIndividual() );
- assertFalse( "should not be data range", or.isDataRange() );
- assertFalse( "should not be ontology", or.isOntology() );
+ assertFalse( or.isAnnotationProperty(), "should not be annotation prop" );
+ assertFalse( or.isAllDifferent(), "should not be all different" );
+ assertFalse( or.isClass(), "should not be class" );
+ assertTrue( or.isProperty(), "should be property" );
+ assertFalse( or.isObjectProperty(), "should not be object property" );
+ assertFalse( or.isDatatypeProperty(), "should not be datatype property" );
+ assertFalse( or.isIndividual(), "should not be individual" );
+ assertFalse( or.isDataRange(), "should not be data range" );
+ assertFalse( or.isOntology(), "should not be ontology" );
RDFNode n = or.asProperty();
- assertTrue( "Should be OntProperty", n instanceof OntProperty);
+ assertTrue( n instanceof OntProperty, "Should be OntProperty");
}
},
new OntTestCase( "OntResource.asIndividual", true, true, true ) {
@@ -547,18 +540,18 @@ public class TestOntResource extends OntTestBase
r.addProperty( RDF.type, s );
OntResource or = r.as( OntResource.class );
- assertFalse( "should not be annotation prop", or.isAnnotationProperty() );
- assertFalse( "should not be all different", or.isAllDifferent() );
- assertFalse( "should not be class", or.isClass() );
- assertFalse( "should not be property", or.isProperty() );
- assertFalse( "should not be object property", or.isObjectProperty() );
- assertFalse( "should not be datatype property", or.isDatatypeProperty() );
- assertTrue( "should be individual", or.isIndividual() );
- assertFalse( "should not be data range", or.isDataRange() );
- assertFalse( "should not be ontology", or.isOntology() );
+ assertFalse( or.isAnnotationProperty(), "should not be annotation prop" );
+ assertFalse( or.isAllDifferent(), "should not be all different" );
+ assertFalse( or.isClass(), "should not be class" );
+ assertFalse( or.isProperty(), "should not be property" );
+ assertFalse( or.isObjectProperty(), "should not be object property" );
+ assertFalse( or.isDatatypeProperty(), "should not be datatype property" );
+ assertTrue( or.isIndividual(), "should be individual" );
+ assertFalse( or.isDataRange(), "should not be data range" );
+ assertFalse( or.isOntology(), "should not be ontology" );
RDFNode n = or.asIndividual();
- assertTrue( "Should be individual", n instanceof Individual);
+ assertTrue( n instanceof Individual, "Should be individual");
}
},
new OntTestCase( "OntResource.asDataRange", true, false, false ) {
@@ -571,18 +564,18 @@ public class TestOntResource extends OntTestBase
r.addProperty( RDF.type, m.getProfile().DATARANGE() );
OntResource or = r.as( OntResource.class );
- assertFalse( "should not be annotation prop", or.isAnnotationProperty() );
- assertFalse( "should not be all different", or.isAllDifferent() );
- assertFalse( "should not be class", or.isClass() );
- assertFalse( "should not be property", or.isProperty() );
- assertFalse( "should not be object property", or.isObjectProperty() );
- assertFalse( "should not be datatype property", or.isDatatypeProperty() );
- assertFalse( "should not be individual", or.isIndividual() );
- assertTrue( "should be data range", or.isDataRange() );
- assertFalse( "should not be ontology", or.isOntology() );
+ assertFalse( or.isAnnotationProperty(), "should not be annotation prop" );
+ assertFalse( or.isAllDifferent(), "should not be all different" );
+ assertFalse( or.isClass(), "should not be class" );
+ assertFalse( or.isProperty(), "should not be property" );
+ assertFalse( or.isObjectProperty(), "should not be object property" );
+ assertFalse( or.isDatatypeProperty(), "should not be datatype property" );
+ assertFalse( or.isIndividual(), "should not be individual" );
+ assertTrue( or.isDataRange(), "should be data range" );
+ assertFalse( or.isOntology(), "should not be ontology" );
RDFNode n = or.asDataRange();
- assertTrue( "Should be DataRange", n instanceof DataRange );
+ assertTrue( n instanceof DataRange, "Should be DataRange" );
}
},
new OntTestCase( "OntResource.asOntology", true, true, false ) {
@@ -595,18 +588,18 @@ public class TestOntResource extends OntTestBase
r.addProperty( RDF.type, m.getProfile().ONTOLOGY() );
OntResource or = r.as( OntResource.class );
- assertFalse( "should not be annotation prop", or.isAnnotationProperty() );
- assertFalse( "should not be all different", or.isAllDifferent() );
- assertFalse( "should not be class", or.isClass() );
- assertFalse( "should not be property", or.isProperty() );
- assertFalse( "should not be object property", or.isObjectProperty() );
- assertFalse( "should not be datatype property", or.isDatatypeProperty() );
- assertFalse( "should not be individual", or.isIndividual() );
- assertFalse( "should not be data range", or.isDataRange() );
- assertTrue( "should be ontology", or.isOntology() );
+ assertFalse( or.isAnnotationProperty(), "should not be annotation prop" );
+ assertFalse( or.isAllDifferent(), "should not be all different" );
+ assertFalse( or.isClass(), "should not be class" );
+ assertFalse( or.isProperty(), "should not be property" );
+ assertFalse( or.isObjectProperty(), "should not be object property" );
+ assertFalse( or.isDatatypeProperty(), "should not be datatype property" );
+ assertFalse( or.isIndividual(), "should not be individual" );
+ assertFalse( or.isDataRange(), "should not be data range" );
+ assertTrue( or.isOntology(), "should be ontology" );
RDFNode n = or.asOntology();
- assertTrue( "Should be Ontology", n instanceof Ontology);
+ assertTrue( n instanceof Ontology, "Should be Ontology");
}
},
new OntTestCase( "OntResource.isLanguageTerm", true, true, true ) {
@@ -614,10 +607,10 @@ public class TestOntResource extends OntTestBase
public void ontTest( OntModel m ) {
// class is defined (differently) in every profile
OntResource or = m.getProfile().CLASS().inModel(m).as( OntResource.class );
- assertTrue( "should be a lang term", or.isOntLanguageTerm() );
+ assertTrue( or.isOntLanguageTerm(), "should be a lang term" );
or = m.createOntResource( "http://foo/bar" );
- assertFalse( "should not be a lang term", or.isOntLanguageTerm() );
+ assertFalse( or.isOntLanguageTerm(), "should not be a lang term" );
}
},
new OntTestCase( "OntResource.getOntModel", true, true, true ) {
@@ -637,7 +630,7 @@ public class TestOntResource extends OntTestBase
m.add( a, p, b );
Object bb = a.getPropertyValue( p );
assertEquals( b, bb );
- assertTrue( "Return value should be an OntResource", bb instanceof OntResource );
+ assertTrue( bb instanceof OntResource, "Return value should be an OntResource" );
}
},
new OntTestCase( "OntResource.getPropertyValue - missing prop", true, true, true ) {
@@ -667,7 +660,7 @@ public class TestOntResource extends OntTestBase
RDFNode n = ni.nextNode();
if (n.isResource()) {
assertEquals( b, n );
- assertTrue( "Return value should be an OntResource", n instanceof OntResource );
+ assertTrue( n instanceof OntResource, "Return value should be an OntResource" );
}
}
}
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java
index 729d21f935..099a0b6646 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java
@@ -23,11 +23,9 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
-import junit.framework.TestCase;
import org.apache.jena.ontology.OntClass;
import org.apache.jena.ontology.OntModel;
import org.apache.jena.ontology.OntModelSpec;
@@ -41,6 +39,12 @@ import org.apache.jena.vocabulary.OWL;
import java.util.List;
import java.util.function.Predicate;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -49,8 +53,10 @@ import java.util.function.Predicate;
*/
@SuppressWarnings("removal")
public class TestOntTools
- extends TestCase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
@@ -79,11 +85,8 @@ public class TestOntTools
// External signature methods
//////////////////////////////////
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() {
+ @BeforeEach
+ public void setUp() {
m_model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF );
m_a = m_model.createClass( NS + "A" );
m_b = m_model.createClass( NS + "B" );
@@ -98,6 +101,7 @@ public class TestOntTools
/**
* Test method for <code>org.apache.jena.ontology.OntTools#indexLCA</code>
*/
+ @Test
public void testIndexLCA0() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -105,6 +109,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_b, m_c ) );
}
+ @Test
public void testIndexLCA1() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -112,6 +117,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_c, m_b ) );
}
+ @Test
public void testIndexLCA2() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -119,6 +125,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_a, m_c ) );
}
+ @Test
public void testIndexLCA3() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -126,6 +133,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_b, m_a ) );
}
+ @Test
public void testIndexLCA4() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -134,6 +142,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_d, m_c ) );
}
+ @Test
public void testIndexLCA5() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -142,6 +151,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_c, m_d ) );
}
+ @Test
public void testIndexLCA6() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -151,6 +161,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_d, m_e ) );
}
+ @Test
public void testIndexLCA7() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -160,6 +171,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_e, m_d ) );
}
+ @Test
public void testIndexLCA8() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -169,6 +181,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_c, m_e ) );
}
+ @Test
public void testIndexLCA9() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -178,6 +191,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_b, m_c ) );
}
+ @Test
public void testIndexLCA10() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -188,6 +202,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_b, m_e ) );
}
+ @Test
public void testIndexLCA11() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -198,6 +213,7 @@ public class TestOntTools
assertEquals( m_a, OntTools.getLCA( m_model, m_b, m_f ) );
}
+ @Test
public void testIndexLCA12() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -208,6 +224,7 @@ public class TestOntTools
assertEquals( m_d, OntTools.getLCA( m_model, m_f, m_e ) );
}
+ @Test
public void testIndexLCA13() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -220,6 +237,7 @@ public class TestOntTools
}
/** Disconnected trees */
+ @Test
public void testIndexLCA14() {
m_a.addSubClass( m_b );
m_a.addSubClass( m_c );
@@ -233,6 +251,7 @@ public class TestOntTools
static final Predicate<Statement> ANY = s -> true;
+ @Test
public void testShortestPath0() {
Property p = m_model.createProperty( NS + "p" );
m_a.addProperty( p, m_b );
@@ -241,6 +260,7 @@ public class TestOntTools
new Property[] {p} );
}
+ @Test
public void testShortestPath1() {
Property p = m_model.createProperty( NS + "p" );
m_a.addProperty( p, m_b );
@@ -250,6 +270,7 @@ public class TestOntTools
new Property[] {p,p} );
}
+ @Test
public void testShortestPath2() {
Property p = m_model.createProperty( NS + "p" );
// a - b - c
@@ -267,6 +288,7 @@ public class TestOntTools
new Property[] {p,p,p} );
}
+ @Test
public void testShortestPath3() {
Property p = m_model.createProperty( NS + "p" );
// a - b - c
@@ -284,6 +306,7 @@ public class TestOntTools
new Property[] {p,p,p} );
}
+ @Test
public void testShortestPath4() {
Property p = m_model.createProperty( NS + "p" );
Property q = m_model.createProperty( NS + "q" );
@@ -303,6 +326,7 @@ public class TestOntTools
}
/** Reflexive loop is allowed */
+ @Test
public void testShortestPath5() {
Property p = m_model.createProperty( NS + "p" );
m_a.addProperty( p, m_a );
@@ -311,6 +335,7 @@ public class TestOntTools
new Property[] {p} );
}
+ @Test
public void testShortestPath6() {
Property p = m_model.createProperty( NS + "p" );
Property q = m_model.createProperty( NS + "q" );
@@ -323,6 +348,7 @@ public class TestOntTools
assertNull( OntTools.findShortestPath( m_model, m_a, m_c, new OntTools.PredicatesFilter( new Property[] {p,q} ) ) );
}
+ @Test
public void testShortestPath7() {
Property p = m_model.createProperty( NS + "p" );
Property q = m_model.createProperty( NS + "q" );
@@ -338,6 +364,7 @@ public class TestOntTools
}
/** Find a literal target */
+ @Test
public void testShortestPath8() {
Property p = m_model.createProperty( NS + "p" );
Property q = m_model.createProperty( NS + "q" );
@@ -357,6 +384,7 @@ public class TestOntTools
/** Tests on {@link OntTools#namedHierarchyRoots(OntModel)} */
+ @Test
public void testNamedHierarchyRoots0() {
m_a.addSubClass( m_b );
m_b.addSubClass( m_c );
@@ -371,6 +399,7 @@ public class TestOntTools
assertTrue( nhr.contains( m_g ));
}
+ @Test
public void testNamedHierarchyRoots1() {
m_a.addSubClass( m_b );
m_b.addSubClass( m_c );
@@ -389,6 +418,7 @@ public class TestOntTools
assertTrue( nhr.contains( m_g ));
}
+ @Test
public void testNamedHierarchyRoots2() {
OntClass anon0 = m_model.createClass();
OntClass anon1 = m_model.createClass();
@@ -411,6 +441,7 @@ public class TestOntTools
}
/** Test for no dups in the returned list */
+ @Test
public void testNamedHierarchyRoots3() {
OntClass anon0 = m_model.createClass();
OntClass anon1 = m_model.createClass();
@@ -431,6 +462,7 @@ public class TestOntTools
}
/** Test for indirect route to a non-root node */
+ @Test
public void testNamedHierarchyRoots4() {
OntClass anon0 = m_model.createClass();
OntClass anon1 = m_model.createClass();
@@ -460,12 +492,11 @@ public class TestOntTools
int i = 0;
for ( Statement aPath : path )
{
- assertEquals( "path position: " + i, expected[i], aPath.getPredicate() );
+ assertEquals( expected[i], aPath.getPredicate(), "path position: " + i );
i++;
}
}
-
//==============================================================================
// Inner class definitions
//==============================================================================
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntology.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntology.java
index 3ed05b2ecc..ffc977cd24 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntology.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntology.java
@@ -23,12 +23,13 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
-import junit.framework.TestSuite;
import org.apache.jena.ontology.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -36,34 +37,23 @@ import org.apache.jena.ontology.*;
* </p>
*/
@SuppressWarnings("removal")
-public class TestOntology
- extends OntTestBase
+public class TestOntology extends OntTestBase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
// Static variables
//////////////////////////////////
-
-
// Instance variables
//////////////////////////////////
// Constructors
//////////////////////////////////
- static public TestSuite suite() {
- return new TestOntology( "TestOntology" );
- }
-
- public TestOntology( String name ) {
- super( name );
- }
-
-
-
-
// External signature methods
//////////////////////////////////
@@ -79,21 +69,21 @@ public class TestOntology
Ontology z = m.createOntology( NS + "z" );
x.addImport( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) );
- assertEquals( "x should import y", y, x.getImport() );
+ assertEquals( 1, x.getCardinality( prof.IMPORTS() ), "Cardinality should be 1" );
+ assertEquals( y, x.getImport(), "x should import y" );
x.addImport( z );
- assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.IMPORTS() ) );
+ assertEquals( 2, x.getCardinality( prof.IMPORTS() ), "Cardinality should be 2" );
iteratorTest( x.listImports(), new Object[] {y,z} );
x.setImport( z );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) );
- assertEquals( "x should import z", z, x.getImport() );
+ assertEquals( 1, x.getCardinality( prof.IMPORTS() ), "Cardinality should be 1" );
+ assertEquals( z, x.getImport(), "x should import z" );
x.removeImport( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) );
+ assertEquals( 1, x.getCardinality( prof.IMPORTS() ), "Cardinality should be 1" );
x.removeImport( z );
- assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.IMPORTS() ) );
+ assertEquals( 0, x.getCardinality( prof.IMPORTS() ), "Cardinality should be 0" );
}
},
new OntTestCase( "Ontology.backwardCompatibleWith", true, true, false ) {
@@ -105,21 +95,21 @@ public class TestOntology
Ontology z = m.createOntology( NS + "z" );
x.addBackwardCompatibleWith( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) );
- assertEquals( "x should be back comp with y", y, x.getBackwardCompatibleWith() );
+ assertEquals( 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ), "Cardinality should be 1" );
+ assertEquals( y, x.getBackwardCompatibleWith(), "x should be back comp with y" );
x.addBackwardCompatibleWith( z );
- assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) );
+ assertEquals( 2, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ), "Cardinality should be 2" );
iteratorTest( x.listBackwardCompatibleWith(), new Object[] {y,z} );
x.setBackwardCompatibleWith( z );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) );
- assertEquals( "x should be back comp with z", z, x.getBackwardCompatibleWith() );
+ assertEquals( 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ), "Cardinality should be 1" );
+ assertEquals( z, x.getBackwardCompatibleWith(), "x should be back comp with z" );
x.removeBackwardCompatibleWith( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) );
+ assertEquals( 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ), "Cardinality should be 1" );
x.removeBackwardCompatibleWith( z );
- assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) );
+ assertEquals( 0, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ), "Cardinality should be 0" );
}
},
new OntTestCase( "Ontology.priorVersion", true, true, false ) {
@@ -131,21 +121,21 @@ public class TestOntology
Ontology z = m.createOntology( NS + "z" );
x.addPriorVersion( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) );
- assertEquals( "x should have prior y", y, x.getPriorVersion() );
+ assertEquals( 1, x.getCardinality( prof.PRIOR_VERSION() ), "Cardinality should be 1" );
+ assertEquals( y, x.getPriorVersion(), "x should have prior y" );
x.addPriorVersion( z );
- assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.PRIOR_VERSION() ) );
+ assertEquals( 2, x.getCardinality( prof.PRIOR_VERSION() ), "Cardinality should be 2" );
iteratorTest( x.listPriorVersion(), new Object[] {y,z} );
x.setPriorVersion( z );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) );
- assertEquals( "x should have prior z", z, x.getPriorVersion() );
+ assertEquals( 1, x.getCardinality( prof.PRIOR_VERSION() ), "Cardinality should be 1" );
+ assertEquals( z, x.getPriorVersion(), "x should have prior z" );
x.removePriorVersion( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) );
+ assertEquals( 1, x.getCardinality( prof.PRIOR_VERSION() ), "Cardinality should be 1" );
x.removePriorVersion( z );
- assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.PRIOR_VERSION() ) );
+ assertEquals( 0, x.getCardinality( prof.PRIOR_VERSION() ), "Cardinality should be 0" );
}
},
new OntTestCase( "Ontology.incompatibleWith", true, true, false ) {
@@ -157,21 +147,21 @@ public class TestOntology
Ontology z = m.createOntology( NS + "z" );
x.addIncompatibleWith( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) );
- assertEquals( "x should be in comp with y", y, x.getIncompatibleWith() );
+ assertEquals( 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ), "Cardinality should be 1" );
+ assertEquals( y, x.getIncompatibleWith(), "x should be in comp with y" );
x.addIncompatibleWith( z );
- assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.INCOMPATIBLE_WITH() ) );
+ assertEquals( 2, x.getCardinality( prof.INCOMPATIBLE_WITH() ), "Cardinality should be 2" );
iteratorTest( x.listIncompatibleWith(), new Object[] {y,z} );
x.setIncompatibleWith( z );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) );
- assertEquals( "x should be incomp with z", z, x.getIncompatibleWith() );
+ assertEquals( 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ), "Cardinality should be 1" );
+ assertEquals( z, x.getIncompatibleWith(), "x should be incomp with z" );
x.removeIncompatibleWith( y );
- assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) );
+ assertEquals( 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ), "Cardinality should be 1" );
x.removeIncompatibleWith( z );
- assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.INCOMPATIBLE_WITH() ) );
+ assertEquals( 0, x.getCardinality( prof.INCOMPATIBLE_WITH() ), "Cardinality should be 0" );
}
},
};
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestProperty.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestProperty.java
index eb9a66c967..dbcae22345 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestProperty.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestProperty.java
@@ -23,20 +23,19 @@
///////////////
package org.apache.jena.ontology.impl;
-
// Imports
///////////////
import java.util.List;
-import junit.framework.TestSuite;
import org.apache.jena.ontology.*;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Property;
-import org.apache.jena.reasoner.test.TestUtil;
import org.apache.jena.util.FileManager;
import org.apache.jena.vocabulary.RDF;
+import static org.junit.jupiter.api.Assertions.*;
+import org.apache.jena.test.JenaTestLib;
/**
* <p>
@@ -44,32 +43,23 @@ import org.apache.jena.vocabulary.RDF;
* </p>
*/
@SuppressWarnings("removal")
-public class TestProperty
- extends OntTestBase
+public class TestProperty extends OntTestBase
{
+
+ static { JenaTestLib.setup(); }
+
// Constants
//////////////////////////////////
// Static variables
//////////////////////////////////
-
-
// Instance variables
//////////////////////////////////
// Constructors
//////////////////////////////////
- static public TestSuite suite() {
- return new TestProperty( "TestProperty" );
- }
-
- public TestProperty( String name ) {
- super( name );
- }
-
-
// External signature methods
//////////////////////////////////
@@ -85,25 +75,25 @@ public class TestProperty
OntProperty r = m.createOntProperty( NS + "r" );
p.addSuperProperty( q );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.SUB_PROPERTY_OF() ) );
- assertEquals( "p have super-prop q", q, p.getSuperProperty() );
+ assertEquals( 1, p.getCardinality( prof.SUB_PROPERTY_OF() ), "Cardinality should be 1" );
+ assertEquals( q, p.getSuperProperty(), "p have super-prop q" );
p.addSuperProperty( r );
- assertEquals( "Cardinality should be 2", 2, p.getCardinality( prof.SUB_PROPERTY_OF() ) );
+ assertEquals( 2, p.getCardinality( prof.SUB_PROPERTY_OF() ), "Cardinality should be 2" );
iteratorTest( p.listSuperProperties(), new Object[] {q, r} );
p.setSuperProperty( r );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.SUB_PROPERTY_OF() ) );
- assertEquals( "p shuold have super-prop r", r, p.getSuperProperty() );
+ assertEquals( 1, p.getCardinality( prof.SUB_PROPERTY_OF() ), "Cardinality should be 1" );
+ assertEquals( r, p.getSuperProperty(), "p shuold have super-prop r" );
p.removeSuperProperty( q );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.SUB_PROPERTY_OF() ) );
+ assertEquals( 1, p.getCardinality( prof.SUB_PROPERTY_OF() ), "Cardinality should be 1" );
p.removeSuperProperty( r );
- assertEquals( "Cardinality should be 0", 0, p.getCardinality( prof.SUB_PROPERTY_OF() ) );
+ assertEquals( 0, p.getCardinality( prof.SUB_PROPERTY_OF() ), "Cardinality should be 0" );
// for symmetry with listSuperClasses(), exclude the reflexive case
List<? extends OntProperty> sp = p.listSuperProperties().toList();
- assertFalse( "super-properties should not include reflexive case", sp.contains( p ) );
+ assertFalse( sp.contains( p ), "super-properties should not include reflexive case" );
}
},
new OntTestCase( "OntProperty.sub-property", true, true, true ) {
@@ -115,23 +105,23 @@ public class TestProperty
OntProperty r = m.createOntProperty( NS + "r" );
p.addSubProperty( q );
- assertEquals( "Cardinality should be 1", 1, q.getCardinality( prof.SUB_PROPERTY_OF() ) );
- assertEquals( "p have sub-prop q", q, p.getSubProperty() );
+ assertEquals( 1, q.getCardinality( prof.SUB_PROPERTY_OF() ), "Cardinality should be 1" );
+ assertEquals( q, p.getSubProperty(), "p have sub-prop q" );
p.addSubProperty( r );
- assertEquals( "Cardinality should be 2", 2, q.getCardinality( prof.SUB_PROPERTY_OF() ) + r.getCardinality( prof.SUB_PROPERTY_OF() ) );
+ assertEquals( 2, q.getCardinality( prof.SUB_PROPERTY_OF() ) + r.getCardinality( prof.SUB_PROPERTY_OF() ), "Cardinality should be 2" );
iteratorTest( p.listSubProperties(), new Object[] {q, r} );
iteratorTest( q.listSuperProperties(), new Object[] {p} );
iteratorTest( r.listSuperProperties(), new Object[] {p} );
p.setSubProperty( r );
- assertEquals( "Cardinality should be 1", 1, q.getCardinality( prof.SUB_PROPERTY_OF() ) + r.getCardinality( prof.SUB_PROPERTY_OF() ) );
- assertEquals( "p should have sub-prop r", r, p.getSubProperty() );
+ assertEquals( 1, q.getCardinality( prof.SUB_PROPERTY_OF() ) + r.getCardinality( prof.SUB_PROPERTY_OF() ), "Cardinality should be 1" );
+ assertEquals( r, p.getSubProperty(), "p should have sub-prop r" );
p.removeSubProperty( q );
- assertTrue( "Should have sub-prop r", p.hasSubProperty( r, false ) );
+ assertTrue( p.hasSubProperty( r, false ), "Should have sub-prop r" );
p.removeSubProperty( r );
- assertTrue( "Should not have sub-prop r", !p.hasSubProperty( r, false ) );
+ assertTrue( !p.hasSubProperty( r, false ), "Should not have sub-prop r" );
}
},
new OntTestCase( "OntProperty.domain", true, true, true ) {
@@ -143,21 +133,21 @@ public class TestProperty
OntResource b = m.getResource( NS + "b" ).as( OntResource.class );
p.addDomain( a );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.DOMAIN() ) );
- assertEquals( "p have domain a", a, p.getDomain() );
+ assertEquals( 1, p.getCardinality( prof.DOMAIN() ), "Cardinality should be 1" );
+ assertEquals( a, p.getDomain(), "p have domain a" );
p.addDomain( b );
- assertEquals( "Cardinality should be 2", 2, p.getCardinality( prof.DOMAIN() ) );
+ assertEquals( 2, p.getCardinality( prof.DOMAIN() ), "Cardinality should be 2" );
iteratorTest( p.listDomain(), new Object[] {a, b} );
p.setDomain( b );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.DOMAIN() ) );
- assertEquals( "p should have domain b", b, p.getDomain() );
+ assertEquals( 1, p.getCardinality( prof.DOMAIN() ), "Cardinality should be 1" );
+ assertEquals( b, p.getDomain(), "p should have domain b" );
p.removeDomain( a );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.DOMAIN() ) );
+ assertEquals( 1, p.getCardinality( prof.DOMAIN() ), "Cardinality should be 1" );
p.removeDomain( b );
- assertEquals( "Cardinality should be 0", 0, p.getCardinality( prof.DOMAIN() ) );
+ assertEquals( 0, p.getCardinality( prof.DOMAIN() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntProperty.range", true, true, true ) {
@@ -169,21 +159,21 @@ public class TestProperty
OntResource b = m.getResource( NS + "b" ).as( OntResource.class );
p.addRange( a );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.RANGE() ) );
- assertEquals( "p have range a", a, p.getRange() );
+ assertEquals( 1, p.getCardinality( prof.RANGE() ), "Cardinality should be 1" );
+ assertEquals( a, p.getRange(), "p have range a" );
p.addRange( b );
- assertEquals( "Cardinality should be 2", 2, p.getCardinality( prof.RANGE() ) );
+ assertEquals( 2, p.getCardinality( prof.RANGE() ), "Cardinality should be 2" );
iteratorTest( p.listRange(), new Object[] {a, b} );
p.setRange( b );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.RANGE() ) );
- assertEquals( "p should have range b", b, p.getRange() );
+ assertEquals( 1, p.getCardinality( prof.RANGE() ), "Cardinality should be 1" );
+ assertEquals( b, p.getRange(), "p should have range b" );
p.removeRange( a );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.RANGE() ) );
+ assertEquals( 1, p.getCardinality( prof.RANGE() ), "Cardinality should be 1" );
p.removeRange( b );
- assertEquals( "Cardinality should be 0", 0, p.getCardinality( prof.RANGE() ) );
+ assertEquals( 0, p.getCardinality( prof.RANGE() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntProperty.equivalentProperty", true, true, false ) {
@@ -195,21 +185,21 @@ public class TestProperty
OntProperty r = m.createObjectProperty( NS + "r" );
p.addEquivalentProperty( q );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.EQUIVALENT_PROPERTY() ) );
- assertEquals( "p have equivalentProperty q", q, p.getEquivalentProperty() );
+ assertEquals( 1, p.getCardinality( prof.EQUIVALENT_PROPERTY() ), "Cardinality should be 1" );
+ assertEquals( q, p.getEquivalentProperty(), "p have equivalentProperty q" );
p.addEquivalentProperty( r );
- assertEquals( "Cardinality should be 2", 2, p.getCardinality( prof.EQUIVALENT_PROPERTY() ) );
+ assertEquals( 2, p.getCardinality( prof.EQUIVALENT_PROPERTY() ), "Cardinality should be 2" );
iteratorTest( p.listEquivalentProperties(), new Object[] {q,r} );
p.setEquivalentProperty( r );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.EQUIVALENT_PROPERTY() ) );
- assertEquals( "p should have equivalentProperty r", r, p.getEquivalentProperty() );
+ assertEquals( 1, p.getCardinality( prof.EQUIVALENT_PROPERTY() ), "Cardinality should be 1" );
+ assertEquals( r, p.getEquivalentProperty(), "p should have equivalentProperty r" );
p.removeEquivalentProperty( q );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.EQUIVALENT_PROPERTY() ) );
+ assertEquals( 1, p.getCardinality( prof.EQUIVALENT_PROPERTY() ), "Cardinality should be 1" );
p.removeEquivalentProperty( r );
- assertEquals( "Cardinality should be 0", 0, p.getCardinality( prof.EQUIVALENT_PROPERTY() ) );
+ assertEquals( 0, p.getCardinality( prof.EQUIVALENT_PROPERTY() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntProperty.inverseOf", true, true, false ) {
@@ -224,23 +214,23 @@ public class TestProperty
assertEquals( null, p.getInverseOf() );
p.addInverseOf( q );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.INVERSE_OF() ) );
- assertEquals( "p should have inverse q", q, p.getInverseOf() );
- assertTrue( "inverse value should be an object property", p.getInverseOf() instanceof ObjectProperty );
- assertTrue( "inverse value should be an object property", q.getInverse() instanceof ObjectProperty );
+ assertEquals( 1, p.getCardinality( prof.INVERSE_OF() ), "Cardinality should be 1" );
+ assertEquals( q, p.getInverseOf(), "p should have inverse q" );
+ assertTrue( p.getInverseOf() instanceof ObjectProperty, "inverse value should be an object property" );
+ assertTrue( q.getInverse() instanceof ObjectProperty, "inverse value should be an object property" );
p.addInverseOf( r );
- assertEquals( "Cardinality should be 2", 2, p.getCardinality( prof.INVERSE_OF() ) );
+ assertEquals( 2, p.getCardinality( prof.INVERSE_OF() ), "Cardinality should be 2" );
iteratorTest( p.listInverseOf(), new Object[] {q,r} );
p.setInverseOf( r );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.INVERSE_OF() ) );
- assertEquals( "p should have inverse r", r, p.getInverseOf() );
+ assertEquals( 1, p.getCardinality( prof.INVERSE_OF() ), "Cardinality should be 1" );
+ assertEquals( r, p.getInverseOf(), "p should have inverse r" );
p.removeInverseProperty( q );
- assertEquals( "Cardinality should be 1", 1, p.getCardinality( prof.INVERSE_OF() ) );
+ assertEquals( 1, p.getCardinality( prof.INVERSE_OF() ), "Cardinality should be 1" );
p.removeInverseProperty( r );
- assertEquals( "Cardinality should be 0", 0, p.getCardinality( prof.INVERSE_OF() ) );
+ assertEquals( 0, p.getCardinality( prof.INVERSE_OF() ), "Cardinality should be 0" );
}
},
new OntTestCase( "OntProperty.subproperty.fromFile", true, true, true ) {
@@ -267,7 +257,7 @@ public class TestProperty
OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class );
OntClass A = m.getResource( NS + "ClassA").as( OntClass.class);
- assertTrue( "p should have domain A", p.hasDomain( A ) );
+ assertTrue( p.hasDomain( A ), "p should have domain A" );
}
},
new OntTestCase( "OntProperty.range.fromFile", true, true, true ) {
@@ -280,7 +270,7 @@ public class TestProperty
OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class );
OntClass B = m.getResource( NS + "ClassB").as( OntClass.class);
- assertTrue( "p should have domain B", p.hasRange( B ) );
+ assertTrue( p.hasRange( B ), "p should have domain B" );
}
},
new OntTestCase( "OntProperty.equivalentProeprty.fromFile", true, true, false ) {
@@ -293,7 +283,7 @@ public class TestProperty
OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class );
OntProperty r = m.getProperty( NS, "r" ).as( OntProperty.class );
- assertTrue( "p should have equiv prop r", p.hasEquivalentProperty( r ) );
+ assertTrue( p.hasEquivalentProperty( r ), "p should have equiv prop r" );
}
},
new OntTestCase( "OntProperty.inversePropertyOf.fromFile", true, true, false ) {
@@ -306,7 +296,7 @@ public class TestProperty
OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class );
OntProperty s = m.getProperty( NS, "s" ).as( OntProperty.class );
- assertTrue( "p should have inv prop s", p.isInverseOf( s ) );
+ assertTrue( p.isInverseOf( s ), "p should have inv prop s" );
}
},
@@ -316,13 +306,13 @@ public class TestProperty
public void ontTest( OntModel m ) {
OntProperty p = m.createDatatypeProperty( NS + "p", true );
- assertTrue( "isFunctionalProperty not correct", p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
+ assertTrue( p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
if (m_owlLang) {
- assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() );
+ assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" );
}
}
},
@@ -331,13 +321,13 @@ public class TestProperty
public void ontTest( OntModel m ) {
OntProperty p = m.createObjectProperty( NS + "p", true );
- assertTrue( "isFunctionalProperty not correct", p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
+ assertTrue( p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
if (m_owlLang) {
- assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() );
+ assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" );
}
}
},
@@ -346,13 +336,13 @@ public class TestProperty
public void ontTest( OntModel m ) {
OntProperty p = m.createDatatypeProperty( NS + "p", false );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
if (m_owlLang) {
- assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() );
+ assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" );
}
}
},
@@ -361,13 +351,13 @@ public class TestProperty
public void ontTest( OntModel m ) {
OntProperty p = m.createObjectProperty( NS + "p", false );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
if (m_owlLang) {
- assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() );
+ assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" );
}
}
},
@@ -376,13 +366,13 @@ public class TestProperty
public void ontTest( OntModel m ) {
OntProperty p = m.createTransitiveProperty( NS + "p" );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() ); // this should be true by entailment, but we have reasoning switched off
- assertTrue( "isTransitiveProperty not correct", p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" ); // this should be true by entailment, but we have reasoning switched off
+ assertTrue( p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
if (m_owlLang) {
- assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() );
+ assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" );
}
}
},
@@ -391,13 +381,13 @@ public class TestProperty
public void ontTest( OntModel m ) {
OntProperty p = m.createInverseFunctionalProperty( NS + "p" );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() ); // this should be true by entailment, but we have reasoning switched off
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", p.isInverseFunctionalProperty() );
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" ); // this should be true by entailment, but we have reasoning switched off
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
if (m_owlLang) {
- assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() );
+ assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" );
}
}
},
@@ -406,13 +396,13 @@ public class TestProperty
public void ontTest( OntModel m ) {
OntProperty p = m.createSymmetricProperty( NS + "p" );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() ); // this should be true by entailment, but we have reasoning switched off
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" ); // this should be true by entailment, but we have reasoning switched off
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
if (m_owlLang) {
- assertTrue( "isSymmetricProperty not correct", p.isSymmetricProperty() );
+ assertTrue( p.isSymmetricProperty(), "isSymmetricProperty not correct" );
}
}
},
@@ -423,21 +413,21 @@ public class TestProperty
pSimple.addProperty( RDF.type, RDF.Property );
OntProperty p = pSimple.as( OntProperty.class );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
p = p.convertToFunctionalProperty();
- assertTrue( "isFunctionalProperty not correct", p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
}
},
new OntTestCase( "OntProperty.convertToDatatypeProperty", true, true, false ) {
@@ -447,21 +437,21 @@ public class TestProperty
pSimple.addProperty( RDF.type, RDF.Property );
OntProperty p = pSimple.as( OntProperty.class );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
p = p.convertToDatatypeProperty();
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
}
},
new OntTestCase( "OntProperty.convertToObjectProperty", true, true, false ) {
@@ -471,21 +461,21 @@ public class TestProperty
pSimple.addProperty( RDF.type, RDF.Property );
OntProperty p = pSimple.as( OntProperty.class );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
p = p.convertToObjectProperty();
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
}
},
new OntTestCase( "OntProperty.convertToTransitiveProperty", true, true, false ) {
@@ -495,21 +485,21 @@ public class TestProperty
pSimple.addProperty( RDF.type, RDF.Property );
OntProperty p = pSimple.as( OntProperty.class );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
p = p.convertToTransitiveProperty();
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
}
},
new OntTestCase( "OntProperty.convertToInverseFunctionalProperty", true, true, false ) {
@@ -519,21 +509,21 @@ public class TestProperty
pSimple.addProperty( RDF.type, RDF.Property );
OntProperty p = pSimple.as( OntProperty.class );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
p = p.convertToInverseFunctionalProperty();
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
}
},
new OntTestCase( "OntProperty.convertToSymmetricProperty", true, true, false ) {
@@ -543,21 +533,21 @@ public class TestProperty
pSimple.addProperty( RDF.type, RDF.Property );
OntProperty p = pSimple.as( OntProperty.class );
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", !p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( !p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
p = p.convertToSymmetricProperty();
- assertTrue( "isFunctionalProperty not correct", !p.isFunctionalProperty() );
- assertTrue( "isDatatypeProperty not correct", !p.isDatatypeProperty() );
- assertTrue( "isObjectProperty not correct", !p.isObjectProperty() );
- assertTrue( "isTransitiveProperty not correct", !p.isTransitiveProperty() );
- assertTrue( "isInverseFunctionalProperty not correct", !p.isInverseFunctionalProperty() );
- if (m_owlLang) {assertTrue( "isSymmetricProperty not correct", p.isSymmetricProperty() ); }
+ assertTrue( !p.isFunctionalProperty(), "isFunctionalProperty not correct" );
+ assertTrue( !p.isDatatypeProperty(), "isDatatypeProperty not correct" );
+ assertTrue( !p.isObjectProperty(), "isObjectProperty not correct" );
+ assertTrue( !p.isTransitiveProperty(), "isTransitiveProperty not correct" );
+ assertTrue( !p.isInverseFunctionalProperty(), "isInverseFunctionalProperty not correct" );
+ if (m_owlLang) {assertTrue( p.isSymmetricProperty(), "isSymmetricProperty not correct" ); }
}
},
new OntTestCase( "ObjectProperty.inverse", true, true, false ) {
@@ -567,12 +557,12 @@ public class TestProperty
ObjectProperty q = m.createObjectProperty( NS + "q" );
ObjectProperty r = m.createObjectProperty( NS + "r" );
- assertFalse( "No inverse of p", p.hasInverse() );
+ assertFalse( p.hasInverse(), "No inverse of p" );
assertEquals( null, p.getInverse() );
q.addInverseOf( p );
- assertTrue( "Inverse of p", p.hasInverse() );
- assertEquals( "inverse of p ", q, p.getInverse() );
+ assertTrue( p.hasInverse(), "Inverse of p" );
+ assertEquals( q, p.getInverse(), "inverse of p " );
r.addInverseOf( p );
iteratorTest( p.listInverse(), new Object[] {q,r} );
@@ -603,7 +593,7 @@ public class TestProperty
FileManager.getInternal().readModelInternal( m0, "file:testing/ontology/testImport9/a.ttl" );
OntProperty p0 = m0.getOntProperty( "http://incubator.apache.org/jena/2011/10/testont/b#propB" );
- TestUtil.assertIteratorLength( p0.listDomain(), 3 );
+ OntTestUtil.assertIteratorLength( p0.listDomain(), 3 );
// repeat test - thus using previously cached model for import
@@ -611,7 +601,7 @@ public class TestProperty
FileManager.getInternal().readModelInternal( m1, "file:testing/ontology/testImport9/a.ttl" );
OntProperty p1 = m1.getOntProperty( "http://incubator.apache.org/jena/2011/10/testont/b#propB" );
- TestUtil.assertIteratorLength( p1.listDomain(), 3 );
+ OntTestUtil.assertIteratorLength( p1.listDomain(), 3 );
}
}
};
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/makers/TS3_ModelMakers.java b/jena-core/src/test/java/org/apache/jena/ontology/makers/TS6_ModelMakers.java
similarity index 74%
rename from jena-core/src/test/java/org/apache/jena/ontology/makers/TS3_ModelMakers.java
rename to jena-core/src/test/java/org/apache/jena/ontology/makers/TS6_ModelMakers.java
index f7fff7be0b..83de579b00 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/makers/TS3_ModelMakers.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/makers/TS6_ModelMakers.java
@@ -21,12 +21,21 @@
package org.apache.jena.ontology.makers;
-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;
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
+import org.apache.jena.test.JenaTestLib;
+
+@Suite
+@SelectClasses({
TestGraphMaker.class,
TestModelMakerImpl.class
})
-public class TS3_ModelMakers {}
+
+public class TS6_ModelMakers {
+ @BeforeSuite
+ public static void beforeSuite() {
+ JenaTestLib.setup();
+ }
+}
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/makers/TestGraphMaker.java b/jena-core/src/test/java/org/apache/jena/ontology/makers/TestGraphMaker.java
index e09295f2b6..8b6e6c7ab9 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/makers/TestGraphMaker.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/makers/TestGraphMaker.java
@@ -21,8 +21,14 @@
package org.apache.jena.ontology.makers;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.util.Set;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.atlas.iterator.Iter;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.GraphTestLib;
@@ -32,14 +38,11 @@ import org.apache.jena.ontology.models.GraphMaker;
import org.apache.jena.ontology.models.SimpleGraphMaker;
import org.apache.jena.shared.AlreadyExistsException;
import org.apache.jena.shared.DoesNotExistException;
-import org.apache.jena.test.JenaTestBase;
import org.apache.jena.test.JenaTestLib;
-public class TestGraphMaker extends JenaTestBase {
+public class TestGraphMaker {
- public TestGraphMaker(String name) {
- super(name);
- }
+ static { JenaTestLib.setup(); }
public GraphMaker getGraphMaker() {
return new SimpleGraphMaker();
@@ -47,12 +50,12 @@ public class TestGraphMaker extends JenaTestBase {
private GraphMaker gf;
- @Override
+ @BeforeEach
public void setUp() {
gf = getGraphMaker();
}
- @Override
+ @AfterEach
public void tearDown() {
gf.close();
}
@@ -61,17 +64,20 @@ public class TestGraphMaker extends JenaTestBase {
* A trivial test that getGraph delivers a proper graph, not cheating with null,
* and that getGraph() "always" delivers the same Graph.
*/
+ @Test
public void testGetGraph() {
Graph g1 = gf.getGraph();
- assertFalse("should deliver a Graph", g1 == null);
+ assertFalse(g1 == null, "should deliver a Graph");
assertSame(g1, gf.getGraph());
g1.close();
}
+ @Test
public void testCreateGraph() {
JenaTestLib.assertDiffer("each created graph must differ", gf.createGraph(), gf.createGraph());
}
+ @Test
public void testAnyName() {
gf.createGraph("plain").close();
gf.createGraph("with.dot").close();
@@ -81,42 +87,44 @@ public class TestGraphMaker extends JenaTestBase {
/**
* Test that we can't create a graph with the same name twice.
*/
+ @Test
public void testCannotCreateTwice() {
String name = jName("bonsai");
gf.createGraph(name, true);
- try {
- gf.createGraph(name, true);
- fail("should not be able to create " + name + " twice");
- } catch (AlreadyExistsException e) {}
+ assertThrows(AlreadyExistsException.class,
+ () -> gf.createGraph(name, true),
+ "should not be able to create " + name + " twice");
}
private String jName(String name) {
return "jena-test-AbstractTestGraphMaker-" + name;
}
+ @Test
public void testCanCreateTwice() {
String name = jName("bridge");
Graph g1 = gf.createGraph(name, true);
Graph g2 = gf.createGraph(name, false);
- assertTrue("graphs should be the same", sameGraph(g1, g2));
+ assertTrue(sameGraph(g1, g2), "graphs should be the same");
Graph g3 = gf.createGraph(name);
- assertTrue("graphs should be the same", sameGraph(g1, g3));
+ assertTrue(sameGraph(g1, g3), "graphs should be the same");
}
/**
* Test that we cannot open a graph that does not exist.
*/
+ @Test
public void testCannotOpenUncreated() {
String name = jName("noSuchGraph");
- try {
- gf.openGraph(name, true);
- fail(name + " should not exist");
- } catch (DoesNotExistException e) {}
+ assertThrows(DoesNotExistException.class,
+ () -> gf.openGraph(name, true),
+ name + " should not exist");
}
/**
* Test that we *can* open a graph that hasn't been created
*/
+ @Test
public void testCanOpenUncreated() {
String name = jName("willBeCreated");
Graph g1 = gf.openGraph(name);
@@ -128,14 +136,14 @@ public class TestGraphMaker extends JenaTestBase {
* Utility - test that a graph with the given name exists.
*/
private void testExists(String name) {
- assertTrue(name + " should exist", gf.hasGraph(name));
+ assertTrue(gf.hasGraph(name), name + " should exist");
}
/**
* Utility - test that no graph with the given name exists.
*/
private void testDoesNotExist(String name) {
- assertFalse(name + " should exist", gf.hasGraph(name));
+ assertFalse(gf.hasGraph(name), name + " should exist");
}
/**
@@ -143,14 +151,15 @@ public class TestGraphMaker extends JenaTestBase {
* graphs are "the same" here: we have a temporary work-around but it is not
* sound.
*/
+ @Test
public void testCanFindCreatedGraph() {
String alpha = jName("alpha"), beta = jName("beta");
Graph g1 = gf.createGraph(alpha, true);
Graph h1 = gf.createGraph(beta, true);
Graph g2 = gf.openGraph(alpha, true);
Graph h2 = gf.openGraph(beta, true);
- assertTrue("should find alpha", sameGraph(g1, g2));
- assertTrue("should find beta", sameGraph(h1, h2));
+ assertTrue(sameGraph(g1, g2), "should find alpha");
+ assertTrue(sameGraph(h1, h2), "should find beta");
}
/**
@@ -169,6 +178,7 @@ public class TestGraphMaker extends JenaTestBase {
* Test that we can remove a graph from the factory without disturbing another
* graph's binding.
*/
+ @Test
public void testCanRemoveGraph() {
String alpha = jName("bingo"), beta = jName("brillo");
gf.createGraph(alpha, true);
@@ -180,30 +190,32 @@ public class TestGraphMaker extends JenaTestBase {
testDoesNotExist(alpha);
}
+ @Test
public void testHasnt() {
- assertFalse("no such graph", gf.hasGraph("john"));
- assertFalse("no such graph", gf.hasGraph("paul"));
- assertFalse("no such graph", gf.hasGraph("george"));
+ assertFalse(gf.hasGraph("john"), "no such graph");
+ assertFalse(gf.hasGraph("paul"), "no such graph");
+ assertFalse(gf.hasGraph("george"), "no such graph");
/* */
gf.createGraph("john", true);
- assertTrue("john now exists", gf.hasGraph("john"));
- assertFalse("no such graph", gf.hasGraph("paul"));
- assertFalse("no such graph", gf.hasGraph("george"));
+ assertTrue(gf.hasGraph("john"), "john now exists");
+ assertFalse(gf.hasGraph("paul"), "no such graph");
+ assertFalse(gf.hasGraph("george"), "no such graph");
/* */
gf.createGraph("paul", true);
- assertTrue("john still exists", gf.hasGraph("john"));
- assertTrue("paul now exists", gf.hasGraph("paul"));
- assertFalse("no such graph", gf.hasGraph("george"));
+ assertTrue(gf.hasGraph("john"), "john still exists");
+ assertTrue(gf.hasGraph("paul"), "paul now exists");
+ assertFalse(gf.hasGraph("george"), "no such graph");
/* */
gf.removeGraph("john");
- assertFalse("john has been removed", gf.hasGraph("john"));
- assertTrue("paul still exists", gf.hasGraph("paul"));
- assertFalse("no such graph", gf.hasGraph("george"));
+ assertFalse(gf.hasGraph("john"), "john has been removed");
+ assertTrue(gf.hasGraph("paul"), "paul still exists");
+ assertFalse(gf.hasGraph("george"), "no such graph");
}
// Up to Jena5, the graph created did open/close counting.
// But only some graph implements provided this.
+ @Test
public void testCarefulClose() {
Graph x = gf.createGraph("x");
Graph y = gf.openGraph("x");
@@ -216,6 +228,7 @@ public class TestGraphMaker extends JenaTestBase {
/**
* Test that a maker with no graphs lists no names.
*/
+ @Test
public void testListNoGraphs() {
Set<String> s = gf.listGraphs().toSet();
if ( s.size() > 0 )
@@ -228,6 +241,7 @@ public class TestGraphMaker extends JenaTestBase {
* the spelling that goes in is the one that comes out [should really be in a
* separate test].
*/
+ @Test
public void testListThreeGraphs() {
String x = "x", y = "y/sub", z = "z:boo";
Graph X = gf.createGraph(x);
@@ -244,6 +258,7 @@ public class TestGraphMaker extends JenaTestBase {
* Test that a maker with some things put in and then some removed gets the right
* things listed.
*/
+ @Test
public void testListAfterDelete() {
String x = "x_y", y = "y//zub", z = "a:b/c";
Graph X = gf.createGraph(x);
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/makers/TestModelMakerImpl.java b/jena-core/src/test/java/org/apache/jena/ontology/makers/TestModelMakerImpl.java
index 6cadb9c282..76bc9ea3cf 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/makers/TestModelMakerImpl.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/makers/TestModelMakerImpl.java
@@ -21,10 +21,14 @@
package org.apache.jena.ontology.makers;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.GraphTestLib;
import org.apache.jena.graph.Node;
@@ -35,13 +39,14 @@ import org.apache.jena.rdf.model.Model;
import org.apache.jena.test.JenaTestLib;
import org.apache.jena.util.iterator.ExtendedIterator;
import org.apache.jena.util.iterator.NullIterator;
-import org.junit.Assert;
/**
* Test ModelMakerImpl using a mock GraphMaker.
*/
-public class TestModelMakerImpl extends TestCase
+public class TestModelMakerImpl
{
+ static { JenaTestLib.setup(); }
+
static class MockGraphMaker implements GraphMaker
{
List<String> history = new ArrayList<>();
@@ -150,14 +155,9 @@ public class TestModelMakerImpl extends TestCase
private Graph graph;
private GraphMaker graphMaker;
- public TestModelMakerImpl( final String name )
- {
- super(name);
- }
-
private void checkHistory( final List<String> expected )
{
- Assert.assertEquals(expected, history());
+ assertEquals(expected, history());
}
private List<String> history()
@@ -165,7 +165,7 @@ public class TestModelMakerImpl extends TestCase
return ((MockGraphMaker) maker.getGraphMaker()).history;
}
- @Override
+ @BeforeEach
public void setUp()
{
graph = GraphTestLib.graphWith("");
@@ -173,77 +173,89 @@ public class TestModelMakerImpl extends TestCase
maker = new ModelMakerImpl(graphMaker);
}
+ @Test
public void testClose()
{
maker.close();
checkHistory(JenaTestLib.listOfOne("close()"));
}
+ @Test
public void testCreateDefaultModel()
{
maker.createDefaultModel();
checkHistory(JenaTestLib.listOfOne("get()"));
}
+ @Test
public void testCreateFalse()
{
final Model m = maker.createModel("leaf", false);
checkHistory(JenaTestLib.listOfOne("create(leaf,false)"));
- Assert.assertTrue(m.getGraph() == graph);
+ assertTrue(m.getGraph() == graph);
}
+ @Test
public void testCreateFreshModel()
{
maker.createFreshModel();
checkHistory(JenaTestLib.listOfOne("create()"));
}
+ @Test
public void testCreateNamed()
{
final Model m = maker.createModel("petal");
checkHistory(JenaTestLib.listOfOne("create(petal,false)"));
- Assert.assertTrue(m.getGraph() == graph);
+ assertTrue(m.getGraph() == graph);
}
+ @Test
public void testCreateTrue()
{
final Model m = maker.createModel("stem", true);
checkHistory(JenaTestLib.listOfOne("create(stem,true)"));
- Assert.assertTrue(m.getGraph() == graph);
+ assertTrue(m.getGraph() == graph);
}
+ @Test
public void testGetGraphMaker()
{
- Assert.assertTrue(maker.getGraphMaker() == graphMaker);
+ assertTrue(maker.getGraphMaker() == graphMaker);
}
+ @Test
public void testListGraphs()
{
maker.listModels().close();
checkHistory(JenaTestLib.listOfOne("listModels()"));
}
+ @Test
public void testOpen()
{
final Model m = maker.openModel("trunk");
checkHistory(JenaTestLib.listOfOne("open(trunk,false)"));
- Assert.assertTrue(m.getGraph() == graph);
+ assertTrue(m.getGraph() == graph);
}
+ @Test
public void testOpenFalse()
{
final Model m = maker.openModel("branch", false);
checkHistory(JenaTestLib.listOfOne("open(branch,false)"));
- Assert.assertTrue(m.getGraph() == graph);
+ assertTrue(m.getGraph() == graph);
}
+ @Test
public void testOpenTrue()
{
final Model m = maker.openModel("bark", true);
checkHistory(JenaTestLib.listOfOne("open(bark,true)"));
- Assert.assertTrue(m.getGraph() == graph);
+ assertTrue(m.getGraph() == graph);
}
+ @Test
public void testRemove()
{
maker.removeModel("London");
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 ec17a00e80..b323842a67 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
@@ -73,8 +73,8 @@ public class JenaCoreTestAll_JU4 extends TestCase {
addTest(ts, "Reasoners", adaptJUnit4(org.apache.jena.reasoner.test.TS3_reasoners.class));
addTest(ts, "RuleReasoners", adaptJUnit4(org.apache.jena.reasoner.rulesys.TS3_RuleReasoners.class));
- addTest(ts, "Ontology ModelMaker", adaptJUnit4(org.apache.jena.ontology.makers.TS3_ModelMakers.class));
- addTest(ts, "Ontology", adaptJUnit4(org.apache.jena.ontology.impl.TS3_ont.class));
+//JU6 addTest(ts, "Ontology ModelMaker", adaptJUnit4(org.apache.jena.ontology.makers.TS3_ModelMakers.class));
+//JU6 addTest(ts, "Ontology", adaptJUnit4(org.apache.jena.ontology.impl.TS3_ont.class));
// Local TTL parser for tests - not fully compliant.
//JU6 addTest(ts, "Turtle", adaptJUnit4(org.apache.jena.ttl_test.test_turtle.TS_TestTurtle.class));
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 408810bcf5..864446eae0 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
@@ -31,6 +31,8 @@ import org.apache.jena.irix.TS6_IRIx2;
import org.apache.jena.langtagx.TS6_LangTagX;
import org.apache.jena.mem.TS6_GraphMem;
import org.apache.jena.memvalue.TS6_GraphMemValue;
+import org.apache.jena.ontology.impl.TS6_ont;
+import org.apache.jena.ontology.makers.TS6_ModelMakers;
import org.apache.jena.rdfxml.xmloutput.TS6_xmloutput;
import org.apache.jena.shared.TS6_SharedPackage;
import org.apache.jena.util.TS6_coreutil;
@@ -58,6 +60,9 @@ import org.apache.jena.vocabulary.TS6_Vocabularies;
TS6_Vocabularies.class,
TS6_SharedPackage.class,
+ TS6_ModelMakers.class,
+ TS6_ont.class,
+
TS6_TestTurtle.class,
})