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 2012/12/02 18:47:09 UTC
svn commit: r1416206 [4/5] - in /jena/branches/jena-core-simplified/src:
main/java/com/hp/hpl/jena/assembler/assemblers/
main/java/com/hp/hpl/jena/graph/ main/java/com/hp/hpl/jena/graph/compose/
main/java/com/hp/hpl/jena/graph/impl/ main/java/com/hp/hp...
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestReifier.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestReifier.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestReifier.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/AbstractTestReifier.java Sun Dec 2 17:46:51 2012
@@ -18,121 +18,54 @@
package com.hp.hpl.jena.graph.test;
-import java.util.Collections;
-
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.impl.GraphBase;
-import com.hp.hpl.jena.shared.*;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator;
-import com.hp.hpl.jena.vocabulary.RDF;
+import com.hp.hpl.jena.graph.Factory ;
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.Triple ;
+import com.hp.hpl.jena.rdf.model.impl.ReifierStd ;
+import com.hp.hpl.jena.shared.AlreadyReifiedException ;
+import com.hp.hpl.jena.shared.CannotReifyException ;
+import com.hp.hpl.jena.vocabulary.RDF ;
/**
Abstract base class for reification tests.
@author kers
-*/
+ */
public abstract class AbstractTestReifier extends GraphTestBase
- {
- protected static final ReificationStyle Minimal = ReificationStyle.Minimal;
- protected static final ReificationStyle Standard = ReificationStyle.Standard;
- protected static final ReificationStyle Convenient = ReificationStyle.Convenient;
-
+{
protected static final Triple ALL = Triple.ANY;
-
+
public AbstractTestReifier( String name )
- { super( name ); }
-
+ { super( name ); }
+
public abstract Graph getGraph();
-
- public abstract Graph getGraph( ReificationStyle style );
protected final Graph getGraphWith( String facts )
- {
+ {
Graph result = getGraph();
graphAdd( result, facts );
return result;
- }
+ }
/**
- Answer true iff g's reifier has style Standard.
- */
- private boolean isStandard( Graph g )
- { return g.getReifier().getStyle() == Standard; }
-
- /**
Answer the empty graph if cond is false, otherwise the graph with the given facts.
- */
+ */
protected final Graph graphWithUnless( boolean cond, String facts )
- { return graphWith( cond ? "" : facts ); }
-
+ { return graphWith( cond ? "" : facts ); }
+
protected final Graph graphWithIf( boolean cond, String facts )
- { return graphWithUnless( !cond, facts ); }
-
+ { return graphWithUnless( !cond, facts ); }
+
public void testGetGraphNotNull()
- { assertNotNull( getGraph() ); }
-
- public void testGotGraphReifierNotNull()
- { assertNotNull( getGraph().getReifier() ); }
-
- public void testGotGraphReifierStyleNotNull()
- { assertNotNull( getGraph().getReifier().getStyle() ); }
-
- public void testStyle()
- {
- assertSame( Minimal, getGraph( Minimal ).getReifier().getStyle() );
- assertSame( Standard, getGraph( Standard ).getReifier().getStyle() );
- assertSame( Convenient, getGraph( Convenient ).getReifier().getStyle() );
- }
-
- public void testEmptyReifiers()
- {
- assertFalse( getGraphWith( "x R y" ).getReifier().findExposed( ALL ).hasNext() );
- assertFalse( getGraphWith( "x R y; p S q" ).getReifier().findExposed( ALL ).hasNext() );
- }
-
- public void testSameReifier()
- {
- Graph G = getGraph();
- Reifier R1 = G.getReifier();
- G.add( triple( "x R y" ) );
- assertTrue( "same reifier", R1 == G.getReifier() );
- }
-
- public void testReifierClosed()
- {
- Graph g = getGraph();
- Reifier r = g.getReifier();
- g.close();
- }
-
- public void testParent()
- {
- Graph G = getGraph(), H = getGraph();
- assertTrue( "correct reifier (G)", G == G.getReifier().getParentGraph() );
- assertTrue( "correct reifier (H)", H == H.getReifier().getParentGraph() );
- }
-
- public void testIntercept()
- {
- Graph g = getGraph( Convenient );
- Reifier r = g.getReifier();
- Node S = node( "sub" ), O = node( "obj" );
- Node RS = node( "http://example.org/type" );
- /* */
- assertFalse( "reifier must not intercept quadlet", r.handledAdd( Triple.create( S, RDF.Nodes.type, RS ) ) );
- assertFalse( "reifier must not intercept quadlet", r.handledAdd( Triple.create( S, S, RDF.Nodes.subject ) ) );
- assertFalse( "reifier must not intercept quadlet", r.handledAdd( Triple.create( S, S, RDF.Nodes.type ) ) );
- /* */
- assertTrue( "reifier must intercept quadlet", r.handledAdd( Triple.create( S, RDF.Nodes.predicate, O ) ) );
- assertTrue( "reifier must intercept quadlet", r.handledAdd( Triple.create( S, RDF.Nodes.type, RDF.Nodes.Statement ) ) );
- }
+ { assertNotNull( getGraph() ); }
/**
Check that the standard reifier will note, but not hide, reification quads.
- */
+ */
public void testStandard()
- {
- Graph g = getGraph( Standard );
- assertFalse( g.getReifier().hasTriple( triple( "s p o" ) ) );
+ {
+ Graph g = getGraph( );
+ assertFalse( ReifierStd.hasTriple(g, triple( "s p o" ) ) );
g.add( NodeCreateUtils.createTriple( "x rdf:subject s" ) );
assertEquals( 1, g.size() );
g.add( NodeCreateUtils.createTriple( "x rdf:predicate p" ) );
@@ -141,419 +74,229 @@ public abstract class AbstractTestReifie
assertEquals( 3, g.size() );
g.add( NodeCreateUtils.createTriple( "x rdf:type rdf:Statement" ) );
assertEquals( 4, g.size() );
- assertTrue( g.getReifier().hasTriple( triple( "s p o" ) ) );
- }
-
+ assertTrue( ReifierStd.hasTriple(g, triple( "s p o" ) ) );
+ }
+
/**
Test that the Standard reifier will expose implicit quads arising from reifyAs().
- */
+ */
public void testStandardExplode()
- {
- Graph g = getGraph( Standard );
- g.getReifier().reifyAs( node( "a" ), triple( "p Q r" ) );
- Graph r = Factory.createDefaultGraph( Minimal );
+ {
+ Graph g = getGraph( );
+ ReifierStd.reifyAs( g, node( "a" ), triple( "p Q r" ) );
+ Graph r = Factory.createDefaultGraph( );
graphAdd( r, "a rdf:type rdf:Statement; a rdf:subject p; a rdf:predicate Q; a rdf:object r" );
assertEquals( 4, g.size() );
assertIsomorphic( r, g );
- }
-
- public void testMinimalExplode()
- {
- Graph g = getGraph( Minimal );
- g.getReifier().reifyAs( node( "a" ), triple( "p Q r" ) );
- assertEquals( 0, g.size() );
- }
-
- /**
- test that a reifier with the given style sees [or not, if it's minimal] the reification quads
- that are inserted through its graph.
- */
- public void testReificationTriples()
- {
- Graph g = getGraph();
- ReificationStyle style = g.getReifier().getStyle();
- Graph quadlets = getReificationTriples( g.getReifier() );
- String S1 = "SSS rdf:predicate PPP", S2 = "SSS rdf:subject SSS";
- g.add( triple( S1 ) );
- assertIsomorphic( graphWithUnless( style == Minimal, S1 ), quadlets );
- g.add( triple( S2 ) );
- assertIsomorphic( graphWithUnless( style == Minimal, S1 + "; " + S2 ), quadlets );
- assertEquals( "convenient hides quadlets", style == Convenient, g.size() == 0 );
- }
-
+ }
+
/**
Ensure that over-specifying a reification means that we don't get a triple
back. Goodness knows why this test wasn't in right from the beginning.
- */
+ */
public void testOverspecificationSuppressesReification()
- {
+ {
Graph g = getGraph();
- if (isStandard( g ))
- {
- Reifier r = g.getReifier();
- graphAdd( g, "x rdf:subject A; x rdf:predicate P; x rdf:object O; x rdf:type rdf:Statement" );
- assertEquals( triple( "A P O" ), r.getTriple( node( "x" ) ) );
- graphAdd( g, "x rdf:subject BOOM" );
- assertEquals( null, r.getTriple( node( "x" ) ) );
- }
- }
-
+ graphAdd( g, "x rdf:subject A; x rdf:predicate P; x rdf:object O; x rdf:type rdf:Statement" );
+ assertEquals( triple( "A P O" ), ReifierStd.getTriple(g, node( "x" ) ) );
+ graphAdd( g, "x rdf:subject BOOM" );
+ assertEquals( null, ReifierStd.getTriple( g, node( "x" ) ) );
+ }
+
public void testReificationSubjectClash()
- {
+ {
testReificationClash( "x rdf:subject SS" );
- }
-
+ }
+
public void testReificationPredicateClash()
- {
+ {
testReificationClash( "x rdf:predicate PP" );
- }
-
+ }
+
public void testReificationObjectClash()
- {
+ {
testReificationClash( "x rdf:object OO" );
- }
-
+ }
+
protected void testReificationClash( String clashingStatement )
- {
+ {
Graph g = getGraph();
- if (isStandard( g ))
- {
- Triple SPO = NodeCreateUtils.createTriple( "S P O" );
- g.getReifier().reifyAs( node( "x" ), SPO );
- assertTrue( g.getReifier().hasTriple( SPO ) );
- graphAdd( g, clashingStatement );
- assertEquals( null, g.getReifier().getTriple( node( "x" ) ) );
- // System.err.println( ">> tRC: clashing = " + clashingStatement );
- assertFalse( g.getReifier().hasTriple( SPO ) );
- }
- }
+ Triple SPO = NodeCreateUtils.createTriple( "S P O" );
+ ReifierStd.reifyAs(g, node( "x" ), SPO );
+ assertTrue( ReifierStd.hasTriple( g , SPO ) );
+ graphAdd( g, clashingStatement );
+ assertEquals( null, ReifierStd.getTriple( g , node( "x" ) ) );
+ // System.err.println( ">> tRC: clashing = " + clashingStatement );
+ assertFalse( ReifierStd.hasTriple(g, SPO ) );
+ }
-// public void testManifestQuadsStandard()
-// { testManifestQuads( Standard ); }
-//
-// public void testManifestQuadsConvenient()
-// { testManifestQuads( Convenient ); }
-//
-// public void testManifestQuadsMinimal()
-// { testManifestQuads( Minimal ); }
-
/**
Test that reifying a triple explicitly has some effect on the graph only for Standard
reifiers.
*/
public void testManifestQuads()
- {
+ {
Graph g = getGraph();
- Reifier r = g.getReifier();
- ReificationStyle style = r.getStyle();
- r.reifyAs( node( "A" ), triple( "S P O" ) );
+ ReifierStd.reifyAs(g, node( "A" ), triple( "S P O" ) ) ;
String reified = "A rdf:type rdf:Statement; A rdf:subject S; A rdf:predicate P; A rdf:object O";
- assertIsomorphic( graphWithIf( style == Standard, reified ), g );
- }
-
-// public void testHiddenVsReificationMinimal()
-// { testHiddenVsReification( Minimal ); }
-//
-// public void testHiddenVsStandard()
-// { testHiddenVsReification( Standard ); }
-//
-// public void testHiddenVsReificationConvenient()
-// { testHiddenVsReification( Convenient ); }
-
+ assertIsomorphic( graphWith( reified ), g );
+ }
+
public void testHiddenVsReification()
- {
+ {
Graph g = getGraph();
- ReificationStyle style = g.getReifier().getStyle();
- Reifier r = g.getReifier();
- r.reifyAs( node( "A" ), triple( "S P O" ) );
- assertEquals( style == Standard, r.findEither( ALL, false ).hasNext() );
- }
-
+ ReifierStd.reifyAs( g, node( "A" ), triple( "S P O" ) );
+ assertTrue( ReifierStd.findEither( g , ALL, false ).hasNext() );
+ }
+
public void testRetrieveTriplesByNode()
- {
+ {
Graph G = getGraph();
- Reifier R = G.getReifier();
Node N = Node.createAnon(), M = Node.createAnon();
- R.reifyAs( N, triple( "x R y" ) );
- assertEquals( "gets correct triple", triple( "x R y" ), R.getTriple( N ) );
- R.reifyAs( M, triple( "p S q" ) );
+ ReifierStd.reifyAs( G , N, triple( "x R y" ) );
+ assertEquals( "gets correct triple", triple( "x R y" ), ReifierStd.getTriple( G , N ) );
+ ReifierStd.reifyAs( G, M, triple( "p S q" ) );
assertDiffer( "the anon nodes must be distinct", N, M );
- assertEquals( "gets correct triple", triple( "p S q" ), R.getTriple( M ) );
- /* */
- assertTrue( "node is known bound", R.hasTriple( M ) );
- assertTrue( "node is known bound", R.hasTriple( N ) );
- assertFalse( "node is known unbound", R.hasTriple( Node.createURI( "any:thing" ) ) );
- /* */
-// Graph GR = R.getReifiedTriples();
-// assertTrue( "reified triples", getGraphWith( "x R y; p S q" ).isIsomorphicWith(GR) );
-// assertTrue( "untouched graph", getGraph().isIsomorphicWith(G) );
- }
-
+ assertEquals( "gets correct triple", triple( "p S q" ), ReifierStd.getTriple( G , M ) );
+
+ assertTrue( "node is known bound", ReifierStd.hasTriple( G, M ) );
+ assertTrue( "node is known bound", ReifierStd.hasTriple( G, N ) );
+ assertFalse( "node is known unbound", ReifierStd.hasTriple( G, Node.createURI( "any:thing" ) ) );
+ }
+
public void testRetrieveTriplesByTriple()
- {
+ {
Graph G = getGraph();
- Reifier R = G.getReifier();
Triple T = triple( "x R y" ), T2 = triple( "y R x" );
Node N = node( "someNode" );
- R.reifyAs( N, T );
- assertTrue( "R must have T", R.hasTriple( T ) );
- assertFalse( "R must not have T2", R.hasTriple( T2 ) );
- }
-
+ ReifierStd.reifyAs( G, N, T );
+ assertTrue( "R must have T", ReifierStd.hasTriple( G, T ) );
+ assertFalse( "R must not have T2", ReifierStd.hasTriple( G, T2 ) );
+ }
+
public void testReifyAs()
- {
+ {
Graph G = getGraph();
- Reifier R = G.getReifier();
Node X = Node.createURI( "some:uri" );
- assertEquals( "node used", X, R.reifyAs( X, triple( "x R y" ) ) );
- assertEquals( "retrieves correctly", triple( "x R y" ), R.getTriple( X ) );
- }
-
+ assertEquals( "node used", X, ReifierStd.reifyAs( G, X, triple( "x R y" ) ) );
+ assertEquals( "retrieves correctly", triple( "x R y" ), ReifierStd.getTriple( G, X ) );
+ }
+
public void testAllNodes()
- {
- Reifier R = getGraph().getReifier();
- R.reifyAs( node("x"), triple( "cows eat grass" ) );
- R.reifyAs( node("y"), triple( "pigs can fly" ) );
- R.reifyAs( node("z"), triple( "dogs may bark" ) );
- assertEquals( "", nodeSet( "z y x" ), iteratorToSet( R.allNodes() ) );
- }
-
+ {
+ Graph G = getGraph();
+ ReifierStd.reifyAs( G, node("x"), triple( "cows eat grass" ) );
+ ReifierStd.reifyAs( G, node("y"), triple( "pigs can fly" ) );
+ ReifierStd.reifyAs( G, node("z"), triple( "dogs may bark" ) );
+ assertEquals( "", nodeSet( "z y x" ), iteratorToSet( ReifierStd.allNodes(G) ) );
+ }
+
public void testRemoveByNode()
- {
+ {
Graph G = getGraph();
- Reifier R = G.getReifier();
Node X = node( "x" ), Y = node( "y" );
- R.reifyAs( X, triple( "x R a" ) );
- R.reifyAs( Y, triple( "y R a" ) );
- R.remove( X, triple( "x R a" ) );
- assertFalse( "triple X has gone", R.hasTriple( X ) );
- assertEquals( "triple Y still there", triple( "y R a" ), R.getTriple( Y ) );
- }
-
+ ReifierStd.reifyAs( G, X, triple( "x R a" ) );
+ ReifierStd.reifyAs( G, Y, triple( "y R a" ) );
+ ReifierStd.remove( G, X, triple( "x R a" ) );
+ assertFalse( "triple X has gone", ReifierStd.hasTriple( G, X ) );
+ assertEquals( "triple Y still there", triple( "y R a" ), ReifierStd.getTriple( G, Y ) );
+ }
+
public void testRemoveFromNothing()
- {
+ {
Graph G = getGraph();
- Reifier R = G.getReifier();
G.delete( triple( "quint rdf:subject S" ) );
- }
-
-// public void testRemoveByTriple()
-// {
-// Graph G = getGraph();
-// Reifier R = G.getReifier();
-// Node X = node( "x" ), Y = node( "y" );
-// R.reifyAs( X, triple( "x R a" ) );
-// R.reifyAs( Y, triple( "y R a" ) );
-// R.remove( triple( "x R a" ) );
-// assertFalse( "triple X has gone", R.hasTriple( X ) );
-// assertEquals( "triple Y still there", triple( "y R a" ), R.getTriple( Y ) );
-// }
-
+ }
+
public void testException()
- {
+ {
Graph G = getGraph();
- Reifier R = G.getReifier();
Node X = node( "x" );
- R.reifyAs( X, triple( "x R y" ) );
- R.reifyAs( X, triple( "x R y" ) );
- try { R.reifyAs( X, triple( "x R z" ) ); fail( "did not detect already reified node" ); }
+ ReifierStd.reifyAs( G, X, triple( "x R y" ) );
+ ReifierStd.reifyAs( G, X, triple( "x R y" ) );
+ try { ReifierStd.reifyAs( G, X, triple( "x R z" ) ); fail( "did not detect already reified node" ); }
catch (AlreadyReifiedException e) { }
- }
-
+ }
+
public void testKevinCaseA()
- {
+ {
Graph G = getGraph();
- if (isStandard( G ))
- {
- Node X = node( "x" ), a = node( "a" ), b = node( "b" ), c = node( "c" );
- G.add( Triple.create( X, RDF.Nodes.type, RDF.Nodes.Statement ) );
- G.getReifier().reifyAs( X, Triple.create( a, b, c ) );
- }
- }
-
+ Node X = node( "x" ), a = node( "a" ), b = node( "b" ), c = node( "c" );
+ G.add( Triple.create( X, RDF.Nodes.type, RDF.Nodes.Statement ) );
+ ReifierStd.reifyAs( G, X, Triple.create( a, b, c ) );
+ }
+
public void testKevinCaseB()
- {
+ {
Graph G = getGraph();
- if (isStandard( G ))
- {
- Node X = node( "x" ), Y = node( "y" );
- Node a = node( "a" ), b = node( "b" ), c = node( "c" );
- G.add( Triple.create( X, RDF.Nodes.subject, Y ) );
- try
- {
- G.getReifier().reifyAs( X, Triple.create( a, b, c ) );
- fail( "X already has subject Y: cannot make it a" );
- }
- catch (CannotReifyException e)
- { pass(); }
- }
- }
-
- /**
- Test that the hidden triples graph is dynamic, not static.
- */
- public void testDynamicHiddenTriples()
- {
- Graph g = getGraph( Minimal );
- Reifier r = g.getReifier();
- Graph h = getHiddenTriples( r );
- Graph wanted = graphWith
- (
- "x rdf:type rdf:Statement"
- + "; x rdf:subject a"
- + "; x rdf:predicate B"
- + "; x rdf:object c"
- );
- assertTrue( h.isEmpty() );
- r.reifyAs( node( "x" ), triple( "a B c" ) );
- assertIsomorphic( wanted, h );
- }
-
- protected Graph getHiddenTriples( final Reifier r )
+ Node X = node( "x" ), Y = node( "y" );
+ Node a = node( "a" ), b = node( "b" ), c = node( "c" );
+ G.add( Triple.create( X, RDF.Nodes.subject, Y ) );
+ try
{
- return new GraphBase()
- {
- @Override public ExtendedIterator<Triple> graphBaseFind( TripleMatch m )
- { return r.findEither( m, true ); }
- };
+ ReifierStd.reifyAs( G, X, Triple.create( a, b, c ) );
+ fail( "X already has subject Y: cannot make it a" );
}
-
- public void testQuadRemove()
- {
- Graph g = getGraph();
- if (isStandard( g ))
- {
- assertEquals( 0, g.size() );
- Triple s = NodeCreateUtils.createTriple( "x rdf:subject s" );
- Triple p = NodeCreateUtils.createTriple( "x rdf:predicate p" );
- Triple o = NodeCreateUtils.createTriple( "x rdf:object o" );
- Triple t = NodeCreateUtils.createTriple( "x rdf:type rdf:Statement");
- g.add(s); g.add(p); g.add(o); g.add(t);
- assertEquals( 4, g.size() );
- g.delete(s); g.delete(p); g.delete(o); g.delete(t);
- assertEquals( 0, g.size() );
- }
- }
+ catch (CannotReifyException e)
+ { pass(); }
+ }
+
+ public void testQuadRemove()
+ {
+ Graph g = getGraph();
+ assertEquals( 0, g.size() );
+ Triple s = NodeCreateUtils.createTriple( "x rdf:subject s" );
+ Triple p = NodeCreateUtils.createTriple( "x rdf:predicate p" );
+ Triple o = NodeCreateUtils.createTriple( "x rdf:object o" );
+ Triple t = NodeCreateUtils.createTriple( "x rdf:type rdf:Statement");
+ g.add(s); g.add(p); g.add(o); g.add(t);
+ assertEquals( 4, g.size() );
+ g.delete(s); g.delete(p); g.delete(o); g.delete(t);
+ assertEquals( 0, g.size() );
+ }
- public void testReifierSize()
- {
- assertEquals( 0, getGraph().getReifier().size() );
- }
-
public void testEmpty()
- {
+ {
Graph g = getGraph();
- if (g.getReifier().getStyle() != Convenient)
- {
- assertTrue( g.isEmpty() );
- graphAdd( g, "x rdf:type rdf:Statement" ); assertFalse( g.isEmpty() );
- graphAdd( g, "x rdf:subject Deconstruction" ); assertFalse( g.isEmpty() );
- graphAdd( g, "x rdf:predicate rdfs:subTypeOf" ); assertFalse( g.isEmpty() );
- graphAdd( g, "x rdf:object LiteraryCriticism" ); assertFalse( g.isEmpty() );
- }
- }
-
+ assertTrue( g.isEmpty() );
+ graphAdd( g, "x rdf:type rdf:Statement" ); assertFalse( g.isEmpty() );
+ graphAdd( g, "x rdf:subject Deconstruction" ); assertFalse( g.isEmpty() );
+ graphAdd( g, "x rdf:predicate rdfs:subTypeOf" ); assertFalse( g.isEmpty() );
+ graphAdd( g, "x rdf:object LiteraryCriticism" ); assertFalse( g.isEmpty() );
+ }
+
public void testReifierEmptyFind()
- {
+ {
Graph g = getGraph();
- Reifier r = g.getReifier();
- assertEquals( tripleSet( "" ), r.findExposed( Triple.ANY ).toSet() );
- }
+ assertEquals( tripleSet( "" ), ReifierStd.findExposed( g , Triple.ANY ).toSet() );
+ }
public void testReifierFindSubject()
- { testReifierFind( "x rdf:subject S" ); }
-
+ { testReifierFind( "x rdf:subject S" ); }
+
public void testReifierFindObject()
- { testReifierFind( "x rdf:object O" ); }
-
+ { testReifierFind( "x rdf:object O" ); }
+
public void testReifierFindPredicate()
- { testReifierFind( "x rdf:predicate P" ); }
-
+ { testReifierFind( "x rdf:predicate P" ); }
+
public void testReifierFindComplete()
- { testReifierFind( "x rdf:predicate P; x rdf:subject S; x rdf:object O; x rdf:type rdf:Statement" ); }
-
+ { testReifierFind( "x rdf:predicate P; x rdf:subject S; x rdf:object O; x rdf:type rdf:Statement" ); }
+
public void testReifierFindFilter()
- {
+ {
Graph g = getGraph();
- Reifier r = g.getReifier();
graphAdd( g, "s rdf:subject S" );
- assertEquals( tripleSet( "" ), r.findExposed( triple( "s otherPredicate S" ) ).toSet() );
- }
+ assertEquals( tripleSet( "" ), ReifierStd.findExposed( g, triple( "s otherPredicate S" ) ).toSet() );
+ }
protected void testReifierFind( String triples )
- { testReifierFind( triples, "?? ?? ??" ); }
+ { testReifierFind( triples, "?? ?? ??" ); }
- /**
- Only applies to style Standard.
- */
protected void testReifierFind( String triples, String pattern )
- {
+ {
Graph g = getGraph();
- Reifier r = g.getReifier();
graphAdd( g, triples );
- if (r.getStyle() == Standard)
- assertEquals( tripleSet( triples ), r.findExposed( triple( pattern ) ).toSet() );
- }
-
- public void testQuintetBug()
- {
- String spec = "rs rdf:type rdf:Statement; foo rdf:value rs; rs rdf:subject X; rs rdf:predicate P; rs rdf:object O1; rs rdf:object O2";
- Graph g = getGraph( Standard );
- Reifier r = g.getReifier();
- graphAdd( g, spec );
- Graph wanted = getGraph( Minimal );
- graphAdd( wanted, spec );
- assertIsomorphic( wanted, g );
- }
-
- public void testBulkClearReificationTriples()
- {
- Graph g = getGraphWith( "x rdf:subject S" );
- g.removeAll();
- assertEquals( "oops: " + g.getClass(), Collections.EMPTY_SET, g.find( Node.ANY, Node.ANY, Node.ANY ).toSet() );
- }
-
- public void testBulkClearReificationTriples2()
- {
- Graph g = getGraphWith( "x rdf:subject S; x rdf:predicate P; x rdf:object O; x rdf:type rdf:Statement" );
- g.removeAll();
- assertEquals( Collections.EMPTY_SET, g.find( Node.ANY, Node.ANY, Node.ANY ).toSet() );
- }
-
-// public void testKevinCaseC()
-// {
-// Graph G = GraphBase.withReification( getGraph() );
-// Node X = node( "x" ), Y = node( "y" );
-// Node a = node( "a" ), b = node( "b" ), c = node( "c" );
-// G.getReifier().reifyAs( X, Triple.create( a, b, c ) );
-// try
-// {
-// G.add( Triple.create( X, Reifier.subject, Y ) );
-// fail( "X already reifies (a, b, c): cannot give it subject Y" );
-// }
-// catch (Reifier.CannotReifyException e)
-// { /* as requried */ }
-// }
-
-// public void testQuads()
-// {
-// Node A = node( "a" ), B = node( "b" );
-// Graph G = getGraph();
-// Graph quads = getGraphWith
-// (
-// "a " + RDF.type + " " + RDF.Statement
-// + "; a " + RDF.subject + " x"
-// + "; a " + RDF.predicate + " R"
-// + "; a " + RDF.object + " y"
-// + "; b " + RDF.type + " " + RDF.Statement
-// + "; b " + RDF.subject + " p"
-// + "; b " + RDF.predicate + " S"
-// + "; b " + RDF.object + " q"
-// );
-// Reifier R = G.getReifier();
-// R.reifyAs( A, triple( "x R y") );
-// R.reifyAs( B, triple( "p S q" ) );
-// assertEquals( "same", quads, R.getReificationQuads() );
-// }
-
+ assertEquals( tripleSet( triples ), ReifierStd.findExposed( g, triple( pattern ) ).toSet() );
}
+}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/GraphTestBase.java Sun Dec 2 17:46:51 2012
@@ -23,15 +23,16 @@ package com.hp.hpl.jena.graph.test;
@author kers
*/
-import com.hp.hpl.jena.util.*;
-import com.hp.hpl.jena.util.iterator.*;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.impl.GraphBase;
-import com.hp.hpl.jena.shared.*;
-import com.hp.hpl.jena.test.*;
+import java.lang.reflect.Constructor ;
+import java.util.* ;
-import java.lang.reflect.Constructor;
-import java.util.*;
+import com.hp.hpl.jena.graph.* ;
+import com.hp.hpl.jena.shared.JenaException ;
+import com.hp.hpl.jena.shared.PrefixMapping ;
+import com.hp.hpl.jena.test.JenaTestBase ;
+import com.hp.hpl.jena.util.CollectionFactory ;
+import com.hp.hpl.jena.util.IteratorCollection ;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
public class GraphTestBase extends JenaTestBase
{
@@ -383,18 +384,17 @@ public class GraphTestBase extends JenaT
@param wrap the outer class instance if graphClass is an inner class
@param graphClass a class implementing Graph
- @param style the reification style to use
@return an instance of graphClass with the given style
@throws RuntimeException or JenaException if construction fails
*/
- public static Graph getGraph( Object wrap, Class<? extends Graph> graphClass, ReificationStyle style )
+ public static Graph getGraph( Object wrap, Class<? extends Graph> graphClass)
{
try
{
- Constructor<?> cons = getConstructor( graphClass, new Class[] {ReificationStyle.class} );
- if (cons != null) return (Graph) cons.newInstance( new Object[] { style } );
- Constructor<?> cons2 = getConstructor( graphClass, new Class [] {wrap.getClass(), ReificationStyle.class} );
- if (cons2 != null) return (Graph) cons2.newInstance( new Object[] { wrap, style } );
+ Constructor<?> cons = getConstructor( graphClass, new Class[] {} );
+ if (cons != null) return (Graph) cons.newInstance( new Object[] { } );
+ Constructor<?> cons2 = getConstructor( graphClass, new Class [] {wrap.getClass()} );
+ if (cons2 != null) return (Graph) cons2.newInstance( new Object[] { wrap} );
throw new JenaException( "no suitable graph constructor found for " + graphClass );
}
catch (RuntimeException e)
@@ -402,15 +402,4 @@ public class GraphTestBase extends JenaT
catch (Exception e)
{ throw new JenaException( e ); }
}
-
- protected static Graph getReificationTriples( final Reifier r )
- {
- return new GraphBase( ReificationStyle.Minimal )
- {
- @Override public ExtendedIterator<Triple> graphBaseFind( TripleMatch m )
- { return r.find( m ); }
- };
- }
-
-
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/MetaTestGraph.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/MetaTestGraph.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/MetaTestGraph.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/MetaTestGraph.java Sun Dec 2 17:46:51 2012
@@ -31,17 +31,15 @@ import com.hp.hpl.jena.shared.*;
public class MetaTestGraph extends AbstractTestGraph
{
protected final Class<? extends Graph> graphClass;
- protected final ReificationStyle style;
- public MetaTestGraph( Class<? extends Graph> graphClass, String name, ReificationStyle style )
+ public MetaTestGraph( Class<? extends Graph> graphClass, String name)
{
super( name );
this.graphClass = graphClass;
- this.style = style;
}
public MetaTestGraph( String name )
- { super( name ); graphClass = null; style = null; }
+ { super( name ); graphClass = null; }
/**
Construct a suite of tests from the test class <code>testClass</code>
@@ -51,42 +49,40 @@ public class MetaTestGraph extends Abstr
public static TestSuite suite( Class<? extends Test> testClass, Class<? extends Graph> graphClass )
{
TestSuite result = new TestSuite();
- result.addTest( suite( testClass, graphClass, ReificationStyle.Minimal ) );
- result.addTest( suite( testClass, graphClass, ReificationStyle.Standard ) );
- result.addTest( suite( testClass, graphClass, ReificationStyle.Convenient ) );
+ result.addTest( suiteX( testClass, graphClass));
result.setName("Meta "+testClass.getName());
return result;
}
- public static TestSuite suite( Class<? extends Test> testClass, Class<? extends Graph> graphClass, ReificationStyle style )
+ public static TestSuite suiteX( Class<? extends Test> testClass, Class<? extends Graph> graphClass)
{
TestSuite result = new TestSuite();
for (Class<?> c = testClass; Test.class.isAssignableFrom( c ); c = c.getSuperclass())
{
Method [] methods = c.getDeclaredMethods();
- addTestMethods( result, testClass, methods, graphClass, style );
+ addTestMethods( result, testClass, methods, graphClass );
}
- result.setName(testClass.getName()+" "+style.toString());
+ result.setName(testClass.getName());
return result;
}
public static void addTestMethods
- ( TestSuite result, Class<? extends Test> testClass, Method [] methods, Class<? extends Graph> graphClass, ReificationStyle style )
+ ( TestSuite result, Class<? extends Test> testClass, Method [] methods, Class<? extends Graph> graphClass)
{
for (int i = 0; i < methods.length; i += 1)
if (isPublicTestMethod( methods[i] ))
- result.addTest( makeTest( testClass, graphClass, methods[i].getName(), style ) );
+ result.addTest( makeTest( testClass, graphClass, methods[i].getName()) );
}
- public static TestCase makeTest( Class<? extends Test> testClass, Class<? extends Graph> graphClass, String name, ReificationStyle style )
+ public static TestCase makeTest( Class<? extends Test> testClass, Class<? extends Graph> graphClass, String name)
{
- Constructor<?> cons = getConstructor( testClass, new Class[] {Class.class, String.class, ReificationStyle.class} );
+ Constructor<?> cons = getConstructor( testClass, new Class[] {Class.class, String.class} );
if (cons == null) throw new JenaException( "cannot find MetaTestGraph constructor" );
- try { return (TestCase) cons.newInstance( new Object [] {graphClass, name, style} ); }
+ try { return (TestCase) cons.newInstance( new Object [] {graphClass, name} ); }
catch (Exception e) { throw new JenaException( e ); }
}
@Override public Graph getGraph()
- { return getGraph( this, graphClass, style ); }
+ { return getGraph( this, graphClass); }
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestFileGraph.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestFileGraph.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestFileGraph.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestFileGraph.java Sun Dec 2 17:46:51 2012
@@ -18,16 +18,18 @@
package com.hp.hpl.jena.graph.test;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.impl.*;
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.shared.ReificationStyle;
-import com.hp.hpl.jena.util.FileUtils;
-
-import java.io.*;
-import java.util.*;
-
-import junit.framework.*;
+import java.io.File ;
+import java.util.ArrayList ;
+import java.util.List ;
+
+import junit.framework.TestSuite ;
+
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.GraphUtil ;
+import com.hp.hpl.jena.graph.impl.FileGraph ;
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+import com.hp.hpl.jena.util.FileUtils ;
/**
Test FileGraph by seeing if we can make some file graphs and then read
@@ -143,7 +145,7 @@ public class TestFileGraph extends Graph
{ history.add( f ); }
};
File file = FileUtils.tempFileName( "fileGraph", ".nt" );
- Graph g = new FileGraph( n, file, true, true, ReificationStyle.Minimal );
+ Graph g = new FileGraph( n, file, true, true );
assertEquals( new ArrayList<File>(), history );
g.close();
assertEquals( oneElementList( file ), history );
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestFileGraphMaker.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestFileGraphMaker.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestFileGraphMaker.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestFileGraphMaker.java Sun Dec 2 17:46:51 2012
@@ -18,15 +18,17 @@
package com.hp.hpl.jena.graph.test;
-import java.io.File;
-import java.util.HashSet;
+import java.io.File ;
+import java.util.HashSet ;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.impl.*;
-import com.hp.hpl.jena.shared.*;
-import com.hp.hpl.jena.util.FileUtils;
+import junit.framework.TestSuite ;
-import junit.framework.*;
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.GraphMaker ;
+import com.hp.hpl.jena.graph.GraphUtil ;
+import com.hp.hpl.jena.graph.impl.FileGraph ;
+import com.hp.hpl.jena.graph.impl.FileGraphMaker ;
+import com.hp.hpl.jena.util.FileUtils ;
/**
Test a FileGraphMaker; use the abstract tests, plus specialised ones for the name
@@ -45,7 +47,7 @@ public class TestFileGraphMaker extends
@Override
public GraphMaker getGraphMaker()
{ String scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker" ).getPath();
- return new FileGraphMaker( scratch, ReificationStyle.Minimal, true ); }
+ return new FileGraphMaker( scratch, true ); }
public void testToFilename()
{ assertEquals( "plain", FileGraphMaker.toFilename( "plain" ) );
@@ -67,8 +69,8 @@ public class TestFileGraphMaker extends
{
File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-already" );
Graph content = graphWith( "something hasProperty someValue" );
- FileGraphMaker A = new FileGraphMaker( scratch.getPath(), ReificationStyle.Minimal, true );
- FileGraphMaker B = new FileGraphMaker( scratch.getPath(), ReificationStyle.Minimal, true );
+ FileGraphMaker A = new FileGraphMaker( scratch.getPath(), true );
+ FileGraphMaker B = new FileGraphMaker( scratch.getPath(), true );
FileGraph gA = (FileGraph) A.createGraph( "already", true );
GraphUtil.addInto( gA, content );
gA.close();
@@ -82,7 +84,7 @@ public class TestFileGraphMaker extends
public void testDeletesFilesOfClosedMaker()
{
File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-forgets" );
- FileGraphMaker A = new FileGraphMaker( scratch.getPath(), ReificationStyle.Minimal, true );
+ FileGraphMaker A = new FileGraphMaker( scratch.getPath(), true );
A.createGraph( "empty" ).close();
assertTrue( "file 'empty' should exist in '" + scratch + "'", new File( scratch, "empty" ) .exists() );
A.close();
@@ -92,7 +94,7 @@ public class TestFileGraphMaker extends
public void testForgetsClosedGraphs()
{
File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-forgets" );
- FileGraphMaker m = new FileGraphMaker( scratch.getPath(), ReificationStyle.Minimal, true );
+ FileGraphMaker m = new FileGraphMaker( scratch.getPath(), true );
m.createGraph( "example" ).close();
assertEquals( new HashSet<String>(), m.listGraphs().toSet() );
m.close();
@@ -101,7 +103,7 @@ public class TestFileGraphMaker extends
public void testDoesntReusedClosedGraphs()
{
File scratch = FileUtils.getScratchDirectory( "jena-test-FileGraphMaker-noReuse" );
- FileGraphMaker m = new FileGraphMaker( scratch.getPath(), ReificationStyle.Minimal, true );
+ FileGraphMaker m = new FileGraphMaker( scratch.getPath(), true );
Graph m1 = m.createGraph( "hello" );
m1.close();
Graph m2 = m.createGraph( "hello" );
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestGraph.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestGraph.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestGraph.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestGraph.java Sun Dec 2 17:46:51 2012
@@ -25,19 +25,13 @@ package com.hp.hpl.jena.graph.test;
@author kers
*/
-import java.util.Set ;
-
import junit.framework.Test ;
import junit.framework.TestSuite ;
import com.hp.hpl.jena.graph.Factory ;
import com.hp.hpl.jena.graph.Graph ;
-import com.hp.hpl.jena.graph.Node ;
import com.hp.hpl.jena.graph.impl.WrappedGraph ;
import com.hp.hpl.jena.mem.GraphMem ;
-import com.hp.hpl.jena.shared.ReificationStyle ;
-import com.hp.hpl.jena.util.CollectionFactory ;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
public class TestGraph extends GraphTestBase
{
@@ -45,7 +39,7 @@ public class TestGraph extends GraphTest
{ super( name ); }
/**
- Answer a test suite that runs the Graph and Reifier tests on GraphMem and on
+ Answer a test suite that runs the Graph tests on GraphMem and on
WrappedGraphMem, the latter standing in for testing WrappedGraph.
*/
public static TestSuite suite()
@@ -79,41 +73,10 @@ public class TestGraph extends GraphTest
/**
Class to provide a constructor that produces a wrapper round a GraphMem.
- @author kers
*/
public static class WrappedGraphMem extends WrappedGraph
{
- public WrappedGraphMem( ReificationStyle style )
- { super( Factory.createGraphMem( style ) ); }
+ public WrappedGraphMem( )
+ { super( Factory.createGraphMem( ) ); }
}
-
- public void testListSubjectsDoesntUseFind()
- {
- final boolean [] called = {false};
- Graph g = Factory.createGraphMem();
- ExtendedIterator<Node> subjects = g.queryHandler().subjectsFor( null, null );
- Set<Node> s = CollectionFactory.createHashedSet();
- while (subjects.hasNext()) s.add( subjects.next() );
- assertFalse( "find should not have been called", called[0] );
- }
-
- public void testListPredicatesDoesntUseFind()
- {
- final boolean [] called = {false};
- Graph g = Factory.createGraphMem();
- ExtendedIterator<Node> predicates = g.queryHandler().predicatesFor( null, null );
- Set<Node> s = CollectionFactory.createHashedSet();
- while (predicates.hasNext()) s.add( predicates.next() );
- assertFalse( "find should not have been called", called[0] );
- }
-
- public void testListObjectsDoesntUseFind()
- {
- final boolean [] called = {false};
- Graph g = Factory.createGraphMem();
- ExtendedIterator<Node> subjects = g.queryHandler().objectsFor( null, null );
- Set<Node> s = CollectionFactory.createHashedSet();
- while (subjects.hasNext()) s.add( subjects.next() );
- assertFalse( "find should not have been called", called[0] );
- }
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestGraphListener.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestGraphListener.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestGraphListener.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestGraphListener.java Sun Dec 2 17:46:51 2012
@@ -19,37 +19,27 @@
package com.hp.hpl.jena.graph.test;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestSuite;
-
-import com.hp.hpl.jena.graph.Factory;
-import com.hp.hpl.jena.graph.Graph;
-import com.hp.hpl.jena.graph.GraphEvents;
-import com.hp.hpl.jena.graph.GraphListener;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler;
+import java.util.Arrays ;
+import java.util.Iterator ;
+import java.util.List ;
+
+import junit.framework.TestSuite ;
+
+import com.hp.hpl.jena.graph.* ;
+import com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler ;
import com.hp.hpl.jena.mem.GraphMem ;
-import com.hp.hpl.jena.shared.ReificationStyle;
/**
* Version of graph tests that set up a listener that copies all changes
* and verifies that after every notification modified graph
* and original are isomorphic.
- * @author Jeremy Carroll
- *
*/
public class TestGraphListener extends MetaTestGraph {
-
-
-
public TestGraphListener(String name) {
super(name);
}
- public TestGraphListener( Class<? extends Graph> graphClass, String name, ReificationStyle style )
- { super( graphClass, name, style ); }
+ public TestGraphListener( Class<? extends Graph> graphClass, String name)
+ { super( graphClass, name); }
public static TestSuite suite()
{ return MetaTestGraph.suite( TestGraphListener.class, GraphMem.class ); }
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestPackage.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestPackage.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestPackage.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestPackage.java Sun Dec 2 17:46:51 2012
@@ -18,8 +18,7 @@
package com.hp.hpl.jena.graph.test;
-import junit.framework.*;
-import com.hp.hpl.jena.graph.query.test.*;
+import junit.framework.TestSuite ;
/**
Collected test suite for the .graph package.
@@ -41,15 +40,9 @@ public class TestPackage extends TestSui
addTest( TestTriple.suite() );
addTest( TestTripleField.suite() );
addTest( TestNodeToTriplesMap.suite() );
- addTest( TestSimpleReifierTripleMap.suite() );
- addTest( TestSimpleReifierFragmentsMap.suite() );
addTest( TestReifier.suite() );
- addTestSuite( TestReifierSearch.class );
- addTest( TestReificationWrapper.suite() );
- addTest( TestReificationPredicates.suite() );
addTest( TestTypedLiterals.suite() );
addTest( TestDateTime.suite() );
- addTest( TestGraphQueryPackage.suite() );
addTest( TestFactory.suite() );
addTest( TestGraph.suite() );
addTest( TestSimpleGraphMaker.suite() );
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestReifier.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestReifier.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestReifier.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestReifier.java Sun Dec 2 17:46:51 2012
@@ -23,32 +23,25 @@ import java.lang.reflect.Constructor ;
import junit.framework.TestSuite ;
import com.hp.hpl.jena.graph.Graph ;
-import com.hp.hpl.jena.graph.Triple ;
-import com.hp.hpl.jena.graph.TripleMatch ;
-import com.hp.hpl.jena.graph.impl.* ;
import com.hp.hpl.jena.mem.GraphMem ;
import com.hp.hpl.jena.shared.JenaException ;
-import com.hp.hpl.jena.shared.ReificationStyle ;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
/**
This class tests the reifiers of ordinary GraphMem graphs.
- @author kers
+ Old test suite - kept to ensure compatibility for teh one and only Standard mode
*/
public class TestReifier extends AbstractTestReifier
{
public TestReifier( String name )
- { super( name ); graphClass = null; style = null; }
+ { super( name ); graphClass = null; }
protected final Class<? extends Graph> graphClass;
- protected final ReificationStyle style;
- public TestReifier( Class<? extends Graph> graphClass, String name, ReificationStyle style )
+ public TestReifier( Class<? extends Graph> graphClass, String name)
{
super( name );
this.graphClass = graphClass;
- this.style = style;
}
public static TestSuite suite()
@@ -59,17 +52,14 @@ public class TestReifier extends Abstrac
return result;
}
- @Override public Graph getGraph()
- { return getGraph( style ); }
-
- @Override public Graph getGraph( ReificationStyle style )
+ @Override public Graph getGraph( )
{
try
{
- Constructor<?> cons = getConstructor( graphClass, new Class[] {ReificationStyle.class} );
- if (cons != null) return (Graph) cons.newInstance( new Object[] { style } );
- Constructor<?> cons2 = getConstructor( graphClass, new Class [] {this.getClass(), ReificationStyle.class} );
- if (cons2 != null) return (Graph) cons2.newInstance( new Object[] { this, style } );
+ Constructor<?> cons = getConstructor( graphClass, new Class[] {} );
+ if (cons != null) return (Graph) cons.newInstance( new Object[] { } );
+ Constructor<?> cons2 = getConstructor( graphClass, new Class [] {this.getClass()} );
+ if (cons2 != null) return (Graph) cons2.newInstance( new Object[] { this } );
throw new JenaException( "no suitable graph constructor found for " + graphClass );
}
catch (RuntimeException e)
@@ -77,18 +67,4 @@ public class TestReifier extends Abstrac
catch (Exception e)
{ throw new JenaException( e ); }
}
-
- public void testExtendedConstructorExists()
- {
- GraphBase parent = new GraphBase() {
-
- @Override public ExtendedIterator<Triple> graphBaseFind( TripleMatch m )
- {
- // TODO Auto-generated method stub
- return null;
- }};
- ReifierTripleMap tm = new SimpleReifierTripleMap();
- ReifierFragmentsMap fm = new SimpleReifierFragmentsMap();
- SimpleReifier sr = new SimpleReifier( parent, tm, fm, ReificationStyle.Minimal );
- }
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/graph/test/TestTypedLiterals.java Sun Dec 2 17:46:51 2012
@@ -41,8 +41,6 @@ import com.hp.hpl.jena.graph.Node ;
import com.hp.hpl.jena.graph.Triple ;
import com.hp.hpl.jena.graph.impl.LiteralLabel ;
import com.hp.hpl.jena.graph.impl.LiteralLabelFactory ;
-import com.hp.hpl.jena.graph.query.Domain ;
-import com.hp.hpl.jena.graph.query.GraphQuery ;
import com.hp.hpl.jena.rdf.model.* ;
import com.hp.hpl.jena.shared.impl.JenaParameters ;
import com.hp.hpl.jena.vocabulary.XSD ;
@@ -755,30 +753,6 @@ public class TestTypedLiterals extends T
}
/**
- * Test query applied to graphs containing typed values
- */
- public void testTypedQueries() {
- Model model = ModelFactory.createDefaultModel();
- Property p = model.createProperty("urn:x-eg/p");
- Literal l1 = model.createTypedLiteral("10", "http://www.w3.org/2001/XMLSchema#integer");
- Literal l2 = model.createTypedLiteral("010", "http://www.w3.org/2001/XMLSchema#integer");
- assertSameValueAs("sameas test", l1, l2);
- Resource a = model.createResource("urn:x-eg/a");
- a.addProperty(p, l1);
- assertTrue(model.getGraph().find(null, p.asNode(), l1.asNode()).hasNext());
- assertTrue(model.getGraph().find(null, p.asNode(), l2.asNode()).hasNext());
- assertTrue(model.getGraph().find(a.asNode(), p.asNode(), l2.asNode()).hasNext());
- assertTrue( model.getGraph().contains( a.asNode(), p.asNode(), l2.asNode() ) );
- GraphQuery q = new GraphQuery();
- q.addMatch(a.asNode(), p.asNode(), l2.asNode());
- Iterator<Domain> qi = model.getGraph().queryHandler().prepareBindings(q, new Node[] {}).executeBindings();
- assertTrue(qi.hasNext());
- // Similar tests at Model API level
- // Selector s1 = new SimpleSelector(a, p, l2);
- assertTrue(model.listStatements( a, p, l2 ).hasNext());
- }
-
- /**
* Test the isValidLiteral machinery
*/
public void testIsValidLiteral() {
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestConcurrentModificationException.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestConcurrentModificationException.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestConcurrentModificationException.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestConcurrentModificationException.java Sun Dec 2 17:46:51 2012
@@ -23,8 +23,6 @@ import java.util.*;
import junit.framework.*;
import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.graph.query.Domain;
-import com.hp.hpl.jena.graph.query.StageElement;
import com.hp.hpl.jena.graph.test.NodeCreateUtils;
import com.hp.hpl.jena.mem.*;
import com.hp.hpl.jena.rdf.model.test.ModelTestBase;
@@ -97,34 +95,4 @@ public abstract class TestConcurrentModi
try { it.next(); fail( "should have thrown ConcurrentModificationException" ); }
catch (ConcurrentModificationException e) { pass(); }
}
-
- private static final MatchOrBind mob = new MatchOrBind()
- {
- @Override
- public boolean matches( Triple t )
- {
- return true;
- }
-
- @Override
- public MatchOrBind reset( Domain d )
- {
- return null;
- }
- };
-
- public void testAddDuringAppThrowsCME()
- {
- final TripleBunch b = getBunch();
- b.add( NodeCreateUtils.createTriple( "a P b" ) );
- b.add( NodeCreateUtils.createTriple( "c Q d" ) );
- StageElement se = new StageElement()
- {
- @Override
- public void run( Domain current )
- { b.add( NodeCreateUtils.createTriple( "S P O" ) ); }
- };
- try { b.app( new Domain( 0 ), se, mob ); fail(" should throw CME" ); }
- catch (ConcurrentModificationException e) { pass(); }
- }
}
Copied: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem.java (from r1415851, jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem.java)
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem.java?p2=jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem.java&p1=jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem.java&r1=1415851&r2=1416206&rev=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem.java Sun Dec 2 17:46:51 2012
@@ -128,16 +128,7 @@ public class TestGraphMem extends Abstra
{
testStatsWithConcreteTriple( 0, "x P y", "" );
}
-
- public void testStatsWithreification()
- {
- ReificationStyle style = ReificationStyle.Standard;
- Graph g = new GraphMem( style );
- GraphStatisticsHandler h = g.getStatisticsHandler();
- graphAdd( g, "x rdf:subject A" );
- assertEquals( -1L, h.getStatistic( node( "x" ), Node.ANY, Node.ANY ) );
- }
-
+
private void testStatsWithConcreteTriple( int expect, String triple, String graph )
{
Graph g = getGraphWith( graph );
Copied: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem2.java (from r1415851, jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/AbstractTestGraphMem.java)
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem2.java?p2=jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem2.java&p1=jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/AbstractTestGraphMem.java&r1=1415851&r2=1416206&rev=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/AbstractTestGraphMem.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMem2.java Sun Dec 2 17:46:51 2012
@@ -18,25 +18,24 @@
package com.hp.hpl.jena.mem.test;
-import java.util.Iterator;
+import java.util.Iterator ;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.impl.SimpleReifier;
-import com.hp.hpl.jena.graph.test.AbstractTestGraph;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator;
+import junit.framework.TestSuite ;
-public class AbstractTestGraphMem extends AbstractTestGraph
+import com.hp.hpl.jena.graph.* ;
+import com.hp.hpl.jena.graph.test.AbstractTestGraph ;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
+
+public class TestGraphMem2 extends AbstractTestGraph
{
- public AbstractTestGraphMem(String name)
+ public TestGraphMem2(String name)
{ super( name ); }
- public void testClosesReifier()
- {
- Graph g = getGraph();
- SimpleReifier r = (SimpleReifier) g.getReifier();
- g.close();
- assertTrue( r.isClosed() );
- }
+ public static TestSuite suite()
+ { return new TestSuite( TestGraphMem2.class ); }
+
+ @Override
+ public Graph getGraph() { return Factory.createGraphMem(); }
public void testBrokenIndexes()
{
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMemPackage.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMemPackage.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMemPackage.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/mem/test/TestGraphMemPackage.java Sun Dec 2 17:46:51 2012
@@ -27,7 +27,7 @@ public class TestGraphMemPackage extends
{
TestSuite result = new TestSuite();
result.addTest( TestGraphMem.suite() );
- result.addTest( TestMemQuery.suite() );
+ result.addTest( TestGraphMem2.suite() );
result.addTest( TestConcurrentModificationException.suite() );
return result;
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java Sun Dec 2 17:46:51 2012
@@ -65,16 +65,15 @@ public abstract class AbstractTestReifie
we can get a ReifiedStatement that represents the reified statement.
*/
public void testBasicReification()
- {
- if (model.getReificationStyle() != ModelFactory.Minimal)
- { 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() ); }
- }
+ {
+ 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,
@@ -98,8 +97,7 @@ public abstract class AbstractTestReifie
{ model.createStatement( SS, RDF.object, O ), new Integer(256) },
{ model.createStatement( SS, RDF.type, RDF.Statement ), new Integer(512) }
};
- if (model.getReificationStyle() != ModelFactory.Minimal)
- testCombinations( model, RR, 0, statements, statements.length );
+ testCombinations( model, RR, 0, statements, statements.length );
}
/**
@@ -118,6 +116,10 @@ public abstract class AbstractTestReifie
// 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." );
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java Sun Dec 2 17:46:51 2012
@@ -18,13 +18,14 @@
package com.hp.hpl.jena.rdf.model.test;
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.test.*;
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.shared.*;
-import com.hp.hpl.jena.util.CollectionFactory;
+import java.util.* ;
-import java.util.*;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.test.GraphTestBase ;
+import com.hp.hpl.jena.graph.test.NodeCreateUtils ;
+import com.hp.hpl.jena.rdf.model.* ;
+import com.hp.hpl.jena.shared.PrefixMapping ;
+import com.hp.hpl.jena.util.CollectionFactory ;
/**
provides useful functionality for testing models, eg building small models
@@ -159,25 +160,14 @@ public class ModelTestBase extends Graph
@return a model containing those facts
*/
public static Model modelWithStatements( String facts )
- { return modelWithStatements( ReificationStyle.Standard, facts ); }
-
- /**
- makes a model with a given reiifcation style, initialised with statements parsed
- from a string.
-
- @param style the required reification style
- @param facts a string in semicolon-separated "S P O" format
- @return a model containing those facts
- */
- public static Model modelWithStatements( ReificationStyle style, String facts )
- { return modelAdd( createModel( style ), facts ); }
+ { return modelAdd( createModel( ), facts ); }
/**
- make a model with a given reification style, give it Extended prefixes
+ make a model, give it Extended prefixes
*/
- public static Model createModel( ReificationStyle style )
+ public static Model createModel( )
{
- Model result = ModelFactory.createDefaultModel( style );
+ Model result = ModelFactory.createDefaultModel( );
result.setNsPrefixes( PrefixMapping.Extended );
return result;
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelBulkUpdate.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelBulkUpdate.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelBulkUpdate.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelBulkUpdate.java Sun Dec 2 17:46:51 2012
@@ -18,55 +18,58 @@
package com.hp.hpl.jena.rdf.model.test;
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.shared.*;
+import java.util.Arrays ;
+import java.util.List ;
-import java.util.*;
-import junit.framework.*;
+import junit.framework.TestSuite ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+import com.hp.hpl.jena.rdf.model.Statement ;
/**
Tests of the Model-level bulk update API.
-
+
@author kers
-*/
+ */
public class TestModelBulkUpdate extends ModelTestBase
- {
+{
public TestModelBulkUpdate( String name )
- { super( name ); }
-
+ { super( name ); }
+
public static TestSuite suite()
- { return new TestSuite( TestModelBulkUpdate.class ); }
+ { return new TestSuite( TestModelBulkUpdate.class ); }
public void testMBU()
- { testMBU( ModelFactory.createDefaultModel() ); }
-
+ { testMBU( ModelFactory.createDefaultModel() ); }
+
public void testContains( Model m, Statement [] statements )
- {
+ {
for (int i = 0; i < statements.length; i += 1)
assertTrue( "it should be here", m.contains( statements[i] ) );
- }
-
+ }
+
public void testContains( Model m, List<Statement> statements )
- {
+ {
for (int i = 0; i < statements.size(); i += 1)
assertTrue( "it should be here", m.contains( statements.get(i) ) );
- }
-
+ }
+
public void testOmits( Model m, Statement [] statements )
- {
+ {
for (int i = 0; i < statements.length; i += 1)
assertFalse( "it should not be here", m.contains( statements[i] ) );
- }
+ }
public void testOmits( Model m, List<Statement> statements )
- {
+ {
for (int i = 0; i < statements.size(); i += 1)
assertFalse( "it should not be here", m.contains( statements.get(i) ) );
- }
-
+ }
+
public void testMBU( Model m )
- {
+ {
Statement [] sArray = statements( m, "moon orbits earth; earth orbits sun" );
List<Statement> sList = Arrays.asList( statements( m, "I drink tea; you drink coffee" ) );
m.add( sArray );
@@ -74,20 +77,20 @@ public class TestModelBulkUpdate extends
m.add( sList );
testContains( m, sList );
testContains( m, sArray );
- /* */
+ /* */
m.remove( sArray );
testOmits( m, sArray );
testContains( m, sList );
m.remove( sList );
testOmits( m, sArray );
testOmits( m, sList );
- }
-
+ }
+
public void testBulkByModel()
- { testBulkByModel( ModelFactory.createDefaultModel() ); }
-
+ { testBulkByModel( ModelFactory.createDefaultModel() ); }
+
public void testBulkByModel( Model m )
- {
+ {
assertEquals( "precondition: model must be empty", 0, m.size() );
Model A = modelWithStatements( "clouds offer rain; trees offer shelter" );
Model B = modelWithStatements( "x R y; y Q z; z P x" );
@@ -98,54 +101,17 @@ public class TestModelBulkUpdate extends
assertIsoModels( B, m );
m.remove( B );
assertEquals( "", 0, m.size() );
- }
-
+ }
+
public void testBulkRemoveSelf()
- {
+ {
Model m = modelWithStatements( "they sing together; he sings alone" );
m.remove( m );
assertEquals( "", 0, m.size() );
- }
-
- public void testBulkByModelReifying()
- {
- testBulkByModelReifying( false );
- testBulkByModelReifying( true );
- }
-
- public void testBulkByModelReifying( boolean suppress )
- {
- Model m = modelWithStatements( ReificationStyle.Minimal, "a P b" );
- addReification( m, "x", "S P O" );
- addReification( m, "a", "x R y" );
- Model target = modelWithStatements( ReificationStyle.Minimal, "" );
- target.add( m, suppress );
- target.setNsPrefixes( PrefixMapping.Standard );
- assertIsoModels( (suppress ? modelWithStatements("a P b") : m), target );
- }
-
- public void testBulkDeleteByModelReifying()
- {
- testBulkDeleteByModelReifying( false );
- testBulkDeleteByModelReifying( true );
- }
-
- public void testBulkDeleteByModelReifying( boolean suppress )
- {
- Model target = modelWithStatements( ReificationStyle.Minimal, "" );
- addReification( target, "x", "S P O" );
- addReification( target, "y", "A P B" );
- Model remove = modelWithStatements( "" );
- addReification( remove, "y", "A P B" );
- Model answer = modelWithStatements( "" );
- addReification( answer, "x", "S P O" );
- if (suppress) addReification( answer, "y", "A P B" );
- target.remove( remove, suppress );
- assertIsoModels( answer, target );
- }
-
+ }
+
public void addReification( Model m, String tag, String statement )
- {
+ {
m.createReifiedStatement( tag, statement( m, statement ) );
- }
}
+}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java Sun Dec 2 17:46:51 2012
@@ -18,16 +18,21 @@
package com.hp.hpl.jena.rdf.model.test;
-import com.hp.hpl.jena.rdf.model.impl.*;
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.shared.*;
-import com.hp.hpl.jena.util.iterator.*;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.test.*;
+import java.util.ArrayList ;
+import java.util.List ;
-import java.util.*;
+import junit.framework.TestSuite ;
-import junit.framework.*;
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.GraphMaker ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.test.GraphTestBase ;
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelMaker ;
+import com.hp.hpl.jena.rdf.model.impl.ModelMakerImpl ;
+import com.hp.hpl.jena.shared.ReificationStyle ;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
+import com.hp.hpl.jena.util.iterator.NullIterator ;
/**
Test ModelMakerImpl using a mock GraphMaker. This is as much an
@@ -147,6 +152,7 @@ public class TestModelMakerImpl extends
{ this.graph = graph; }
@Override
+ @Deprecated
public ReificationStyle getReificationStyle()
{
history.add( "getReificationStyle()" );
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java Sun Dec 2 17:46:51 2012
@@ -54,7 +54,6 @@ public class TestPackage extends TestSui
addTest( "TestModelPrefixMapping", TestModelPrefixMapping.suite() );
addTest( TestContainers.suite() );
addTest( "TestStandardModels", TestStandardModels.suite() );
- addTest( "TestQuery", TestQuery.suite() );
addTest( "TestSelectors", TestSelectors.suite() );
addTest( "TestModelEvents", TestModelEvents.suite() );
addTest( "TestReaderEvents", TestReaderEvents.suite() );
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestReifiedStatements.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestReifiedStatements.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestReifiedStatements.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/rdf/model/test/TestReifiedStatements.java Sun Dec 2 17:46:51 2012
@@ -18,54 +18,27 @@
package com.hp.hpl.jena.rdf.model.test;
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.shared.ReificationStyle;
+import junit.framework.TestSuite ;
-import junit.framework.*;
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
/**
test the properties required of ReifiedStatement objects.
- @author kers
*/
-public class TestReifiedStatements extends ModelTestBase
+public class TestReifiedStatements extends AbstractTestReifiedStatements
{
- public TestReifiedStatements( String name )
- { super( name ); }
+ public TestReifiedStatements(String name)
+ {
+ super(name) ;
+ }
+
public static TestSuite suite()
- { TestSuite result = new TestSuite();
- result.addTest( new TestSuite( TestStandard.class ) );
- result.addTest( new TestSuite( TestConvenient.class ) );
- result.addTest( new TestSuite( TestMinimal.class ) );
- return result; }
+ { return new TestSuite(TestReifiedStatements.class, "TestReifiedStatements" ) ; }
+ @Override
public Model getModel()
{ return ModelFactory.createDefaultModel(); }
- public static class TestStandard extends AbstractTestReifiedStatements
- {
- public TestStandard( String name ) { super( name ); }
- public static final ReificationStyle style = ModelFactory.Standard;
- @Override
- public Model getModel() { return ModelFactory.createDefaultModel( style ); }
- public void testStyle() { assertEquals( style, getModel().getReificationStyle() ); }
- }
-
- public static class TestConvenient extends AbstractTestReifiedStatements
- {
- public TestConvenient( String name ) { super( name ); }
- public static final ReificationStyle style = ModelFactory.Convenient;
- @Override
- public Model getModel() { return ModelFactory.createDefaultModel( style ); }
- public void testStyle() { assertEquals( style, getModel().getReificationStyle() ); }
- }
-
- public static class TestMinimal extends AbstractTestReifiedStatements
- {
- public TestMinimal( String name ) { super( name ); }
- public static final ReificationStyle style = ModelFactory.Minimal;
- @Override
- public Model getModel() { return ModelFactory.createDefaultModel( style); }
- public void testStyle() { assertEquals( style, getModel().getReificationStyle() ); }
- }
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/reasoner/rulesys/test/ConcurrencyTest.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/reasoner/rulesys/test/ConcurrencyTest.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/reasoner/rulesys/test/ConcurrencyTest.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/reasoner/rulesys/test/ConcurrencyTest.java Sun Dec 2 17:46:51 2012
@@ -18,9 +18,13 @@
package com.hp.hpl.jena.reasoner.rulesys.test;
+import java.lang.management.ManagementFactory ;
+import java.lang.management.ThreadInfo ;
+import java.lang.management.ThreadMXBean ;
import java.util.concurrent.ExecutorService ;
import java.util.concurrent.Executors ;
+import junit.framework.Assert ;
import junit.framework.TestCase ;
import junit.framework.TestSuite ;
@@ -117,6 +121,11 @@ public class ConcurrencyTest extends Te
try {
// Iterate over all statements
StmtIterator it = model.listStatements();
+
+// // Debug
+// List<Statement> s = it.toList();
+// it = new StmtIteratorImpl(s.iterator()) ;
+
while(it.hasNext()) it.nextStatement();
it.close();
@@ -155,26 +164,26 @@ public class ConcurrencyTest extends Te
if(!executorService.isTerminated()) {
/* uncomment this block to perform deadlock checking, only on java 1.6 */
-// // Check for deadlock
-// ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
-// long[] ids = tmx.findDeadlockedThreads();
-// if (ids != null) {
-// ThreadInfo[] infos = tmx.getThreadInfo(ids, true, true);
-//
-// System.err.println("*** Deadlocked threads");
-// for (ThreadInfo ti : infos) {
-// System.err.println("Thread \"" + ti.getThreadName() + "\" id=" + ti.getThreadId() + " "
-// + ti.getThreadState().toString());
-// System.err.println("Lock name: " + ti.getLockName() + " owned by \""
-// + ti.getLockOwnerName() + "\" id=" + ti.getLockOwnerId());
-// System.err.println("\nStack trace:");
-// for(StackTraceElement st : ti.getStackTrace())
-// System.err.println(" " + st.getClassName() + "." + st.getMethodName()
-// + " (" + st.getFileName() + ":" + st.getLineNumber() + ")" );
-// System.err.println();
-// }
-// }
-// Assert.assertTrue("Deadlock detected!", false);
+ // Check for deadlock
+ ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
+ long[] ids = tmx.findDeadlockedThreads();
+ if (ids != null) {
+ ThreadInfo[] infos = tmx.getThreadInfo(ids, true, true);
+
+ System.err.println("*** Deadlocked threads");
+ for (ThreadInfo ti : infos) {
+ System.err.println("Thread \"" + ti.getThreadName() + "\" id=" + ti.getThreadId() + " "
+ + ti.getThreadState().toString());
+ System.err.println("Lock name: " + ti.getLockName() + " owned by \""
+ + ti.getLockOwnerName() + "\" id=" + ti.getLockOwnerId());
+ System.err.println("\nStack trace:");
+ for(StackTraceElement st : ti.getStackTrace())
+ System.err.println(" " + st.getClassName() + "." + st.getMethodName()
+ + " (" + st.getFileName() + ":" + st.getLineNumber() + ")" );
+ System.err.println();
+ }
+ }
+ Assert.assertTrue("Deadlock detected!", false);
/* end deadlock block */
assertTrue("Failed to terminate execution", false);
}
Modified: jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/reasoner/rulesys/test/OWLWGTester.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/reasoner/rulesys/test/OWLWGTester.java?rev=1416206&r1=1416205&r2=1416206&view=diff
==============================================================================
--- jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/reasoner/rulesys/test/OWLWGTester.java (original)
+++ jena/branches/jena-core-simplified/src/test/java/com/hp/hpl/jena/reasoner/rulesys/test/OWLWGTester.java Sun Dec 2 17:46:51 2012
@@ -18,23 +18,26 @@
package com.hp.hpl.jena.reasoner.rulesys.test;
-import com.hp.hpl.jena.reasoner.*;
-import com.hp.hpl.jena.reasoner.rulesys.FBRuleInfGraph;
-import com.hp.hpl.jena.reasoner.test.WGReasonerTester;
-import com.hp.hpl.jena.util.FileManager;
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.vocabulary.*;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.query.*;
-
-import com.hp.hpl.jena.shared.*;
-
-import junit.framework.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.*;
-import java.util.*;
+import java.io.BufferedReader ;
+import java.io.FileReader ;
+import java.io.IOException ;
+import java.io.Reader ;
+
+import junit.framework.Assert ;
+import junit.framework.TestCase ;
+import org.slf4j.Logger ;
+import org.slf4j.LoggerFactory ;
+
+import com.hp.hpl.jena.rdf.model.* ;
+import com.hp.hpl.jena.reasoner.InfGraph ;
+import com.hp.hpl.jena.reasoner.Reasoner ;
+import com.hp.hpl.jena.reasoner.ReasonerFactory ;
+import com.hp.hpl.jena.reasoner.rulesys.FBRuleInfGraph ;
+import com.hp.hpl.jena.reasoner.test.WGReasonerTester ;
+import com.hp.hpl.jena.shared.JenaException ;
+import com.hp.hpl.jena.util.FileManager ;
+import com.hp.hpl.jena.vocabulary.RDF ;
+import com.hp.hpl.jena.vocabulary.ReasonerVocabulary ;
/**
@@ -195,10 +198,10 @@ public class OWLWGTester {
// Check the results against the official conclusions
boolean correct = true;
if (testType.equals(PositiveEntailmentTest)) {
- correct = testConclusions(conclusions.getGraph(), result.getGraph());
+ correct = WGReasonerTester.testConclusions(conclusions.getGraph(), result.getGraph());
} else {
// A negative entailment check
- correct = !testConclusions(conclusions.getGraph(), result.getGraph());
+ correct = !WGReasonerTester.testConclusions(conclusions.getGraph(), result.getGraph());
}
long t2 = System.currentTimeMillis();
timeCost += (t2-t1);
@@ -252,17 +255,6 @@ public class OWLWGTester {
return result;
}
- /**
- * Test a conclusions graph against a result graph. This works by
- * translating the conclusions graph into a find query which contains one
- * variable for each distinct bNode in the conclusions graph.
- */
- private boolean testConclusions(Graph conclusions, Graph result) {
- QueryHandler qh = result.queryHandler();
- GraphQuery query = WGReasonerTester.graphToQuery(conclusions);
- Iterator<Domain> i = qh.prepareBindings(query, new Node[] {}).executeBindings();
- return i.hasNext();
- }
/**
* Log (info level) some summary information on the timecost of the tests.