You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2013/09/14 00:32:06 UTC

svn commit: r1523135 [2/6] - in /jena/Experimental/new-test/src/test/java/com/hp/hpl/jena: graph/ graph/compose/ graph/impl/ mem/ rdf/ rdf/model/ rdf/model/impl/ rdf/model/temp/ shared/ testing_framework/

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractFindPropertiesTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractFindPropertiesTests.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractFindPropertiesTests.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractFindPropertiesTests.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,435 @@
+/*
+ * 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;
+
+import static com.hp.hpl.jena.testing_framework.ModelHelper.*;
+
+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.testing_framework.AbstractModelProducerUser;
+import com.hp.hpl.jena.testing_framework.ModelProducerInterface;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractFindPropertiesTests extends AbstractModelProducerUser
+{
+	
+	/*
+	 * 
+	 * boolean predf[] = new boolean[num];
+	 * 
+	 * boolean objf[] = new boolean[numObj];
+	 * 
+	 * try {
+	 */
+	
+	Model model;
+
+	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 tvBooleanArray[] = { false, true };
+	long tvLongArray[] = { 123, 321 };
+	char tvCharArray[] = { '@', ';' };
+	float tvFloatArray[] = { 456.789f, 789.456f };
+	double tvDoubleArray[] = { 123.456, 456.123 };
+	String tvStringArray[] = { "testing string 1", "testing string 2" };
+	String lang[] = { "en", "fr" };
+
+	int numObj = 7;
+	RDFNode object[] = new RDFNode[numObj];
+
+	// Literal tvLitObj[];
+	// Resource tvResObj[] =;
+
+	
+
+	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);
+		}
+	}
+
+	@Before
+	public void setUpAbstractFindPropertiesTests() throws Exception
+	{
+		// tvLitObj = { model.createTypedLiteral(new LitTestObjF()),
+		// model.createTypedLiteral(new LitTestObjF()) };
+		// tvResObj = { model.createResource(new ResTestObjF()),
+		// model.createResource(new ResTestObjF()) };
+
+		model = getModelProducer().newModel();
+		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(tvBooleanArray[j]));
+				model.add(stmt);
+				stmt = model.createLiteralStatement(subject[i], predicate[j],
+						tvLongArray[j]);
+				model.add(stmt);
+				stmt = model.createLiteralStatement(subject[i], predicate[j],
+						tvCharArray[j]);
+				model.add(stmt);
+
+				stmt = model.createStatement(subject[i], predicate[j],
+						model.createTypedLiteral(tvFloatArray[j]));
+				model.add(stmt);
+				stmt = model.createStatement(subject[i], predicate[j],
+						model.createTypedLiteral(tvDoubleArray[j]));
+				model.add(stmt);
+
+				stmt = model.createStatement(subject[i], predicate[j],
+						tvStringArray[j]);
+				model.add(stmt);
+				stmt = model.createStatement(subject[i], predicate[j],
+						tvStringArray[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(tvBooleanArray[1]);
+		object[1] = model.createTypedLiteral(tvLongArray[1]);
+		object[2] = model.createTypedLiteral(tvCharArray[1]);
+		object[3] = model.createTypedLiteral(tvFloatArray[1]);
+		object[4] = model.createTypedLiteral(tvDoubleArray[1]);
+		object[5] = model.createLiteral(tvStringArray[1]);
+		object[6] = model.createLiteral(tvStringArray[1], lang[1]);
+		// object[7] = tvLitObj[1];
+		// object[7] = tvResObj[1];
+
+	}
+
+	@Test
+	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]);
+		}
+
+	}
+
+	@Test
+	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(tvBooleanArray[0])), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvBooleanArray[1])), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], (byte) tvLongArray[0]),
+				subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], (byte) tvLongArray[1]),
+				subjf);
+		assertFoundNone(subjf);
+
+		processIterator(model.listResourcesWithProperty(predicate[0],
+				(short) tvLongArray[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(model.listResourcesWithProperty(predicate[0],
+				(short) tvLongArray[1]), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], (int) tvLongArray[0]),
+				subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], (int) tvLongArray[1]),
+				subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], tvLongArray[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], tvLongArray[1]), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], tvCharArray[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0], tvCharArray[1]), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvDoubleArray[0])), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvDoubleArray[1])), subjf);
+		assertFoundNone(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvDoubleArray[0])), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listResourcesWithProperty(predicate[0],
+						model.createTypedLiteral(tvDoubleArray[1])), subjf);
+		assertFoundNone(subjf);
+	}
+
+	@Test
+	public void testListSubjectsWithProperty()
+	{
+		final boolean subjf[] = new boolean[num];
+		processIterator(
+				model.listSubjectsWithProperty(predicate[0], tvStringArray[0]),
+				subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listSubjectsWithProperty(predicate[0], tvStringArray[1]),
+				subjf);
+		assertFoundNone(subjf);
+
+		processIterator(model.listSubjectsWithProperty(predicate[0],
+				tvStringArray[0], lang[0]), subjf);
+		checkBooleanSubjects(subjf);
+
+		processIterator(
+				model.listSubjectsWithProperty(predicate[0], tvStringArray[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);
+		// }
+	}
+
+	
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractFindPropertiesTests.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractIteratorTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractIteratorTest.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractIteratorTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractIteratorTest.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,323 @@
+/*
+ * 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;
+
+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.testing_framework.AbstractModelProducerUser;
+import com.hp.hpl.jena.testing_framework.ModelProducerInterface;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractIteratorTest extends AbstractModelProducerUser 
+{
+	protected Model model;
+	private static int num = 5;
+	Resource subject[];
+	Property predicate[];
+	Statement stmts[];
+	
+	public static final String suri = "http://aldabaran/test6/s";
+	public static final String puri = "http://aldabaran/test6/";
+
+	@Override
+	public ModelProducerInterface getModelProducer() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Before
+	public void setupTestIterators() throws Exception
+	{
+		model = getModelProducer().newModel();
+		 subject = new Resource[num];
+		 predicate = new Property[num];
+		 stmts = new Statement[num * num];
+
+		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.
+	 */
+	@Test
+	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();
+		}
+
+	}
+
+	@Test
+	public void testListObjects()
+	{
+		int count = 0;
+		NodeIterator iter;
+		iter = model.listObjects();
+		while (iter.hasNext())
+		{
+			iter.nextNode();
+			count++;
+		}
+		Assert.assertEquals(num * num, count);
+	}
+
+	@Test
+	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]);
+		}
+	}
+
+	@Test
+	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]);
+			}
+		}
+
+	}
+
+	@Test
+	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]);
+		}
+	}
+
+	@Test
+	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 );
+		// }
+
+	}
+
+	@Test
+	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);
+	// } */
+	// }
+
+	
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractIteratorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListObjectsTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListObjectsTest.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListObjectsTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListObjectsTest.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,214 @@
+/*
+ * 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;
+
+import static com.hp.hpl.jena.testing_framework.ModelHelper.*;
+
+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.testing_framework.AbstractModelProducerUser;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractListObjectsTest extends AbstractModelProducerUser
+{
+	protected Model model;
+	protected Resource S;
+	protected Property P;
+
+	int num = 5;
+	
+	protected static int numObj = 7;
+	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/";
+	
+	Resource subject[] = new Resource[num];
+	Property predicate[] = new Property[num];
+	RDFNode object[] = new RDFNode[numObj];
+
+	@Before
+	public void setUp() throws Exception
+	{
+		model = getModelProducer().newModel();
+		S = model.createResource("http://nowhere.man/subject");
+		P = model.createProperty("http://nowhere.man/predicate");
+	}
+
+	protected Set<Statement> fill( final Model model )
+	{
+		final Set<Statement> statements = new HashSet<Statement>();
+		for (int i = 0; i < AbstractListObjectsTest.numberSubjects; i += 1)
+		{
+			for (int j = 0; j < AbstractListObjectsTest.numberPredicates; j += 1)
+			{
+				final Statement s = model
+						.createLiteralStatement(
+								resource(AbstractListObjectsTest.subjectPrefix + i),
+								property(AbstractListObjectsTest.predicatePrefix
+												+ j + "/p"),
+								(i * AbstractListObjectsTest.numberPredicates) + j);
+				model.add(s);
+				statements.add(s);
+			}
+		}
+		Assert.assertEquals(AbstractListObjectsTest.numberSubjects
+				* AbstractListObjectsTest.numberPredicates, model.size());
+		return statements;
+	}
+
+	protected Set<Literal> literalsFor( final int predicate )
+	{
+		final Set<Literal> result = new HashSet<Literal>();
+		for (int i = 0; i < AbstractListObjectsTest.numberSubjects; i += 1)
+		{
+			result.add(model
+					.createTypedLiteral((i * AbstractListObjectsTest.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(AbstractListObjectsTest.predicatePrefix + i + "/");
+		}
+		return result;
+	}
+
+	
+
+	protected Set<Resource> subjectSet( final int limit )
+	{
+		final Set<Resource> result = new HashSet<Resource>();
+		for (int i = 0; i < limit; i += 1)
+		{
+			result.add(resource(AbstractListObjectsTest.subjectPrefix + i));
+		}
+		return result;
+	}
+
+	@Test
+	public void testListNamespaces()
+	{
+		fill(model);
+		final List<String> L = model.listNameSpaces().toList();
+		Assert.assertEquals(AbstractListObjectsTest.numberPredicates, L.size());
+		final Set<String> wanted = predicateSet(AbstractListObjectsTest.numberPredicates);
+		Assert.assertEquals(wanted, new HashSet<String>(L));
+	}
+
+	@Test
+	public void testListObjects()
+	{
+		fill(model);
+		final Set<Literal> wanted = literalsUpto(AbstractListObjectsTest.numberSubjects
+				* AbstractListObjectsTest.numberPredicates);
+		Assert.assertEquals(wanted,
+				iteratorToSet(model.listObjects()));
+	}
+
+	@Test
+	public void testListObjectsOfPropertyByProperty()
+	{
+		fill(model);
+		final List<RDFNode> L = iteratorToList(model
+				.listObjectsOfProperty(
+						property(AbstractListObjectsTest.predicatePrefix + "0/p")));
+		Assert.assertEquals(AbstractListObjectsTest.numberSubjects, L.size());
+		final Set<Literal> wanted = literalsFor(0);
+		Assert.assertEquals(wanted, new HashSet<RDFNode>(L));
+	}
+
+	@Test
+	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 = iteratorToList(model
+				.listObjectsOfProperty(s, RDF.value));
+		Assert.assertEquals(size, L.size());
+		final Set<Literal> wanted = literalsUpto(size);
+		Assert.assertEquals(wanted, new HashSet<RDFNode>(L));
+	}
+	String suri = "http://aldabaran/test8/s";
+	String puri = "http://aldabaran/test8/";
+
+	boolean tvBooleanArray[] = { false, true };
+	long tvLongArray[] = { 123, 321 };
+	char tvCharArray[] = { '@', ';' };
+	float tvFloatArray[] = { 456.789f, 789.456f };
+	double tvDoubleArray[] = { 123.456, 456.123 };
+	String tvStringArray[] = { "testing string 1", "testing string 2" };
+	String lang[] = { "en", "fr" };
+	
+	@Test
+	public void testListObjectsNoRemove()
+	{
+		final Model m = modelWithStatements(getModelProducer(),
+				"a P b; b Q c; c R a");
+		final NodeIterator it = m.listObjects();
+		it.next();
+		try
+		{
+			it.remove();
+			Assert.fail("listObjects should not support .remove()");
+		}
+		catch (final UnsupportedOperationException e)
+		{
+			// expected
+		}
+	}
+	
+	
+	
+	
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListObjectsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListStatementsTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListStatementsTest.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListStatementsTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListStatementsTest.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,163 @@
+/**
+ * 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;
+
+import static com.hp.hpl.jena.testing_framework.ModelHelper.property;
+import static com.hp.hpl.jena.testing_framework.ModelHelper.resource;
+
+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.Resource;
+import com.hp.hpl.jena.rdf.model.Statement;
+import com.hp.hpl.jena.rdf.model.StmtIterator;
+import com.hp.hpl.jena.testing_framework.AbstractModelProducerUser;
+import com.hp.hpl.jena.vocabulary.OWL;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractListStatementsTest extends AbstractModelProducerUser
+{
+	private Model model;
+	private Resource s;
+	private Property p;
+
+	@Before
+	public void setupAbstractListStatementsTest() throws Exception
+	{
+		model = getModelProducer().newModel();
+		final Resource s = model
+				.createResource("http://www.a.com/s");
+		final Property p = model
+				.createProperty("http://www.a.com/p");
+
+		model.add(s, p,
+				model.createResource("http://www.a.com/o"));
+		model.add(s, p, "texte", "fr");
+		model.add(s, p, "text", "en");
+		model.add(s, p, "text");
+		model.add(model.createLiteralStatement(s,
+				p, 1789));
+	}
+
+	@Test
+	public final void thereAre2LitsWoLang()
+	{
+		final StmtIterator it = model.listStatements(
+				s, p, null, "");
+		Assert.assertTrue(it.toList().size() == 2);
+	}
+
+	@Test
+	public final void thereAre4Literals()
+	{
+		final StmtIterator it = model.listStatements(
+				s, p, null, null);
+		Assert.assertTrue(it.toList().size() == 4);
+	}
+
+	@Test
+	public final void thereIsOneFrench()
+	{
+		final StmtIterator it = model.listStatements(
+				s, p, null, "fr");
+		final List<Statement> lis = it.toList();
+		Assert.assertTrue(lis.size() == 1);
+		Assert.assertTrue(lis.get(0).getObject().toString().equals("texte@fr"));
+	}
+
+	@Test
+	public final void theresAreTwoText()
+	{
+		final StmtIterator it = model.listStatements(
+				s, p, "text", null);
+		final List<Statement> lis = it.toList();
+		Assert.assertTrue(lis.size() == 2);
+	}
+
+	@Test
+	public final void theresOneTextEN()
+	{
+		final StmtIterator it = model.listStatements(
+				s, p, "text", "en");
+		final List<Statement> lis = it.toList();
+		Assert.assertTrue(lis.size() == 1);
+		Assert.assertTrue(lis.get(0).getObject().toString().equals("text@en"));
+	}
+
+	@Test
+	public final void theresOneTextWoLang()
+	{
+		final StmtIterator it = model.listStatements(
+				s, p, "text", "");
+		final List<Statement> lis = it.toList();
+		Assert.assertTrue(lis.size() == 1);
+	}
+	
+	@Test
+	public final void theresOneWithABNodeObject()
+	{
+	    Model m = ModelFactory.createDefaultModel();
+	    Resource anon = m.createResource();
+	    m.createResource("http://example").addProperty(RDF.type, anon);
+	    
+	    StmtIterator it = m.listStatements(null, null, anon);
+	    final List<Statement> lis = it.toList();
+	    Assert.assertTrue(lis.size() == 1);
+	    
+	}
+	
+	protected Set<Statement> fill( final Model model )
+	{
+		final Set<Statement> statements = new HashSet<Statement>();
+		for (int i = 0; i < AbstractListObjectsTest.numberSubjects; i += 1)
+		{
+			for (int j = 0; j < AbstractListObjectsTest.numberPredicates; j += 1)
+			{
+				final Statement s = model
+						.createLiteralStatement(
+								resource(AbstractListObjectsTest.subjectPrefix + i),
+								property(AbstractListObjectsTest.predicatePrefix
+												+ j + "/p"),
+								(i * AbstractListObjectsTest.numberPredicates) + j);
+				model.add(s);
+				statements.add(s);
+			}
+		}
+		Assert.assertEquals(AbstractListObjectsTest.numberSubjects
+				* AbstractListObjectsTest.numberPredicates, model.size());
+		return statements;
+	}
+
+	@Test
+	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));
+	}
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListStatementsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListSubjectsTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListSubjectsTest.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListSubjectsTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListSubjectsTest.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,362 @@
+/*
+ * 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;
+
+import static com.hp.hpl.jena.testing_framework.GraphHelper.iteratorToSet;
+import static com.hp.hpl.jena.testing_framework.ModelHelper.*;
+
+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.shared.PropertyNotFoundException;
+import com.hp.hpl.jena.testing_framework.AbstractModelProducerUser;
+import com.hp.hpl.jena.util.iterator.WrappedIterator;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractListSubjectsTest extends AbstractModelProducerUser
+{
+
+	private static final String subjectPrefix = "http://aldabaran/test8/s";
+
+	private static final String predicatePrefix = "http://aldabaran/test8/";
+
+	private Model model;
+	
+	private Resource[] subjects;
+
+	private Property[] predicates;
+
+	private RDFNode[] objects;
+	// Literal [] tvLitObjs;
+	private static Resource[] tvResObjs;
+	private static boolean[] tvBooleans = { false, true };
+	private static long[] tvLongs = { 123, 321 };
+
+	private static char[] tvChars = { '@', ';' };
+	private static float[] tvFloats = { 456.789f, 789.456f };
+	private static double[] tvDoubles = { 123.456, 456.123 };
+	private static String[] tvStrings = { "test8 testing string 1", "test8 testing string 2" };
+	private static String[] langs = { "en", "fr" };
+
+	
+	private void assertEquiv( final Set<? extends Resource> set,
+			final Iterator<? extends Resource> iterator )
+	{
+		final List<? extends Resource> L = WrappedIterator.create(iterator)
+				.toList();
+		Assert.assertEquals(set.size(), L.size());
+		Assert.assertEquals(set, new HashSet<Resource>(L));
+	}
+	
+	@Before
+	public void fillModel()
+	{
+		model = getModelProducer().newModel();
+		final int num = 5;
+		// tvLitObjs = new Literal[]
+		// { model.createTypedLiteral( new LitTestObjF() ),
+		// model.createTypedLiteral( new LitTestObjF() ) };
+
+		// tvResObjs = new Resource[]
+		// { model.createResource( new ResTestObjF() ),
+		// model.createResource( new ResTestObjF() ) };
+
+		objects = new RDFNode[] { model.createTypedLiteral(tvBooleans[1]),
+				model.createTypedLiteral(tvLongs[1]),
+				model.createTypedLiteral(tvChars[1]),
+				model.createTypedLiteral(tvFloats[1]),
+				model.createTypedLiteral(tvDoubles[1]),
+				model.createLiteral(tvStrings[1]),
+				model.createLiteral(tvStrings[1], langs[1])
+		// tvLitObjs[1],
+		// tvResObjs[1]
+		};
+
+		subjects = new Resource[num];
+		predicates = new Property[num];
+
+		for (int i = 0; i < num; i++)
+		{
+			subjects[i] = model.createResource(AbstractListSubjectsTest.subjectPrefix
+					+ i);
+			predicates[i] = model.createProperty(
+					AbstractListSubjectsTest.predicatePrefix + i, "p");
+		}
+
+		for (int i = 0; i < num; i += 1)
+		{
+			model.addLiteral(subjects[i], predicates[4], false);
+		}
+
+		for (int i = 0; i < 2; i += 1)
+		{
+			for (int j = 0; j < 2; j += 1)
+			{
+				model.add(subjects[i], predicates[j],
+						model.createTypedLiteral(tvBooleans[j]));
+				model.addLiteral(subjects[i], predicates[j], tvLongs[j]);
+				model.addLiteral(subjects[i], predicates[j], tvChars[j]);
+				model.add(subjects[i], predicates[j],
+						model.createTypedLiteral(tvFloats[j]));
+				model.add(subjects[i], predicates[j],
+						model.createTypedLiteral(tvDoubles[j]));
+				model.add(subjects[i], predicates[j], tvStrings[j]);
+				model.add(subjects[i], predicates[j], tvStrings[j], langs[j]);
+				// model.add(subjects[i], predicates[j], tvLitObjs[j] );
+				// model.add(subjects[i], predicates[j], tvResObjs[j] );
+			}
+		}
+	}
+
+	// the methods are deprecated, the tests eliminated
+	// public void testListResourcesOnObject()
+	// {
+	// Object d = new Date();
+	// Model model = modelWithStatements( "" );
+	// model.addLiteral( resource( "S" ), property( "P" ), d );
+	// model.addLiteral( resource( "X" ), property( "P" ), new Object() );
+	// List answers = model.listResourcesWithProperty( property( "P" ), d
+	// ).toList();
+	// assertEquals( listOfOne( resource( "S" ) ), answers );
+	// }
+
+	protected Set<Resource> subjectsTo( final String prefix, final int limit )
+	{
+		final Set<Resource> result = new HashSet<Resource>();
+		for (int i = 0; i < limit; i += 1)
+		{
+			result.add(resource(prefix + i));
+		}
+		return result;
+	}
+
+	@Test
+	public void testGetRequiredProperty()
+	{
+		model.getRequiredProperty(subjects[1], predicates[1]);
+		try
+		{
+			model.getRequiredProperty(subjects[1], RDF.value);
+			Assert.fail("should not find absent property");
+		}
+		catch (final PropertyNotFoundException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testListSubjects()
+	{
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 5),
+				model.listResourcesWithProperty(predicates[4]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0], tvBooleans[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listResourcesWithProperty(predicates[0], tvBooleans[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0], tvChars[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listResourcesWithProperty(predicates[0], tvChars[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0], tvLongs[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listResourcesWithProperty(predicates[0], tvLongs[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0], tvFloats[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listResourcesWithProperty(predicates[0], tvFloats[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0], tvDoubles[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listResourcesWithProperty(predicates[0], tvDoubles[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0],
+						(byte) tvLongs[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listResourcesWithProperty(predicates[0],
+						(byte) tvLongs[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0],
+						(short) tvLongs[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listResourcesWithProperty(predicates[0],
+						(short) tvLongs[1]));
+
+		assertEquiv(
+				subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listResourcesWithProperty(predicates[0], (int) tvLongs[0]));
+
+		assertEquiv(
+				subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listResourcesWithProperty(predicates[0], (int) tvLongs[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listSubjectsWithProperty(predicates[0], tvStrings[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listSubjectsWithProperty(predicates[0], tvStrings[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 2),
+				model.listSubjectsWithProperty(predicates[0], tvStrings[0],
+						langs[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listSubjectsWithProperty(predicates[0], tvStrings[1],
+						langs[0]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listSubjectsWithProperty(predicates[0], tvStrings[0],
+						langs[1]));
+
+		assertEquiv(subjectsTo(AbstractListSubjectsTest.subjectPrefix, 0),
+				model.listSubjectsWithProperty(predicates[0], tvStrings[1],
+						langs[1]));
+
+		// assertEquiv( subjectsTo( subjectPrefix, 2 ),
+		// model.listResourcesWithProperty( predicates[0], tvLitObjs[0] ) );
+		//
+		// assertEquiv( subjectsTo( subjectPrefix, 0 ),
+		// model.listResourcesWithProperty( predicates[0], tvLitObjs[1] ) );
+		//
+		// assertEquiv( subjectsTo( subjectPrefix, 0 ),
+		// model.listResourcesWithProperty( predicates[0], tvResObjs[0] ) );
+		//
+		// assertEquiv( subjectsTo( subjectPrefix, 0 ),
+		// model.listResourcesWithProperty( predicates[0], tvResObjs[1] ) );
+
+		// assertEquiv( new HashSet( Arrays.asList( objects ) ),
+		// model.listObjectsOfProperty( predicates[1] ) );
+	}
+
+	@Test
+	public void testListSubjectsNoRemove()
+	{
+		final Model m = modelWithStatements(getModelProducer(),
+				"a P b; b Q c; c R a");
+		final ResIterator it = m.listSubjects();
+		it.next();
+		try
+		{
+			it.remove();
+			Assert.fail("listSubjects should not support .remove()");
+		}
+		catch (final UnsupportedOperationException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testListSubjectsWorksAfterRemoveProperties()
+	{
+		final Model m = modelWithStatements(getModelProducer(),
+				"p1 before terminal; p2 before terminal");
+		m.createResource("eh:/p1").removeProperties();
+		assertIsoModels(
+				modelWithStatements(getModelProducer(), "p2 before terminal"), m);
+		Assert.assertEquals(resourceSet("p2"), m.listSubjects()
+				.toSet());
+	}
+
+	@Test
+	public void testListSubjectsWorksAfterRemovePropertiesWIthLots()
+	{
+		final Model m = modelWithStatements(getModelProducer(),
+				"p2 before terminal");
+		for (int i = 0; i < 100; i += 1)
+		{
+			modelAdd(m, "p1 hasValue " + i);
+		}
+		m.createResource("eh:/p1").removeProperties();
+		assertIsoModels(
+				modelWithStatements(getModelProducer(), "p2 before terminal"), m);
+		Assert.assertEquals(resourceSet("p2"), m.listSubjects()
+				.toSet());
+	}
+
+	protected Set<Statement> fill( final Model model )
+	{
+		final Set<Statement> statements = new HashSet<Statement>();
+		for (int i = 0; i < AbstractListObjectsTest.numberSubjects; i += 1)
+		{
+			for (int j = 0; j < AbstractListObjectsTest.numberPredicates; j += 1)
+			{
+				final Statement s = model
+						.createLiteralStatement(
+								resource(AbstractListObjectsTest.subjectPrefix + i),
+								property(AbstractListObjectsTest.predicatePrefix
+												+ j + "/p"),
+								(i * AbstractListObjectsTest.numberPredicates) + j);
+				model.add(s);
+				statements.add(s);
+			}
+		}
+		Assert.assertEquals(AbstractListObjectsTest.numberSubjects
+				* AbstractListObjectsTest.numberPredicates, model.size());
+		return statements;
+	}
+	
+	protected Set<Resource> subjectSet( final int limit )
+	{
+		final Set<Resource> result = new HashSet<Resource>();
+		for (int i = 0; i < limit; i += 1)
+		{
+			result.add(resource(AbstractListObjectsTest.subjectPrefix + i));
+		}
+		return result;
+	}
+	
+	@Test
+	public void testListSubjects2()
+	{
+		fill(model);
+		final List<Resource> L = model.listSubjects().toList();
+		Assert.assertEquals(AbstractListObjectsTest.numberSubjects, L.size());
+		final Set<Resource> wanted = subjectSet(AbstractListObjectsTest.numberSubjects);
+		Assert.assertEquals(wanted, iteratorToSet(L.iterator()));
+	}
+	
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListSubjectsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractLiteralTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractLiteralTest.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractLiteralTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractLiteralTest.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,543 @@
+/*
+ * 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;
+
+import static com.hp.hpl.jena.testing_framework.ModelHelper.*;
+
+import com.hp.hpl.jena.datatypes.TypeMapper;
+import com.hp.hpl.jena.graph.impl.AdhocDatatype;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.LiteralRequiredException;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.testing_framework.AbstractModelProducerUser;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * TestLiteralImpl - minimal, this is the first time an extra test has
+ * been needed above
+ * the regression testing.
+ */
+public abstract class AbstractLiteralTest extends AbstractModelProducerUser 
+{
+
+	private static Model model;
+	private Resource X;
+	private Property P;
+	
+	static class UniqueValueClass1
+	{
+		String value;
+
+		UniqueValueClass1( final String value )
+		{
+			this.value = value;
+		}
+
+		@Override
+		public String toString()
+		{
+			return value;
+		}
+	}
+
+	static class UniqueValueClass2
+	{
+		String value;
+
+		UniqueValueClass2( final String value )
+		{
+			this.value = value;
+		}
+
+		@Override
+		public String toString()
+		{
+			return value;
+		}
+	}
+	
+	@Before
+	public void setupAbstractLiteralTest() {
+		model = getModelProducer().newModel();
+		X = resource("X");
+		P = property("P");
+	}
+
+	/**
+	 * Test that a literal node can be as'ed into a literal.
+	 */
+	@Test
+	public void testAsLiteral()
+	{
+		literal( "17").as(Literal.class);
+	}
+
+	/**
+	 * Test that a non-literal node cannot be as'ed into a literal
+	 */
+	@Test
+	public void testCannotAsNonLiteral()
+	{
+		try
+		{
+			resource("plumPie").as(Literal.class);
+			Assert.fail("non-literal cannot be converted to literal");
+		}
+		catch (final LiteralRequiredException l)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testInModel()
+	{
+		final Model m2 = getModelProducer().newModel();
+		final Literal l1 = model.createLiteral("17");
+		final Literal l2 = l1.inModel(m2);
+		Assert.assertEquals(l1, l2);
+		Assert.assertSame(m2, l2.getModel());
+	}
+
+	@Test
+	public void testLiteralHasModel()
+	{
+		testLiteralHasModel(model, model.createLiteral("hello, world"));
+		testLiteralHasModel(model, model.createLiteral("hello, world", "en-UK"));
+		testLiteralHasModel(model, model.createLiteral("hello, world", true));
+		testLiteralHasModel(model, model.createTypedLiteral("hello, world"));
+		testLiteralHasModel(model, model.createTypedLiteral(false));
+		testLiteralHasModel(model, model.createTypedLiteral(17));
+		testLiteralHasModel(model, model.createTypedLiteral('x'));
+	}
+
+	private void testLiteralHasModel( final Model m, final Literal lit )
+	{
+		Assert.assertSame(m, lit.getModel());
+	}
+
+	@Test
+	public void testSameAdhocClassUS()
+	{
+		try
+		{
+			final UniqueValueClass1 ra = new UniqueValueClass1("rhubarb");
+			final UniqueValueClass1 rb = new UniqueValueClass1("cottage");
+			Assert.assertNull("not expecting registered RDF Datatype",
+					TypeMapper.getInstance().getTypeByValue(ra));
+			final Literal la = model.createTypedLiteral(ra); // Sets the type
+																// mapper
+			// - contaminates it
+			// with
+			// UniqueValueClass1
+			final Literal lb = model.createTypedLiteral(rb);
+			assertInstanceOf(AdhocDatatype.class, la.getDatatype());
+			Assert.assertSame(la.getDatatype(), lb.getDatatype());
+			Assert.assertNotNull(TypeMapper.getInstance().getTypeByValue(ra));
+		}
+		finally
+		{
+			TypeMapper.reset();
+		}
+	}
+
+	// Tests are not necessarily run in order so use UniqueValueClass2
+	@Test
+	public void testTypedLiteralTypesAndValues()
+	{
+		// Resource r = model.createResource( "eh:/rhubarb" );
+		final UniqueValueClass2 r = new UniqueValueClass2("rhubarb");
+		Assert.assertNull("not expecting registered RDF Datatype", TypeMapper
+				.getInstance().getTypeByValue(r));
+		final Literal typed = model.createTypedLiteral(r); // Sets the type
+		// mapper -
+		// contaminates it
+		// with
+		// UniqueValueClass2
+		final Literal string = model.createLiteral(r.value);
+		Assert.assertEquals(string.getLexicalForm(), typed.getLexicalForm());
+		Assert.assertEquals(string.getLanguage(), typed.getLanguage());
+		assertDiffer(string.getDatatypeURI(),
+				typed.getDatatypeURI());
+		Assert.assertNotNull(
+				"a datatype should have been invented for Resource[Impl]",
+				typed.getDatatype());
+		assertDiffer(typed, string);
+		assertDiffer(typed.getValue(), string.getValue());
+		Assert.assertEquals(r, typed.getValue());
+		assertDiffer(typed.hashCode(), string.hashCode());
+	}
+
+	protected void assertInRange( final long min, final long x, final long max )
+	{
+		if ((min <= x) && (x <= max))
+		{
+			return;
+		}
+		else
+		{
+			Assert.fail("outside range: " + x + " min: " + min + " max: " + max);
+		}
+	}
+
+	protected void assertOutsideRange( final long min, final long x,
+			final long max )
+	{
+		if ((min <= x) && (x <= max))
+		{
+			Assert.fail("inside range: " + x + " min: " + min + " max: " + max);
+		}
+	}
+
+	@Test
+	public void testBooleans()
+	{
+		Assert.assertTrue(model.createTypedLiteral(true).getBoolean());
+		Assert.assertFalse(model.createTypedLiteral(false).getBoolean());
+	}
+
+	protected void testByte( final Model model, final byte tv )
+	{
+		final Literal l = model.createTypedLiteral(tv);
+		Assert.assertEquals(tv, l.getByte());
+		Assert.assertEquals(tv, l.getShort());
+		Assert.assertEquals(tv, l.getInt());
+		Assert.assertEquals(tv, l.getLong());
+	}
+
+	@Test
+	public void testByteLiterals()
+	{
+		testByte(model, (byte) 0);
+		testByte(model, (byte) -1);
+		testByte(model, Byte.MIN_VALUE);
+		testByte(model, Byte.MAX_VALUE);
+	}
+
+	protected void testCharacter( final Model model, final char tv )
+	{
+		Assert.assertEquals(tv, model.createTypedLiteral(tv).getChar());
+	}
+
+	@Test
+	public void testCharacterLiterals()
+	{
+		testCharacter(model, 'A');
+		testCharacter(model, 'a');
+		testCharacter(model, '#');
+		testCharacter(model, '@');
+		testCharacter(model, '0');
+		testCharacter(model, '9');
+		testCharacter(model, '\u1234');
+		testCharacter(model, '\u5678');
+	}
+
+	protected void testDouble( final Model model, final double tv )
+	{
+		Assert.assertEquals(tv, model.createTypedLiteral(tv).getDouble(),
+				dDelta);
+	}
+
+	@Test
+	public void testDoubleLiterals()
+	{
+		testDouble(model, 0.0);
+		testDouble(model, 1.0);
+		testDouble(model, -1.0);
+		testDouble(model, 12345.678901);
+		testDouble(model, Double.MIN_VALUE);
+		testDouble(model, Double.MAX_VALUE);
+	}
+
+	protected void testFloat( final Model model, final float tv )
+	{
+		Assert.assertEquals(tv, model.createTypedLiteral(tv).getFloat(),
+				fDelta);
+	}
+
+	@Test
+	public void testFloatLiterals()
+	{
+		testFloat(model, 0.0f);
+		testFloat(model, 1.0f);
+		testFloat(model, -1.0f);
+		testFloat(model, 12345.6789f);
+		testFloat(model, Float.MIN_VALUE);
+		testFloat(model, Float.MAX_VALUE);
+	}
+
+	// public void testLiteralObjects()
+	// {
+	// // testLiteralObject( model, 0 );
+	// // testLiteralObject( model, 12345 );
+	// // testLiteralObject( model, -67890 );
+	// }
+
+	protected void testInt( final Model model, final int tv )
+	{
+		final Literal l = model.createTypedLiteral(tv);
+		try
+		{
+			Assert.assertEquals(tv, l.getByte());
+			assertInRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		catch (final NumberFormatException e)
+		{
+			assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		catch (final IllegalArgumentException e)
+		{
+			assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		try
+		{
+			Assert.assertEquals(tv, l.getShort());
+			assertInRange(Short.MIN_VALUE, tv, Short.MAX_VALUE);
+		}
+		catch (final NumberFormatException e)
+		{
+			assertOutsideRange(Short.MIN_VALUE, tv, Short.MAX_VALUE);
+		}
+		catch (final IllegalArgumentException e)
+		{
+			assertOutsideRange(Short.MIN_VALUE, tv, Short.MAX_VALUE);
+		}
+		Assert.assertEquals(tv, l.getInt());
+		Assert.assertEquals(tv, l.getLong());
+	}
+
+	@Test
+	public void testIntLiterals()
+	{
+		testInt(model, 0);
+		testInt(model, -1);
+		testInt(model, Integer.MIN_VALUE);
+		testInt(model, Integer.MAX_VALUE);
+	}
+
+	protected void testLanguagedString( final Model model, final String tv,
+			final String lang )
+	{
+		final Literal l = model.createLiteral(tv, lang);
+		Assert.assertEquals(tv, l.getString());
+		Assert.assertEquals(tv, l.getLexicalForm());
+		Assert.assertEquals(lang, l.getLanguage());
+	}
+
+	@Test
+	public void testLanguagedStringLiterals()
+	{
+		testLanguagedString(model, "", "en");
+		testLanguagedString(model, "chat", "fr");
+	}
+
+	protected void testLong( final Model model, final long tv )
+	{
+		final Literal l = model.createTypedLiteral(tv);
+		try
+		{
+			Assert.assertEquals(tv, l.getByte());
+			assertInRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		catch (final NumberFormatException e)
+		{
+			assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		catch (final IllegalArgumentException e)
+		{
+			assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		try
+		{
+			Assert.assertEquals(tv, l.getShort());
+			assertInRange(Short.MIN_VALUE, tv, Short.MAX_VALUE);
+		}
+		catch (final NumberFormatException e)
+		{
+			assertOutsideRange(Short.MIN_VALUE, tv, Short.MAX_VALUE);
+		}
+		catch (final IllegalArgumentException e)
+		{
+			assertOutsideRange(Short.MIN_VALUE, tv, Short.MAX_VALUE);
+		}
+		try
+		{
+			Assert.assertEquals(tv, l.getInt());
+			assertInRange(Integer.MIN_VALUE, tv, Integer.MAX_VALUE);
+		}
+		catch (final NumberFormatException e)
+		{
+			assertOutsideRange(Integer.MIN_VALUE, tv, Integer.MAX_VALUE);
+		}
+		catch (final IllegalArgumentException e)
+		{
+			assertOutsideRange(Integer.MIN_VALUE, tv, Integer.MAX_VALUE);
+		}
+		Assert.assertEquals(tv, l.getLong());
+	}
+
+	@Test
+	public void testLongLiterals()
+	{
+		testLong(model, 0);
+		testLong(model, -1);
+		testLong(model, Long.MIN_VALUE);
+		testLong(model, Long.MAX_VALUE);
+	}
+
+	protected void testPlainString( final Model model, final String tv )
+	{
+		final Literal l = model.createLiteral(tv);
+		Assert.assertEquals(tv, l.getString());
+		Assert.assertEquals(tv, l.getLexicalForm());
+		Assert.assertEquals("", l.getLanguage());
+	}
+
+	@Test
+	public void testPlainStringLiterals()
+	{
+		testPlainString(model, "");
+		testPlainString(model, "A test string");
+		testPlainString(model, "Another test string");
+	}
+
+	protected void testShort( final Model model, final short tv )
+	{
+		final Literal l = model.createTypedLiteral(tv);
+		try
+		{
+			Assert.assertEquals(tv, l.getByte());
+			assertInRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		catch (final NumberFormatException e)
+		{
+			assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		catch (final IllegalArgumentException e)
+		{
+			assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE);
+		}
+		Assert.assertEquals(tv, l.getShort());
+		Assert.assertEquals(tv, l.getInt());
+		Assert.assertEquals(tv, l.getLong());
+	}
+
+	@Test
+	public void testShortLiterals()
+	{
+		testShort(model, (short) 0);
+		testShort(model, (short) -1);
+		testShort(model, Short.MIN_VALUE);
+		testShort(model, Short.MAX_VALUE);
+	}
+
+	@Test
+	public void testStringLiteralEquality()
+	{
+		Assert.assertEquals(model.createLiteral("A"), model.createLiteral("A"));
+		Assert.assertEquals(model.createLiteral("Alpha"),
+				model.createLiteral("Alpha"));
+		assertDiffer(model.createLiteral("Alpha"),
+				model.createLiteral("Beta"));
+		assertDiffer(model.createLiteral("A", "en"),
+				model.createLiteral("A"));
+		assertDiffer(model.createLiteral("A"),
+				model.createLiteral("A", "en"));
+		assertDiffer(model.createLiteral("A", "en"),
+				model.createLiteral("A", "fr"));
+		Assert.assertEquals(model.createLiteral("A", "en"),
+				model.createLiteral("A", "en"));
+	}
+
+	// protected void testLiteralObject( Model model, int x )
+	// {
+	// LitTestObj tv = new LitTestObj( x );
+	// LitTestObjF factory = new LitTestObjF();
+	// assertEquals( tv, model.createTypedLiteral( tv ).getObject( factory ) );
+	// }
+	
+	@Test
+	public void testAddWithBooleanObject()
+	{
+		model.addLiteral(X, P, true);
+		Assert.assertTrue(model.contains(X, P, model.createTypedLiteral(true)));
+		Assert.assertTrue(model.containsLiteral(X, P, true));
+	}
+
+	@Test
+	public void testAddWithCharObject()
+	{
+		model.addLiteral(X, P, 'x');
+		Assert.assertTrue(model.contains(X, P, model.createTypedLiteral('x')));
+		Assert.assertTrue(model.containsLiteral(X, P, 'x'));
+	}
+
+	@Test
+	public void testAddWithDoubleObject()
+	{
+		model.addLiteral(X, P, 14.0d);
+		Assert.assertTrue(model.contains(X, P, model.createTypedLiteral(14.0d)));
+		Assert.assertTrue(model.containsLiteral(X, P, 14.0d));
+	}
+
+	@Test
+	public void testAddWithFloatObject()
+	{
+		model.addLiteral(X, P, 14.0f);
+		Assert.assertTrue(model.contains(X, P, model.createTypedLiteral(14.0f)));
+		Assert.assertTrue(model.containsLiteral(X, P, 14.0f));
+	}
+
+	@Test
+	public void testAddWithIntObject()
+	{
+		model.addLiteral(X, P, 99);
+		Assert.assertTrue(model.contains(X, P, model.createTypedLiteral(99)));
+		Assert.assertTrue(model.containsLiteral(X, P, 99));
+	}
+
+	@Test
+	public void testAddWithLiteralObject()
+	{
+		final Literal lit = model.createLiteral("spoo");
+		model.addLiteral(X, P, lit);
+		Assert.assertTrue(model.contains(X, P, lit));
+		Assert.assertTrue(model.containsLiteral(X, P, lit));
+	}
+
+	@Test
+	public void testAddWithLongObject()
+	{
+		model.addLiteral(X, P, 99L);
+		Assert.assertTrue(model.contains(X, P, model.createTypedLiteral(99L)));
+		Assert.assertTrue(model.containsLiteral(X, P, 99L));
+	}
+
+	// that version of addLiteral is deprecated; test removed.
+	// public void testAddWithAnObject()
+	// {
+	// Object z = new Date();
+	// model.addLiteral( X, P, z );
+	// assertTrue( model.contains( X, P, model.createTypedLiteral( z ) ) );
+	// assertTrue( model.containsLiteral( X, P, z ) );
+	// }
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractLiteralTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,158 @@
+/*
+ * 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;
+
+import static com.hp.hpl.jena.testing_framework.ModelHelper.*;
+
+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.testing_framework.AbstractModelProducerUser;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public abstract class AbstractModelExtractTest extends AbstractModelProducerUser
+{
+	
+	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;
+		}
+	};
+
+	@Test
+	public void testAsTripleBoundary()
+	{
+		final Model m = ModelFactory.createDefaultModel();
+		Assert.assertTrue(AbstractModelExtractTest.sbTrue.asTripleBoundary(m).stopAt(
+				GraphTestBase.triple("x R y")));
+		Assert.assertFalse(AbstractModelExtractTest.sbFalse.asTripleBoundary(m).stopAt(
+				GraphTestBase.triple("x R y")));
+	}
+
+	@Test
+	public void testInvokesExtract()
+	{
+		final MockModelExtract mock = new MockModelExtract(
+				AbstractModelExtractTest.sbTrue);
+		final Model source = modelWithStatements(getModelProducer(), "a R b");
+		final Model m = mock.extract(resource("a"), source);
+		Assert.assertEquals(GraphTestBase.node("a"), mock.root);
+		Assert.assertSame(mock.result, m.getGraph());
+		Assert.assertSame(mock.subject, source.getGraph());
+	}
+
+	@Test
+	public void testRemembersBoundary()
+	{
+		Assert.assertSame(AbstractModelExtractTest.sbTrue, new MockModelExtract(
+				AbstractModelExtractTest.sbTrue).getStatementBoundary());
+		Assert.assertSame(AbstractModelExtractTest.sbFalse, new MockModelExtract(
+				AbstractModelExtractTest.sbFalse).getStatementBoundary());
+	}
+
+	@Test
+	public void testStatementContinueWith()
+	{
+		final StatementBoundary sb = new StatementBoundaryBase() {
+			@Override
+			public boolean continueWith( final Statement s )
+			{
+				return false;
+			}
+		};
+		Assert.assertTrue(sb.stopAt(statement("x pings y")));
+	}
+
+	@Test
+	public void testStatementTripleBoundaryAnon()
+	{
+		final TripleBoundary anon = TripleBoundary.stopAtAnonObject;
+		Assert.assertSame(anon,
+				new StatementTripleBoundary(anon).asTripleBoundary(null));
+		Assert.assertFalse(new StatementTripleBoundary(anon).stopAt(statement("s P o")));
+		Assert.assertTrue(new StatementTripleBoundary(anon).stopAt(statement("s P _o")));
+	}
+
+	@Test
+	public void testStatementTripleBoundaryNowhere()
+	{
+		final TripleBoundary nowhere = TripleBoundary.stopNowhere;
+		Assert.assertSame(nowhere,
+				new StatementTripleBoundary(nowhere).asTripleBoundary(null));
+		Assert.assertFalse(new StatementTripleBoundary(nowhere)
+				.stopAt(statement("s P _o")));
+		Assert.assertFalse(new StatementTripleBoundary(nowhere)
+				.stopAt(statement("s P o")));
+	}
+
+	
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelMakerTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelMakerTest.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelMakerTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelMakerTest.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,263 @@
+/*
+ * 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;
+
+import static com.hp.hpl.jena.testing_framework.ModelHelper.*;
+
+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.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 java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Test ModelMakerImpl using a mock GraphMaker.
+ */
+@SuppressWarnings("deprecation")
+public abstract class AbstractModelMakerTest 
+{
+	abstract protected ModelMaker getModelMaker();
+	
+	abstract protected Graph getModelMakerGraph();
+	
+	abstract protected GraphMaker getGraphMaker();
+	
+	public 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 graphWith("");
+		}
+
+		public Graph getDescription( final Node root )
+		{
+			history.add("getDescription(Node)");
+			return graphWith("");
+		}
+
+		@Override
+		public Graph getGraph()
+		{
+			history.add("get()");
+			return graph;
+		}
+
+		@Override
+		@Deprecated
+		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 void checkHistory( final List<String> expected )
+	{
+		Assert.assertEquals(expected, history());
+	}
+
+	private List<String> history()
+	{
+		return ((MockGraphMaker) getModelMaker().getGraphMaker()).history;
+	}
+
+	@Test
+	public void testClose()
+	{
+		getModelMaker().close();
+		checkHistory(listOfOne("close()"));
+	}
+
+	@Test
+	public void testCreateDefaultModel()
+	{
+		getModelMaker().createDefaultModel();
+		checkHistory(listOfOne("get()"));
+	}
+
+	@Test
+	public void testCreateFalse()
+	{
+		final Model m = getModelMaker().createModel("leaf", false);
+		checkHistory(listOfOne("create(leaf,false)"));
+		Assert.assertTrue(m.getGraph() == getModelMakerGraph() );
+	}
+
+	@Test
+	public void testCreateFreshModel()
+	{
+		getModelMaker().createFreshModel();
+		checkHistory(listOfOne("create()"));
+	}
+
+	@Test
+	public void testCreateNamed()
+	{
+		final Model m = getModelMaker().createModel("petal");
+		checkHistory(listOfOne("create(petal,false)"));
+		Assert.assertTrue(m.getGraph() == getModelMakerGraph());
+	}
+
+	@Test
+	public void testCreateTrue()
+	{
+		final Model m = getModelMaker().createModel("stem", true);
+		checkHistory(listOfOne("create(stem,true)"));
+		Assert.assertTrue(m.getGraph() == getModelMakerGraph());
+	}
+
+	@Test
+	public void testGetGraphMaker()
+	{
+		Assert.assertTrue(getModelMaker().getGraphMaker() == getGraphMaker());
+	}
+
+	@Test
+	public void testListGraphs()
+	{
+		getModelMaker().listModels().close();
+		checkHistory(listOfOne("listModels()"));
+	}
+
+	@Test
+	public void testOpen()
+	{
+		final Model m = getModelMaker().openModel("trunk");
+		checkHistory(listOfOne("open(trunk,false)"));
+		Assert.assertTrue(m.getGraph() == getModelMakerGraph());
+	}
+
+	@Test
+	public void testOpenFalse()
+	{
+		final Model m = getModelMaker().openModel("branch", false);
+		checkHistory(listOfOne("open(branch,false)"));
+		Assert.assertTrue(m.getGraph() == getModelMakerGraph());
+	}
+
+	@Test
+	public void testOpenTrue()
+	{
+		final Model m = getModelMaker().openModel("bark", true);
+		checkHistory(listOfOne("open(bark,true)"));
+		Assert.assertTrue(m.getGraph() == getModelMakerGraph());
+	}
+
+	@Test
+	public void testRemove()
+	{
+		getModelMaker().removeModel("London");
+		checkHistory(listOfOne("remove(London)"));
+	}
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelMakerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelPrefixMappingTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelPrefixMappingTest.java?rev=1523135&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelPrefixMappingTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelPrefixMappingTest.java Fri Sep 13 22:32:05 2013
@@ -0,0 +1,154 @@
+/*
+ * 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;
+
+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.impl.ModelCom;
+import com.hp.hpl.jena.shared.AbstractPrefixMappingTest;
+import com.hp.hpl.jena.shared.PrefixMapping;
+import com.hp.hpl.jena.testing_framework.ModelProducerUserInterface;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test that a model is a prefix mapping.
+ * 
+ */
+public abstract class AbstractModelPrefixMappingTest extends AbstractPrefixMappingTest implements ModelProducerUserInterface
+{
+
+	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(AbstractModelPrefixMappingTest.alphaPrefix,
+					AbstractModelPrefixMappingTest.alphaURI)
+			.setNsPrefix(AbstractModelPrefixMappingTest.betaPrefix,
+					AbstractModelPrefixMappingTest.betaURI);
+
+	private PrefixMapping prevMap;
+
+	final protected PrefixMapping getMapping()
+	{
+		return getModelProducer().newModel();
+	}
+	
+	/**
+	 * 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(AbstractModelPrefixMappingTest.alphaPrefix, newURI);
+		final Model m = ModelFactory.createModelForGraph(g);
+		Assert.assertEquals(newURI,
+				m.getNsPrefixURI(AbstractModelPrefixMappingTest.alphaPrefix));
+		Assert.assertEquals(AbstractModelPrefixMappingTest.betaURI,
+				m.getNsPrefixURI(AbstractModelPrefixMappingTest.betaPrefix));
+	}
+
+	private void restorePrefixes()
+	{
+		ModelCom.setDefaultModelPrefixes(prevMap);
+	}
+
+	
+	private void setPrefixes()
+	{
+		prevMap = ModelCom.setDefaultModelPrefixes(baseMap);
+	}
+
+	/**
+	 * Test that a freshly-created Model has the prefixes established by the
+	 * default in ModelCom.
+	 */
+	@Test
+	public void testDefaultPrefixes()
+	{
+		setPrefixes();
+		final Model m = getModelProducer().newModel();
+		Assert.assertEquals(baseMap.getNsPrefixMap(), m.getNsPrefixMap());
+		restorePrefixes();
+	}
+
+	@Test
+	public void testGetDefault()
+	{
+		setPrefixes();
+		try
+		{
+			Assert.assertSame(baseMap, ModelCom.getDefaultModelPrefixes());
+		}
+		finally
+		{
+			restorePrefixes();
+		}
+	}
+
+	@Test
+	public void testOnlyFreshPrefixes()
+	{
+		setPrefixes();
+		try
+		{
+			doOnlyFreshPrefixes();
+		}
+		finally
+		{
+			restorePrefixes();
+		}
+	}
+
+	
+	public static void assertSameMapping( final PrefixMapping L, final PrefixMapping R )
+	{
+		if (sameMapping(L, R) == false)
+		{
+			Assert.fail("wanted " + L + " but got " + R);
+		}
+	}
+
+	private static boolean sameMapping( final PrefixMapping L, final PrefixMapping R )
+	{
+		// System.err.println( ">> " + L.getNsPrefixMap() );
+		// System.err.println( ">> " + R.getNsPrefixMap() );
+		return L.getNsPrefixMap().equals(R.getNsPrefixMap());
+	}
+
+	/**
+	 * Test that withHiddenStatements copies the prefix mapping
+	 * TODO add some extra prefixs for checking; should check for non-
+	 * default models.
+	 */
+	@Test
+	public void testPrefixCopied()
+	{
+		Model model = getModelProducer().newModel();
+		model.setNsPrefixes(PrefixMapping.Standard);
+		assertSameMapping(PrefixMapping.Standard, model) ;
+	}
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelPrefixMappingTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain