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/08/31 13:01:48 UTC

svn commit: r1519171 [1/4] - in /jena/Experimental/new-test: ./ src/test/java/com/hp/hpl/jena/datatypes/ src/test/java/com/hp/hpl/jena/datatypes/xsd/ src/test/java/com/hp/hpl/jena/graph/ src/test/java/com/hp/hpl/jena/graph/impl/ src/test/java/com/hp/hp...

Author: claude
Date: Sat Aug 31 11:01:47 2013
New Revision: 1519171

URL: http://svn.apache.org/r1519171
Log:
Added graph suite and multiple abstract tests

Added:
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/datatypes/
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/datatypes/xsd/
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/datatypes/xsd/TestDateTime.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractEventManagerTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducerUser.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractReifierTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTestGraphMaker.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/LiteralsTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestFactory.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphBaseToString.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphEvents.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestReifier.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/AbstractTestTripleStore.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/CollectionGraphSuite.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraph.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraphMaker.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TripleStoreProducerInterface.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphSuite.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java   (with props)
Modified:
    jena/Experimental/new-test/pom.xml
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphProducerInterface.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphTestUtils.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/NodeCreateUtils.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/RecordingListener.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestCollectionGraph.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/test/TestUtils.java

Modified: jena/Experimental/new-test/pom.xml
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/pom.xml?rev=1519171&r1=1519170&r2=1519171&view=diff
==============================================================================
--- jena/Experimental/new-test/pom.xml (original)
+++ jena/Experimental/new-test/pom.xml Sat Aug 31 11:01:47 2013
@@ -22,5 +22,11 @@
 			<version>${version}</version>
 			<type>pom</type>
 		</dependency>
+  <dependency>
+  	<groupId>org.mockito</groupId>
+  	<artifactId>mockito-all</artifactId>
+  	<version>1.9.5</version>
+  	<scope>test</scope>
+  </dependency>
   </dependencies>
 </project>
\ No newline at end of file

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/datatypes/xsd/TestDateTime.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/datatypes/xsd/TestDateTime.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/datatypes/xsd/TestDateTime.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/datatypes/xsd/TestDateTime.java Sat Aug 31 11:01:47 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.datatypes.xsd;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.junit.Test;
+
+import com.hp.hpl.jena.datatypes.xsd.AbstractDateTime;
+
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests behaviour of the AbstractDateTime support, specifically for comparison
+ * operations. This complements the main tests in TestTypedLiterals.
+ */
+public class TestDateTime {
+
+	private final AbstractDateTime[] time = {
+			makeDateTime("2009-08-13T17:54:40.348Z"),
+			makeDateTime("2009-08-13T18:54:39Z"),
+			makeDateTime("2009-08-13T18:54:40Z"),
+			makeDateTime("2009-08-13T18:54:40.077Z"),
+			makeDateTime("2009-08-13T18:54:40.348Z"),
+			makeDateTime("2009-08-13T18:54:40.505Z"),
+			makeDateTime("2009-08-13T18:54:40.77Z"),
+			makeDateTime("2009-08-13T18:54:40.780Z"),
+			makeDateTime("2009-08-13T18:54:40.88Z"),
+			makeDateTime("2009-08-13T18:54:40.989Z"),
+			makeDateTime("2009-08-13T19:54:40.989Z")
+
+	};
+
+	private AbstractDateTime makeDateTime(String time) {
+		return (XSDDateTime) XSDDatatype.XSDdateTime.parse(time);
+	}
+
+	@Test
+	public void testXSDOrder() {
+		for (int i = 0; i < time.length; i++) {
+			for (int j = 0; j < i; j++) {
+				assertEquals(String.format("%s > %s", time[i], time[j]),
+						time[i].compare(time[j]), AbstractDateTime.GREATER_THAN);
+			}
+
+			assertEquals(String.format("%s == %s", time[i], time[i]),
+					time[i].compare(time[i]), AbstractDateTime.EQUAL);
+
+			for (int j = i + 1; j < time.length; j++) {
+				assertEquals(String.format("%s < %s", time[i], time[j]),
+						time[i].compare(time[j]), AbstractDateTime.LESS_THAN);
+			}
+		}
+	}
+
+	@Test
+	public void testJavaOrder() {
+		for (int i = 0; i < time.length; i++) {
+			for (int j = 0; j < i; j++) {
+				assertEquals(String.format("%s > %s", time[i], time[j]),
+						time[i].compareTo(time[j]),
+						AbstractDateTime.GREATER_THAN);
+			}
+
+			assertEquals(String.format("%s == %s", time[i], time[i]),
+					time[i].compareTo(time[i]), AbstractDateTime.EQUAL);
+
+			for (int j = i + 1; j < time.length; j++) {
+				assertEquals(String.format("%s < %s", time[i], time[j]),
+						time[i].compareTo(time[j]), AbstractDateTime.LESS_THAN);
+			}
+		}
+	}
+
+	// TODO move this to model test
+	@Test
+	public void testRoundTripping1() {
+		Model m = ModelFactory.createDefaultModel();
+		Property startTime = m
+				.createProperty("http://jena.hpl.hp.com/test#startTime");
+
+		Calendar cal = Calendar.getInstance();
+		cal.set(Calendar.MILLISECOND, 0);
+		Literal xsdlit0 = m.createTypedLiteral(cal);
+
+		Resource event = m.createResource();
+		event.addProperty(startTime, xsdlit0);
+
+		StringWriter sw = new StringWriter();
+		m.write(sw);
+		StringReader reader = new StringReader(sw.toString());
+		Model m1 = ModelFactory.createDefaultModel();
+		m1.read(reader, null);
+
+		assertTrue(m.isIsomorphicWith(m1));
+
+		Literal xsdlit1 = m1.listStatements().next().getObject()
+				.as(Literal.class);
+		assertEquals(xsdlit0, xsdlit1);
+	}
+
+	// Test that the string and calendar versions are the same.
+	@Test
+	public void testRoundTripping2() {
+		// String lex = "2013-04-16T15:40:07.3Z" ;
+		testCalendarRT(1366126807300L);
+	}
+
+	@Test
+	public void testRoundTripping3() {
+		// String lex = "2013-04-16T15:40:07.31Z" ;
+		testCalendarRT(1366126807310L);
+	}
+
+	@Test
+	public void testRoundTripping4() {
+		// String lex = "2013-04-16T15:40:07.301Z" ;
+		testCalendarRT(1366126807301L);
+	}
+
+	private void testCalendarRT(long value) {
+		Calendar cal = Calendar.getInstance();
+		cal.setTimeInMillis(value);
+		Literal lit1 = ResourceFactory.createTypedLiteral(cal);
+		Literal lit2 = ResourceFactory.createTypedLiteral(
+				lit1.getLexicalForm(), lit1.getDatatype());
+
+		assertEquals("equals: ", lit1, lit2);
+		assertEquals("hash code: ", lit1.hashCode(), lit2.hashCode());
+	}
+
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/datatypes/xsd/TestDateTime.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractEventManagerTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractEventManagerTest.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractEventManagerTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractEventManagerTest.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,271 @@
+/*
+ * 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.graph;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.GraphEventManager;
+import com.hp.hpl.jena.graph.GraphEvents;
+import com.hp.hpl.jena.graph.GraphListener;
+import com.hp.hpl.jena.graph.GraphUtil;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.util.CollectionFactory;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator;
+import static com.hp.hpl.jena.graph.GraphTestUtils.*;
+
+/**
+ * AbstractTestGraph provides a bunch of basic tests for something that purports
+ * to be a Graph. The abstract method getGraph must be overridden in subclasses
+ * to deliver a Graph of interest.
+ */
+
+public abstract class AbstractEventManagerTest extends
+		AbstractGraphProducerUser {
+
+	protected Graph graphWithTxn(String s) {
+		Graph g = getGraphProducer().newGraph();
+		txnBegin(g);
+		try {
+			graphAdd(g, s);
+			txnCommit(g);
+		} catch (Exception e) {
+			txnRollback(g);
+			fail(e.getMessage());
+		}
+		return g;
+	}
+
+	static final Triple[] tripleArray = tripleArray("S P O; A R B; X Q Y");
+
+	static final List<Triple> tripleList = Arrays
+			.asList(tripleArray("i lt j; p equals q"));
+
+	static final Triple[] setTriples = tripleArray("scissors cut paper; paper wraps stone; stone breaks scissors");
+
+	static final Set<Triple> tripleSet = CollectionFactory
+			.createHashedSet(Arrays.asList(setTriples));
+
+	protected boolean canBeEmpty(Graph g) {
+		return g.isEmpty();
+	}
+
+	@Test
+	public void testEventRegister() {
+		Graph g = getGraphProducer().newGraph();
+		GraphEventManager gem = g.getEventManager();
+		assertSame(gem, gem.register(new RecordingListener()));
+	}
+
+	/**
+	 * Test that we can safely unregister a listener that isn't registered.
+	 */
+	@Test
+	public void testEventUnregister() {
+		getGraphProducer().newGraph().getEventManager().unregister(L);
+	}
+
+	/**
+	 * Handy triple for test purposes.
+	 */
+	protected Triple SPO = NodeCreateUtils.createTriple("S P O");
+	protected RecordingListener L = new RecordingListener();
+
+	/**
+	 * Utility: get a graph, register L with its manager, return the graph.
+	 */
+	protected Graph getAndRegister(GraphListener gl) {
+		Graph g = getGraphProducer().newGraph();
+		g.getEventManager().register(gl);
+		return g;
+	}
+
+	@Test
+	public void testAddTriple() {
+		Graph g = getAndRegister(L);
+		g.add(SPO);
+		L.assertHas(new Object[] { "add", g, SPO });
+	}
+
+	@Test
+	public void testDeleteTriple() {
+		Graph g = getAndRegister(L);
+		g.delete(SPO);
+		L.assertHas(new Object[] { "delete", g, SPO });
+	}
+
+	/**
+	 * Ensure that triples removed by calling .remove() on the iterator returned
+	 * by a find() will generate deletion notifications.
+	 */
+	@Test
+	public void testEventDeleteByFind() {
+		Graph g = getAndRegister(L);
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			Triple toRemove = triple("remove this triple");
+			g.add(toRemove);
+			ExtendedIterator<Triple> rtr = g.find(toRemove);
+			assertTrue("ensure a(t least) one triple", rtr.hasNext());
+			rtr.next();
+			rtr.remove();
+			rtr.close();
+			L.assertHas(new Object[] { "add", g, toRemove, "delete", g,
+					toRemove });
+		}
+	}
+
+	@Test
+	public void testTwoListeners() {
+		RecordingListener L1 = new RecordingListener();
+		RecordingListener L2 = new RecordingListener();
+		Graph g = getGraphProducer().newGraph();
+		GraphEventManager gem = g.getEventManager();
+		gem.register(L1).register(L2);
+		g.add(SPO);
+		L2.assertHas(new Object[] { "add", g, SPO });
+		L1.assertHas(new Object[] { "add", g, SPO });
+	}
+
+	@Test
+	public void testUnregisterWorks() {
+		Graph g = getGraphProducer().newGraph();
+		GraphEventManager gem = g.getEventManager();
+		gem.register(L).unregister(L);
+		g.add(SPO);
+		L.assertHas(new Object[] {});
+	}
+
+	@Test
+	public void testRegisterTwice() {
+		Graph g = getAndRegister(L);
+		g.getEventManager().register(L);
+		g.add(SPO);
+		L.assertHas(new Object[] { "add", g, SPO, "add", g, SPO });
+	}
+
+	@Test
+	public void testUnregisterOnce() {
+		Graph g = getAndRegister(L);
+		g.getEventManager().register(L).unregister(L);
+		g.delete(SPO);
+		L.assertHas(new Object[] { "delete", g, SPO });
+	}
+
+	@Test
+	public void testBulkAddArrayEvent() {
+		Graph g = getAndRegister(L);
+		Triple[] triples = tripleArray("x R y; a P b");
+		GraphUtil.add(g, triples);
+		L.assertHas(new Object[] { "add[]", g, triples });
+	}
+
+	@Test
+	public void testBulkAddList() {
+		Graph g = getAndRegister(L);
+		List<Triple> elems = Arrays
+				.asList(tripleArray("bells ring loudly; pigs might fly"));
+		GraphUtil.add(g, elems);
+		L.assertHas(new Object[] { "addList", g, elems });
+	}
+
+	@Test
+	public void testBulkDeleteArray() {
+		Graph g = getAndRegister(L);
+		Triple[] triples = tripleArray("x R y; a P b");
+		GraphUtil.delete(g, triples);
+		L.assertHas(new Object[] { "delete[]", g, triples });
+	}
+
+	@Test
+	public void testBulkDeleteList() {
+		Graph g = getAndRegister(L);
+		List<Triple> elems = Arrays
+				.asList(tripleArray("bells ring loudly; pigs might fly"));
+		GraphUtil.delete(g, elems);
+		L.assertHas(new Object[] { "deleteList", g, elems });
+	}
+
+	@Test
+	public void testBulkAddIterator() {
+		Graph g = getAndRegister(L);
+		Triple[] triples = tripleArray("I wrote this; you read that; I wrote this");
+		GraphUtil.add(g, asIterator(triples));
+		L.assertHas(new Object[] { "addIterator", g, Arrays.asList(triples) });
+	}
+
+	@Test
+	public void testBulkDeleteIterator() {
+		Graph g = getAndRegister(L);
+		Triple[] triples = tripleArray("I wrote this; you read that; I wrote this");
+		GraphUtil.delete(g, asIterator(triples));
+		L.assertHas(new Object[] { "deleteIterator", g, Arrays.asList(triples) });
+	}
+
+	private Iterator<Triple> asIterator(Triple[] triples) {
+		return Arrays.asList(triples).iterator();
+	}
+
+	@Test
+	public void testBulkAddGraph() {
+		Graph g = getAndRegister(L);
+		Graph triples = graphWithTxn("this type graph; I type slowly");
+		GraphUtil.addInto(g, triples);
+		L.assertHas(new Object[] { "addGraph", g, triples });
+	}
+
+	@Test
+	public void testBulkDeleteGraph() {
+		Graph g = getAndRegister(L);
+		Graph triples = graphWithTxn("this type graph; I type slowly");
+		GraphUtil.deleteFrom(g, triples);
+		L.assertHas(new Object[] { "deleteGraph", g, triples });
+	}
+
+	@Test
+	public void testGeneralEvent() {
+		Graph g = getAndRegister(L);
+		Object value = new int[] {};
+		g.getEventManager().notifyEvent(g, value);
+		L.assertHas(new Object[] { "someEvent", g, value });
+	}
+
+	@Test
+	public void testRemoveAllEvent() {
+		Graph g = getAndRegister(L);
+		g.clear();
+		L.assertHas(new Object[] { "someEvent", g, GraphEvents.removeAll });
+	}
+
+	@Test
+	public void testRemoveSomeEvent() {
+		Graph g = getAndRegister(L);
+		Node S = node("S"), P = node("??"), O = node("??");
+		g.remove(S, P, O);
+		Object event = GraphEvents.remove(S, P, O);
+		L.assertHas(new Object[] { "someEvent", g, event });
+	}
+
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,118 @@
+/*
+ * 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.graph;
+
+import java.util.Arrays;
+import java.util.Set;
+
+import static com.hp.hpl.jena.graph.GraphTestUtils.*;
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.util.iterator.Map1;
+
+@RunWith(Parameterized.class)
+abstract public class AbstractFindLiteralsTest {
+	private final String data;
+	private final int size;
+	private final String search;
+	private final String results;
+
+	protected static GraphProducerInterface graphProducer;
+
+	public AbstractFindLiteralsTest(final String data, final int size,
+			final String search, final String results) {
+
+		this.data = data;
+		this.size = size;
+		this.search = search;
+		this.results = results;
+
+	}
+
+	static final Map1<Triple, Node> getObject = new Map1<Triple, Node>() {
+		@Override
+		public Node map1(Triple o) {
+			return o.getObject();
+		}
+	};
+
+	@Test
+	public void testFind() {
+		Graph g = graphWith(graphProducer.newGraph(), data);
+
+		Node literal = NodeCreateUtils.create(search);
+		//
+		assertEquals("graph has wrong size", size, g.size());
+		Set<Node> got = g.find(Node.ANY, Node.ANY, literal).mapWith(getObject)
+				.toSet();
+		assertEquals(nodeSet(results), got);
+	}
+
+	@After
+	public void closeGraphs() {
+		graphProducer.closeGraphs();
+	}
+
+	@Parameters(name = "TestFindLiterals: graph '{'{0}'}' size {1} search {2} expecting '{'{3}'}'")
+	public static Iterable<Object[]> data() {
+		Object[][] result = {
+				{ "a P 'simple'", 1, "'simple'", "'simple'" },
+
+				{ "a P 'simple'xsd:string", 1, "'simple'", "'simple'xsd:string" },
+				{ "a P 'simple'", 1, "'simple'xsd:string", "'simple'" },
+				{ "a P 'simple'xsd:string", 1, "'simple'xsd:string",
+						"'simple'xsd:string" },
+				//
+				{ "a P 'simple'; a P 'simple'xsd:string", 2, "'simple'",
+						"'simple' 'simple'xsd:string" },
+				{ "a P 'simple'; a P 'simple'xsd:string", 2,
+						"'simple'xsd:string", "'simple' 'simple'xsd:string" },
+				//
+				{ "a P 1", 1, "1", "1" },
+				{ "a P '1'xsd:float", 1, "'1'xsd:float", "'1'xsd:float" },
+				{ "a P '1'xsd:double", 1, "'1'xsd:double", "'1'xsd:double" },
+				{ "a P '1'xsd:float", 1, "'1'xsd:float", "'1'xsd:float" },
+				{ "a P '1.1'xsd:float", 1, "'1'xsd:float", "" },
+				{ "a P '1'xsd:double", 1, "'1'xsd:int", "" },
+				//
+				{ "a P 'abc'rdf:XMLLiteral", 1, "'abc'", "" },
+				{ "a P 'abc'", 1, "'abc'rdf:XMLLiteral", "" },
+				//
+				// floats & doubles are not compatible
+				//
+				{ "a P '1'xsd:float", 1, "'1'xsd:double", "" },
+				{ "a P '1'xsd:double", 1, "'1'xsd:float", "" },
+				//
+				{ "a P 1", 1, "'1'", "" },
+				{ "a P 1", 1, "'1'xsd:integer", "'1'xsd:integer" },
+				{ "a P 1", 1, "'1'", "" },
+				{ "a P '1'xsd:short", 1, "'1'xsd:integer", "'1'xsd:short" },
+				{ "a P '1'xsd:int", 1, "'1'xsd:integer", "'1'xsd:int" }, };
+		return Arrays.asList(result);
+	}
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,122 @@
+/*
+ * 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.graph;
+
+import static com.hp.hpl.jena.graph.GraphTestUtils.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Tests for recursive sub-graph extraction.
+ */
+public abstract class AbstractGraphExtractTest extends
+		AbstractGraphProducerUser {
+
+	@Test
+	public void testExtractNothing() {
+		testExtract("", "x", "");
+		testExtract("", "x", "a R b");
+		testExtract("", "x", "a R x");
+		testExtract("", "x", "a x y");
+	}
+
+	@Test
+	public void testExtractOneLevel() {
+		testExtract("a R b", "a", "a R b");
+		testExtract("a R b; a R c", "a", "a R b; a R c");
+		testExtract("a R b; a S d", "a", "a R b; a S d");
+	}
+
+	@Test
+	public void testNoJunk() {
+		testExtract("a R b", "a", "a R b; x R y");
+	}
+
+	@Test
+	public void testExtractTwoLevels() {
+		testExtract("a R b; b S c", "a", "a R b; b S c");
+		testExtract("a R b; b S c", "a", "a R b; b S c; x P y");
+		testExtract("a R b; b S c; b T d", "a", "a R b; b S c; b T d");
+		testExtract("a R b; b S c; a T d", "a", "a R b; a T d; b S c");
+	}
+
+	@Test
+	public void testExtractSeveralLevels() {
+		testExtract("a R b; b S c; c T d; d U e", "a",
+				"a R b; b S c; c T d; d U e");
+	}
+
+	@Test
+	public void testExtractNoLoop() {
+		testExtract("a R a", "a", "a R a");
+		testExtract("a R b; b R a", "a", "a R b; b R a; z P a");
+		testExtract("a R b; b S c; c T a", "a",
+				"a R b; b S c; c T a; junk P junk");
+	}
+
+	@Test
+	public void testTripleFilter() {
+		assertTrue(TripleBoundary.stopAtAnonObject.stopAt(triple("a R _b")));
+		assertFalse(TripleBoundary.stopAtAnonObject.stopAt(triple("a R b")));
+		assertFalse(TripleBoundary.stopAtAnonObject.stopAt(triple("a _R b")));
+		assertFalse(TripleBoundary.stopAtAnonObject.stopAt(triple("_a R b")));
+	}
+
+	public void testExtractBoundary() {
+		testExtract("a R b; b S _c", "a", "a R b; b S _c; _c T d",
+				TripleBoundary.stopAtAnonObject);
+	}
+
+	/**
+	 * This test exposed that the update-existing-graph functionality was broken
+	 * if the target graph already contained any statements with a subject S
+	 * appearing as subject in the source graph - no further Spo statements were
+	 * added.
+	 */
+	@Test
+	public void testPartialUpdate() {
+		Graph source = graphWith(getGraphProducer().newGraph(), "a R b; b S e");
+		Graph dest = graphWith(getGraphProducer().newGraph(), "b R d");
+		GraphExtract e = new GraphExtract(TripleBoundary.stopNowhere);
+		e.extractInto(dest, node("a"), source);
+		assertIsomorphic(
+				graphWith(getGraphProducer().newGraph(), "a R b; b S e; b R d"),
+				dest);
+	}
+
+	private void testExtract(String wanted, String node, String source) {
+		testExtract(wanted, node, source, TripleBoundary.stopNowhere);
+	}
+
+	/**
+    */
+	private void testExtract(String wanted, String node, String source,
+			TripleBoundary b) {
+		assertIsomorphic(
+				graphWith(getGraphProducer().newGraph(), wanted),
+				extract(node(node), b,
+						graphWith(getGraphProducer().newGraph(), source)));
+	}
+
+	private Graph extract(Node node, TripleBoundary b, Graph graph) {
+		return new GraphExtract(b).extract(node, graph);
+	}
+
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,27 @@
+package com.hp.hpl.jena.graph;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractGraphProducer implements GraphProducerInterface {
+
+	public List<Graph> graphList = new ArrayList<Graph>();
+
+	abstract protected Graph createNewGraph();
+
+	@Override
+	final public Graph newGraph() {
+		Graph retval = createNewGraph();
+		graphList.add(retval);
+		return retval;
+	}
+
+	@Override
+	final public void closeGraphs() {
+		for (Graph g : graphList) {
+			g.close();
+		}
+		graphList.clear();
+	}
+
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducerUser.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducerUser.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducerUser.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducerUser.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,14 @@
+package com.hp.hpl.jena.graph;
+
+import org.junit.After;
+
+public abstract class AbstractGraphProducerUser {
+
+	abstract protected GraphProducerInterface getGraphProducer();
+
+	@After
+	final public void closeGraphs() {
+		getGraphProducer().closeGraphs();
+	}
+
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,72 @@
+package com.hp.hpl.jena.graph;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/*
+ TestSuite result = new TestSuite( WrappedGraphTest.class );
+ result.addTest( suite( MetaTestGraph.class, GraphMem.class ) );
+ result.addTest( suite( TestReifier.class, GraphMem.class ) );
+ result.addTest( suite( MetaTestGraph.class, WrappedGraphMem.class ) );
+ result.addTest( suite( TestReifier.class, WrappedGraphMem.class ) );
+ result.addTest( TestGraphListener.suite() );
+ result.addTestSuite( TestRegisterGraphListener.class );
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ AbstractGraphSuite.GraphTest.class,
+		AbstractGraphSuite.ReifierTest.class,
+		AbstractGraphSuite.FindLiterals.class,
+		AbstractGraphSuite.ExtractTest.class,
+		AbstractGraphSuite.EventManagerTest.class,
+		AbstractGraphSuite.TransactionTest.class, })
+public abstract class AbstractGraphSuite {
+
+	static protected GraphProducerInterface graphProducer;
+
+	protected static void setGraphProducer(GraphProducerInterface graphProducer) {
+		AbstractGraphSuite.graphProducer = graphProducer;
+	}
+
+	public static class GraphTest extends AbstractGraphTest {
+		@Override
+		protected GraphProducerInterface getGraphProducer() {
+			return AbstractGraphSuite.graphProducer;
+		}
+
+	}
+
+	public static class ReifierTest extends AbstractReifierTest {
+		@Override
+		protected GraphProducerInterface getGraphProducer() {
+			return AbstractGraphSuite.graphProducer;
+		}
+	}
+
+	public static class FindLiterals extends AbstractFindLiteralsTest {
+		public FindLiterals(String data, int size, String search, String results) {
+			super(data, size, search, results);
+			AbstractFindLiteralsTest.graphProducer = AbstractGraphSuite.graphProducer;
+		}
+	}
+
+	public static class ExtractTest extends AbstractGraphExtractTest {
+		@Override
+		protected GraphProducerInterface getGraphProducer() {
+			return AbstractGraphSuite.graphProducer;
+		}
+	}
+
+	public static class EventManagerTest extends AbstractEventManagerTest {
+		@Override
+		protected GraphProducerInterface getGraphProducer() {
+			return AbstractGraphSuite.graphProducer;
+		}
+	}
+
+	public static class TransactionTest extends AbstractTransactionHandlerTest {
+		@Override
+		protected GraphProducerInterface getGraphProducer() {
+			return AbstractGraphSuite.graphProducer;
+		}
+	}
+}

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