Repository: jena Updated Branches: refs/heads/JENA-380 11d2d0e36 -> be0e6f278
JENA-380 Migrate TestSafeModel and create its test suite Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/be0e6f27 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/be0e6f27 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/be0e6f27 Branch: refs/heads/JENA-380 Commit: be0e6f278ee81db7af8932dd140cd87684dc550e Parents: 11d2d0e Author: Bruno P. Kinoshita <[email protected]> Authored: Tue Apr 21 17:46:28 2015 +1200 Committer: Bruno P. Kinoshita <[email protected]> Committed: Tue Apr 21 17:46:28 2015 +1200 ---------------------------------------------------------------------- .../hp/hpl/jena/reasoner/test/TS_SafeModel.java | 28 ++++++++++++++++++ .../hpl/jena/reasoner/test/TestSafeModel.java | 30 ++++++-------------- .../com/hp/hpl/jena/reasoner/test/TestUtil.java | 2 ++ 3 files changed, 38 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/be0e6f27/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TS_SafeModel.java ---------------------------------------------------------------------- diff --git a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TS_SafeModel.java b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TS_SafeModel.java new file mode 100644 index 0000000..e31f23c --- /dev/null +++ b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TS_SafeModel.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.hp.hpl.jena.reasoner.test; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses(TestSafeModel.class) +public class TS_SafeModel { + +} http://git-wip-us.apache.org/repos/asf/jena/blob/be0e6f27/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestSafeModel.java ---------------------------------------------------------------------- diff --git a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestSafeModel.java b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestSafeModel.java index 1501fa9..7d012aa 100644 --- a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestSafeModel.java +++ b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestSafeModel.java @@ -20,6 +20,8 @@ package com.hp.hpl.jena.reasoner.test; import java.util.List; +import org.junit.Test; + import com.hp.hpl.jena.graph.Graph; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Triple; @@ -35,36 +37,20 @@ import com.hp.hpl.jena.reasoner.rulesys.Rule; import com.hp.hpl.jena.reasoner.rulesys.impl.SafeGraph; import static com.hp.hpl.jena.util.PrintUtil.egNS; - -import junit.framework.TestCase; -import junit.framework.TestSuite; +import static org.junit.Assert.assertTrue; /** * Some Jena reasoners support extended graphs which relax the RDF syntactic constraints * against literals in the subject position. By default getDeductionsModel in those * cases will return a SafeModel */ -public class TestSafeModel extends TestCase { - - /** - * Boilerplate for junit - */ - public TestSafeModel( String name ) { - super( name ); - } - - /** - * Boilerplate for junit. - * This is its own test suite - */ - public static TestSuite suite() { - return new TestSuite(TestSafeModel.class); - } +public class TestSafeModel { /** * Create a generalized model via inference and check it is * safe but unwrappable */ + @Test public void testBasics() { Model base = ModelFactory.createDefaultModel(); Resource r = base.createResource(egNS + "r"); @@ -77,17 +63,17 @@ public class TestSafeModel extends TestCase { List<Rule> rules = Rule.parseRules("(?r eg:p ?v) -> (?v eg:q ?r)."); GenericRuleReasoner reasoner = new GenericRuleReasoner(rules); InfModel inf = ModelFactory.createInfModel(reasoner, base); - TestUtil.assertIteratorValues(this, inf.listStatements(), new Statement[]{asserted}); + TestUtil.assertIteratorValues(TestSafeModel.class, "TestSafeModel", inf.listStatements(), new Statement[]{asserted}); Model deductions = inf.getDeductionsModel(); - TestUtil.assertIteratorValues(this, deductions.listStatements(), new Statement[]{}); + TestUtil.assertIteratorValues(TestSafeModel.class, "TestSafeModel", deductions.listStatements(), new Statement[]{}); Graph safeGraph = deductions.getGraph(); assertTrue(safeGraph instanceof SafeGraph); Graph rawGraph = ((SafeGraph)safeGraph).getRawGraph(); Triple deduction = new Triple(l.asNode(), q.asNode(), r.asNode()); - TestUtil.assertIteratorValues(this, + TestUtil.assertIteratorValues(TestSafeModel.class, "TestSafeModel", rawGraph.find(Node.ANY, Node.ANY, Node.ANY), new Triple[]{deduction}); } http://git-wip-us.apache.org/repos/asf/jena/blob/be0e6f27/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestUtil.java ---------------------------------------------------------------------- diff --git a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestUtil.java b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestUtil.java index cd08396..7d05bd3 100644 --- a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestUtil.java +++ b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestUtil.java @@ -30,6 +30,8 @@ import com.hp.hpl.jena.rdf.model.Statement ; /** * Collection of utilities to assist with unit testing. + * + * TODO: remove JUnit 3 imports once JENA-380 is solved */ public class TestUtil {
