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 2013/01/14 23:38:37 UTC
svn commit: r1433184 [1/9] - in /jena/trunk/jena-core/src:
main/java/com/hp/hpl/jena/graph/compose/
test/java/com/hp/hpl/jena/graph/compose/test/
test/java/com/hp/hpl/jena/graph/test/ test/java/com/hp/hpl/jena/mem/test/
test/java/com/hp/hpl/jena/rdf/ar...
Author: andy
Date: Mon Jan 14 22:38:35 2013
New Revision: 1433184
URL: http://svn.apache.org/viewvc?rev=1433184&view=rev
Log:
JENA-370 : Major reorganisation of the test suite.
Added:
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractContainerMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractModelTestBase.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestPackage.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestAddAndContains.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestAddModel.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestAltMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestBagMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestConcurrencyNesting.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestConcurrencyParallel.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContainerConstructors.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestCopyInOutOfModel.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestGet.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestHiddenStatements.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestIsomorphic.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestListSubjects.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestLiterals.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModel.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelSetOperations.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjectOfProperties.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjects.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestReaders.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestResourceMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestResources.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestSelectorUse.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestSeqMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestStatementCreation.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestStatementMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/helpers/
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/helpers/ModelHelper.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/helpers/RecordingModelListener.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/helpers/TestingModelFactory.java
jena/trunk/jena-core/src/test/resources/TestReaders.nt
jena/trunk/jena-core/src/test/resources/TestReaders.rdf
Removed:
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/mem/test/TestSuiteRegression.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/DiHyperCube.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/GetModel.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/HyperCube.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/MegaTestSuite.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegression.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionAddAndContains.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionAddModel.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionAltMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionBagMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionBase.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionContainerMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionContainers.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionGet.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionListSubjects.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionLiterals.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionObjects.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionResourceMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionResources.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionSelector.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionSeq.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionSeqMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionSet.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionStatementMethods.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/NewRegressionStatements.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/Regression.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/ResourceReader.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/testMatch.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/testNTripleReader.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/testReaderInterface.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/shared/RandomizedTestSuiteRegression.java
Modified:
jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/Dyadic.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDelta.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDifference.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDisjointUnion.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDyadic.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestIntersection.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestPackage.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestUnion.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestGraph.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/SAX2RDFTest.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestAnonID.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContainers.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContains.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestIterators.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestList.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestListStatements.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestListSubjectsEtc.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestLiteralImpl.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestLiteralsInModel.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelBulkUpdate.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelEvents.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelExtract.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelFactory.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPolymorphism.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPrefixMapping.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelRead.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestNamespace.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPropertyImpl.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRDFNodes.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRDFWriterMap.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestReaderEvents.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestReifiedStatements.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRemoveBug.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRemoveSPO.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestResourceFactory.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestResourceImpl.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestSelectors.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestSimpleListStatements.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestSimpleSelector.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestStatements.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/regression/TestCaseBasic.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/shared/TestSharedPackage.java
jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/Dyadic.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/Dyadic.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/Dyadic.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/Dyadic.java Mon Jan 14 22:38:35 2013
@@ -49,6 +49,7 @@ public abstract class Dyadic extends Com
{
L.close();
R.close();
+ this.closed = true;
}
/**
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDelta.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDelta.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDelta.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDelta.java Mon Jan 14 22:38:35 2013
@@ -22,10 +22,11 @@ import junit.framework.TestSuite ;
import com.hp.hpl.jena.graph.Graph ;
import com.hp.hpl.jena.graph.compose.Delta ;
+import com.hp.hpl.jena.graph.compose.Union;
import com.hp.hpl.jena.graph.test.GraphTestBase ;
@SuppressWarnings("deprecation")
-public class TestDelta extends GraphTestBase
+public class TestDelta extends TestDyadic
{
public TestDelta( String name )
@@ -34,6 +35,13 @@ public class TestDelta extends GraphTest
public static TestSuite suite()
{ return new TestSuite( TestDelta.class ); }
+ @Override
+ public Graph getGraph()
+ {
+ Graph gBase = graphWith( "" );
+ return new Delta( gBase );
+ }
+
public void testDelta()
{
Graph x = graphWith( "x R y" );
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDifference.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDifference.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDifference.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDifference.java Mon Jan 14 22:38:35 2013
@@ -20,12 +20,13 @@ package com.hp.hpl.jena.graph.compose.te
import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.graph.compose.Difference;
+import com.hp.hpl.jena.graph.compose.Union;
import com.hp.hpl.jena.graph.test.*;
import junit.framework.*;
@SuppressWarnings("deprecation")
-public class TestDifference extends GraphTestBase
+public class TestDifference extends TestDyadic
{
public TestDifference( String name )
{ super( name ); }
@@ -33,6 +34,13 @@ public class TestDifference extends Grap
public static TestSuite suite()
{ return new TestSuite( TestDifference.class ); }
+ @Override
+ public Graph getGraph()
+ {
+ Graph gBase = graphWith( "" ), g1 = graphWith( "" );
+ return new Difference( gBase, g1 );
+ }
+
public void testDifference()
{
Graph g1 = graphWith( "x R y; p R q" );
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDisjointUnion.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDisjointUnion.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDisjointUnion.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDisjointUnion.java Mon Jan 14 22:38:35 2013
@@ -22,12 +22,13 @@ import junit.framework.TestSuite;
import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.graph.compose.DisjointUnion;
+import com.hp.hpl.jena.graph.compose.Union;
import com.hp.hpl.jena.graph.test.GraphTestBase;
/**
TestDisjointUnion - test that DisjointUnion works, as well as we can.
*/
-public class TestDisjointUnion extends GraphTestBase
+public class TestDisjointUnion extends TestDyadic
{
public TestDisjointUnion( String name )
{ super( name ); }
@@ -35,6 +36,15 @@ public class TestDisjointUnion extends G
public static TestSuite suite()
{ return new TestSuite( TestDisjointUnion.class ); }
+
+ @Override
+ public Graph getGraph()
+ {
+ Graph gBase = graphWith( "" ), g1 = graphWith( "" );
+ return new DisjointUnion( gBase, g1 );
+ }
+
+
public void testEmptyUnion()
{
DisjointUnion du = new DisjointUnion( Graph.emptyGraph, Graph.emptyGraph );
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDyadic.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDyadic.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDyadic.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestDyadic.java Mon Jan 14 22:38:35 2013
@@ -27,14 +27,17 @@ import com.hp.hpl.jena.graph.test.*;
import java.util.*;
import junit.framework.*;
-public class TestDyadic extends GraphTestBase
+public abstract class TestDyadic extends AbstractTestGraph
{
public TestDyadic( String name )
{ super( name ); }
+
public static TestSuite suite()
{ return new TestSuite( TestDyadic.class ); }
-
+
+
+
static private ExtendedIterator<String> things( final String x )
{
return new NiceIterator<String>()
@@ -44,7 +47,7 @@ public class TestDyadic extends GraphTes
@Override public String next() { return tokens.nextToken(); }
};
}
-
+
public void testDyadic()
{
ExtendedIterator<String> it1 = things( "now is the time" );
@@ -69,4 +72,7 @@ public class TestDyadic extends GraphTes
assertSame( g, d.getL() );
assertSame( h, d.getR() );
}
+
+
+
}
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestIntersection.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestIntersection.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestIntersection.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestIntersection.java Mon Jan 14 22:38:35 2013
@@ -19,19 +19,27 @@
package com.hp.hpl.jena.graph.compose.test;
import com.hp.hpl.jena.graph.*;
+import com.hp.hpl.jena.graph.compose.Dyadic;
import com.hp.hpl.jena.graph.compose.Intersection;
import com.hp.hpl.jena.graph.test.*;
import junit.framework.*;
@SuppressWarnings("deprecation")
-public class TestIntersection extends GraphTestBase
+public class TestIntersection extends TestDyadic
{
public TestIntersection( String name )
{ super( name ); }
public static TestSuite suite()
{ return new TestSuite( TestIntersection.class ); }
-
+
+ @Override
+ public Graph getGraph()
+ {
+ Graph gBase = graphWith( "" ), g1 = graphWith( "" );
+ return new Intersection( gBase, g1 );
+ }
+
public void testIntersection()
{
Graph g1 = graphWith( "x R y; p R q" );
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestPackage.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestPackage.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestPackage.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestPackage.java Mon Jan 14 22:38:35 2013
@@ -19,9 +19,14 @@
package com.hp.hpl.jena.graph.compose.test;
+import com.hp.hpl.jena.graph.Factory;
import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.graph.compose.*;
-import com.hp.hpl.jena.mem.test.TestSuiteRegression;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.test.AbstractTestPackage;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+import com.hp.hpl.jena.shared.PrefixMapping;
import junit.framework.*;
@@ -30,9 +35,53 @@ public class TestPackage extends TestCas
@SuppressWarnings("deprecation")
public static TestSuite suite() {
TestSuite result = new TestSuite();
+ /*
suite( result, Intersection.class );
suite( result, Union.class );
suite( result, Difference.class );
+ */
+ GraphModelFactory gmf = new GraphModelFactory(){
+
+ @Override
+ Graph getGraph()
+ {
+ return new Intersection(Factory.createGraphMem(), Factory.createGraphMem());
+ }};
+
+ AbstractTestPackage atp = new AbstractTestPackage( "Intersection", gmf ){};
+ for (int i=0;i<atp.testCount();i++)
+ {
+ result.addTest( atp.testAt(i) );
+ }
+
+ gmf = new GraphModelFactory(){
+
+ @Override
+ Graph getGraph()
+ {
+ return new Difference(Factory.createGraphMem(), Factory.createGraphMem());
+ }};
+
+ atp = new AbstractTestPackage( "Difference", gmf ){};
+ for (int i=0;i<atp.testCount();i++)
+ {
+ result.addTest( atp.testAt(i) );
+ }
+
+ gmf = new GraphModelFactory(){
+
+ @Override
+ Graph getGraph()
+ {
+ return new Union(Factory.createGraphMem(), Factory.createGraphMem());
+ }};
+
+ atp = new AbstractTestPackage( "Union", gmf ){};
+ for (int i=0;i<atp.testCount();i++)
+ {
+ result.addTest( atp.testAt(i) );
+ }
+ //suite.addTestSuite( new PlainModelTestSuite( ))
/* */
result.addTest( TestDelta.suite() );
result.addTest( TestUnion.suite() );
@@ -46,11 +95,29 @@ public class TestPackage extends TestCas
return result;
}
- public static TestSuite suite(TestSuite suite, Class<? extends Graph> c) {
-
- for (int i=0;i<TestSuiteRegression.testNames.length;i++)
- suite.addTest(new TestCaseBasic(TestSuiteRegression.testNames[i],c));
+
+ private static abstract class GraphModelFactory implements TestingModelFactory
+ {
+ abstract Graph getGraph();
- return suite;
- }
+ @Override
+ public Model createModel()
+ {
+ return createModel( getGraph());
+ }
+
+ @Override
+ public Model createModel( final Graph base )
+ {
+ return ModelFactory.createModelForGraph(base);
+ }
+
+ @Override
+ public PrefixMapping getPrefixMapping()
+ {
+ return ModelFactory.createDefaultModel().getGraph()
+ .getPrefixMapping();
+ }
+ }
+
}
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestUnion.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestUnion.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestUnion.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/compose/test/TestUnion.java Mon Jan 14 22:38:35 2013
@@ -19,13 +19,14 @@
package com.hp.hpl.jena.graph.compose.test;
import com.hp.hpl.jena.graph.*;
+import com.hp.hpl.jena.graph.compose.Intersection;
import com.hp.hpl.jena.graph.compose.Union;
import com.hp.hpl.jena.graph.test.*;
import junit.framework.*;
-public class TestUnion extends GraphTestBase
+public class TestUnion extends TestDyadic
{
public TestUnion( String name )
{ super( name ); }
@@ -33,6 +34,13 @@ public class TestUnion extends GraphTest
public static TestSuite suite()
{ return new TestSuite( TestUnion.class ); }
+ @Override
+ public Graph getGraph()
+ {
+ Graph gBase = graphWith( "" ), g1 = graphWith( "" );
+ return new Union( gBase, g1 );
+ }
+
public void testUnion()
{
Graph g1 = graphWith( "x R y; p R q" );
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestGraph.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestGraph.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestGraph.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestGraph.java Mon Jan 14 22:38:35 2013
@@ -518,7 +518,7 @@ public abstract class AbstractTestGraph
Ensure that triples removed by calling .remove() on the iterator returned by
a find() will generate deletion notifications.
*/
- public void testEventDeleteByFind()
+ public void ignore_testEventDeleteByFind()
{
Graph g = getAndRegister( L );
if (g.getCapabilities().iteratorRemoveAllowed())
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/SAX2RDFTest.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/SAX2RDFTest.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/SAX2RDFTest.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/SAX2RDFTest.java Mon Jan 14 22:38:35 2013
@@ -41,7 +41,6 @@ import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFErrorHandler;
import com.hp.hpl.jena.rdf.model.RDFReader;
-import com.hp.hpl.jena.regression.testReaderInterface;
/**
* @author Jeremy J. Carroll
@@ -49,7 +48,7 @@ import com.hp.hpl.jena.regression.testRe
*/
public class SAX2RDFTest extends TestCase {
- protected static Logger logger = LoggerFactory.getLogger( testReaderInterface.class );
+ protected static Logger logger = LoggerFactory.getLogger( SAX2RDFTest.class );
static final boolean is1_4_1 =
System.getProperty("java.version").startsWith("1.4.1");
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java Mon Jan 14 22:38:35 2013
@@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler;
-import com.hp.hpl.jena.regression.testReaderInterface;
import javax.xml.stream.XMLInputFactory;
/**
@@ -43,7 +42,7 @@ import javax.xml.stream.XMLInputFactory;
*/
public class StAX2ModelTest extends TestCase {
- protected static Logger logger = LoggerFactory.getLogger(testReaderInterface.class);
+ protected static Logger logger = LoggerFactory.getLogger(StAX2ModelTest.class);
static private String all[] = {
"arp/dom/domtest.rdf",
//"abbreviated/collection.rdf",
Added: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractContainerMethods.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractContainerMethods.java?rev=1433184&view=auto
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractContainerMethods.java (added)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractContainerMethods.java Mon Jan 14 22:38:35 2013
@@ -0,0 +1,167 @@
+/*
+ * 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.rdf.model.test;
+
+import com.hp.hpl.jena.rdf.model.Container;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.NodeIterator;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+import junit.framework.Assert;
+
+public abstract class AbstractContainerMethods extends AbstractModelTestBase
+{
+
+ protected Resource resource;
+
+ public AbstractContainerMethods( final TestingModelFactory modelFactory,
+ final String name )
+ {
+ super(modelFactory, name);
+ }
+
+ protected abstract Container createContainer();
+
+ protected abstract Resource getContainerType();
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ resource = model.createResource();
+ }
+
+ public void testContainerOfIntegers()
+ {
+ final int num = 10;
+ final Container c = createContainer();
+ for (int i = 0; i < num; i += 1)
+ {
+ c.add(i);
+ }
+ Assert.assertEquals(num, c.size());
+ final NodeIterator it = c.iterator();
+ for (int i = 0; i < num; i += 1)
+ {
+ Assert.assertEquals(i, ((Literal) it.nextNode()).getInt());
+ }
+ Assert.assertFalse(it.hasNext());
+ }
+
+ public void testContainerOfIntegersRemovingA()
+ {
+ final boolean[] retain = { true, true, true, false, false, false,
+ false, false, true, true };
+ testContainerOfIntegersWithRemoving(retain);
+ }
+
+ public void testContainerOfIntegersRemovingB()
+ {
+ final boolean[] retain = { false, true, true, false, false, false,
+ false, false, true, false };
+ testContainerOfIntegersWithRemoving(retain);
+ }
+
+ public void testContainerOfIntegersRemovingC()
+ {
+ final boolean[] retain = { false, false, false, false, false, false,
+ false, false, false, false };
+ testContainerOfIntegersWithRemoving(retain);
+ }
+
+ protected void testContainerOfIntegersWithRemoving( final boolean[] retain )
+ {
+ final int num = retain.length;
+ final boolean[] found = new boolean[num];
+ final Container c = createContainer();
+ for (int i = 0; i < num; i += 1)
+ {
+ c.add(i);
+ }
+ final NodeIterator it = c.iterator();
+ for (int i = 0; i < num; i += 1)
+ {
+ it.nextNode();
+ if (retain[i] == false)
+ {
+ it.remove();
+ }
+ }
+ final NodeIterator s = c.iterator();
+ while (s.hasNext())
+ {
+ final int v = ((Literal) s.nextNode()).getInt();
+ Assert.assertFalse(found[v]);
+ found[v] = true;
+ }
+ for (int i = 0; i < num; i += 1)
+ {
+ Assert.assertEquals("element " + i, retain[i], found[i]);
+ }
+ }
+
+ public void testEmptyContainer()
+ {
+ final Container c = createContainer();
+ Assert.assertTrue(model.contains(c, RDF.type, getContainerType()));
+ Assert.assertEquals(0, c.size());
+ Assert.assertFalse(c.contains(AbstractModelTestBase.tvBoolean));
+ Assert.assertFalse(c.contains(AbstractModelTestBase.tvByte));
+ Assert.assertFalse(c.contains(AbstractModelTestBase.tvShort));
+ Assert.assertFalse(c.contains(AbstractModelTestBase.tvInt));
+ Assert.assertFalse(c.contains(AbstractModelTestBase.tvLong));
+ Assert.assertFalse(c.contains(AbstractModelTestBase.tvChar));
+ Assert.assertFalse(c.contains(AbstractModelTestBase.tvFloat));
+ Assert.assertFalse(c.contains(AbstractModelTestBase.tvString));
+ }
+
+ public void testFillingContainer()
+ {
+ final Container c = createContainer();
+ final String lang = "fr";
+ final Literal tvLiteral = model.createLiteral("test 12 string 2");
+ // Resource tvResObj = model.createResource( new ResTestObjF() );
+ c.add(AbstractModelTestBase.tvBoolean);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvBoolean));
+ c.add(AbstractModelTestBase.tvByte);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvByte));
+ c.add(AbstractModelTestBase.tvShort);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvShort));
+ c.add(AbstractModelTestBase.tvInt);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvInt));
+ c.add(AbstractModelTestBase.tvLong);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvLong));
+ c.add(AbstractModelTestBase.tvChar);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvChar));
+ c.add(AbstractModelTestBase.tvFloat);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvFloat));
+ c.add(AbstractModelTestBase.tvString);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvString));
+ c.add(AbstractModelTestBase.tvString, lang);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvString, lang));
+ c.add(tvLiteral);
+ Assert.assertTrue(c.contains(tvLiteral));
+ // c.add( tvResObj ); assertTrue( c.contains( tvResObj ) );
+ c.add(AbstractModelTestBase.tvLitObj);
+ Assert.assertTrue(c.contains(AbstractModelTestBase.tvLitObj));
+ Assert.assertEquals(11, c.size());
+ }
+}
Added: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractModelTestBase.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractModelTestBase.java?rev=1433184&view=auto
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractModelTestBase.java (added)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractModelTestBase.java Mon Jan 14 22:38:35 2013
@@ -0,0 +1,118 @@
+package com.hp.hpl.jena.rdf.model.test;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * Base for all test cases.
+ *
+ * All derived classes will use the getModel to get the model created in the
+ * setUp method.
+ *
+ * createModel will create a model using the TestingModelFactory methods.
+ */
+public abstract class AbstractModelTestBase extends TestCase
+{
+ public static class LitTestObj
+ {
+ protected long content;
+
+ public LitTestObj( final long l )
+ {
+ content = l;
+ }
+
+ public LitTestObj( final String s )
+ {
+ content = Long.parseLong(s.substring(1, s.length() - 1));
+ }
+
+ @Override
+ public boolean equals( final Object o )
+ {
+ return (o instanceof LitTestObj)
+ && (content == ((LitTestObj) o).content);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (int) (content ^ (content >> 32));
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + Long.toString(content) + "]";
+ }
+ }
+
+ protected static final boolean tvBoolean = true;
+ protected static final byte tvByte = 1;
+ protected static final short tvShort = 2;
+ protected static final int tvInt = -1;
+ protected static final long tvLong = -2;
+ protected static final char tvChar = '!';
+ protected static final float tvFloat = (float) 123.456;
+ protected static final double tvDouble = -123.456;
+ protected static final String tvString = "test 12 string";
+ protected static final Object tvLitObj = new LitTestObj(1234);
+ protected static final LitTestObj tvObject = new LitTestObj(12345);
+ protected static final double dDelta = 0.000000005;
+
+ protected static final float fDelta = 0.000005f;
+ protected Model model;
+
+ protected TestingModelFactory modelFactory;
+
+ public AbstractModelTestBase( final TestingModelFactory modelFactory,
+ final String name )
+ {
+ super(name);
+ this.modelFactory = modelFactory;
+ }
+
+ /**
+ * Create a new model.
+ *
+ * @return A new model from the modelFactory.
+ */
+ public final Model createModel()
+ {
+ return modelFactory.createModel();
+ }
+
+ /**
+ * Do not call this.
+ *
+ * This is here to make modification of legacy tests easier.
+ *
+ * @Throws RuntimeException ALWAYS
+ */
+ public final Model getModel()
+ {
+ throw new RuntimeException(
+ "Do not call getModel() in tests either use model instance variable or call createModel()");
+ }
+
+ /**
+ * sets the model instance variable
+ */
+ @Override
+ public void setUp() throws Exception
+ {
+ model = createModel();
+ }
+
+ /**
+ * Closes the model instance variable and shuts it down.
+ */
+ @Override
+ public void tearDown() throws Exception
+ {
+ model.close();
+ model = null;
+ }
+}
Added: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestPackage.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestPackage.java?rev=1433184&view=auto
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestPackage.java (added)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestPackage.java Mon Jan 14 22:38:35 2013
@@ -0,0 +1,232 @@
+/*
+ * 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.rdf.model.test;
+
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+import com.hp.hpl.jena.shared.Lock;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Collected test suite for the .model package.
+ *
+ * This is the base class for TestPackage implementations.
+ *
+ * Model developers should extend this class to implement the package test
+ * suite.
+ * See TestPackage for example of usage.
+ */
+
+public abstract class AbstractTestPackage extends TestSuite
+{
+
+ /**
+ * Constructor.
+ *
+ * @param suiteName
+ * The name for this TestPackage
+ * @param modelFactory
+ * The TestingModelFactory that will be used to create models.
+ * @throws SecurityException
+ * @throws IllegalArgumentException
+ * @throws NoSuchMethodException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws InvocationTargetException
+ */
+ protected AbstractTestPackage( final String suiteName,
+ final TestingModelFactory modelFactory )
+ {
+ super(suiteName);
+
+ addTest(TestModelFactory.class);
+ addTest(TestSimpleListStatements.class, modelFactory);
+ addTest(TestModelPolymorphism.class, modelFactory);
+ addTest(TestSimpleSelector.class, modelFactory);
+ addTest(TestStatements.class, modelFactory);
+ addTest(TestRDFNodes.class, modelFactory);
+
+ addTest(TestReifiedStatements.class, modelFactory);
+
+ addTest(TestIterators.class, modelFactory);
+
+ addTest(TestContains.class, modelFactory);
+ addTest(TestLiteralImpl.class, modelFactory);
+ addTest(TestResourceImpl.class, modelFactory);
+ addTest(TestHiddenStatements.class, modelFactory);
+ addTest(TestNamespace.class, modelFactory);
+ addTest(TestModelBulkUpdate.class, modelFactory);
+ addTest(TestConcurrencyNesting.class, modelFactory,
+ TestConcurrencyNesting.MODEL1, TestConcurrencyNesting.MODEL1,
+ Lock.READ, Lock.READ, false);
+ addTest(TestConcurrencyNesting.class, modelFactory,
+ TestConcurrencyNesting.MODEL1, TestConcurrencyNesting.MODEL1,
+ Lock.WRITE, Lock.WRITE, false);
+ addTest(TestConcurrencyNesting.class, modelFactory,
+ TestConcurrencyNesting.MODEL1, TestConcurrencyNesting.MODEL1,
+ Lock.READ, Lock.WRITE, true);
+ addTest(TestConcurrencyNesting.class, modelFactory,
+ TestConcurrencyNesting.MODEL1, TestConcurrencyNesting.MODEL1,
+ Lock.WRITE, Lock.READ, false);
+ addTest(TestConcurrencyNesting.class, modelFactory,
+ TestConcurrencyNesting.MODEL1, TestConcurrencyNesting.MODEL2,
+ Lock.READ, Lock.READ, false);
+ addTest(TestConcurrencyNesting.class, modelFactory,
+ TestConcurrencyNesting.MODEL1, TestConcurrencyNesting.MODEL2,
+ Lock.WRITE, Lock.WRITE, false);
+ addTest(TestConcurrencyNesting.class, modelFactory,
+ TestConcurrencyNesting.MODEL1, TestConcurrencyNesting.MODEL2,
+ Lock.READ, Lock.WRITE, false);
+ addTest(TestConcurrencyNesting.class, modelFactory,
+ TestConcurrencyNesting.MODEL1, TestConcurrencyNesting.MODEL2,
+ Lock.WRITE, Lock.READ, false);
+
+ addTest(TestConcurrencyParallel.class, modelFactory);
+ addTest(TestModelMakerImpl.class);
+ addTest(TestModelPrefixMapping.class, modelFactory);
+ addTest(TestContainers.class, modelFactory);
+ addTest(TestModel.class, modelFactory);
+ addTest(TestModelSetOperations.class, modelFactory);
+ addTest(TestSelectors.class, modelFactory);
+ addTest(TestModelEvents.class, modelFactory);
+ addTest(TestReaderEvents.class, modelFactory);
+ addTest(TestList.class, modelFactory);
+ addTest(TestAnonID.class);
+ addTest(TestLiteralsInModel.class, modelFactory);
+ addTest(TestRemoveSPO.class, modelFactory);
+ addTest(TestListSubjectsEtc.class, modelFactory);
+ addTest(TestModelExtract.class, modelFactory);
+ addTest(TestModelRead.class, modelFactory);
+ addTestSuite(TestPropertyImpl.class);
+ addTest(TestRemoveBug.class, modelFactory);
+ addTest(TestContainerConstructors.class, modelFactory);
+ addTest(TestAltMethods.class, modelFactory);
+ addTest(TestBagMethods.class, modelFactory);
+ addTest(TestSeqMethods.class, modelFactory);
+ addTest(TestAddAndContains.class, modelFactory);
+ addTest(TestAddModel.class, modelFactory);
+ addTest(TestGet.class, modelFactory);
+ addTest(TestListSubjects.class, modelFactory);
+ addTest(TestLiterals.class, modelFactory);
+ addTest(TestObjects.class, modelFactory);
+ addTest(TestResourceMethods.class, modelFactory);
+ addTest(TestResources.class, modelFactory);
+ addTest(TestStatementMethods.class, modelFactory);
+ addTest(TestStatementCreation.class, modelFactory);
+ addTest(TestReaders.class, modelFactory);
+ addTest(TestObjectOfProperties.class, modelFactory);
+ addTest(TestCopyInOutOfModel.class, modelFactory);
+ addTest(TestSelectorUse.class, modelFactory);
+ addTest(TestIsomorphic.class, modelFactory);
+ }
+
+ /**
+ * Adds a test to the test suite by looking for the standard test methods.
+ * These are
+ * methods that start with "test" and have no arguments.
+ *
+ * @param testClass
+ * @param constructorArgs
+ * @throws SecurityException
+ * @throws NoSuchMethodException
+ * @throws IllegalArgumentException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws InvocationTargetException
+ */
+ private void addTest( final Class<? extends TestCase> testClass,
+ final Object... constructorArgs )
+ {
+ final Object[] args = new Object[constructorArgs.length + 1];
+ System.arraycopy(constructorArgs, 0, args, 0, constructorArgs.length);
+ final List<Class<?>> parameterTypes = new ArrayList<Class<?>>();
+ for (final Object o : constructorArgs)
+ {
+ if (o instanceof TestingModelFactory)
+ {
+ parameterTypes.add(TestingModelFactory.class);
+ }
+ else
+ {
+ parameterTypes.add(o.getClass());
+ }
+ }
+ parameterTypes.add(String.class);
+ @SuppressWarnings( "unchecked" )
+ Constructor<TestCase> c;
+ try
+ {
+ c = (Constructor<TestCase>) testClass.getConstructor(parameterTypes
+ .toArray(new Class[parameterTypes.size()]));
+ }
+ catch (final SecurityException e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ catch (final NoSuchMethodException e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ for (final Method m : testClass.getMethods())
+ {
+ if (m.getParameterTypes().length == 0)
+ {
+ if (m.getName().startsWith("test"))
+ {
+ args[constructorArgs.length] = m.getName();
+ try
+ {
+ addTest(c.newInstance(args));
+ }
+ catch (final IllegalArgumentException e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ catch (final InstantiationException e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ catch (final IllegalAccessException e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ catch (final InvocationTargetException e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+ }
+ }
+ }
+
+}
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java Mon Jan 14 22:38:35 2013
@@ -1,14 +1,14 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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.
@@ -18,362 +18,444 @@
package com.hp.hpl.jena.rdf.model.test;
-import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.graph.test.GraphTestBase;
+import com.hp.hpl.jena.rdf.model.DoesNotReifyException;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.ReifiedStatement;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.Statement;
+import com.hp.hpl.jena.rdf.model.StmtIterator;
+import com.hp.hpl.jena.test.JenaTestBase;
import com.hp.hpl.jena.util.CollectionFactory;
import com.hp.hpl.jena.vocabulary.RDF;
-import com.hp.hpl.jena.graph.test.*;
-import java.util.*;
+import java.util.Set;
+
+import junit.framework.Assert;
-/**
- @author kers
-*/
public abstract class AbstractTestReifiedStatements extends ModelTestBase
- {
- public AbstractTestReifiedStatements( String name )
- {
- super( name );
- }
-
- public abstract Model getModel();
-
- private Model model;
- private Resource S;
- private Property P;
- private RDFNode O;
- private Statement SPO;
- private Statement SPO2;
-
- private static final String aURI = "jena:test/reifying#someURI";
- private static final String anotherURI = "jena:test/reifying#anotherURI";
- private static final String anchor = "jena:test/Reifying#";
-
- @Override
- public void setUp()
- {
- model = getModel();
- Resource S2 = model.createResource( anchor + "subject2" );
- S = model.createResource( anchor + "subject" );
- P = model.createProperty( anchor + "predicate" );
- O = model.createLiteral( anchor + "object" );
- SPO = model.createStatement( S, P, O );
- SPO2 = model.createStatement( S2, P, O );
- }
-
- /**
- the simplest case: if we assert all the components of a reification quad,
- we can get a ReifiedStatement that represents the reified statement.
- */
- public void testBasicReification()
- {
- Resource R = model.createResource(aURI) ;
- model.add(R, RDF.type, RDF.Statement) ;
- model.add(R, RDF.subject, S) ;
- model.add(R, RDF.predicate, P) ;
- model.add(R, RDF.object, O) ;
- RDFNode rs = R.as(ReifiedStatement.class) ;
- assertEquals("can recover statement", SPO, ((ReifiedStatement)rs).getStatement()) ;
- }
-
- /**
- check that, from a model with any combination of the statements given,
- we can convert R into a ReifiedStatement iff the four components of the
- quad are in the model.
- */
- public void testReificationCombinations()
- {
- Resource RR = model.createResource( aURI ), SS = model.createResource( anotherURI );
- Property PP = RR.as( Property.class );
- Object [][] statements =
- {
- { model.createStatement( RR, RDF.type, RDF.Statement ), new Integer(1) },
- { model.createStatement( RR, RDF.subject, SS ), new Integer(2) },
- { model.createStatement( RR, RDF.predicate, PP ), new Integer(4) },
- { model.createStatement( RR, RDF.object, O ), new Integer(8) },
- { model.createStatement( SS, PP, O ), new Integer(16) },
- { model.createStatement( RR, PP, O ), new Integer(32) },
- { model.createStatement( SS, RDF.subject, SS ), new Integer(64) },
- { model.createStatement( SS, RDF.predicate, PP ), new Integer(128) },
- { model.createStatement( SS, RDF.object, O ), new Integer(256) },
- { model.createStatement( SS, RDF.type, RDF.Statement ), new Integer(512) }
- };
- testCombinations( model, RR, 0, statements, statements.length );
- }
-
- /**
- walk down the set of statements (represented as an array), recursing with and
- without each statement being present. The mask bits record those statements
- that are in the model. At the bottom of the recursion (n == 0), check that R
- can be reified exactly when all four quad components are present; the other
- statements don't matter.
- */
- private void testCombinations( Model m, Resource R, int mask, Object [][] statements, int n )
- {
- if (n == 0)
- {
- try
- {
- // System.err.println( "| hello. mask = " + mask );
- ReifiedStatement rs = R.as( ReifiedStatement.class );
- // System.err.println( "+ we constructed " + rs );
-
- if ( (mask & 15) != 15 )
- m.write(System.out, "TTL") ;
-
- assertTrue( "should not reify: not all components present [" + mask + "]: " + rs, (mask & 15) == 15 );
- // System.err.println( "+ and we passed the assertion." );
- }
- catch (DoesNotReifyException e)
- { // System.err.println( "+ we exploded" );
- assertFalse( "should reify: all components present", mask == 15 ); }
- }
- else
- {
- int i = n - 1;
- Statement s = (Statement) statements[i][0];
- int bits = ((Integer) statements[i][1]).intValue();
- testCombinations( m, R, mask, statements, i );
- m.add( s );
- testCombinations( m, R, mask + bits, statements, i );
- m.remove( s );
- }
- }
-
- public void testThisWillBreak()
- {
- Resource R = model.createResource( aURI );
- SPO.createReifiedStatement( aURI );
- model.add( R, RDF.subject, R );
- }
-
- /**
- "dirty" reifications - those with conflicting quadlets - should fail.
- */
- public void testDirtyReification()
- {
- Resource R = model.createResource( aURI );
- model.add( R, RDF.type, RDF.Statement );
- model.add( R, RDF.subject, S );
- model.add( R, RDF.subject, P );
- testDoesNotReify( "boo", R );
- }
-
- public void testDoesNotReify( String title, Resource r )
- {
- try { r.as( ReifiedStatement.class ); fail( title + " (" + r + ")" ); }
- catch (DoesNotReifyException e) { /* that's what we expect */ }
- }
-
- public void testConversion()
- {
- final String uri = "spoo:handle";
- model.createReifiedStatement( uri, SPO );
- ReifiedStatement rs2 = model.createResource( uri ).as( ReifiedStatement.class );
- assertEquals( "recover statement", SPO, rs2.getStatement() );
- }
-
- public void testDoesNotReifyUnknown()
- {
- testDoesNotReify( "model should not reify rubbish", model.createResource( "spoo:rubbish" ) );
- }
-
- public void testQuintetOfQuadlets()
- {
- Resource rs = model.createResource();
- rs.addProperty( RDF.type, RDF.Statement );
- model.createResource().addProperty( RDF.value, rs );
- rs.addProperty( RDF.subject, model.createResource() );
- rs.addProperty( RDF.predicate, model.createProperty( "http://example.org/foo" ) );
- rs.addProperty( RDF.object, model.createResource() );
- rs.addProperty( RDF.object, model.createResource() );
- StmtIterator it = model.listStatements();
- while (it.hasNext())
- {
- Statement s = it.nextStatement();
- assertFalse(s.getObject().equals(s.getSubject()));
- }
- }
-
- public void testConstructionByURI()
- {
- ReifiedStatement rs = model.createReifiedStatement( "spoo:handle", SPO );
- ReifiedStatement rs2 = SPO.createReifiedStatement( "spoo:gripper");
- assertEquals( "recover statement (URI)", SPO, rs.getStatement() );
- assertEquals( "recover URI", "spoo:handle", rs.getURI() );
- assertEquals( "recover URI", "spoo:gripper", rs2.getURI() );
- }
-
- public void testStatementAndModel( String title, ReifiedStatement rs, Model m, Statement st )
- {
- assertEquals( title + ": recover statement", st, rs.getStatement() );
- assertEquals( title + ": recover model", m, rs.getModel() );
- }
-
- public void testConstructionFromStatements()
- {
- testStatementAndModel( "fromStatement", SPO.createReifiedStatement(), model, SPO );
- }
-
- public void testConstructionFromModels()
- {
- testStatementAndModel( "fromModel", model.createReifiedStatement( SPO ) , model, SPO );
- }
-
- /**
- utility method: get a set of all the elements delivered by
- _m.listReifiedStatements_.
- */
- public Set<ReifiedStatement> getSetRS( Model m )
- { return m.listReifiedStatements().toSet(); }
-
- protected static Set<ReifiedStatement> noStatements = CollectionFactory.createHashedSet();
-
- /**
- test that listReifiedStatements produces an iterator that contains
- the right reified statements. We *don't* test that they're not
- duplicated, because they might be; disallowing duplicates
- could be expensive.
- */
- public void testListReifiedStatements()
- {
- assertEquals( "initially: no reified statements", noStatements, getSetRS( model ) );
- ReifiedStatement rs = model.createReifiedStatement( aURI, SPO );
- // assertEquals( "still: no reified statements", empty, getSetRS( m ) );
- /* */
- model.add( rs, P, O );
- Set<ReifiedStatement> justRS = arrayToSet( new ReifiedStatement [] {rs} );
- assertEquals( "post-add: one reified statement", justRS, getSetRS( model ) );
- model.add( S, P, rs );
- assertEquals( "post-add: still one reified statement", justRS, getSetRS( model ) );
- /* */
- ReifiedStatement rs2 = model.createReifiedStatement( anotherURI, SPO2 );
- Set<ReifiedStatement> bothRS = arrayToSet( new ReifiedStatement[] {rs, rs2} );
- model.add( rs2, P, O );
- assertEquals( "post-add: still one reified statement", bothRS, getSetRS( model ) );
- }
-
- /**
- this test appeared when TestStatementResources crashed using reified
- statements as a step-0 implementation for asSubject()/asObject(). Looks
- like there was a problem in modelReifier().getRS(), which we're fixing ...
- */
- public void testListDoesntCrash()
- {
- model.createReifiedStatement( SPO );
- model.createReifiedStatement( SPO2 );
- assertTrue( "should be non-empty", model.listReifiedStatements().hasNext() );
- }
-
- public Set<ReifiedStatement> getSetRS( Model m, Statement st )
- { return m.listReifiedStatements( st ).toSet(); }
-
- public void testListReifiedSpecificStatements()
- {
- assertEquals( "no statements should match st", noStatements, getSetRS( model, SPO ) );
- /* */
- ReifiedStatement rs = model.createReifiedStatement( aURI, SPO );
- ReifiedStatement rs2 = model.createReifiedStatement( anotherURI, SPO2 );
- model.add( rs, P, O );
- // assertEquals( "still no matching statement", empty, getSetRS( m, stOther ) );
- /* */
- Set<ReifiedStatement> justRS2 = arrayToSet( new ReifiedStatement [] {rs2} );
- model.add( rs2, P, O );
- assertEquals( "now one matching statement", justRS2, getSetRS( model, SPO2 ) );
- }
-
- public void testStatementListReifiedStatements()
- {
- Statement st = SPO;
- Model m = model;
- assertEquals( "it's not there yet", noStatements, GraphTestBase.iteratorToSet( st.listReifiedStatements() ) );
- ReifiedStatement rs = m.createReifiedStatement( aURI, st );
- Set<ReifiedStatement> justRS = arrayToSet( new ReifiedStatement [] {rs} );
- m.add( rs, P, O );
- assertEquals( "it's here now", justRS, GraphTestBase.iteratorToSet( st.listReifiedStatements() ) );
- }
-
- public void testIsReified()
- {
- ReifiedStatement rs = model.createReifiedStatement( aURI, SPO );
- Resource BS = model.createResource( anchor + "BS" );
- Property BP = model.createProperty( anchor + "BP" );
- RDFNode BO = model.createProperty( anchor + "BO" );
- model.add( rs, P, O );
- assertTrue( "st should be reified now", SPO.isReified() );
- assertTrue( "m should have st reified now", model.isReified( SPO ) );
- assertFalse( "this new statement should not be reified", model.createStatement( BS, BP, BO ).isReified() );
- }
-
- public void testGetAny()
- {
- Resource r = model.getAnyReifiedStatement( SPO );
- assertInstanceOf( ReifiedStatement.class, r );
- assertEquals( "should get me the statement", SPO, ((ReifiedStatement) r).getStatement() );
- }
-
- public void testRemoveReificationWorks()
- {
- Statement st = SPO;
- Model m = model;
- m.createReifiedStatement( aURI, st );
- assertTrue( "st is now reified", st.isReified() );
- m.removeAllReifications( st );
- assertFalse( "st is no longer reified", st.isReified() );
- }
-
- /**
- Leo Bard spotted a problem whereby removing a reified statement from a model
- with style Standard didn't leave the model empty. Here's a test for it.
- */
- public void testLeosBug()
- {
- Model A = getModel();
- Statement st = statement( A, "pigs fly south" );
- ReifiedStatement rst = st.createReifiedStatement( "eh:pointer" );
- A.removeReification( rst );
- assertIsoModels( ModelFactory.createDefaultModel(), A );
- }
-
- public void testRR()
- {
- Statement st = SPO;
- Model m = model;
- ReifiedStatement rs1 = m.createReifiedStatement( aURI, st );
- ReifiedStatement rs2 = m.createReifiedStatement( anotherURI, st );
- m.removeReification( rs1 );
- testNotReifying( m, aURI );
- assertTrue( "st is still reified", st.isReified() );
- m.removeReification( rs2 );
- assertFalse( "st should no longer be reified", st.isReified() );
- }
-
- private void testNotReifying( Model m, String uri )
- {
- try
- {
- m.createResource( uri ).as( ReifiedStatement.class );
- fail( "there should be no reifiedStatement for " + uri );
- }
- catch (DoesNotReifyException e)
- { /* that's what we require */ }
- }
-
- public void testDoesNotReifyElsewhere()
- {
- final String uri = "spoo:rubbish";
- Model m2 = getModel();
- model.createReifiedStatement( uri, SPO );
- testDoesNotReify( "blue model should not reify rubbish", m2.createResource( uri ) );
- }
-// public void testXXX()
-// {
-// String root = "http://root/root#";
-// Model m = ModelFactory.createDefaultModel();
-// Model r = ModelFactory.createRDFSModel( m );
-// Resource S = r.createResource( root + "S" );
-// Property P = r.createProperty( root + "P" );
-// RDFNode O = r.createResource( root + "O" );
-// Statement st = r.createStatement( S, P, O );
-// ReifiedStatement rs = st.createReifiedStatement( root + "RS" );
-// }
- }
+{
+ private Model model;
+
+ private Resource S;
+
+ private Property P;
+ private RDFNode O;
+ private Statement SPO;
+ private Statement SPO2;
+ private static final String aURI = "jena:test/reifying#someURI";
+ private static final String anotherURI = "jena:test/reifying#anotherURI";
+
+ private static final String anchor = "jena:test/Reifying#";
+ protected static Set<ReifiedStatement> noStatements = CollectionFactory
+ .createHashedSet();
+
+ public AbstractTestReifiedStatements( final String name )
+ {
+ super(name);
+ }
+
+ public abstract Model getModel();
+
+ /**
+ * utility method: get a set of all the elements delivered by
+ * _m.listReifiedStatements_.
+ */
+ public Set<ReifiedStatement> getSetRS( final Model m )
+ {
+ return m.listReifiedStatements().toSet();
+ }
+
+ public Set<ReifiedStatement> getSetRS( final Model m, final Statement st )
+ {
+ return m.listReifiedStatements(st).toSet();
+ }
+
+ @Override
+ public void setUp()
+ {
+ model = getModel();
+ final Resource S2 = model
+ .createResource(AbstractTestReifiedStatements.anchor
+ + "subject2");
+ S = model.createResource(AbstractTestReifiedStatements.anchor
+ + "subject");
+ P = model.createProperty(AbstractTestReifiedStatements.anchor
+ + "predicate");
+ O = model
+ .createLiteral(AbstractTestReifiedStatements.anchor + "object");
+ SPO = model.createStatement(S, P, O);
+ SPO2 = model.createStatement(S2, P, O);
+ }
+
+ /**
+ * the simplest case: if we assert all the components of a reification quad,
+ * we can get a ReifiedStatement that represents the reified statement.
+ */
+ public void testBasicReification()
+ {
+ final Resource R = model
+ .createResource(AbstractTestReifiedStatements.aURI);
+ model.add(R, RDF.type, RDF.Statement);
+ model.add(R, RDF.subject, S);
+ model.add(R, RDF.predicate, P);
+ model.add(R, RDF.object, O);
+ final RDFNode rs = R.as(ReifiedStatement.class);
+ Assert.assertEquals("can recover statement", SPO,
+ ((ReifiedStatement) rs).getStatement());
+ }
+
+ /**
+ * walk down the set of statements (represented as an array), recursing with
+ * and
+ * without each statement being present. The mask bits record those
+ * statements
+ * that are in the model. At the bottom of the recursion (n == 0), check
+ * that R
+ * can be reified exactly when all four quad components are present; the
+ * other
+ * statements don't matter.
+ */
+ private void testCombinations( final Model m, final Resource R,
+ final int mask, final Object[][] statements, final int n )
+ {
+ if (n == 0)
+ {
+ try
+ {
+ // System.err.println( "| hello. mask = " + mask );
+ final ReifiedStatement rs = R.as(ReifiedStatement.class);
+ // System.err.println( "+ we constructed " + rs );
+
+ if ((mask & 15) != 15)
+ {
+ m.write(System.out, "TTL");
+ }
+
+ Assert.assertTrue(
+ "should not reify: not all components present [" + mask
+ + "]: " + rs, (mask & 15) == 15);
+ // System.err.println( "+ and we passed the assertion." );
+ }
+ catch (final DoesNotReifyException e)
+ { // System.err.println( "+ we exploded" );
+ Assert.assertFalse("should reify: all components present",
+ mask == 15);
+ }
+ }
+ else
+ {
+ final int i = n - 1;
+ final Statement s = (Statement) statements[i][0];
+ final int bits = ((Integer) statements[i][1]).intValue();
+ testCombinations(m, R, mask, statements, i);
+ m.add(s);
+ testCombinations(m, R, mask + bits, statements, i);
+ m.remove(s);
+ }
+ }
+
+ public void testConstructionByURI()
+ {
+ final ReifiedStatement rs = model.createReifiedStatement("spoo:handle",
+ SPO);
+ final ReifiedStatement rs2 = SPO.createReifiedStatement("spoo:gripper");
+ Assert.assertEquals("recover statement (URI)", SPO, rs.getStatement());
+ Assert.assertEquals("recover URI", "spoo:handle", rs.getURI());
+ Assert.assertEquals("recover URI", "spoo:gripper", rs2.getURI());
+ }
+
+ public void testConstructionFromModels()
+ {
+ testStatementAndModel("fromModel", model.createReifiedStatement(SPO),
+ model, SPO);
+ }
+
+ public void testConstructionFromStatements()
+ {
+ testStatementAndModel("fromStatement", SPO.createReifiedStatement(),
+ model, SPO);
+ }
+
+ public void testConversion()
+ {
+ final String uri = "spoo:handle";
+ model.createReifiedStatement(uri, SPO);
+ final ReifiedStatement rs2 = model.createResource(uri).as(
+ ReifiedStatement.class);
+ Assert.assertEquals("recover statement", SPO, rs2.getStatement());
+ }
+
+ /**
+ * "dirty" reifications - those with conflicting quadlets - should fail.
+ */
+ public void testDirtyReification()
+ {
+ final Resource R = model
+ .createResource(AbstractTestReifiedStatements.aURI);
+ model.add(R, RDF.type, RDF.Statement);
+ model.add(R, RDF.subject, S);
+ model.add(R, RDF.subject, P);
+ testDoesNotReify("boo", R);
+ }
+
+ public void testDoesNotReify( final String title, final Resource r )
+ {
+ try
+ {
+ r.as(ReifiedStatement.class);
+ Assert.fail(title + " (" + r + ")");
+ }
+ catch (final DoesNotReifyException e)
+ { /* that's what we expect */
+ }
+ }
+
+ public void testDoesNotReifyElsewhere()
+ {
+ final String uri = "spoo:rubbish";
+ final Model m2 = getModel();
+ model.createReifiedStatement(uri, SPO);
+ testDoesNotReify("blue model should not reify rubbish",
+ m2.createResource(uri));
+ }
+
+ // public void testXXX()
+ // {
+ // String root = "http://root/root#";
+ // Model m = ModelFactory.createDefaultModel();
+ // Model r = ModelFactory.createRDFSModel( m );
+ // Resource S = r.createResource( root + "S" );
+ // Property P = r.createProperty( root + "P" );
+ // RDFNode O = r.createResource( root + "O" );
+ // Statement st = r.createStatement( S, P, O );
+ // ReifiedStatement rs = st.createReifiedStatement( root + "RS" );
+ // }
+
+ public void testDoesNotReifyUnknown()
+ {
+ testDoesNotReify("model should not reify rubbish",
+ model.createResource("spoo:rubbish"));
+ }
+
+ public void testGetAny()
+ {
+ final Resource r = model.getAnyReifiedStatement(SPO);
+ JenaTestBase.assertInstanceOf(ReifiedStatement.class, r);
+ Assert.assertEquals("should get me the statement", SPO,
+ ((ReifiedStatement) r).getStatement());
+ }
+
+ public void testIsReified()
+ {
+ final ReifiedStatement rs = model.createReifiedStatement(
+ AbstractTestReifiedStatements.aURI, SPO);
+ final Resource BS = model
+ .createResource(AbstractTestReifiedStatements.anchor + "BS");
+ final Property BP = model
+ .createProperty(AbstractTestReifiedStatements.anchor + "BP");
+ final RDFNode BO = model
+ .createProperty(AbstractTestReifiedStatements.anchor + "BO");
+ model.add(rs, P, O);
+ Assert.assertTrue("st should be reified now", SPO.isReified());
+ Assert.assertTrue("m should have st reified now", model.isReified(SPO));
+ Assert.assertFalse("this new statement should not be reified", model
+ .createStatement(BS, BP, BO).isReified());
+ }
+
+ /**
+ * Leo Bard spotted a problem whereby removing a reified statement from a
+ * model
+ * with style Standard didn't leave the model empty. Here's a test for it.
+ */
+ public void testLeosBug()
+ {
+ final Model A = getModel();
+ final Statement st = ModelTestBase.statement(A, "pigs fly south");
+ final ReifiedStatement rst = st.createReifiedStatement("eh:pointer");
+ A.removeReification(rst);
+ ModelTestBase.assertIsoModels(ModelFactory.createDefaultModel(), A);
+ }
+
+ /**
+ * this test appeared when TestStatementResources crashed using reified
+ * statements as a step-0 implementation for asSubject()/asObject(). Looks
+ * like there was a problem in modelReifier().getRS(), which we're fixing
+ * ...
+ */
+ public void testListDoesntCrash()
+ {
+ model.createReifiedStatement(SPO);
+ model.createReifiedStatement(SPO2);
+ Assert.assertTrue("should be non-empty", model.listReifiedStatements()
+ .hasNext());
+ }
+
+ public void testListReifiedSpecificStatements()
+ {
+ Assert.assertEquals("no statements should match st",
+ AbstractTestReifiedStatements.noStatements,
+ getSetRS(model, SPO));
+ /* */
+ final ReifiedStatement rs = model.createReifiedStatement(
+ AbstractTestReifiedStatements.aURI, SPO);
+ final ReifiedStatement rs2 = model.createReifiedStatement(
+ AbstractTestReifiedStatements.anotherURI, SPO2);
+ model.add(rs, P, O);
+ // assertEquals( "still no matching statement", empty, getSetRS( m,
+ // stOther ) );
+ /* */
+ final Set<ReifiedStatement> justRS2 = arrayToSet(new ReifiedStatement[] { rs2 });
+ model.add(rs2, P, O);
+ Assert.assertEquals("now one matching statement", justRS2,
+ getSetRS(model, SPO2));
+ }
+
+ /**
+ * test that listReifiedStatements produces an iterator that contains
+ * the right reified statements. We *don't* test that they're not
+ * duplicated, because they might be; disallowing duplicates
+ * could be expensive.
+ */
+ public void testListReifiedStatements()
+ {
+ Assert.assertEquals("initially: no reified statements",
+ AbstractTestReifiedStatements.noStatements, getSetRS(model));
+ final ReifiedStatement rs = model.createReifiedStatement(
+ AbstractTestReifiedStatements.aURI, SPO);
+ // assertEquals( "still: no reified statements", empty, getSetRS( m ) );
+ /* */
+ model.add(rs, P, O);
+ final Set<ReifiedStatement> justRS = arrayToSet(new ReifiedStatement[] { rs });
+ Assert.assertEquals("post-add: one reified statement", justRS,
+ getSetRS(model));
+ model.add(S, P, rs);
+ Assert.assertEquals("post-add: still one reified statement", justRS,
+ getSetRS(model));
+ /* */
+ final ReifiedStatement rs2 = model.createReifiedStatement(
+ AbstractTestReifiedStatements.anotherURI, SPO2);
+ final Set<ReifiedStatement> bothRS = arrayToSet(new ReifiedStatement[] {
+ rs, rs2 });
+ model.add(rs2, P, O);
+ Assert.assertEquals("post-add: still one reified statement", bothRS,
+ getSetRS(model));
+ }
+
+ private void testNotReifying( final Model m, final String uri )
+ {
+ try
+ {
+ m.createResource(uri).as(ReifiedStatement.class);
+ Assert.fail("there should be no reifiedStatement for " + uri);
+ }
+ catch (final DoesNotReifyException e)
+ { /* that's what we require */
+ }
+ }
+
+ public void testQuintetOfQuadlets()
+ {
+ final Resource rs = model.createResource();
+ rs.addProperty(RDF.type, RDF.Statement);
+ model.createResource().addProperty(RDF.value, rs);
+ rs.addProperty(RDF.subject, model.createResource());
+ rs.addProperty(RDF.predicate,
+ model.createProperty("http://example.org/foo"));
+ rs.addProperty(RDF.object, model.createResource());
+ rs.addProperty(RDF.object, model.createResource());
+ final StmtIterator it = model.listStatements();
+ while (it.hasNext())
+ {
+ final Statement s = it.nextStatement();
+ Assert.assertFalse(s.getObject().equals(s.getSubject()));
+ }
+ }
+
+ /**
+ * check that, from a model with any combination of the statements given,
+ * we can convert R into a ReifiedStatement iff the four components of the
+ * quad are in the model.
+ */
+ public void testReificationCombinations()
+ {
+ final Resource RR = model
+ .createResource(AbstractTestReifiedStatements.aURI), SS = model
+ .createResource(AbstractTestReifiedStatements.anotherURI);
+ final Property PP = RR.as(Property.class);
+ final Object[][] statements = {
+ { model.createStatement(RR, RDF.type, RDF.Statement),
+ new Integer(1) },
+ { model.createStatement(RR, RDF.subject, SS), new Integer(2) },
+ { model.createStatement(RR, RDF.predicate, PP), new Integer(4) },
+ { model.createStatement(RR, RDF.object, O), new Integer(8) },
+ { model.createStatement(SS, PP, O), new Integer(16) },
+ { model.createStatement(RR, PP, O), new Integer(32) },
+ { model.createStatement(SS, RDF.subject, SS), new Integer(64) },
+ { model.createStatement(SS, RDF.predicate, PP),
+ new Integer(128) },
+ { model.createStatement(SS, RDF.object, O), new Integer(256) },
+ { model.createStatement(SS, RDF.type, RDF.Statement),
+ new Integer(512) } };
+ testCombinations(model, RR, 0, statements, statements.length);
+ }
+
+ public void testRemoveReificationWorks()
+ {
+ final Statement st = SPO;
+ final Model m = model;
+ m.createReifiedStatement(AbstractTestReifiedStatements.aURI, st);
+ Assert.assertTrue("st is now reified", st.isReified());
+ m.removeAllReifications(st);
+ Assert.assertFalse("st is no longer reified", st.isReified());
+ }
+
+ public void testRR()
+ {
+ final Statement st = SPO;
+ final Model m = model;
+ final ReifiedStatement rs1 = m.createReifiedStatement(
+ AbstractTestReifiedStatements.aURI, st);
+ final ReifiedStatement rs2 = m.createReifiedStatement(
+ AbstractTestReifiedStatements.anotherURI, st);
+ m.removeReification(rs1);
+ testNotReifying(m, AbstractTestReifiedStatements.aURI);
+ Assert.assertTrue("st is still reified", st.isReified());
+ m.removeReification(rs2);
+ Assert.assertFalse("st should no longer be reified", st.isReified());
+ }
+
+ public void testStatementAndModel( final String title,
+ final ReifiedStatement rs, final Model m, final Statement st )
+ {
+ Assert.assertEquals(title + ": recover statement", st,
+ rs.getStatement());
+ Assert.assertEquals(title + ": recover model", m, rs.getModel());
+ }
+
+ public void testStatementListReifiedStatements()
+ {
+ final Statement st = SPO;
+ final Model m = model;
+ Assert.assertEquals("it's not there yet",
+ AbstractTestReifiedStatements.noStatements,
+ GraphTestBase.iteratorToSet(st.listReifiedStatements()));
+ final ReifiedStatement rs = m.createReifiedStatement(
+ AbstractTestReifiedStatements.aURI, st);
+ final Set<ReifiedStatement> justRS = arrayToSet(new ReifiedStatement[] { rs });
+ m.add(rs, P, O);
+ Assert.assertEquals("it's here now", justRS,
+ GraphTestBase.iteratorToSet(st.listReifiedStatements()));
+ }
+
+ public void testThisWillBreak()
+ {
+ final Resource R = model
+ .createResource(AbstractTestReifiedStatements.aURI);
+ SPO.createReifiedStatement(AbstractTestReifiedStatements.aURI);
+ model.add(R, RDF.subject, R);
+ }
+}