jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1433184 [5/9] - in /jena/trunk/jena-core/src: main/java/com/hp/hpl/jena/graph/compose/ test/java/com/hp/hpl/jena/graph/compose/test/ test/java/com/hp/hpl/jena/graph/test/ test/java/com/hp/hpl/jena/mem/test/ test/java/com/hp/hpl/jena/rdf/ar...
Date Mon, 14 Jan 2013 22:38:37 GMT
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelExtract.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelExtract.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelExtract.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelExtract.java Mon Jan 14 22:38:35 2013
@@ -1,14 +1,14 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,122 +18,164 @@
 
 package com.hp.hpl.jena.rdf.model.test;
 
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.rdf.model.*;
-
-import junit.framework.TestSuite;
-
-/**
- @author hedgehog
-*/
-public class TestModelExtract extends ModelTestBase
-    {
-    protected static final StatementBoundary sbTrue = new StatementBoundaryBase()
-        { 
-        @Override
-        public boolean stopAt( Statement s ) { return true; } 
-        };
-        
-    protected static final StatementBoundary sbFalse = new StatementBoundaryBase()
-        { 
-        @Override
-        public boolean stopAt( Statement s ) { return false; }
-        };
-
-    public TestModelExtract( String name )
-        { super( name ); }
-    
-    public static TestSuite suite()
-        { return new TestSuite( TestModelExtract.class ); }
-
-    static class MockModelExtract extends ModelExtract
-        {
-        Node root;
-        Graph result;
-        Graph subject;
-       
-        public MockModelExtract( StatementBoundary b )
-            { super( b ); }
-            
-        public StatementBoundary getStatementBoundary()
-            { return boundary; }
-        
-        @Override
-        protected GraphExtract getGraphExtract( TripleBoundary b )
-            {
-            return new GraphExtract( b )
-                {
-                @Override
-                public Graph extractInto( Graph toUpdate, Node n, Graph source )
-                    {
-                    root = n;
-                    return result = super.extractInto( toUpdate, n, subject = source );
-                    }
-                };
-            }
-        }
-    
-    public void testAsTripleBoundary()
-        {
-        Model m = ModelFactory.createDefaultModel();
-        assertTrue( sbTrue.asTripleBoundary( m ).stopAt( triple( "x R y" ) ) );
-        assertFalse( sbFalse.asTripleBoundary( m ).stopAt( triple( "x R y" ) ) );
-        }
-    
-    public void testStatementTripleBoundaryAnon()
-        {
-        TripleBoundary anon = TripleBoundary.stopAtAnonObject;
-        assertSame( anon, new StatementTripleBoundary( anon ).asTripleBoundary( null ) );
-        assertFalse( new StatementTripleBoundary( anon ).stopAt( statement( "s P o" ) ) );
-        assertTrue( new StatementTripleBoundary( anon ).stopAt( statement( "s P _o" ) ) );
-        }
-    
-    public void testStatementContinueWith()
-        {
-        StatementBoundary sb = new StatementBoundaryBase()
-             { @Override
-            public boolean continueWith( Statement s ) { return false; } };
-        assertTrue( sb.stopAt( statement( "x pings y" ) ) );
-        }
-    
-    public void testStatementTripleBoundaryNowhere()
-        {
-        TripleBoundary nowhere = TripleBoundary.stopNowhere;
-        assertSame( nowhere, new StatementTripleBoundary( nowhere ).asTripleBoundary( null ) );
-        assertFalse( new StatementTripleBoundary( nowhere ).stopAt( statement( "s P _o" ) ) );
-        assertFalse( new StatementTripleBoundary( nowhere ).stopAt( statement( "s P o" ) ) );
-        }
-    public void testRemembersBoundary()
-        {
-        assertSame( sbTrue, new MockModelExtract( sbTrue ).getStatementBoundary() );
-        assertSame( sbFalse, new MockModelExtract( sbFalse ).getStatementBoundary() );
-        }
-    
-    public void testInvokesExtract()
-        {
-        MockModelExtract mock = new MockModelExtract( sbTrue );
-        Model source = modelWithStatements( "a R b" );
-        Model m = mock.extract( resource( "a" ), source );
-        assertEquals( node( "a" ), mock.root );
-        assertSame( mock.result, m.getGraph() );
-        assertSame( mock.subject, source.getGraph() );
-        }
-
-    /* (non-Javadoc)
-     * @see com.hp.hpl.jena.rdf.model.StatementBoundary#stopAt(com.hp.hpl.jena.rdf.model.Statement)
-     */
-    public boolean stopAt( Statement s )
-        {
-        // TODO Auto-generated method stub
-        return false;
-        }
-
-    /* (non-Javadoc)
-     * @see com.hp.hpl.jena.rdf.model.StatementBoundary#asTripleBoundary(com.hp.hpl.jena.rdf.model.Model)
-     */
-    public TripleBoundary asTripleBoundary( Model m )
-        {
-        // TODO Auto-generated method stub
-        return null;
-        }
-    }
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.GraphExtract;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.TripleBoundary;
+import com.hp.hpl.jena.graph.test.GraphTestBase;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelExtract;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Statement;
+import com.hp.hpl.jena.rdf.model.StatementBoundary;
+import com.hp.hpl.jena.rdf.model.StatementBoundaryBase;
+import com.hp.hpl.jena.rdf.model.StatementTripleBoundary;
+import com.hp.hpl.jena.rdf.model.test.helpers.ModelHelper;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+
+import junit.framework.Assert;
+
+public class TestModelExtract extends AbstractModelTestBase
+{
+	static class MockModelExtract extends ModelExtract
+	{
+		Node root;
+		Graph result;
+		Graph subject;
+
+		public MockModelExtract( final StatementBoundary b )
+		{
+			super(b);
+		}
+
+		@Override
+		protected GraphExtract getGraphExtract( final TripleBoundary b )
+		{
+			return new GraphExtract(b) {
+				@Override
+				public Graph extractInto( final Graph toUpdate, final Node n,
+						final Graph source )
+				{
+					root = n;
+					return result = super.extractInto(toUpdate, n,
+							subject = source);
+				}
+			};
+		}
+
+		public StatementBoundary getStatementBoundary()
+		{
+			return boundary;
+		}
+	}
+
+	protected static final StatementBoundary sbTrue = new StatementBoundaryBase() {
+		@Override
+		public boolean stopAt( final Statement s )
+		{
+			return true;
+		}
+	};
+
+	protected static final StatementBoundary sbFalse = new StatementBoundaryBase() {
+		@Override
+		public boolean stopAt( final Statement s )
+		{
+			return false;
+		}
+	};
+
+	public TestModelExtract( final TestingModelFactory modelFactory,
+			final String name )
+	{
+		super(modelFactory, name);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * com.hp.hpl.jena.rdf.model.StatementBoundary#asTripleBoundary(com.hp.hpl
+	 * .jena.rdf.model.Model)
+	 */
+	public TripleBoundary asTripleBoundary( final Model m )
+	{
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * com.hp.hpl.jena.rdf.model.StatementBoundary#stopAt(com.hp.hpl.jena.rdf
+	 * .model.Statement)
+	 */
+	public boolean stopAt( final Statement s )
+	{
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public void testAsTripleBoundary()
+	{
+		final Model m = ModelFactory.createDefaultModel();
+		Assert.assertTrue(TestModelExtract.sbTrue.asTripleBoundary(m).stopAt(
+				GraphTestBase.triple("x R y")));
+		Assert.assertFalse(TestModelExtract.sbFalse.asTripleBoundary(m).stopAt(
+				GraphTestBase.triple("x R y")));
+	}
+
+	public void testInvokesExtract()
+	{
+		final MockModelExtract mock = new MockModelExtract(
+				TestModelExtract.sbTrue);
+		final Model source = ModelHelper.modelWithStatements(this, "a R b");
+		final Model m = mock.extract(ModelHelper.resource("a"), source);
+		Assert.assertEquals(GraphTestBase.node("a"), mock.root);
+		Assert.assertSame(mock.result, m.getGraph());
+		Assert.assertSame(mock.subject, source.getGraph());
+	}
+
+	public void testRemembersBoundary()
+	{
+		Assert.assertSame(TestModelExtract.sbTrue, new MockModelExtract(
+				TestModelExtract.sbTrue).getStatementBoundary());
+		Assert.assertSame(TestModelExtract.sbFalse, new MockModelExtract(
+				TestModelExtract.sbFalse).getStatementBoundary());
+	}
+
+	public void testStatementContinueWith()
+	{
+		final StatementBoundary sb = new StatementBoundaryBase() {
+			@Override
+			public boolean continueWith( final Statement s )
+			{
+				return false;
+			}
+		};
+		Assert.assertTrue(sb.stopAt(ModelHelper.statement("x pings y")));
+	}
+
+	public void testStatementTripleBoundaryAnon()
+	{
+		final TripleBoundary anon = TripleBoundary.stopAtAnonObject;
+		Assert.assertSame(anon,
+				new StatementTripleBoundary(anon).asTripleBoundary(null));
+		Assert.assertFalse(new StatementTripleBoundary(anon).stopAt(ModelHelper
+				.statement("s P o")));
+		Assert.assertTrue(new StatementTripleBoundary(anon).stopAt(ModelHelper
+				.statement("s P _o")));
+	}
+
+	public void testStatementTripleBoundaryNowhere()
+	{
+		final TripleBoundary nowhere = TripleBoundary.stopNowhere;
+		Assert.assertSame(nowhere,
+				new StatementTripleBoundary(nowhere).asTripleBoundary(null));
+		Assert.assertFalse(new StatementTripleBoundary(nowhere)
+				.stopAt(ModelHelper.statement("s P _o")));
+		Assert.assertFalse(new StatementTripleBoundary(nowhere)
+				.stopAt(ModelHelper.statement("s P o")));
+	}
+}

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelFactory.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelFactory.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelFactory.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelFactory.java Mon Jan 14 22:38:35 2013
@@ -1,14 +1,14 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,92 +18,100 @@
 
 package com.hp.hpl.jena.rdf.model.test;
 
-import junit.framework.TestSuite ;
+import com.hp.hpl.jena.graph.compose.Union;
+import com.hp.hpl.jena.rdf.model.InfModel;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.impl.ModelCom;
+import com.hp.hpl.jena.reasoner.InfGraph;
+import com.hp.hpl.jena.reasoner.Reasoner;
+import com.hp.hpl.jena.reasoner.rulesys.GenericRuleReasoner;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+import com.hp.hpl.jena.shared.PrefixMapping;
+import com.hp.hpl.jena.test.JenaTestBase;
 
-import com.hp.hpl.jena.graph.compose.Union ;
-import com.hp.hpl.jena.rdf.model.InfModel ;
-import com.hp.hpl.jena.rdf.model.Model ;
-import com.hp.hpl.jena.rdf.model.ModelFactory ;
-import com.hp.hpl.jena.rdf.model.impl.ModelCom ;
-import com.hp.hpl.jena.reasoner.InfGraph ;
-import com.hp.hpl.jena.reasoner.Reasoner ;
-import com.hp.hpl.jena.reasoner.rulesys.GenericRuleReasoner ;
-import com.hp.hpl.jena.reasoner.rulesys.Rule ;
-import com.hp.hpl.jena.shared.PrefixMapping ;
+import junit.framework.Assert;
+import junit.framework.TestCase;
 
 /**
-    Tests the ModelFactory code. Very skeletal at the moment. It's really
-    testing that the methods actually exists, but it doesn't check much in
-    the way of behaviour.
-*/
-
-public class TestModelFactory extends ModelTestBase
-    {
-    public TestModelFactory(String name)
-        { super(name); }
-        
-    public static TestSuite suite()
-        { return new TestSuite( TestModelFactory.class ); }   
-        
-    /**
-        Test that ModelFactory.createDefaultModel() exists. [Should check that the Model
-        is truly a "default" model.]
-     */
-    public void testCreateDefaultModel()
-        { ModelFactory.createDefaultModel().close(); }    
-
-    public void testGetDefaultPrefixMapping()
-        {
-        assertSame( ModelCom.getDefaultModelPrefixes(), ModelFactory.getDefaultModelPrefixes() );
-        }
-    
-    public void testSetDefaultPrefixMapping()
-        {
-        PrefixMapping original = ModelCom.getDefaultModelPrefixes();
-        PrefixMapping pm = PrefixMapping.Factory.create();
-        ModelFactory.setDefaultModelPrefixes( pm );
-        assertSame( pm, ModelCom.getDefaultModelPrefixes() );
-        assertSame( pm, ModelFactory.getDefaultModelPrefixes() );
-        ModelCom.setDefaultModelPrefixes( original );
-        }
-    
-    public void testCreateInfModel() 
-        {
-        String rule = "-> (eg:r eg:p eg:v).";
-        Reasoner r = new GenericRuleReasoner( Rule.parseRules(rule) );
-        InfGraph ig = r.bind( ModelFactory.createDefaultModel().getGraph() );
-        InfModel im = ModelFactory.createInfModel(ig);
-        assertInstanceOf( InfModel.class, im );
-        assertEquals( 1, im.size() );
-        }
-    
-    /**
-         test that a union model is a model over the union of the two underlying
-         graphs. (We don't check that Union works - that's done in the Union
-         tests, we hope.)
-    */
-    public void testCreateUnion()
-        {
-        Model m1 = ModelFactory.createDefaultModel();
-        Model m2 = ModelFactory.createDefaultModel();
-        Model m = ModelFactory.createUnion( m1, m2 );
-        assertInstanceOf( Union.class, m.getGraph() );
-        assertSame( m1.getGraph(), ((Union) m.getGraph()).getL() );
-        assertSame( m2.getGraph(), ((Union) m.getGraph()).getR() );
-        }
-    
-    public void testAssembleModelFromModel()
-        {
-        // TODO Model ModelFactory.assembleModelFrom( Model singleRoot )
-        }
-    
-    public void testFindAssemblerRoots()
-        {
-        // TODO Set ModelFactory.findAssemblerRoots( Model m )
-        }
-
-    public void testAssmbleModelFromRoot()
-        {
-        // TODO Model assembleModelFrom( Resource root )
-        }
-    }
+ * Tests the ModelFactory code. Very skeletal at the moment. It's really
+ * testing that the methods actually exists, but it doesn't check much in
+ * the way of behaviour.
+ * 
+ */
+
+public class TestModelFactory extends TestCase
+{
+
+	public TestModelFactory( final String name )
+	{
+		super(name);
+	}
+
+	public void testAssembleModelFromModel()
+	{
+		// TODO Model ModelFactory.assembleModelFrom( Model singleRoot )
+	}
+
+	public void testAssmbleModelFromRoot()
+	{
+		// TODO Model assembleModelFrom( Resource root )
+	}
+
+	/**
+	 * Test that ModelFactory.createDefaultModel() exists. [Should check that
+	 * the Model
+	 * is truly a "default" model.]
+	 */
+	public void testCreateDefaultModel()
+	{
+		ModelFactory.createDefaultModel().close();
+	}
+
+	public void testCreateInfModel()
+	{
+		final String rule = "-> (eg:r eg:p eg:v).";
+		final Reasoner r = new GenericRuleReasoner(Rule.parseRules(rule));
+		final InfGraph ig = r
+				.bind(ModelFactory.createDefaultModel().getGraph());
+		final InfModel im = ModelFactory.createInfModel(ig);
+		JenaTestBase.assertInstanceOf(InfModel.class, im);
+		Assert.assertEquals(1, im.size());
+	}
+
+	/**
+	 * test that a union model is a model over the union of the two underlying
+	 * graphs. (We don't check that Union works - that's done in the Union
+	 * tests, we hope.)
+	 */
+	public void testCreateUnion()
+	{
+		final Model m1 = ModelFactory.createDefaultModel();
+		final Model m2 = ModelFactory.createDefaultModel();
+		final Model m = ModelFactory.createUnion(m1, m2);
+		JenaTestBase.assertInstanceOf(Union.class, m.getGraph());
+		Assert.assertSame(m1.getGraph(), ((Union) m.getGraph()).getL());
+		Assert.assertSame(m2.getGraph(), ((Union) m.getGraph()).getR());
+	}
+
+	public void testFindAssemblerRoots()
+	{
+		// TODO Set ModelFactory.findAssemblerRoots( Model model )
+	}
+
+	public void testGetDefaultPrefixMapping()
+	{
+		Assert.assertSame(ModelCom.getDefaultModelPrefixes(),
+				ModelFactory.getDefaultModelPrefixes());
+	}
+
+	public void testSetDefaultPrefixMapping()
+	{
+		final PrefixMapping original = ModelCom.getDefaultModelPrefixes();
+		final PrefixMapping pm = PrefixMapping.Factory.create();
+		ModelFactory.setDefaultModelPrefixes(pm);
+		Assert.assertSame(pm, ModelCom.getDefaultModelPrefixes());
+		Assert.assertSame(pm, ModelFactory.getDefaultModelPrefixes());
+		ModelCom.setDefaultModelPrefixes(original);
+	}
+}

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelMakerImpl.java Mon Jan 14 22:38:35 2013
@@ -1,14 +1,14 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,237 +18,241 @@
 
 package com.hp.hpl.jena.rdf.model.test;
 
-import java.util.ArrayList ;
-import java.util.List ;
+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.test.JenaTestBase;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator;
+import com.hp.hpl.jena.util.iterator.NullIterator;
 
-import junit.framework.TestSuite ;
+import java.util.ArrayList;
+import java.util.List;
 
-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 ;
+import junit.framework.Assert;
+import junit.framework.TestCase;
 
 /**
-    Test ModelMakerImpl using a mock GraphMaker. This is as much an
-    exercise in learning testing technique as it is in actually doing the test ....
-*/
-@SuppressWarnings("deprecation")
-public class TestModelMakerImpl extends ModelTestBase
-    {
-    public TestModelMakerImpl(String name)
-        { super(name); }
-
-    public static TestSuite suite()
-        { return new TestSuite( TestModelMakerImpl.class ); }
-
-    private ModelMaker maker;
-    private Graph graph;
-    private GraphMaker graphMaker;
-
-    @Override
-    public void setUp()
-        {
-        graph = GraphTestBase.graphWith( "" );
-        graphMaker = new MockGraphMaker( graph );
-        maker = new ModelMakerImpl( graphMaker );
-        }
-
-    public void testClose()
-        {
-        maker.close();
-        checkHistory( listOfOne( "close()") );
-        }
-
-    public void testRemove()
-        {
-        maker.removeModel( "London" );
-        checkHistory( listOfOne( "remove(London)" ) );
-        }
-
-    public void testCreateFreshModel()
-        {
-        maker.createFreshModel();
-        checkHistory( listOfOne( "create()" ) );
-        }
-
-    public void testCreateDefaultModel()
-        {
-        maker.createDefaultModel();
-        checkHistory( listOfOne( "get()" ) );
-        }
-
-    public void testCreateNamed()
-        {
-        Model m = maker.createModel( "petal" );
-        checkHistory( listOfOne("create(petal,false)" ) );
-        assertTrue( m.getGraph() == graph );
-        }
-
-    public void testCreateTrue()
-        {
-        Model m = maker.createModel( "stem", true );
-        checkHistory( listOfOne("create(stem,true)" ) );
-        assertTrue( m.getGraph() == graph );
-        }
-
-    public void testCreateFalse()
-        {
-        Model m = maker.createModel( "leaf", false );
-        checkHistory( listOfOne("create(leaf,false)" ) );
-        assertTrue( m.getGraph() == graph );
-        }
-
-    public void testOpen()
-        {
-        Model m = maker.openModel( "trunk" );
-        checkHistory( listOfOne("open(trunk,false)" ) );
-        assertTrue( m.getGraph() == graph );
-        }
-
-    public void testOpenFalse()
-        {
-        Model m = maker.openModel( "branch", false );
-        checkHistory( listOfOne("open(branch,false)" ) );
-        assertTrue( m.getGraph() == graph );
-        }
-
-    public void testOpenTrue()
-        {
-        Model m = maker.openModel( "bark", true );
-        checkHistory( listOfOne("open(bark,true)" ) );
-        assertTrue( m.getGraph() == graph );
-        }
-
-    public void testListGraphs()
-        {
-        maker.listModels().close();
-        checkHistory( listOfOne("listModels()" ) );
-        }
-
-    public void testGetGraphMaker()
-        {
-        assertTrue( maker.getGraphMaker() == graphMaker );
-        }
-
-    private void checkHistory( List<String> expected )
-        { assertEquals( expected, history() ); }
-
-    private List<String> history()
-        { return ((MockGraphMaker) maker.getGraphMaker()).history; }
-
-    static class MockGraphMaker implements GraphMaker
-        {
-        List<String> history = new ArrayList<String>();
-        Graph graph;
-
-        public MockGraphMaker( Graph graph )
-            { this.graph = graph; }
-
-        @Override
-        @Deprecated
-        public ReificationStyle getReificationStyle()
-            {
-            history.add( "getReificationStyle()" );
-            return null;
-            }
-
-        @Override
-        public Graph getGraph()
-            {
-            history.add( "get()" );
-            return graph;
-            }
-
-        @Override
-        public Graph createGraph()
-            {
-            history.add( "create()" );
-            return graph;
-            }
-
-        @Override
-        public Graph createGraph( String name, boolean strict )
-            {
-            history.add( "create(" + name + "," + strict + ")" );
-            return graph;
-            }
-
-        @Override
-        public Graph createGraph( String name )
-            {
-            history.add( "create(" + name + ")" );
-            return graph;
-            }
-
-        @Override
-        public Graph openGraph( String name, boolean strict )
-            {
-            history.add( "open(" + name + "," + strict + ")" );
-            return graph;
-            }
-
-        @Override
-        public Graph openGraph( String name )
-            {
-            history.add( "open(" + name + ")" );
-            return graph;
-            }
-
-        @Override
-        public void removeGraph( String name )
-            {
-            history.add( "remove(" + name + ")" );
-            }
-
-        @Override
-        public boolean hasGraph( String name )
-            {
-            history.add( "has(" + name + ")" );
-            return false;
-            }
-
-        public Graph getDescription()
-            {
-            history.add( "getDescription()" );
-            return graphWith( "" );
-            }
-
-        public Graph getDescription( Node root )
-            {
-            history.add( "getDescription(Node)" );
-            return graphWith( "" );
-            }
-
-        public Graph addDescription( Graph desc, Node self )
-            {
-            history.add( "addDescription()" );
-            return desc;
-            }
-
-        @Override
-        public void close()
-            {
-            history.add( "close()" );
-            }
-
-        @Override
-        public ExtendedIterator<String> listGraphs()
-            {
-            history.add( "listModels()" );
-            return NullIterator.instance();
-            }
-
-        @Override
-        public Graph openGraph()
-            {
-            
-            return null;
-            }
-        }
-    }
+ * Test ModelMakerImpl using a mock GraphMaker.
+ */
+public class TestModelMakerImpl extends TestCase
+{
+	static class MockGraphMaker implements GraphMaker
+	{
+		List<String> history = new ArrayList<String>();
+		Graph graph;
+
+		public MockGraphMaker( final Graph graph )
+		{
+			this.graph = graph;
+		}
+
+		public Graph addDescription( final Graph desc, final Node self )
+		{
+			history.add("addDescription()");
+			return desc;
+		}
+
+		@Override
+		public void close()
+		{
+			history.add("close()");
+		}
+
+		@Override
+		public Graph createGraph()
+		{
+			history.add("create()");
+			return graph;
+		}
+
+		@Override
+		public Graph createGraph( final String name )
+		{
+			history.add("create(" + name + ")");
+			return graph;
+		}
+
+		@Override
+		public Graph createGraph( final String name, final boolean strict )
+		{
+			history.add("create(" + name + "," + strict + ")");
+			return graph;
+		}
+
+		public Graph getDescription()
+		{
+			history.add("getDescription()");
+			return GraphTestBase.graphWith("");
+		}
+
+		public Graph getDescription( final Node root )
+		{
+			history.add("getDescription(Node)");
+			return GraphTestBase.graphWith("");
+		}
+
+		@Override
+		public Graph getGraph()
+		{
+			history.add("get()");
+			return graph;
+		}
+
+		@Override
+		public ReificationStyle getReificationStyle()
+		{
+			history.add("getReificationStyle()");
+			return null;
+		}
+
+		@Override
+		public boolean hasGraph( final String name )
+		{
+			history.add("has(" + name + ")");
+			return false;
+		}
+
+		@Override
+		public ExtendedIterator<String> listGraphs()
+		{
+			history.add("listModels()");
+			return NullIterator.instance();
+		}
+
+		@Override
+		public Graph openGraph()
+		{
+
+			return null;
+		}
+
+		@Override
+		public Graph openGraph( final String name )
+		{
+			history.add("open(" + name + ")");
+			return graph;
+		}
+
+		@Override
+		public Graph openGraph( final String name, final boolean strict )
+		{
+			history.add("open(" + name + "," + strict + ")");
+			return graph;
+		}
+
+		@Override
+		public void removeGraph( final String name )
+		{
+			history.add("remove(" + name + ")");
+		}
+	}
+
+	private ModelMaker maker;
+	private Graph graph;
+	private GraphMaker graphMaker;
+
+	public TestModelMakerImpl( final String name )
+	{
+		super(name);
+	}
+
+	private void checkHistory( final List<String> expected )
+	{
+		Assert.assertEquals(expected, history());
+	}
+
+	private List<String> history()
+	{
+		return ((MockGraphMaker) maker.getGraphMaker()).history;
+	}
+
+	@Override
+	public void setUp()
+	{
+		graph = GraphTestBase.graphWith("");
+		graphMaker = new MockGraphMaker(graph);
+		maker = new ModelMakerImpl(graphMaker);
+	}
+
+	public void testClose()
+	{
+		maker.close();
+		checkHistory(JenaTestBase.listOfOne("close()"));
+	}
+
+	public void testCreateDefaultModel()
+	{
+		maker.createDefaultModel();
+		checkHistory(JenaTestBase.listOfOne("get()"));
+	}
+
+	public void testCreateFalse()
+	{
+		final Model m = maker.createModel("leaf", false);
+		checkHistory(JenaTestBase.listOfOne("create(leaf,false)"));
+		Assert.assertTrue(m.getGraph() == graph);
+	}
+
+	public void testCreateFreshModel()
+	{
+		maker.createFreshModel();
+		checkHistory(JenaTestBase.listOfOne("create()"));
+	}
+
+	public void testCreateNamed()
+	{
+		final Model m = maker.createModel("petal");
+		checkHistory(JenaTestBase.listOfOne("create(petal,false)"));
+		Assert.assertTrue(m.getGraph() == graph);
+	}
+
+	public void testCreateTrue()
+	{
+		final Model m = maker.createModel("stem", true);
+		checkHistory(JenaTestBase.listOfOne("create(stem,true)"));
+		Assert.assertTrue(m.getGraph() == graph);
+	}
+
+	public void testGetGraphMaker()
+	{
+		Assert.assertTrue(maker.getGraphMaker() == graphMaker);
+	}
+
+	public void testListGraphs()
+	{
+		maker.listModels().close();
+		checkHistory(JenaTestBase.listOfOne("listModels()"));
+	}
+
+	public void testOpen()
+	{
+		final Model m = maker.openModel("trunk");
+		checkHistory(JenaTestBase.listOfOne("open(trunk,false)"));
+		Assert.assertTrue(m.getGraph() == graph);
+	}
+
+	public void testOpenFalse()
+	{
+		final Model m = maker.openModel("branch", false);
+		checkHistory(JenaTestBase.listOfOne("open(branch,false)"));
+		Assert.assertTrue(m.getGraph() == graph);
+	}
+
+	public void testOpenTrue()
+	{
+		final Model m = maker.openModel("bark", true);
+		checkHistory(JenaTestBase.listOfOne("open(bark,true)"));
+		Assert.assertTrue(m.getGraph() == graph);
+	}
+
+	public void testRemove()
+	{
+		maker.removeModel("London");
+		checkHistory(JenaTestBase.listOfOne("remove(London)"));
+	}
+}

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPolymorphism.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPolymorphism.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPolymorphism.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPolymorphism.java Mon Jan 14 22:38:35 2013
@@ -1,14 +1,14 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,28 +18,31 @@
 
 package com.hp.hpl.jena.rdf.model.test;
 
-import com.hp.hpl.jena.graph.test.GraphTestBase;
-import com.hp.hpl.jena.rdf.model.*;
-import junit.framework.*;
-
-public class TestModelPolymorphism extends GraphTestBase
-    {
-    public static TestSuite suite()
-        { return new TestSuite( TestModelPolymorphism.class ); }   
-        
-    public TestModelPolymorphism(String name)
-        {
-        super(name);
-        }
-
-    public void testPoly()
-        {
-        Model m = ModelFactory.createDefaultModel();
-        Resource r = m.createResource( "http://www.electric-hedgehog.net/a-o-s.html" );
-        assertFalse( "the Resouce should not be null", r == null );
-        assertTrue( "the Resource can be a Property", r.canAs( Property.class ) );
-        Property p = r.as( Property.class );
-        assertFalse( "the Property should not be null", p == null );
-        assertFalse( "the Resource and Property should not be identical", r == p );
-        }
-    }
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+
+import junit.framework.Assert;
+
+public class TestModelPolymorphism extends AbstractModelTestBase
+{
+
+	public TestModelPolymorphism( final TestingModelFactory modelFactory,
+			final String name )
+	{
+		super(modelFactory, name);
+	}
+
+	public void testPoly()
+	{
+		final Resource r = model
+				.createResource("http://www.electric-hedgehog.net/a-o-s.html");
+		Assert.assertFalse("the Resouce should not be null", r == null);
+		Assert.assertTrue("the Resource can be a Property",
+				r.canAs(Property.class));
+		final Property p = r.as(Property.class);
+		Assert.assertFalse("the Property should not be null", p == null);
+		Assert.assertFalse("the Resource and Property should not be identical",
+				r == p);
+	}
+}

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPrefixMapping.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPrefixMapping.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPrefixMapping.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelPrefixMapping.java Mon Jan 14 22:38:35 2013
@@ -1,14 +1,14 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,86 +18,112 @@
 
 package com.hp.hpl.jena.rdf.model.test;
 
-import junit.framework.TestSuite;
-
 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.ModelFactory;
 import com.hp.hpl.jena.rdf.model.impl.ModelCom;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
 import com.hp.hpl.jena.shared.AbstractTestPrefixMapping;
 import com.hp.hpl.jena.shared.PrefixMapping;
 
+import junit.framework.Assert;
+
 /**
-    Test that a model is a prefix mapping.
- 	@author kers
-*/
+ * Test that a model is a prefix mapping.
+ * 
+ */
 public class TestModelPrefixMapping extends AbstractTestPrefixMapping
-    {
-    public TestModelPrefixMapping( String name )
-        { super( name ); }
-    
-    public static TestSuite suite()
-        { return new TestSuite( TestModelPrefixMapping.class ); }   
-
-    @Override
-    protected PrefixMapping getMapping()
-        { return ModelFactory.createDefaultModel(); }       
-    
-    protected static final String alphaPrefix = "alpha";
-    protected static final String betaPrefix = "beta";
-    protected static final String alphaURI = "http://testing.jena.hpl.hp.com/alpha#";
-    protected static final String betaURI = "http://testing.jena.hpl.hp.com/beta#";
-    
-    protected PrefixMapping baseMap = PrefixMapping.Factory.create()
-        .setNsPrefix( alphaPrefix, alphaURI )
-        .setNsPrefix( betaPrefix, betaURI );
-    
-    private PrefixMapping prevMap;
-    
-    public void setPrefixes()
-        {
-        prevMap = ModelCom.setDefaultModelPrefixes( baseMap );
-        }
-    
-    public void restorePrefixes()
-        {
-        ModelCom.setDefaultModelPrefixes( prevMap );
-        }
-    
-    /**
-        Test that a freshly-created Model has the prefixes established by the
-        default in ModelCom.
-    */
-    public void testDefaultPrefixes()
-        {
-        setPrefixes();
-        Model m = ModelFactory.createDefaultModel();
-        assertEquals( baseMap.getNsPrefixMap(), m.getNsPrefixMap() );
-        restorePrefixes();
-        }
-    
-    public void testOnlyFreshPrefixes()
-        {
-        setPrefixes();
-        try { doOnlyFreshPrefixes(); } finally { restorePrefixes(); }
-        }
-    
-    /**
-       Test that existing prefixes are not over-ridden by the default ones.
-    */
-    private void doOnlyFreshPrefixes()
-        { 
-        String newURI = "abc:def/";
-        Graph g = Factory.createDefaultGraph();
-        PrefixMapping pm = g.getPrefixMapping();
-        pm.setNsPrefix( alphaPrefix, newURI );
-        Model m = ModelFactory.createModelForGraph( g );
-        assertEquals( newURI, m.getNsPrefixURI( alphaPrefix ) );
-        assertEquals( betaURI, m.getNsPrefixURI( betaPrefix ) ); }
-    
-    public void testGetDefault()
-        { setPrefixes();
-        try { assertSame( baseMap, ModelCom.getDefaultModelPrefixes() ); } 
-        finally { restorePrefixes(); } }
-    }
+{
+	private final TestingModelFactory modelFactory;
+	protected static final String alphaPrefix = "alpha";
+
+	protected static final String betaPrefix = "beta";
+	protected static final String alphaURI = "http://testing.jena.hpl.hp.com/alpha#";
+	protected static final String betaURI = "http://testing.jena.hpl.hp.com/beta#";
+	protected PrefixMapping baseMap = PrefixMapping.Factory
+			.create()
+			.setNsPrefix(TestModelPrefixMapping.alphaPrefix,
+					TestModelPrefixMapping.alphaURI)
+			.setNsPrefix(TestModelPrefixMapping.betaPrefix,
+					TestModelPrefixMapping.betaURI);
+
+	private PrefixMapping prevMap;
+
+	public TestModelPrefixMapping( final TestingModelFactory modelFactory,
+			final String name )
+	{
+		super(name);
+		this.modelFactory = modelFactory;
+	}
+
+	/**
+	 * Test that existing prefixes are not over-ridden by the default ones.
+	 */
+	private void doOnlyFreshPrefixes()
+	{
+		final String newURI = "abc:def/";
+		final Graph g = Factory.createDefaultGraph();
+		final PrefixMapping pm = g.getPrefixMapping();
+		pm.setNsPrefix(TestModelPrefixMapping.alphaPrefix, newURI);
+		final Model m = ModelFactory.createModelForGraph(g);
+		Assert.assertEquals(newURI,
+				m.getNsPrefixURI(TestModelPrefixMapping.alphaPrefix));
+		Assert.assertEquals(TestModelPrefixMapping.betaURI,
+				m.getNsPrefixURI(TestModelPrefixMapping.betaPrefix));
+	}
+
+	@Override
+	protected PrefixMapping getMapping()
+	{
+		return modelFactory.getPrefixMapping();
+	}
+
+	public void restorePrefixes()
+	{
+		ModelCom.setDefaultModelPrefixes(prevMap);
+	}
+
+	public void setPrefixes()
+	{
+		prevMap = ModelCom.setDefaultModelPrefixes(baseMap);
+	}
+
+	/**
+	 * Test that a freshly-created Model has the prefixes established by the
+	 * default in ModelCom.
+	 */
+	public void testDefaultPrefixes()
+	{
+		setPrefixes();
+		final Model m = ModelFactory.createDefaultModel();
+		Assert.assertEquals(baseMap.getNsPrefixMap(), m.getNsPrefixMap());
+		restorePrefixes();
+	}
+
+	public void testGetDefault()
+	{
+		setPrefixes();
+		try
+		{
+			Assert.assertSame(baseMap, ModelCom.getDefaultModelPrefixes());
+		}
+		finally
+		{
+			restorePrefixes();
+		}
+	}
+
+	public void testOnlyFreshPrefixes()
+	{
+		setPrefixes();
+		try
+		{
+			doOnlyFreshPrefixes();
+		}
+		finally
+		{
+			restorePrefixes();
+		}
+	}
+}

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelRead.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelRead.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelRead.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelRead.java Mon Jan 14 22:38:35 2013
@@ -1,14 +1,14 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,117 +18,132 @@
 
 package com.hp.hpl.jena.rdf.model.test;
 
+import com.hp.hpl.jena.n3.IRIResolver;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.test.helpers.ModelHelper;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+import com.hp.hpl.jena.shared.ConfigException;
+import com.hp.hpl.jena.shared.JenaException;
+
 import java.io.IOException;
 import java.net.ConnectException;
 import java.net.NoRouteToHostException;
 import java.net.UnknownHostException;
 
+import junit.framework.Assert;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.hp.hpl.jena.n3.IRIResolver;
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.shared.ConfigException;
-import com.hp.hpl.jena.shared.JenaException;
-
-import junit.framework.TestSuite;
-
 /**
-     TestModelRead - test that the new model.read operation(s) exist.
-     @author kers
+ * TestModelRead - test that the new model.read operation(s) exist.
  */
-public class TestModelRead extends ModelTestBase
-    {
-    protected static Logger logger = LoggerFactory.getLogger( TestModelRead.class );
-
-    public TestModelRead( String name )
-        { super( name ); }
-    
-    public static TestSuite suite()
-        { return new TestSuite( TestModelRead.class ); }
-    
-    public void testReturnsSelf()
-        {
-        Model m = ModelFactory.createDefaultModel();
-        assertSame( m, m.read( "file:testing/modelReading/empty.n3", "base", "N3" ) );
-        assertTrue( m.isEmpty() );
-        }
-    
-    public void testGRDDLConfigMessage() {
-    	Model m = ModelFactory.createDefaultModel();
-    	try {
-    		m.read("http://www.w3.org/","GRDDL");
-    		// ok.
-    	}
-    	catch (ConfigException e) {
-    		// expected.
-    	}
-    }
-    public void testLoadsSimpleModel()
-        {
-        Model expected = ModelFactory.createDefaultModel();
-        Model m = ModelFactory.createDefaultModel();
-        expected.read( "file:testing/modelReading/simple.n3", "N3" );
-        assertSame( m, m.read( "file:testing/modelReading/simple.n3", "base", "N3" ) );
-        assertIsoModels( expected, m );
-        }    
-    
-    /*
-         Suppressed, since the other Model::read(String url) operations apparently
-         don't retry failing URLs as filenames. But the code text remains, so that
-         when-and-if, we have a basis.
-     */
-//    public void testLoadsSimpleModelWithoutProtocol()
-//        {
-//        Model expected = ModelFactory.createDefaultModel();
-//        Model m = ModelFactory.createDefaultModel();
-//        expected.read( "testing/modelReading/simple.n3", "RDF/XML" );
-//        assertSame( m, m.read( "testing/modelReading/simple.n3", "base", "N3" ) );
-//        assertIsoModels( expected, m );
-//        }    
-    
-    public void testSimpleLoadImplictBase()
-        {
-        Model mBasedImplicit = ModelFactory.createDefaultModel();
-        String fn = IRIResolver.resolveFileURL("file:testing/modelReading/based.n3" );
-        Model wanted = 
-            ModelFactory.createDefaultModel()
-            .add( resource( fn ), property( "ja:predicate" ), resource( "ja:object" ) );
-        mBasedImplicit.read( fn, "N3" );
-        assertIsoModels( wanted, mBasedImplicit );
-        }
-    
-    public void testSimpleLoadExplicitBase()
-        {
-        Model mBasedExplicit = ModelFactory.createDefaultModel();
-        mBasedExplicit.read( "file:testing/modelReading/based.n3", "http://example/", "N3" );
-        assertIsoModels( modelWithStatements( "http://example/ ja:predicate ja:object" ), mBasedExplicit );
-        }
-    
-    public void testDefaultLangXML()
-        {
-        Model m = ModelFactory.createDefaultModel();
-        m.read( "file:testing/modelReading/plain.rdf", null, null );
-        }
-    
-    public void testContentNegotiation() {
-		Model m = ModelFactory.createDefaultModel();
-//		Model m2 = ModelFactory.createDefaultModel();
-
-		try {
-			m.read("http://jena.sourceforge.net/test/mime/test1");
-		    assertEquals(m.size(),1);
-//		    m2.read("http://xmlns.com/foaf/0.1/");
-		} catch (JenaException jx) {
-			if (jx.getCause() instanceof NoRouteToHostException
-					|| jx.getCause() instanceof UnknownHostException
-					|| jx.getCause() instanceof ConnectException
-					|| jx.getCause() instanceof IOException) {
-				logger
+public class TestModelRead extends AbstractModelTestBase
+{
+	protected static Logger logger = LoggerFactory
+			.getLogger(TestModelRead.class);
+
+	public TestModelRead( final TestingModelFactory modelFactory,
+			final String name )
+	{
+		super(modelFactory, name);
+	}
+
+	public void testContentNegotiation()
+	{
+		try
+		{
+			model.read("http://jena.sourceforge.net/test/mime/test1");
+			Assert.assertEquals(model.size(), 1);
+		}
+		catch (final JenaException jx)
+		{
+			if ((jx.getCause() instanceof NoRouteToHostException)
+					|| (jx.getCause() instanceof UnknownHostException)
+					|| (jx.getCause() instanceof ConnectException)
+					|| (jx.getCause() instanceof IOException))
+			{
+				TestModelRead.logger
 						.warn("Cannot access public internet - content negotiation test not executed");
-			} else
+			}
+			else
+			{
 				throw jx;
+			}
 		}
 	}
-    
-    }
+
+	public void testDefaultLangXML()
+	{
+		final Model model = ModelFactory.createDefaultModel();
+		model.read("file:testing/modelReading/plain.rdf", null, null);
+	}
+
+	public void testGRDDLConfigMessage()
+	{
+		try
+		{
+			model.read("http://www.w3.org/", "GRDDL");
+			// ok.
+		}
+		catch (final ConfigException e)
+		{
+			// expected.
+		}
+	}
+
+	/*
+	 * Suppressed, since the other Model::read(String url) operations apparently
+	 * don't retry failing URLs as filenames. But the code text remains, so that
+	 * when-and-if, we have a basis.
+	 */
+	// public void testLoadsSimpleModelWithoutProtocol()
+	// {
+	// Model expected = ModelFactory.createDefaultModel();
+	// Model model = ModelFactory.createDefaultModel();
+	// expected.read( "testing/modelReading/simple.n3", "RDF/XML" );
+	// assertSame( model, model.read( "testing/modelReading/simple.n3", "base",
+	// "N3" ) );
+	// assertIsoModels( expected, model );
+	// }
+
+	public void testLoadsSimpleModel()
+	{
+		final Model expected = createModel();
+		expected.read("file:testing/modelReading/simple.n3", "N3");
+		Assert.assertSame(model,
+				model.read("file:testing/modelReading/simple.n3", "base", "N3"));
+		ModelHelper.assertIsoModels(expected, model);
+	}
+
+	public void testReturnsSelf()
+	{
+
+		Assert.assertSame(model,
+				model.read("file:testing/modelReading/empty.n3", "base", "N3"));
+		Assert.assertTrue(model.isEmpty());
+	}
+
+	public void testSimpleLoadExplicitBase()
+	{
+		final Model mBasedExplicit = createModel();
+		mBasedExplicit.read("file:testing/modelReading/based.n3",
+				"http://example/", "N3");
+		ModelHelper.assertIsoModels(ModelHelper.modelWithStatements(this,
+				"http://example/ ja:predicate ja:object"), mBasedExplicit);
+	}
+
+	public void testSimpleLoadImplictBase()
+	{
+		final Model mBasedImplicit = createModel();
+		final String fn = IRIResolver
+				.resolveFileURL("file:testing/modelReading/based.n3");
+		final Model wanted = createModel().add(ModelHelper.resource(fn),
+				ModelHelper.property("ja:predicate"),
+				ModelHelper.resource("ja:object"));
+		mBasedImplicit.read(fn, "N3");
+		ModelHelper.assertIsoModels(wanted, mBasedImplicit);
+	}
+
+}

Added: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelSetOperations.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelSetOperations.java?rev=1433184&view=auto
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelSetOperations.java (added)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestModelSetOperations.java Mon Jan 14 22:38:35 2013
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.rdf.model.test;
+
+import com.hp.hpl.jena.rdf.model.Model;
+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.ModelHelper;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+
+import junit.framework.Assert;
+
+/**
+ * A revamped version of the regression set-operation tests.
+ */
+public class TestModelSetOperations extends AbstractModelTestBase
+{
+	private Model model2;
+
+	public TestModelSetOperations( final TestingModelFactory modelFactory,
+			final String name )
+	{
+		super(modelFactory, name);
+	}
+
+	@Override
+	public void setUp() throws Exception
+	{
+		super.setUp();
+		model2 = createModel();
+	}
+
+	@Override
+	public void tearDown() throws Exception
+	{
+		super.tearDown();
+		model2.close();
+	}
+
+	public void testDifference()
+	{
+		ModelHelper.modelAdd(model, "a P b; w R x");
+		ModelHelper.modelAdd(model2, "w R x; y S z");
+		final Model dm = model.difference(model2);
+		for (final StmtIterator it = dm.listStatements(); it.hasNext();)
+		{
+			final Statement s = it.nextStatement();
+			Assert.assertTrue(model.contains(s) && !model2.contains(s));
+		}
+		for (final StmtIterator it = model.union(model2).listStatements(); it
+				.hasNext();)
+		{
+			final Statement s = it.nextStatement();
+			Assert.assertEquals(model.contains(s) && !model2.contains(s),
+					dm.contains(s));
+		}
+		Assert.assertTrue(dm.containsAny(model));
+		Assert.assertTrue(dm.containsAny(model.listStatements()));
+		Assert.assertFalse(dm.containsAny(model2));
+		Assert.assertFalse(dm.containsAny(model2.listStatements()));
+		Assert.assertTrue(model.containsAll(dm));
+
+	}
+
+	public void testIntersection()
+	{
+
+		ModelHelper.modelAdd(model, "a P b; w R x");
+		ModelHelper.modelAdd(model2, "w R x; y S z");
+		final Model im = model.intersection(model2);
+		Assert.assertFalse(model.containsAll(model2));
+		Assert.assertFalse(model2.containsAll(model));
+		Assert.assertTrue(model.containsAll(im));
+		Assert.assertTrue(model2.containsAll(im));
+		for (final StmtIterator it = im.listStatements(); it.hasNext();)
+		{
+			final Statement s = it.nextStatement();
+			Assert.assertTrue(model.contains(s) && model2.contains(s));
+		}
+		for (final StmtIterator it = im.listStatements(); it.hasNext();)
+		{
+			Assert.assertTrue(model.contains(it.nextStatement()));
+		}
+		for (final StmtIterator it = im.listStatements(); it.hasNext();)
+		{
+			Assert.assertTrue(model2.contains(it.nextStatement()));
+		}
+		Assert.assertTrue(model.containsAll(im.listStatements()));
+		Assert.assertTrue(model2.containsAll(im.listStatements()));
+
+	}
+
+	public void testUnion()
+	{
+
+		ModelHelper.modelAdd(model, "a P b; w R x");
+		ModelHelper.modelAdd(model2, "w R x; y S z");
+		final Model um = model.union(model2);
+		Assert.assertFalse(model.containsAll(model2));
+		Assert.assertFalse(model2.containsAll(model));
+		Assert.assertTrue(um.containsAll(model));
+		Assert.assertTrue(um.containsAll(model2));
+		for (final StmtIterator it = um.listStatements(); it.hasNext();)
+		{
+			final Statement s = it.nextStatement();
+			Assert.assertTrue(model.contains(s) || model2.contains(s));
+		}
+		for (final StmtIterator it = model.listStatements(); it.hasNext();)
+		{
+			Assert.assertTrue(um.contains(it.nextStatement()));
+		}
+		for (final StmtIterator it = model2.listStatements(); it.hasNext();)
+		{
+			Assert.assertTrue(um.contains(it.nextStatement()));
+		}
+		Assert.assertTrue(um.containsAll(model.listStatements()));
+		Assert.assertTrue(um.containsAll(model2.listStatements()));
+
+	}
+}

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestNamespace.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestNamespace.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestNamespace.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestNamespace.java Mon Jan 14 22:38:35 2013
@@ -1,14 +1,14 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,14 @@
 
 package com.hp.hpl.jena.rdf.model.test;
 
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+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 com.hp.hpl.jena.shared.AbstractTestPrefixMapping;
+import com.hp.hpl.jena.util.CollectionFactory;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -26,102 +34,102 @@ import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
 
-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.impl.ModelCom;
-import com.hp.hpl.jena.shared.AbstractTestPrefixMapping;
-import com.hp.hpl.jena.util.CollectionFactory;
+import junit.framework.Assert;
 
-/**
- 	@author kers
-*/
-public class TestNamespace extends ModelTestBase
-    {
-    public TestNamespace( String name )
-        { super( name ); }
-
-    public static TestSuite suite()
-         { return new TestSuite( TestNamespace.class ); }   
-
-    /**
-        a simple test of the prefix reader on a known file. test0014.rdf is known to
-        have a namespace definition for eg and rdf, and not for spoo so we see if we
-        can extract them (or not, for spoo).
-    */
-    public void testReadPrefixes()
-        {
-        Model m = ModelFactory.createDefaultModel();
-        m.read( "file:testing/wg/rdf-ns-prefix-confusion/test0014.rdf" );
-        Map<String, String> ns = m.getNsPrefixMap(); 
-        // System.err.println( ">> " + ns );
-        assertEquals( "namespace eg", "http://example.org/", ns.get( "eg" ) );
-        assertEquals( "namespace rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#", ns.get( "rdf" ) );
-        assertEquals( "not present", null, ns.get( "spoo" ) );
-        }
-        
-    /**
-        a horridly written test to write out a model with some known namespace
-        prefixes and see if they can be read back in again.
-        
-        TODO tidy and abstract this - we want some more tests.
-        
-        TODO there's a problem: namespaces that aren't used on properties
-        don't reliably get used. Maybe they shouldn't be - but it seems odd.
-    */
-    public void testWritePrefixes() throws IOException
-        {
-        Model m = ModelFactory.createDefaultModel();
-        ModelCom.addNamespaces( m, makePrefixes( "fred=ftp://net.fred.org/;spoo=http://spoo.net/" ) );
-        File f =  File.createTempFile( "hedgehog", ".rdf" );
-        m.add( statement( m, "http://spoo.net/S http://spoo.net/P http://spoo.net/O" ) );
-        m.add( statement( m, "http://spoo.net/S ftp://net.fred.org/P http://spoo.net/O" ) );
-        m.write( new FileOutputStream( f ) );
-    /* */
-        Model m2 = ModelFactory.createDefaultModel();
-        m2.read( "file:" + f.getAbsolutePath() );
-        Map<String, String> ns = m2.getNsPrefixMap();
-        assertEquals( "namespace spoo", "http://spoo.net/", ns.get( "spoo" ) );
-        assertEquals( "namespace fred", "ftp://net.fred.org/", ns.get( "fred" ) );
-    /* */
-        f.deleteOnExit();
-        }
-    
-    /**
-        turn a semi-separated set of P=U definitions into a namespace map.
-    */
-    private Map<String, Set<String>> makePrefixes( String prefixes )
-        {
-        Map<String, Set<String>> result = new HashMap<String, Set<String>>();
-        StringTokenizer st = new StringTokenizer( prefixes, ";" );
-        while (st.hasMoreTokens())
-            {
-            String def = st.nextToken();
-            // System.err.println( "| def is " + def );
-            int eq = def.indexOf( '=' );
-            result.put( def.substring( 0, eq ), set( def.substring( eq + 1 ) ) );
-            }
-        // result.put( "spoo", set( "http://spoo.net/" ) );
-        return result;
-        }
-        
-    /**
-        make a single-element set.
-        @param element the single element to contain
-        @return a set whose only element == element
-    */
-    private Set<String> set( String element )
-        {
-        Set<String> s = CollectionFactory.createHashedSet();
-        s.add( element );
-        return s;
-        }
-        
-    public void testUseEasyPrefix()
-        {
-        AbstractTestPrefixMapping.testUseEasyPrefix
-            ( "default model", ModelFactory.createDefaultModel() );
-        }
+public class TestNamespace extends AbstractModelTestBase
+{
+	public TestNamespace( final TestingModelFactory modelFactory,
+			final String name )
+	{
+		super(modelFactory, name);
+	}
+
+	/**
+	 * turn a semi-separated set of P=U definitions into a namespace map.
+	 */
+	private Map<String, Set<String>> makePrefixes( final String prefixes )
+	{
+		final Map<String, Set<String>> result = new HashMap<String, Set<String>>();
+		final StringTokenizer st = new StringTokenizer(prefixes, ";");
+		while (st.hasMoreTokens())
+		{
+			final String def = st.nextToken();
+			// System.err.println( "| def is " + def );
+			final int eq = def.indexOf('=');
+			result.put(def.substring(0, eq), set(def.substring(eq + 1)));
+		}
+		// result.put( "spoo", set( "http://spoo.net/" ) );
+		return result;
+	}
+
+	/**
+	 * make a single-element set.
+	 * 
+	 * @param element
+	 *            the single element to contain
+	 * @return a set whose only element == element
+	 */
+	private Set<String> set( final String element )
+	{
+		final Set<String> s = CollectionFactory.createHashedSet();
+		s.add(element);
+		return s;
+	}
+
+	/**
+	 * a simple test of the prefix reader on a known file. test0014.rdf is known
+	 * to
+	 * have a namespace definition for eg and rdf, and not for spoo so we see if
+	 * we
+	 * can extract them (or not, for spoo).
+	 */
+	public void testReadPrefixes()
+	{
+
+		model.read("file:testing/wg/rdf-ns-prefix-confusion/test0014.rdf");
+		final Map<String, String> ns = model.getNsPrefixMap();
+		// System.err.println( ">> " + ns );
+		Assert.assertEquals("namespace eg", "http://example.org/", ns.get("eg"));
+		Assert.assertEquals("namespace rdf",
+				"http://www.w3.org/1999/02/22-rdf-syntax-ns#", ns.get("rdf"));
+		Assert.assertEquals("not present", null, ns.get("spoo"));
+	}
+
+	public void testUseEasyPrefix()
+	{
+		AbstractTestPrefixMapping.testUseEasyPrefix("default model",
+				ModelFactory.createDefaultModel());
+	}
+
+	/**
+	 * a horridly written test to write out a model with some known namespace
+	 * prefixes and see if they can be read back in again.
+	 * 
+	 * TODO tidy and abstract this - we want some more tests.
+	 * 
+	 * TODO there's a problem: namespaces that aren't used on properties
+	 * don't reliably get used. Maybe they shouldn't be - but it seems odd.
+	 */
+	public void testWritePrefixes() throws IOException
+	{
+		ModelCom.addNamespaces(model,
+				makePrefixes("fred=ftp://net.fred.org/;spoo=http://spoo.net/"));
+		final File f = File.createTempFile("hedgehog", ".rdf");
+		model.add(ModelHelper.statement(model,
+				"http://spoo.net/S http://spoo.net/P http://spoo.net/O"));
+		model.add(ModelHelper.statement(model,
+				"http://spoo.net/S ftp://net.fred.org/P http://spoo.net/O"));
+		model.write(new FileOutputStream(f));
+		/* */
+		final Model m2 = ModelFactory.createDefaultModel();
+		m2.read("file:" + f.getAbsolutePath());
+		final Map<String, String> ns = m2.getNsPrefixMap();
+		Assert.assertEquals("namespace spoo", "http://spoo.net/",
+				ns.get("spoo"));
+		Assert.assertEquals("namespace fred", "ftp://net.fred.org/",
+				ns.get("fred"));
+		/* */
+		f.deleteOnExit();
+	}
 
-    }
+}

Added: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjectOfProperties.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjectOfProperties.java?rev=1433184&view=auto
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjectOfProperties.java (added)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjectOfProperties.java Mon Jan 14 22:38:35 2013
@@ -0,0 +1,408 @@
+package com.hp.hpl.jena.rdf.model.test;
+
+import com.hp.hpl.jena.rdf.model.NodeIterator;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+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.test.helpers.TestingModelFactory;
+
+import org.junit.Assert;
+
+public class TestObjectOfProperties extends AbstractModelTestBase
+{
+	/*
+	 * 
+	 * boolean predf[] = new boolean[num];
+	 * 
+	 * boolean objf[] = new boolean[numObj];
+	 * 
+	 * try {
+	 */
+
+	int num = 5;
+
+	Resource subject[] = new Resource[num];
+	Property predicate[] = new Property[num];
+	Statement stmts[];
+	Statement stmt;
+
+	String suri = "http://aldabaran/test8/s";
+	String puri = "http://aldabaran/test8/";
+
+	boolean tvBoolean[] = { false, true };
+	long tvLong[] = { 123, 321 };
+	char tvChar[] = { '@', ';' };
+	float tvFloat[] = { 456.789f, 789.456f };
+	double tvDouble[] = { 123.456, 456.123 };
+	String tvString[] = { "testing string 1", "testing string 2" };
+	String lang[] = { "en", "fr" };
+
+	int numObj = 7;
+	RDFNode object[] = new RDFNode[numObj];
+
+	// Literal tvLitObj[];
+	// Resource tvResObj[] =;
+
+	public TestObjectOfProperties( final TestingModelFactory modelFactory,
+			final String name )
+	{
+		super(modelFactory, name);
+	}
+
+	private void assertFoundAll( final boolean[] subjf )
+	{
+		for (int i = 0; i < num; i++)
+		{
+			Assert.assertTrue("Should have found " + subject[i], subjf[i]);
+		}
+	}
+
+	private void assertFoundNone( final boolean[] subjf )
+	{
+		for (int i = 0; i < num; i++)
+		{
+			Assert.assertFalse("Should not have found " + subject[i], subjf[i]);
+		}
+	}
+
+	private void checkBooleanSubjects( final boolean[] subjf )
+	{
+		for (int i = 0; i < num; i++)
+		{
+			if (subjf[i])
+			{
+				Assert.assertFalse(i > 1);
+			}
+			else
+			{
+				Assert.assertFalse(i < 2);
+			}
+		}
+	}
+
+	private void processIterator( final ResIterator rIter, final boolean[] subjf )
+	{
+		for (int i = 0; i < num; i++)
+		{
+			subjf[i] = false;
+		}
+
+		while (rIter.hasNext())
+		{
+			final Resource subj = rIter.nextResource();
+			Boolean 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);
+		}
+	}
+
+	@Override
+	public void setUp() throws Exception
+	{
+		super.setUp();
+		// tvLitObj = { model.createTypedLiteral(new LitTestObjF()),
+		// model.createTypedLiteral(new LitTestObjF()) };
+		// tvResObj = { model.createResource(new ResTestObjF()),
+		// model.createResource(new ResTestObjF()) };
+
+		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++)
+		{
+			model.addLiteral(subject[i], predicate[4], false);
+		}
+
+		for (int i = 0; i < 2; i++)
+		{
+			for (int j = 0; j < 2; j++)
+			{
+				stmt = model.createStatement(subject[i], predicate[j],
+						model.createTypedLiteral(tvBoolean[j]));
+				model.add(stmt);
+				stmt = model.createLiteralStatement(subject[i], predicate[j],
+						tvLong[j]);
+				model.add(stmt);
+				stmt = model.createLiteralStatement(subject[i], predicate[j],
+						tvChar[j]);
+				model.add(stmt);
+
+				stmt = model.createStatement(subject[i], predicate[j],
+						model.createTypedLiteral(tvFloat[j]));
+				model.add(stmt);
+				stmt = model.createStatement(subject[i], predicate[j],
+						model.createTypedLiteral(tvDouble[j]));
+				model.add(stmt);
+
+				stmt = model.createStatement(subject[i], predicate[j],
+						tvString[j]);
+				model.add(stmt);
+				stmt = model.createStatement(subject[i], predicate[j],
+						tvString[j], lang[j]);
+				model.add(stmt);
+				// stmt = model.createStatement(subject[i], predicate[j],
+				// tvLitObj[j]);
+				// model.add(stmt);
+				// stmt = model.createStatement(subject[i], predicate[j],
+				// tvResObj[j]);
+				model.add(stmt);
+			}
+		}
+		object[0] = model.createTypedLiteral(tvBoolean[1]);
+		object[1] = model.createTypedLiteral(tvLong[1]);
+		object[2] = model.createTypedLiteral(tvChar[1]);
+		object[3] = model.createTypedLiteral(tvFloat[1]);
+		object[4] = model.createTypedLiteral(tvDouble[1]);
+		object[5] = model.createLiteral(tvString[1]);
+		object[6] = model.createLiteral(tvString[1], lang[1]);
+		// object[7] = tvLitObj[1];
+		// object[7] = tvResObj[1];
+
+	}
+
+	public void testListObjectsOfProperty()
+	{
+		final boolean objf[] = new boolean[numObj];
+
+		final NodeIterator nIter = model.listObjectsOfProperty(predicate[1]);
+		while (nIter.hasNext())
+		{
+			final RDFNode obj = nIter.nextNode();
+			Boolean found = false;
+			for (int i = 0; i < numObj; i++)
+			{
+				if (obj.equals(object[i]))
+				{
+					found = true;
+					Assert.assertFalse("Should not have found " + object[i]
+							+ " already", objf[i]);
+					objf[i] = true;
+				}
+			}
+			Assert.assertTrue("Should have found " + obj, found);
+		}
+		for (int i = 0; i < numObj; i++)
+		{
+			Assert.assertTrue("Should have found " + object[i], objf[i]);
+		}
+
+	}
+
+	public void testListResourcesWIthProperty()
+	{
+		final boolean subjf[] = new boolean[num];
+		processIterator(model.listResourcesWithProperty(predicate[4]), subjf);
+		assertFoundAll(subjf);
+
+		processIterator(model.listResourcesWithProperty(predicate[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvBoolean[0])), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvBoolean[1])), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], (byte) tvLong[0]),
+				subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], (byte) tvLong[1]),
+				subjf);
+		assertFoundNone(subjf);
+
+		processIterator(model.listResourcesWithProperty(predicate[0],
+				(short) tvLong[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(model.listResourcesWithProperty(predicate[0],
+				(short) tvLong[1]), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], (int) tvLong[0]),
+				subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], (int) tvLong[1]),
+				subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], tvLong[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], tvLong[1]), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], tvChar[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], tvChar[1]), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvDouble[0])), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvDouble[1])), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvDouble[0])), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvDouble[1])), subjf);
+		assertFoundNone(subjf);
+	}
+
+	public void testListSubjectsWithProperty()
+	{
+		final boolean subjf[] = new boolean[num];
+		processIterator(
+				model.listSubjectsWithProperty(predicate[0], tvString[0]),
+				subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listSubjectsWithProperty(predicate[0], tvString[1]),
+				subjf);
+		assertFoundNone(subjf);
+
+		processIterator(model.listSubjectsWithProperty(predicate[0],
+				tvString[0], lang[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listSubjectsWithProperty(predicate[0], tvString[1]),
+				subjf);
+		assertFoundNone(subjf);
+
+		// n=1200;
+		// // System.out.println( "* -- n := " + n );
+		// for (int i=0; i<num; i++) {
+		// subjf[i] = false;
+		// }
+		// found = false;
+		// rIter = model.listResourcesWithProperty(predicate[0], tvLitObj[0]);
+		// while (rIter.hasNext()) {
+		// Resource subj = rIter.nextResource();
+		// found = false;
+		// for (int i=0; i<num; i++) {
+		// if (subj.equals(subject[i])) {
+		// found = true;
+		// if (subjf[i]) error(test, n+10);
+		// subjf[i] = true;
+		// }
+		// }
+		// if (! found) error(test, n+20);
+		// }
+		// for (int i=0; i<num; i++) {
+		// if (subjf[i]) {
+		// if (i>1) error(test, n+30+i);
+		// } else {
+		// if (i<2) error(test, n+40+i);
+		// }
+		// }
+		//
+		// for (int i=0; i<num; i++) {
+		// subjf[i] = false;
+		// }
+		// found = false;
+		// rIter = model.listResourcesWithProperty(predicate[0], tvLitObj[1]);
+		// while (rIter.hasNext()) {
+		// Resource subj = rIter.nextResource();
+		// found = false;
+		// for (int i=0; i<num; i++) {
+		// if (subj.equals(subject[i])) {
+		// found = true;
+		// if (subjf[i]) error(test, n+50);
+		// subjf[i] = true;
+		// }
+		// }
+		// if (! found) error(test, n+60);
+		// }
+		// for (int i=0; i<num; i++) {
+		// if (subjf[i]) error(test, n+70+i);
+		// }
+
+		// n=1300;
+		// // System.out.println( "* -- n := " + n );
+		// for (int i=0; i<num; i++) {
+		// subjf[i] = false;
+		// }
+		// found = false;
+		// rIter = model.listResourcesWithProperty(predicate[0], tvResObj[0]);
+		// while (rIter.hasNext()) {
+		// Resource subj = rIter.nextResource();
+		// found = false;
+		// for (int i=0; i<num; i++) {
+		// if (subj.equals(subject[i])) {
+		// found = true;
+		// if (subjf[i]) error(test, n+10);
+		// subjf[i] = true;
+		// }
+		// }
+		// if (! found) error(test, n+20);
+		// }
+		// for (int i=0; i<num; i++) {
+		// if (subjf[i]) {
+		// if (i>1) error(test, n+30+i);
+		// } else {
+		// if (i<2) error(test, n+40+i);
+		// }
+		// }
+		//
+		// for (int i=0; i<num; i++) {
+		// subjf[i] = false;
+		// }
+		// found = false;
+		// rIter = model.listResourcesWithProperty(predicate[0], tvResObj[1]);
+		// while (rIter.hasNext()) {
+		// Resource subj = rIter.nextResource();
+		// found = false;
+		// for (int i=0; i<num; i++) {
+		// if (subj.equals(subject[i])) {
+		// found = true;
+		// if (subjf[i]) error(test, n+50);
+		// subjf[i] = true;
+		// }
+		// }
+		// if (! found) error(test, n+60);
+		// }
+		// for (int i=0; i<num; i++) {
+		// if (subjf[i]) error(test, n+70+i);
+		// }
+	}
+}

Added: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjects.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjects.java?rev=1433184&view=auto
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjects.java (added)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestObjects.java Mon Jan 14 22:38:35 2013
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.rdf.model.test;
+
+import com.hp.hpl.jena.graph.test.GraphTestBase;
+import com.hp.hpl.jena.rdf.model.Literal;
+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.Statement;
+import com.hp.hpl.jena.rdf.model.test.helpers.ModelHelper;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+public class TestObjects extends AbstractModelTestBase
+{
+
+	protected Resource S;
+	protected Property P;
+
+	protected static int numberSubjects = 7;
+
+	protected static int numberPredicates = 3;
+
+	protected static final String subjectPrefix = "http://aldabaran/test6/s";
+
+	protected static final String predicatePrefix = "http://aldabaran/test6/";
+
+	public TestObjects( final TestingModelFactory modelFactory,
+			final String name )
+	{
+		super(modelFactory, name);
+	}
+
+	protected Set<Statement> fill( final Model model )
+	{
+		final Set<Statement> statements = new HashSet<Statement>();
+		for (int i = 0; i < TestObjects.numberSubjects; i += 1)
+		{
+			for (int j = 0; j < TestObjects.numberPredicates; j += 1)
+			{
+				final Statement s = model
+						.createLiteralStatement(ModelHelper
+								.resource(TestObjects.subjectPrefix + i),
+								ModelHelper
+										.property(TestObjects.predicatePrefix
+												+ j + "/p"),
+								(i * TestObjects.numberPredicates) + j);
+				model.add(s);
+				statements.add(s);
+			}
+		}
+		Assert.assertEquals(TestObjects.numberSubjects
+				* TestObjects.numberPredicates, model.size());
+		return statements;
+	}
+
+	protected Set<Literal> literalsFor( final int predicate )
+	{
+		final Set<Literal> result = new HashSet<Literal>();
+		for (int i = 0; i < TestObjects.numberSubjects; i += 1)
+		{
+			result.add(model
+					.createTypedLiteral((i * TestObjects.numberPredicates)
+							+ predicate));
+		}
+		return result;
+	}
+
+	protected Set<Literal> literalsUpto( final int limit )
+	{
+		final Set<Literal> result = new HashSet<Literal>();
+		for (int i = 0; i < limit; i += 1)
+		{
+			result.add(model.createTypedLiteral(i));
+		}
+		return result;
+	}
+
+	protected Set<String> predicateSet( final int limit )
+	{
+		final Set<String> result = new HashSet<String>();
+		for (int i = 0; i < limit; i += 1)
+		{
+			result.add(TestObjects.predicatePrefix + i + "/");
+		}
+		return result;
+	}
+
+	@Override
+	public void setUp() throws Exception
+	{
+		super.setUp();
+		S = model.createResource("http://nowhere.man/subject");
+		P = model.createProperty("http://nowhere.man/predicate");
+	}
+
+	protected Set<Resource> subjectSet( final int limit )
+	{
+		final Set<Resource> result = new HashSet<Resource>();
+		for (int i = 0; i < limit; i += 1)
+		{
+			result.add(ModelHelper.resource(TestObjects.subjectPrefix + i));
+		}
+		return result;
+	}
+
+	@Override
+	public void tearDown() throws Exception
+	{
+		S = null;
+		P = null;
+		super.tearDown();
+	}
+
+	public void testListNamespaces()
+	{
+		fill(model);
+		final List<String> L = model.listNameSpaces().toList();
+		Assert.assertEquals(TestObjects.numberPredicates, L.size());
+		final Set<String> wanted = predicateSet(TestObjects.numberPredicates);
+		Assert.assertEquals(wanted, new HashSet<String>(L));
+	}
+
+	public void testListObjects()
+	{
+		fill(model);
+		final Set<Literal> wanted = literalsUpto(TestObjects.numberSubjects
+				* TestObjects.numberPredicates);
+		Assert.assertEquals(wanted,
+				GraphTestBase.iteratorToSet(model.listObjects()));
+	}
+
+	public void testListObjectsOfPropertyByProperty()
+	{
+		fill(model);
+		final List<RDFNode> L = GraphTestBase.iteratorToList(model
+				.listObjectsOfProperty(ModelHelper
+						.property(TestObjects.predicatePrefix + "0/p")));
+		Assert.assertEquals(TestObjects.numberSubjects, L.size());
+		final Set<Literal> wanted = literalsFor(0);
+		Assert.assertEquals(wanted, new HashSet<RDFNode>(L));
+	}
+
+	public void testListObjectsOfPropertyBySubject()
+	{
+		final int size = 10;
+		final Resource s = model.createResource();
+		for (int i = 0; i < size; i += 1)
+		{
+			model.addLiteral(s, RDF.value, i);
+		}
+		final List<RDFNode> L = GraphTestBase.iteratorToList(model
+				.listObjectsOfProperty(s, RDF.value));
+		Assert.assertEquals(size, L.size());
+		final Set<Literal> wanted = literalsUpto(size);
+		Assert.assertEquals(wanted, new HashSet<RDFNode>(L));
+	}
+
+	public void testListStatements()
+	{
+		final Set<Statement> statements = fill(model);
+		final List<Statement> L = model.listStatements().toList();
+		Assert.assertEquals(statements.size(), L.size());
+		Assert.assertEquals(statements, new HashSet<Statement>(L));
+	}
+
+	public void testListSubjects()
+	{
+		fill(model);
+		final List<Resource> L = model.listSubjects().toList();
+		Assert.assertEquals(TestObjects.numberSubjects, L.size());
+		final Set<Resource> wanted = subjectSet(TestObjects.numberSubjects);
+		Assert.assertEquals(wanted, GraphTestBase.iteratorToSet(L.iterator()));
+	}
+
+}

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java?rev=1433184&r1=1433183&r2=1433184&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestPackage.java Mon Jan 14 22:38:35 2013
@@ -1,72 +1,68 @@
 /*
  * 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.hp.hpl.jena.rdf.model.test;
 
-import junit.framework.*;
-
-public class TestPackage extends TestSuite {
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+import com.hp.hpl.jena.shared.PrefixMapping;
+
+import junit.framework.TestSuite;
+
+/**
+ * Implementation of the basic Model TestPackage. Uses the standard
+ * ModelFactory to create models for testing.
+ * 
+ */
 
-    static public TestSuite suite() {
-        return new TestPackage();
-    }
-    
-    /** Creates new TestPackage */
-    private TestPackage() {
-        super("Model");
-        addTest( "TestModel", TestModelFactory.suite() );
-        addTest(TestListStatements.suite() );
-        
-        addTest( "TestModelFactory", TestModelFactory.suite() );
-        addTest( "TestSimpleListStatements", TestSimpleListStatements.suite() );
-        addTest( "TestModelPolymorphism", TestModelPolymorphism.suite() );
-        addTest( "TestSimpleSelector", TestSimpleSelector.suite() );
-        addTest( "TestStatements", TestStatements.suite() );
-        addTest( "TestRDFNodes", TestRDFNodes.suite() );
-        addTest( "TestReifiedStatements", TestReifiedStatements.suite() );
-        addTest( "TestIterators", TestIterators.suite() );
-        addTest( "TestContains", TestContains.suite() );
-        addTest( "TestLiteralImpl", TestLiteralImpl.suite() );
-        addTest( "TestResourceImpl", TestResourceImpl.suite() );
-        addTest( "TestNamespace", TestNamespace.suite() );
-        addTest( "TestModelBulkUpdate", TestModelBulkUpdate.suite() );
-        addTest( "TestConcurrency", TestConcurrency.suite() ) ;
-        addTest( "TestModelMakerImpl", TestModelMakerImpl.suite() );
-        addTest( "TestModelPrefixMapping", TestModelPrefixMapping.suite() );
-        addTest( TestContainers.suite() );
-        addTest( "TestStandardModels", TestStandardModels.suite() );
-        addTest( "TestSelectors", TestSelectors.suite() );
-        addTest( "TestModelEvents", TestModelEvents.suite() );
-        addTest( "TestReaderEvents", TestReaderEvents.suite() );
-        addTest( "TestList", TestList.suite() );
-        addTest( "TestAnonID", TestAnonID.suite() );
-        addTestSuite( TestLiteralsInModel.class );
-        addTest( TestRemoveSPO.suite() );
-        addTest( TestListSubjectsEtc.suite() );
-        addTest( TestModelExtract.suite() );
-        addTest( TestModelRead.suite() );
-        addTestSuite( TestPropertyImpl.class );
-        addTestSuite( TestRemoveBug.class );
-        }
-
-    private void addTest(String name, TestSuite tc) {
-        tc.setName(name);
-        addTest(tc);
-    }
+public class TestPackage extends AbstractTestPackage
+{
 
+	private static class PlainModelFactory implements TestingModelFactory
+	{
+		@Override
+		public Model createModel()
+		{
+			return ModelFactory.createDefaultModel();
+		}
+
+		@Override
+		public Model createModel( final Graph base )
+		{
+			return ModelFactory.createModelForGraph(base);
+		}
+
+		@Override
+		public PrefixMapping getPrefixMapping()
+		{
+			return ModelFactory.createDefaultModel().getGraph()
+					.getPrefixMapping();
+		}
+	}
+
+	static public TestSuite suite()
+	{
+		return new TestPackage();
+	}
+
+	public TestPackage()
+	{
+		super("Model", new PlainModelFactory());
+	}
 }



Mime
View raw message