Repository: jena
Updated Branches:
  refs/heads/JENA-380 e2f4d02d1 -> ac43ab9da


JENA-380 Migrate more reasoner tests to JUnit4


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ac43ab9d
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ac43ab9d
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ac43ab9d

Branch: refs/heads/JENA-380
Commit: ac43ab9da88b558da4f40b3b6024f9f636311aae
Parents: e2f4d02
Author: Bruno P. Kinoshita <[email protected]>
Authored: Tue Apr 21 20:27:16 2015 +1200
Committer: Bruno P. Kinoshita <[email protected]>
Committed: Tue Apr 21 20:27:16 2015 +1200

----------------------------------------------------------------------
 .../hp/hpl/jena/graph/test/GraphTestBase.java   |  6 ++++--
 .../hpl/jena/rdf/model/test/ModelTestBase.java  |  5 -----
 .../jena/reasoner/test/ReasonerTestBase.java    |  2 --
 .../hpl/jena/reasoner/test/ReasonerTester.java  | 22 +++++++++++++-------
 .../jena/reasoner/test/TestRDFSReasoners.java   | 16 ++++++--------
 .../jena/reasoner/test/WGReasonerTester.java    | 21 +++++++------------
 .../java/com/hp/hpl/jena/test/JenaTestBase.java |  7 +++----
 7 files changed, 35 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/ac43ab9d/jena-core/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java
----------------------------------------------------------------------
diff --git 
a/jena-core/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java 
b/jena-core/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java
index 26be7e8..ec44be7 100644
--- a/jena-core/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java
+++ b/jena-core/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java
@@ -22,6 +22,10 @@ package com.hp.hpl.jena.graph.test;
     An extension of JenaTestBase (which see) with Graph-specific methods.
 */
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.FileNotFoundException;
 import java.lang.reflect.Constructor ;
 import java.net.URISyntaxException;
@@ -63,8 +67,6 @@ public class GraphTestBase extends JenaTestBase
                        throw new RuntimeException( e );
                }
        }
-    public GraphTestBase( String name )
-       { super( name ); }
        
     /**
         Answer a Node as described by <code>x</code>; a shorthand for

http://git-wip-us.apache.org/repos/asf/jena/blob/ac43ab9d/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java
----------------------------------------------------------------------
diff --git 
a/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java 
b/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java
index b7380ff..2f02dba 100644
--- a/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java
+++ b/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java
@@ -269,9 +269,4 @@ public class ModelTestBase extends GraphTestBase
                return sl.toArray(new Statement[sl.size()]);
        }
 
-       public ModelTestBase( final String name )
-       {
-               super(name);
-       }
-
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/ac43ab9d/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTestBase.java
----------------------------------------------------------------------
diff --git 
a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTestBase.java 
b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTestBase.java
index 682bb5e..8f49580 100644
--- 
a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTestBase.java
+++ 
b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTestBase.java
@@ -27,8 +27,6 @@ import com.hp.hpl.jena.rdf.model.test.*;
 
 public class ReasonerTestBase extends ModelTestBase 
     {
-       public ReasonerTestBase( String name ) 
-        { super( name ); }
               
     /**
         Answer a new resource guaranteed to be in a different model from any 
other

http://git-wip-us.apache.org/repos/asf/jena/blob/ac43ab9d/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTester.java
----------------------------------------------------------------------
diff --git 
a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTester.java 
b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTester.java
index 0e3b7b8..16830a1 100644
--- a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTester.java
+++ b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/ReasonerTester.java
@@ -189,14 +189,15 @@ public class ReasonerTester {
      * Run all the tests in the manifest
      * @param reasonerF the factory for the reasoner to be tested
      * @param configuration optional configuration information
+     * @param assertion whether to run assertion or not
      * @return true if all the tests pass
      * @throws IOException if one of the test files can't be found
      * @throws JenaException if the test can't be found or fails internally
      */
-    public boolean runTests(ReasonerFactory reasonerF, Resource configuration) 
throws IOException {
+    public boolean runTests(ReasonerFactory reasonerF, Resource configuration, 
boolean assertion) throws IOException {
         for ( String test : listTests() )
         {
-            if ( !runTest( test, reasonerF, configuration ) )
+            if ( !runTest( test, reasonerF, configuration, assertion ) )
             {
                 return false;
             }
@@ -207,14 +208,15 @@ public class ReasonerTester {
     /**
      * Run all the tests in the manifest
      * @param reasoner the reasoner to be tested
+     * @param assertion whether to run assertion or not
      * @return true if all the tests pass
      * @throws IOException if one of the test files can't be found
      * @throws JenaException if the test can't be found or fails internally
      */
-    public boolean runTests(Reasoner reasoner) throws IOException {
+    public boolean runTests(Reasoner reasoner, boolean assertion) throws 
IOException {
         for ( String test : listTests() )
         {
-            if ( !runTest( test, reasoner ) )
+            if ( !runTest( test, reasoner, assertion ) )
             {
                 return false;
             }
@@ -240,24 +242,26 @@ public class ReasonerTester {
      * @param uri the uri of the test, as defined in the manifest file
      * @param reasonerF the factory for the reasoner to be tested
      * @param configuration optional configuration information
+     * @param assertion whether to run assertion or not
      * @return true if the test passes
      * @throws IOException if one of the test files can't be found
      * @throws JenaException if the test can't be found or fails internally
      */
-    public boolean runTest(String uri, ReasonerFactory reasonerF, Resource 
configuration) throws IOException {
+    public boolean runTest(String uri, ReasonerFactory reasonerF, Resource 
configuration, boolean assertion) throws IOException {
         Reasoner reasoner = reasonerF.create(configuration);
-        return runTest(uri, reasoner);
+        return runTest(uri, reasoner, assertion);
     }
     
     /**
      * Run a single designated test.
      * @param uri the uri of the test, as defined in the manifest file
      * @param reasoner the reasoner to be tested
+     * @param assertion whether to run assertion or not
      * @return true if the test passes
      * @throws IOException if one of the test files can't be found
      * @throws JenaException if the test can't be found or fails internally
      */
-    public boolean runTest(String uri, Reasoner reasoner) throws IOException {
+    public boolean runTest(String uri, Reasoner reasoner, boolean assertion) 
throws IOException {
         // Find the specification for the named test
         Resource test = testManifest.getResource(uri);
         if (!test.hasProperty(RDF.type, testClass)) {
@@ -315,7 +319,9 @@ public class ReasonerTester {
         }
         */
         // ... end of debugging hack
-        assertTrue(description, correct);
+        if (assertion) {
+            assertTrue(description, correct);
+        }
         return correct;
     }
     

http://git-wip-us.apache.org/repos/asf/jena/blob/ac43ab9d/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestRDFSReasoners.java
----------------------------------------------------------------------
diff --git 
a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestRDFSReasoners.java 
b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestRDFSReasoners.java
index cd31c22..55e39c3 100644
--- 
a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestRDFSReasoners.java
+++ 
b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/TestRDFSReasoners.java
@@ -32,12 +32,15 @@ import java.util.Iterator;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.junit.runner.RunWith;
+import org.junit.runners.AllTests;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Test the set of admissable RDFS reasoners.
  */
+@RunWith(AllTests.class)
 public class TestRDFSReasoners extends ReasonerTestBase {
     
     /** Base URI for the test names */
@@ -46,13 +49,6 @@ public class TestRDFSReasoners extends ReasonerTestBase {
     protected static Logger logger = 
LoggerFactory.getLogger(TestReasoners.class);
 
     /**
-     * Boilerplate for junit
-     */ 
-    public TestRDFSReasoners( String name ) {
-        super( name ); 
-    }
-    
-    /**
      * Boilerplate for junit.
      * This is its own test suite
      */
@@ -168,7 +164,7 @@ public class TestRDFSReasoners extends ReasonerTestBase {
          */
         @Override
         public void runTest() throws IOException {
-            tester.runTest(test, reasoner, this);
+            tester.runTest(test, reasoner, true);
         }
 
     }
@@ -206,7 +202,7 @@ public class TestRDFSReasoners extends ReasonerTestBase {
          */
         @Override
         public void runTest() throws IOException {
-            tester.runTest(test, reasonerFactory, this, config);
+            tester.runTest(test, reasonerFactory, config);
         }
 
     }
@@ -246,7 +242,7 @@ public class TestRDFSReasoners extends ReasonerTestBase {
             }
             configuration.addProperty(ReasonerVocabulary.PROPenableCMPScan, 
"false");
             assertTrue("scanproperties off", 
-                        !tester.runTest(NAMESPACE + "rdfs/test17", 
reasonerFactory, null, configuration));
+                        !tester.runTest(NAMESPACE + "rdfs/test17", 
reasonerFactory, configuration, false));
         
             // Check capabilities description
             Reasoner r = reasonerFactory.create(null);

http://git-wip-us.apache.org/repos/asf/jena/blob/ac43ab9d/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/WGReasonerTester.java
----------------------------------------------------------------------
diff --git 
a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/WGReasonerTester.java 
b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/WGReasonerTester.java
index 8e60665..3964f67 100644
--- 
a/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/WGReasonerTester.java
+++ 
b/jena-core/src/test/java/com/hp/hpl/jena/reasoner/test/WGReasonerTester.java
@@ -18,6 +18,8 @@
 
 package com.hp.hpl.jena.reasoner.test;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.BufferedInputStream ;
 import java.io.FileInputStream ;
 import java.io.IOException ;
@@ -26,8 +28,6 @@ import java.net.URL ;
 import java.util.ArrayList ;
 import java.util.List ;
 
-import junit.framework.TestCase ;
-import org.junit.Assert ;
 import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
 
@@ -203,16 +203,15 @@ public class WGReasonerTester {
     /**
      * Run all the tests in the manifest
      * @param reasonerF the factory for the reasoner to be tested
-     * @param testcase the JUnit test case which is requesting this test
      * @param configuration optional configuration information
      * @return true if all the tests pass
      * @throws IOException if one of the test files can't be found
      * @throws JenaException if the test can't be found or fails internally
      */
-    public boolean runTests(ReasonerFactory reasonerF, TestCase testcase, 
Resource configuration) throws IOException {
+    public boolean runTests(ReasonerFactory reasonerF, Resource configuration) 
throws IOException {
         for ( String test : listTests() )
         {
-            if ( !runTest( test, reasonerF, testcase, configuration ) )
+            if ( !runTest( test, reasonerF, configuration ) )
             {
                 return false;
             }
@@ -248,14 +247,13 @@ public class WGReasonerTester {
      * Run a single designated test.
      * @param uri the uri of the test, as defined in the manifest file
      * @param reasonerF the factory for the reasoner to be tested
-     * @param testcase the JUnit test case which is requesting this test
      * @param configuration optional configuration information
      * @return true if the test passes
      * @throws IOException if one of the test files can't be found
      * @throws JenaException if the test can't be found or fails internally
      */
-    public boolean runTest(String uri, ReasonerFactory reasonerF, TestCase 
testcase, Resource configuration) throws IOException {
-        return runTestDetailedResponse(uri,reasonerF,testcase,configuration) 
!= FAIL;
+    public boolean runTest(String uri, ReasonerFactory reasonerF, Resource 
configuration) throws IOException {
+        return runTestDetailedResponse(uri,reasonerF,configuration) != FAIL;
     }
     static final public int FAIL = -1;
     static final public int NOT_APPLICABLE = 0;
@@ -266,7 +264,6 @@ public class WGReasonerTester {
                 * Run a single designated test.
                 * @param uri the uri of the test, as defined in the manifest 
file
                 * @param reasonerF the factory for the reasoner to be tested
-                * @param testcase the JUnit test case which is requesting this 
test
                 * @param configuration optional configuration information
                 * @return true if the test passes
                 * @throws IOException if one of the test files can't be found
@@ -274,7 +271,7 @@ public class WGReasonerTester {
                 */
     
        
-          public int runTestDetailedResponse(String uri, ReasonerFactory 
reasonerF, TestCase testcase, Resource configuration) throws IOException {
+          public int runTestDetailedResponse(String uri, ReasonerFactory 
reasonerF, Resource configuration) throws IOException {
     
         // Find the specification for the named test
         Resource test = testManifest.getResource(uri);
@@ -373,7 +370,6 @@ public class WGReasonerTester {
         }
         
         // Signal the results        
-        if (testcase != null) {
 //            if ( !correct )
 //            {
 //                boolean b = testConclusions(conclusions.getGraph(), 
result.getGraph());
@@ -382,8 +378,7 @@ public class WGReasonerTester {
 //                System.out.println("**** expected") ;
 //                conclusions.write(System.out, "TTL") ;
 //            }
-            Assert.assertTrue("Test: " + test + "\n" +  description, correct);
-        }
+        assertTrue("Test: " + test + "\n" +  description, correct);
         return correct?goodResult:FAIL;
     }
     

http://git-wip-us.apache.org/repos/asf/jena/blob/ac43ab9d/jena-core/src/test/java/com/hp/hpl/jena/test/JenaTestBase.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/com/hp/hpl/jena/test/JenaTestBase.java 
b/jena-core/src/test/java/com/hp/hpl/jena/test/JenaTestBase.java
index 3d455bc..9df0c24 100644
--- a/jena-core/src/test/java/com/hp/hpl/jena/test/JenaTestBase.java
+++ b/jena-core/src/test/java/com/hp/hpl/jena/test/JenaTestBase.java
@@ -18,8 +18,9 @@
 
 package com.hp.hpl.jena.test;
 
+import static org.junit.Assert.fail;
+
 import java.lang.reflect.*;
-import junit.framework.*;
 import java.util.*;
 
 import com.hp.hpl.jena.util.CollectionFactory;
@@ -29,10 +30,8 @@ import com.hp.hpl.jena.util.iterator.*;
     A basis for Jena test cases which provides assertFalse and assertDiffer.
     Often the logic of the names is clearer than using a negation.
 */
-public class JenaTestBase extends TestCase
+public class JenaTestBase 
     {
-    public JenaTestBase( String name )
-        { super( name ); }
         
     /**
         Does what it says on the can.

Reply via email to