You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by sa...@apache.org on 2013/01/29 21:27:39 UTC
svn commit: r1440101 [10/16] - in /jena/branches/streaming-update: ./
apache-jena-libs/ apache-jena/ apache-jena/bat/ apache-jena/bin/ jena-arq/
jena-arq/src-examples/arq/examples/riot/ jena-arq/src/main/java/arq/
jena-arq/src/main/java/arq/cmdline/ je...
Modified: jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java?rev=1440101&r1=1440100&r2=1440101&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java (original)
+++ jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/AbstractTestReifiedStatements.java Tue Jan 29 20:27:24 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);
+ }
+}
Modified: jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java?rev=1440101&r1=1440100&r2=1440101&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java (original)
+++ jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ModelTestBase.java Tue Jan 29 20:27:24 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,190 +18,261 @@
package com.hp.hpl.jena.rdf.model.test;
-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.Literal;
+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.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+import com.hp.hpl.jena.rdf.model.Statement;
+import com.hp.hpl.jena.shared.PrefixMapping;
+import com.hp.hpl.jena.util.CollectionFactory;
-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 ;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import junit.framework.Assert;
/**
- provides useful functionality for testing models, eg building small models
- from strings, testing equality, etc.
-
- @author kers
-*/
+ * provides useful functionality for testing models, eg building small models
+ * from strings, testing equality, etc.
+ */
public class ModelTestBase extends GraphTestBase
- {
- public ModelTestBase(String name)
- { super(name); }
-
- protected static Model aModel = extendedModel();
-
- protected static final Model empty = ModelFactory.createDefaultModel();
-
- protected static Model extendedModel()
- {
- Model result = ModelFactory.createDefaultModel();
- result.setNsPrefixes( PrefixMapping.Extended );
- return result;
- }
-
- protected static String nice( RDFNode n )
- { return nice( n.asNode() ); }
-
- /**
- create a Statement in a given Model with (S, P, O) extracted by parsing a string.
-
- @param m the model the statement is attached to
- @param an "S P O" string.
- @return m.createStatement(S, P, O)
- */
- public static Statement statement( Model m, String fact )
- {
- StringTokenizer st = new StringTokenizer( fact );
- Resource sub = resource( m, st.nextToken() );
- Property pred = property( m, st.nextToken() );
- RDFNode obj = rdfNode( m, st.nextToken() );
- return m.createStatement( sub, pred, obj );
- }
-
- public static Statement statement( String fact )
- { return statement( aModel, fact ); }
-
- public static RDFNode rdfNode( Model m, String s )
- { return m.asRDFNode( NodeCreateUtils.create( m, s ) ); }
-
- public static <T extends RDFNode> T rdfNode( Model m, String s, Class<T> c )
- { return rdfNode( m, s ).as( c ); }
-
- protected static Resource resource()
- { return ResourceFactory.createResource(); }
-
- public static Resource resource( String s )
- { return resource( aModel, s ); }
-
- public static Resource resource( Model m, String s )
- { return (Resource) rdfNode( m, s ); }
-
- public static Property property( String s )
- { return property( aModel, s ); }
-
- public static Property property( Model m, String s )
- { return rdfNode( m, s ).as( Property.class ); }
-
- public static Literal literal( Model m, String s )
- { return rdfNode( m, s ).as( Literal.class ); }
-
- /**
- Create an array of Statements parsed from a semi-separated string.
-
- @param m a model to serve as a statement factory
- @param facts a sequence of semicolon-separated "S P O" facts
- @return a Statement[] of the (S P O) statements from the string
- */
- public static Statement [] statements( Model m, String facts )
- {
- ArrayList<Statement> sl = new ArrayList<Statement>();
- StringTokenizer st = new StringTokenizer( facts, ";" );
- while (st.hasMoreTokens()) sl.add( statement( m, st.nextToken() ) );
- return sl.toArray( new Statement[sl.size()] );
- }
-
- /**
- Create an array of Resources from a whitespace-separated string
-
- @param m a model to serve as a resource factory
- @param items a whitespace-separated sequence to feed to resource
- @return a RDFNode[] of the parsed resources
- */
- public static Resource [] resources( Model m, String items )
- {
- ArrayList<Resource> rl = new ArrayList<Resource>();
- StringTokenizer st = new StringTokenizer( items );
- while (st.hasMoreTokens()) rl.add( resource( m, st.nextToken() ) );
- return rl.toArray( new Resource[rl.size()] );
- }
-
- /**
- Answer the set of resources given by the space-separated
- <code>items</code> string. Each resource specification is interpreted
- as per <code>resource</code>.
- */
- public static Set<Resource> resourceSet( String items )
- {
- Set<Resource> result = new HashSet<Resource>();
- StringTokenizer st = new StringTokenizer( items );
- while (st.hasMoreTokens()) result.add( resource( st.nextToken() ) );
- return result;
- }
-
- /**
- add to a model all the statements expressed by a string.
-
- @param m the model to be updated
- @param facts a sequence of semicolon-separated "S P O" facts
- @return the updated model
- */
- public static Model modelAdd( Model m, String facts )
- {
- StringTokenizer semis = new StringTokenizer( facts, ";" );
- while (semis.hasMoreTokens()) m.add( statement( m, semis.nextToken() ) );
- return m;
- }
-
- /**
- makes a model initialised with statements parsed from a string.
-
- @param facts a string in semicolon-separated "S P O" format
- @return a model containing those facts
- */
- public static Model modelWithStatements( String facts )
- { return modelAdd( createModel( ), facts ); }
-
- /**
- make a model, give it Extended prefixes
- */
- public static Model createModel( )
- {
- Model result = ModelFactory.createDefaultModel( );
- result.setNsPrefixes( PrefixMapping.Extended );
- return result;
- }
-
- /**
- Answer a default model; it exists merely to abbreviate the rather long explicit
- invocation.
-
- @return a new default [aka memory-based] model
- */
- public static Model createMemModel()
- { return ModelFactory.createDefaultModel(); }
-
- /**
- test that two models are isomorphic and fail if they are not.
-
- @param title a String appearing at the beginning of the failure message
- @param wanted the model value that is expected
- @param got the model value to check
- @exception if the models are not isomorphic
- */
- public static void assertIsoModels( String title, Model wanted, Model got )
- {
- if (wanted.isIsomorphicWith( got ) == false)
- {
- Map<Node, Object> map = CollectionFactory.createHashedMap();
- fail( title + ": expected " + nice( wanted.getGraph(), map ) + "\n but had " + nice( got.getGraph(), map ) );
- }
- }
-
- /**
- Fail if the two models are not isomorphic. See assertIsoModels(String,Model,Model).
- */
- public static void assertIsoModels( Model wanted, Model got )
- { assertIsoModels( "models must be isomorphic", wanted, got ); }
-
- }
+{
+ protected static Model aModel = ModelTestBase.extendedModel();
+
+ protected static final Model empty = ModelFactory.createDefaultModel();
+
+ /**
+ * Fail if the two models are not isomorphic. See
+ * assertIsoModels(String,Model,Model).
+ */
+ public static void assertIsoModels( final Model wanted, final Model got )
+ {
+ ModelTestBase.assertIsoModels("models must be isomorphic", wanted, got);
+ }
+
+ /**
+ * test that two models are isomorphic and fail if they are not.
+ *
+ * @param title
+ * a String appearing at the beginning of the failure message
+ * @param wanted
+ * the model value that is expected
+ * @param got
+ * the model value to check
+ * @exception if
+ * the models are not isomorphic
+ */
+ public static void assertIsoModels( final String title, final Model wanted,
+ final Model got )
+ {
+ if (wanted.isIsomorphicWith(got) == false)
+ {
+ final Map<Node, Object> map = CollectionFactory.createHashedMap();
+ Assert.fail(title + ": expected "
+ + GraphTestBase.nice(wanted.getGraph(), map)
+ + "\n but had " + GraphTestBase.nice(got.getGraph(), map));
+ }
+ }
+
+ /**
+ * Answer a default model; it exists merely to abbreviate the rather long
+ * explicit
+ * invocation.
+ *
+ * @return a new default [aka memory-based] model
+ */
+ public static Model createMemModel()
+ {
+ return ModelFactory.createDefaultModel();
+ }
+
+ /**
+ * make a model, give it Extended prefixes
+ */
+ public static Model createModel()
+ {
+ final Model result = ModelFactory.createDefaultModel();
+ result.setNsPrefixes(PrefixMapping.Extended);
+ return result;
+ }
+
+ protected static Model extendedModel()
+ {
+ final Model result = ModelFactory.createDefaultModel();
+ result.setNsPrefixes(PrefixMapping.Extended);
+ return result;
+ }
+
+ public static Literal literal( final Model m, final String s )
+ {
+ return ModelTestBase.rdfNode(m, s).as(Literal.class);
+ }
+
+ /**
+ * add to a model all the statements expressed by a string.
+ *
+ * @param m
+ * the model to be updated
+ * @param facts
+ * a sequence of semicolon-separated "S P O" facts
+ * @return the updated model
+ */
+ public static Model modelAdd( final Model m, final String facts )
+ {
+ final StringTokenizer semis = new StringTokenizer(facts, ";");
+ while (semis.hasMoreTokens())
+ {
+ m.add(ModelTestBase.statement(m, semis.nextToken()));
+ }
+ return m;
+ }
+
+ /**
+ * makes a model initialised with statements parsed from a string.
+ *
+ * @param facts
+ * a string in semicolon-separated "S P O" format
+ * @return a model containing those facts
+ */
+ public static Model modelWithStatements( final String facts )
+ {
+ return ModelTestBase.modelAdd(ModelTestBase.createModel(), facts);
+ }
+
+ protected static String nice( final RDFNode n )
+ {
+ return GraphTestBase.nice(n.asNode());
+ }
+
+ public static Property property( final Model m, final String s )
+ {
+ return ModelTestBase.rdfNode(m, s).as(Property.class);
+ }
+
+ public static Property property( final String s )
+ {
+ return ModelTestBase.property(ModelTestBase.aModel, s);
+ }
+
+ public static RDFNode rdfNode( final Model m, final String s )
+ {
+ return m.asRDFNode(NodeCreateUtils.create(m, s));
+ }
+
+ public static <T extends RDFNode> T rdfNode( final Model m, final String s,
+ final Class<T> c )
+ {
+ return ModelTestBase.rdfNode(m, s).as(c);
+ }
+
+ protected static Resource resource()
+ {
+ return ResourceFactory.createResource();
+ }
+
+ public static Resource resource( final Model m, final String s )
+ {
+ return (Resource) ModelTestBase.rdfNode(m, s);
+ }
+
+ public static Resource resource( final String s )
+ {
+ return ModelTestBase.resource(ModelTestBase.aModel, s);
+ }
+
+ /**
+ * Create an array of Resources from a whitespace-separated string
+ *
+ * @param m
+ * a model to serve as a resource factory
+ * @param items
+ * a whitespace-separated sequence to feed to resource
+ * @return a RDFNode[] of the parsed resources
+ */
+ public static Resource[] resources( final Model m, final String items )
+ {
+ final ArrayList<Resource> rl = new ArrayList<Resource>();
+ final StringTokenizer st = new StringTokenizer(items);
+ while (st.hasMoreTokens())
+ {
+ rl.add(ModelTestBase.resource(m, st.nextToken()));
+ }
+ return rl.toArray(new Resource[rl.size()]);
+ }
+
+ /**
+ * Answer the set of resources given by the space-separated
+ * <code>items</code> string. Each resource specification is interpreted
+ * as per <code>resource</code>.
+ */
+ public static Set<Resource> resourceSet( final String items )
+ {
+ final Set<Resource> result = new HashSet<Resource>();
+ final StringTokenizer st = new StringTokenizer(items);
+ while (st.hasMoreTokens())
+ {
+ result.add(ModelTestBase.resource(st.nextToken()));
+ }
+ return result;
+ }
+
+ /**
+ * create a Statement in a given Model with (S, P, O) extracted by parsing a
+ * string.
+ *
+ * @param m
+ * the model the statement is attached to
+ * @param an
+ * "S P O" string.
+ * @return m.createStatement(S, P, O)
+ */
+ public static Statement statement( final Model m, final String fact )
+ {
+ final StringTokenizer st = new StringTokenizer(fact);
+ final Resource sub = ModelTestBase.resource(m, st.nextToken());
+ final Property pred = ModelTestBase.property(m, st.nextToken());
+ final RDFNode obj = ModelTestBase.rdfNode(m, st.nextToken());
+ return m.createStatement(sub, pred, obj);
+ }
+
+ public static Statement statement( final String fact )
+ {
+ return ModelTestBase.statement(ModelTestBase.aModel, fact);
+ }
+
+ /**
+ * Create an array of Statements parsed from a semi-separated string.
+ *
+ * @param m
+ * a model to serve as a statement factory
+ * @param facts
+ * a sequence of semicolon-separated "S P O" facts
+ * @return a Statement[] of the (S P O) statements from the string
+ */
+ public static Statement[] statements( final Model m, final String facts )
+ {
+ final ArrayList<Statement> sl = new ArrayList<Statement>();
+ final StringTokenizer st = new StringTokenizer(facts, ";");
+ while (st.hasMoreTokens())
+ {
+ sl.add(ModelTestBase.statement(m, st.nextToken()));
+ }
+ return sl.toArray(new Statement[sl.size()]);
+ }
+
+ public ModelTestBase( final String name )
+ {
+ super(name);
+ }
+
+}
Modified: jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestAnonID.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestAnonID.java?rev=1440101&r1=1440100&r2=1440101&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestAnonID.java (original)
+++ jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestAnonID.java Tue Jan 29 20:27:24 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.
@@ -22,74 +22,79 @@ import com.hp.hpl.jena.rdf.model.AnonId;
import com.hp.hpl.jena.shared.impl.JenaParameters;
import com.hp.hpl.jena.test.JenaTestBase;
+import junit.framework.Assert;
import junit.framework.TestSuite;
/**
* Test for anonID generation. (Originally test for the debugging hack
* that switches off anonID generation.)
- *
- * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
- * @version $Revision: 1.1 $ on $Date: 2009-06-29 08:55:33 $
*/
-public class TestAnonID extends JenaTestBase {
-
- /**
- * Boilerplate for junit
- */
- public TestAnonID( String name ) {
- super( name );
- }
-
- /**
- * Boilerplate for junit.
- * This is its own test suite
- */
- public static TestSuite suite() {
- return new TestSuite( TestAnonID.class );
- }
-
- /**
- * Check that anonIDs are distinct whichever state the flag is in.
- */
- public void testAnonID() {
- boolean prior = JenaParameters.disableBNodeUIDGeneration;
- try
- {
- JenaParameters.disableBNodeUIDGeneration = false;
- doTestAnonID();
- JenaParameters.disableBNodeUIDGeneration = true;
- doTestAnonID();
- }
- finally
- { JenaParameters.disableBNodeUIDGeneration = prior; }
- }
-
- /**
- Check that anonIDs are distinct whichever state the flag is in.
- */
- public void doTestAnonID() {
- AnonId id1 = AnonId.create();
- AnonId id2 = AnonId.create();
- AnonId id3 = AnonId.create();
- AnonId id4 = AnonId.create();
-
- assertDiffer( id1, id2 );
- assertDiffer( id1, id3 );
- assertDiffer( id1, id4 );
- assertDiffer( id2, id3 );
- assertDiffer( id2, id4 );
- }
-
- /**
- Test that creation of an AnonId from an AnonId string preserves that
- string and is equal to the original AnonId.
- */
- public void testAnonIdPreserved()
- {
- AnonId anon = AnonId.create();
- String id = anon.toString();
- assertEquals( anon, AnonId.create( id ) );
- assertEquals( id, AnonId.create( id ).toString() );
- }
+public class TestAnonID extends JenaTestBase
+{
+
+ /**
+ * Boilerplate for junit.
+ * This is its own test suite
+ */
+ public static TestSuite suite()
+ {
+ return new TestSuite(TestAnonID.class);
+ }
+
+ /**
+ * Boilerplate for junit
+ */
+ public TestAnonID( final String name )
+ {
+ super(name);
+ }
+
+ /**
+ * Check that anonIDs are distinct whichever state the flag is in.
+ */
+ public void doTestAnonID()
+ {
+ final AnonId id1 = AnonId.create();
+ final AnonId id2 = AnonId.create();
+ final AnonId id3 = AnonId.create();
+ final AnonId id4 = AnonId.create();
+
+ JenaTestBase.assertDiffer(id1, id2);
+ JenaTestBase.assertDiffer(id1, id3);
+ JenaTestBase.assertDiffer(id1, id4);
+ JenaTestBase.assertDiffer(id2, id3);
+ JenaTestBase.assertDiffer(id2, id4);
+ }
+
+ /**
+ * Check that anonIDs are distinct whichever state the flag is in.
+ */
+ public void testAnonID()
+ {
+ final boolean prior = JenaParameters.disableBNodeUIDGeneration;
+ try
+ {
+ JenaParameters.disableBNodeUIDGeneration = false;
+ doTestAnonID();
+ JenaParameters.disableBNodeUIDGeneration = true;
+ doTestAnonID();
+ }
+ finally
+ {
+ JenaParameters.disableBNodeUIDGeneration = prior;
+ }
+ }
+
+ /**
+ * Test that creation of an AnonId from an AnonId string preserves that
+ * string and is equal to the original AnonId.
+ */
+ public void testAnonIdPreserved()
+ {
+ final AnonId anon = AnonId.create();
+ final String id = anon.toString();
+ Assert.assertEquals(anon, AnonId.create(id));
+ Assert.assertEquals(id, AnonId.create(id).toString());
+ }
}
Modified: jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContainers.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContainers.java?rev=1440101&r1=1440100&r2=1440101&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContainers.java (original)
+++ jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContainers.java Tue Jan 29 20:27:24 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,31 +18,34 @@
package com.hp.hpl.jena.rdf.model.test;
-import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.rdf.model.Container;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.Seq;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
-import junit.framework.TestSuite;
+import junit.framework.Assert;
/**
- @author kers
-*/
-public class TestContainers extends ModelTestBase
- {
- public TestContainers( String name )
- { super( name ); }
-
- public static TestSuite suite()
- { return new TestSuite( TestContainers.class ); }
-
- /**
- Contributed by Damian, turned into a test case by Chris.
- */
- public void testCanAsContainer()
- {
- String seqUri = "http://example.com/#seq";
- Model model = ModelFactory.createDefaultModel();
- Seq seq = model.createSeq( seqUri );
- Resource res = model.createResource( seqUri );
- assertTrue( res.canAs( Seq.class ) );
- assertTrue( res.canAs( Container.class ) );
- }
- }
+ * Tests for containers.
+ */
+public class TestContainers extends AbstractModelTestBase
+{
+
+ public TestContainers( final TestingModelFactory modelFactory,
+ final String name )
+ {
+ super(modelFactory, name);
+ }
+
+ /**
+ * Contributed by Damian, turned into a test case by Chris.
+ */
+ public void testCanAsContainer()
+ {
+ final String seqUri = "http://example.com/#seq";
+ model.createSeq(seqUri);
+ final Resource res = model.createResource(seqUri);
+ Assert.assertTrue(res.canAs(Seq.class));
+ Assert.assertTrue(res.canAs(Container.class));
+ }
+}
Modified: jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContains.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContains.java?rev=1440101&r1=1440100&r2=1440101&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContains.java (original)
+++ jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestContains.java Tue Jan 29 20:27:24 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,82 +18,101 @@
package com.hp.hpl.jena.rdf.model.test;
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.graph.Factory;
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.impl.ModelCom;
+import com.hp.hpl.jena.rdf.model.test.helpers.ModelHelper;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
-import junit.framework.*;
+import junit.framework.Assert;
-/**
- @author kers
-*/
-public class TestContains extends ModelTestBase
- {
- public TestContains( String name )
- { super( name ); }
-
- public static TestSuite suite()
- { return new TestSuite( TestContains.class ); }
-
- public void testContains( boolean yes, String facts, String resource )
- {
- Model m = modelWithStatements( facts );
- RDFNode r = rdfNode( m, resource );
- if (modelWithStatements( facts ).containsResource( r ) != yes)
- fail( "[" + facts + "] should" + (yes ? "" : " not") + " contain " + resource );
- }
-
- public void testContains()
- {
- testContains( false, "", "x" );
- testContains( false, "a R b", "x" );
- testContains( false, "a R b; c P d", "x" );
- /* */
- testContains( false, "a R b", "z" );
- /* */
- testContains( true, "x R y", "x" );
- testContains( true, "a P b", "P" );
- testContains( true, "i Q j", "j" );
- testContains( true, "x R y; a P b; i Q j", "y" );
- /* */
- testContains( true, "x R y; a P b; i Q j", "y" );
- testContains( true, "x R y; a P b; i Q j", "R" );
- testContains( true, "x R y; a P b; i Q j", "a" );
- }
-
- private Resource res( String uri )
- { return ResourceFactory.createResource( "eh:/" + uri ); }
-
- private Property prop( String uri )
- { return ResourceFactory.createProperty( "eh:/" + uri ); }
-
- public void testContainsWithNull()
- {
- testCWN( false, "", null, null, null );
- testCWN( true, "x R y", null, null, null );
- testCWN( false, "x R y", null, null, res( "z" ) );
- testCWN( true, "x RR y", res( "x" ), prop( "RR" ), null );
- testCWN( true, "a BB c", null, prop( "BB" ), res( "c" ) );
- testCWN( false, "a BB c", null, prop( "ZZ" ), res( "c" ) );
- }
-
- public void testCWN( boolean yes, String facts, Resource S, Property P, RDFNode O )
- { assertEquals( yes, modelWithStatements( facts ).contains( S, P, O ) ); }
-
- public void testModelComContainsSPcallsContainsSPO()
- {
- Graph g = Factory.createDefaultGraph();
- final boolean [] wasCalled = {false};
- Model m = new ModelCom( g )
- {
- @Override
- public boolean contains( Resource s, Property p, RDFNode o )
- {
- wasCalled[0] = true;
- return super.contains( s, p, o );
- }
- };
- assertFalse( m.contains( resource( "r" ), property( "p" ) ) );
- assertTrue( "contains(S,P) should call contains(S,P,O)", wasCalled[0] );
- }
- }
+public class TestContains extends AbstractModelTestBase
+{
+ public TestContains( final TestingModelFactory modelFactory,
+ final String name )
+ {
+ super(modelFactory, name);
+ }
+
+ private Property prop( final String uri )
+ {
+ return ResourceFactory.createProperty("eh:/" + uri);
+ }
+
+ private Resource res( final String uri )
+ {
+ return ResourceFactory.createResource("eh:/" + uri);
+ }
+
+ public void testContains()
+ {
+ testContains(false, "", "x");
+ testContains(false, "a R b", "x");
+ testContains(false, "a R b; c P d", "x");
+ /* */
+ testContains(false, "a R b", "z");
+ /* */
+ testContains(true, "x R y", "x");
+ testContains(true, "a P b", "P");
+ testContains(true, "i Q j", "j");
+ testContains(true, "x R y; a P b; i Q j", "y");
+ /* */
+ testContains(true, "x R y; a P b; i Q j", "y");
+ testContains(true, "x R y; a P b; i Q j", "R");
+ testContains(true, "x R y; a P b; i Q j", "a");
+ }
+
+ public void testContains( final boolean yes, final String facts,
+ final String resource )
+ {
+ final Model m = ModelHelper.modelWithStatements(this, facts);
+ final RDFNode r = ModelHelper.rdfNode(m, resource);
+ if (ModelHelper.modelWithStatements(this, facts).containsResource(r) != yes)
+ {
+ Assert.fail("[" + facts + "] should" + (yes ? "" : " not")
+ + " contain " + resource);
+ }
+ }
+
+ public void testContainsWithNull()
+ {
+ testCWN(false, "", null, null, null);
+ testCWN(true, "x R y", null, null, null);
+ testCWN(false, "x R y", null, null, res("z"));
+ testCWN(true, "x RR y", res("x"), prop("RR"), null);
+ testCWN(true, "a BB c", null, prop("BB"), res("c"));
+ testCWN(false, "a BB c", null, prop("ZZ"), res("c"));
+ }
+
+ public void testCWN( final boolean yes, final String facts,
+ final Resource S, final Property P, final RDFNode O )
+ {
+ Assert.assertEquals(yes, ModelHelper.modelWithStatements(this, facts)
+ .contains(S, P, O));
+ }
+
+ public void testModelComContainsSPcallsContainsSPO()
+ {
+ final Graph g = Factory.createDefaultGraph();
+ final boolean[] wasCalled = { false };
+ // FIXME change to dynamic proxy
+ final Model m = new ModelCom(g) {
+ @Override
+ public boolean contains( final Resource s, final Property p,
+ final RDFNode o )
+ {
+ wasCalled[0] = true;
+ return super.contains(s, p, o);
+ }
+ };
+ Assert.assertFalse(m.contains(ModelHelper.resource("r"),
+ ModelHelper.property("p")));
+ Assert.assertTrue("contains(S,P) should call contains(S,P,O)",
+ wasCalled[0]);
+ }
+}
Modified: jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestIterators.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestIterators.java?rev=1440101&r1=1440100&r2=1440101&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestIterators.java (original)
+++ jena/branches/streaming-update/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestIterators.java Tue Jan 29 20:27:24 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,37 +18,290 @@
package com.hp.hpl.jena.rdf.model.test;
-import com.hp.hpl.jena.graph.test.*;
-import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.NodeIterator;
+import com.hp.hpl.jena.rdf.model.NsIterator;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.ResIterator;
+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.rdf.model.test.helpers.TestingModelFactory;
+import com.hp.hpl.jena.vocabulary.RDF;
-import junit.framework.TestSuite;
+import junit.framework.Assert;
-/**
- @author kers
-*/
-public class TestIterators extends GraphTestBase
- {
- public static TestSuite suite()
- { return new TestSuite( TestIterators.class ); }
-
- public TestIterators(String name)
- { super(name); }
-
- /**
- bug detected in StatementIteratorImpl - next does not
- advance current, so remove doesn't work with next;
- this test should expose the bug.
- */
- public void testIterators()
- {
- Model m = ModelFactory.createDefaultModel();
- Resource S = m.createResource( "S" );
- Property P = m.createProperty( "P" );
- RDFNode O = m.createResource( "O " );
- m.add( S, P, O );
- StmtIterator it = m.listStatements();
- it.next();
- it.remove();
- assertEquals( "", 0, m.size() );
- }
- }
+public class TestIterators extends AbstractModelTestBase
+{
+ int num = 5;
+ Resource subject[] = new Resource[num];
+ Property predicate[] = new Property[num];
+ Statement stmts[] = new Statement[num * num];
+
+ String suri = "http://aldabaran/test6/s";
+ String puri = "http://aldabaran/test6/";
+
+ public TestIterators( final TestingModelFactory modelFactory,
+ final String name )
+ {
+ super(modelFactory, name);
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ for (int i = 0; i < num; i++)
+ {
+ subject[i] = model.createResource(suri + Integer.toString(i));
+ predicate[i] = model
+ .createProperty(puri + Integer.toString(i), "p");
+ }
+
+ for (int i = 0; i < num; i++)
+ {
+ for (int j = 0; j < num; j++)
+ {
+ final Statement stmt = model.createStatement(subject[i],
+ predicate[j], model.createTypedLiteral((i * num) + j));
+ model.add(stmt);
+ model.add(stmt);
+ stmts[(i * num) + j] = stmt;
+ }
+ }
+ }
+
+ /**
+ * bug detected in StatementIteratorImpl - next does not
+ * advance current, so remove doesn't work with next;
+ * this test should expose the bug.
+ */
+ public void testIteratorRemove()
+ {
+ final StmtIterator it = model.listStatements();
+ try
+ {
+ while (it.hasNext())
+ {
+ it.next();
+ it.remove();
+ }
+ Assert.assertEquals("Remove failed", 0, model.size());
+ }
+ finally
+ {
+ it.close();
+ }
+
+ }
+
+ public void testListObjects()
+ {
+ int count = 0;
+ NodeIterator iter;
+ iter = model.listObjects();
+ while (iter.hasNext())
+ {
+ iter.nextNode();
+ count++;
+ }
+ Assert.assertEquals(num * num, count);
+ }
+
+ public void testNamespaceIterator()
+ {
+ final boolean predf[] = new boolean[num];
+ for (int i = 0; i < num; i++)
+ {
+ predf[i] = false;
+ }
+ final NsIterator nIter = model.listNameSpaces();
+ while (nIter.hasNext())
+ {
+ final String ns = nIter.nextNs();
+ boolean found = false;
+ for (int i = 0; i < num; i++)
+ {
+ if (ns.equals(predicate[i].getNameSpace()))
+ {
+ found = true;
+ Assert.assertFalse("Should not have found " + predicate[i]
+ + " already.", predf[i]);
+ predf[i] = true;
+ }
+ }
+ Assert.assertTrue("Should have found " + ns, found);
+ }
+ for (int i = 0; i < num; i++)
+ {
+ Assert.assertTrue("Should have found " + predicate[i], predf[i]);
+ }
+ }
+
+ public void testObjectsOfProperty()
+ {
+
+ NodeIterator iter;
+ final boolean[] object = new boolean[num * num];
+ for (int i = 0; i < (num * num); i++)
+ {
+ object[i] = false;
+ }
+ iter = model.listObjectsOfProperty(predicate[0]);
+ while (iter.hasNext())
+ {
+ final Literal l = (Literal) iter.nextNode();
+ final int i = l.getInt();
+ object[i] = true;
+ }
+ for (int i = 0; i < (num * num); i++)
+ {
+ if ((i % num) == 0)
+ {
+ Assert.assertTrue(object[i]);
+ }
+ else
+ {
+ Assert.assertFalse(object[i]);
+ }
+ }
+
+ }
+
+ public void testObjectsOfPropertyAndValue()
+ {
+ NodeIterator iter;
+ final boolean[] object = new boolean[num];
+ final Resource subj = model.createResource();
+ for (int i = 0; i < num; i++)
+ {
+ model.addLiteral(subj, RDF.value, i);
+ object[i] = false;
+ }
+
+ iter = model.listObjectsOfProperty(subj, RDF.value);
+ while (iter.hasNext())
+ {
+ final int i = ((Literal) iter.nextNode()).getInt();
+ object[i] = true;
+ }
+ for (int i = 0; i < (num); i++)
+ {
+ Assert.assertTrue(object[i]);
+ }
+ }
+
+ public void testResourceIterator()
+ {
+
+ final boolean subjf[] = new boolean[num];
+
+ for (int i = 0; i < num; i++)
+ {
+ subjf[i] = false;
+ }
+
+ boolean found = false;
+ final ResIterator rIter = model.listSubjects();
+ while (rIter.hasNext())
+ {
+ final Resource subj = rIter.nextResource();
+ found = false;
+ for (int i = 0; i < num; i++)
+ {
+ if (subj.equals(subject[i]))
+ {
+ found = true;
+ Assert.assertFalse("Should not have found " + subject[i]
+ + " already.", subjf[i]);
+ subjf[i] = true;
+ }
+ }
+ Assert.assertTrue("Should have found " + subj, found);
+ }
+ for (int i = 0; i < num; i++)
+ {
+ Assert.assertTrue("Should have found " + subject[i], subjf[i]);
+ }
+
+ // System.err.println(
+ // "WARNING: listNameSpace testing wonky for the moment" );
+ // NsIterator nIter = model.listNameSpaces();
+ // HashSet fromIterator = new HashSet();
+ // HashSet fromPredicates = new HashSet();
+ // while (nIter.hasNext()) fromIterator.add( nIter.next() );
+ // for (int i = 0; i < num; i += 1) fromPredicates.add(
+ // predicate[i].getNameSpace() );
+ // if (fromIterator.equals( fromPredicates ))
+ // {}
+ // else
+ // {
+ // System.err.println( "| oh dear." );
+ // System.err.println( "| predicate namespaces: " + fromPredicates );
+ // System.err.println( "| iterator namespaces: " + fromIterator );
+ // }
+
+ }
+
+ public void testStatementIter()
+ {
+ final int numStmts = num * num;
+ final boolean stmtf[] = new boolean[numStmts];
+ Assert.assertEquals(numStmts, model.size());
+ for (int i = 0; i < numStmts; i++)
+ {
+ stmtf[i] = false;
+ }
+
+ final StmtIterator sIter = model.listStatements();
+ while (sIter.hasNext())
+ {
+ final Statement stmt = sIter.nextStatement();
+ boolean found = false;
+ for (int i = 0; i < numStmts; i++)
+ {
+ if (stmt.equals(stmts[i]))
+ {
+ found = true;
+ Assert.assertFalse("Should not have found " + stmts[i]
+ + " already.", stmtf[i]);
+ stmtf[i] = true;
+ }
+ }
+ Assert.assertTrue("Should have found " + stmt, found);
+ }
+ for (int i = 0; i < numStmts; i++)
+ {
+ Assert.assertTrue("Should have found " + stmts[i], stmtf[i]);
+ }
+ }
+ // SEE the tests in model.test: TestReifiedStatements and
+ // TestStatementResources
+ // {
+ // System.err.println(
+ // "WARNING: reification testing suppressed for the moment" );
+ // /* Reification is not working properly
+ //
+ // for (int i=0; i<num; i++) {
+ // stmtf[i] = false;
+ // model.add(stmts[i], predicate[i], i);
+ // }
+ // sIter = model.listReifiedStatements();
+ // while (sIter.hasNext()) {
+ // Statement stmt = sIter.next();
+ // found = false;
+ // for (int i=0; i<num; i++) {
+ // if (stmt.equals(stmts[i])) {
+ // found = true;
+ // if (stmtf[i]) error(test, 200);
+ // stmtf[i] = true;
+ // }
+ // }
+ // if (! found) error(test, 210);
+ // }
+ // for (int i=0; i<num; i++) {
+ // if (! stmtf[i]) error(test, 220+i);
+ // } */
+ // }
+}