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 [3/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...

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTestGraphMaker.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTestGraphMaker.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTestGraphMaker.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTestGraphMaker.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,279 @@
+/*
+ * 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 org.junit.Assert.*;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.GraphMaker;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.shared.AlreadyExistsException;
+import com.hp.hpl.jena.shared.DoesNotExistException;
+import com.hp.hpl.jena.test.TestUtils;
+
+/**
+ * Abstract base class for testing graph factories. Subclasses define the method
+ * <code>getGraphFactory()</code> which supplies a new graph factory to be
+ * tested: ATGF invokes that during <code>setUp</code> and closes it in
+ * <code>tearDown</code>.
+ * <p>
+ * This bunch of tests is not remotely exhaustive, but it was sufficent to drive
+ * the development of the first full graph factory. (Although at the time it
+ * wasn't abstract.)
+ */
+
+public abstract class AbstractTestGraphMaker {
+
+	public abstract GraphMaker getGraphMaker();
+
+	private GraphMaker gf;
+
+	@Before
+	public void setUp() {
+		gf = getGraphMaker();
+	}
+
+	@After
+	public void tearDown() {
+		gf.close();
+	}
+
+	/**
+	 * A trivial test that getGraph delivers a proper graph, not cheating with
+	 * null, and that getGraph() "always" delivers the same Graph.
+	 */
+	@Test
+	public void testGetGraph() {
+		Graph g1 = gf.getGraph();
+		assertFalse("should deliver a Graph", g1 == null);
+		assertSame(g1, gf.getGraph());
+		g1.close();
+	}
+
+	@Test
+	public void testCreateGraph() {
+		TestUtils.assertDiffer("each created graph must differ",
+				gf.createGraph(), gf.createGraph());
+	}
+
+	@Test
+	public void testAnyName() {
+		gf.createGraph("plain").close();
+		gf.createGraph("with.dot").close();
+		gf.createGraph("http://electric-hedgehog.net/topic#marker").close();
+	}
+
+	/**
+	 * Test that we can't create a graph with the same name twice.
+	 */
+	@Test
+	public void testCannotCreateTwice() {
+		String name = jName("bonsai");
+		gf.createGraph(name, true);
+		try {
+			gf.createGraph(name, true);
+			fail("should not be able to create " + name + " twice");
+		} catch (AlreadyExistsException e) {
+		}
+	}
+
+	private String jName(String name) {
+		return "jena-test-AbstractTestGraphMaker-" + name;
+	}
+
+	@Test
+	public void testCanCreateTwice() {
+		String name = jName("bridge");
+		Graph g1 = gf.createGraph(name, true);
+		Graph g2 = gf.createGraph(name, false);
+		assertTrue("graphs should be the same", sameGraph(g1, g2));
+		Graph g3 = gf.createGraph(name);
+		assertTrue("graphs should be the same", sameGraph(g1, g3));
+	}
+
+	/**
+	 * Test that we cannot open a graph that does not exist.
+	 */
+	@Test
+	public void testCannotOpenUncreated() {
+		String name = jName("noSuchGraph");
+		try {
+			gf.openGraph(name, true);
+			fail(name + " should not exist");
+		} catch (DoesNotExistException e) {
+		}
+	}
+
+	/**
+	 * Test that we *can* open a graph that hasn't been created
+	 */
+	@Test
+	public void testCanOpenUncreated() {
+		String name = jName("willBeCreated");
+		Graph g1 = gf.openGraph(name);
+		g1.close();
+		gf.openGraph(name, true);
+	}
+
+	/**
+	 * Utility - test that a graph with the given name exists.
+	 */
+	private void testExists(String name) {
+		assertTrue(name + " should exist", gf.hasGraph(name));
+	}
+
+	/**
+	 * Utility - test that no graph with the given name exists.
+	 */
+	private void testDoesNotExist(String name) {
+		assertFalse(name + " should exist", gf.hasGraph(name));
+	}
+
+	/**
+	 * Test that we can find a graph once its been created. We need to know if
+	 * two graphs are "the same" here: we have a temporary work-around but it is
+	 * not sound.
+	 * 
+	 */
+	@Test
+	public void testCanFindCreatedGraph() {
+		String alpha = jName("alpha"), beta = jName("beta");
+		Graph g1 = gf.createGraph(alpha, true);
+		Graph h1 = gf.createGraph(beta, true);
+		Graph g2 = gf.openGraph(alpha, true);
+		Graph h2 = gf.openGraph(beta, true);
+		assertTrue("should find alpha", sameGraph(g1, g2));
+		assertTrue("should find beta", sameGraph(h1, h2));
+	}
+
+	/**
+	 * Weak test for "same graph": adding this to one is visible in t'other.
+	 * Stopgap for use in testCanFindCreatedGraph. TODO: clean that test up
+	 * (left over from RDB days)
+	 */
+	private boolean sameGraph(Graph g1, Graph g2) {
+		Node S = GraphTestUtils.node("S"), P = GraphTestUtils.node("P"), O = GraphTestUtils
+				.node("O");
+		g1.add(Triple.create(S, P, O));
+		g2.add(Triple.create(O, P, S));
+		return g2.contains(S, P, O) && g1.contains(O, P, S);
+	}
+
+	/**
+	 * Test that we can remove a graph from the factory without disturbing
+	 * another graph's binding.
+	 */
+	@Test
+	public void testCanRemoveGraph() {
+		String alpha = jName("bingo"), beta = jName("brillo");
+		gf.createGraph(alpha, true);
+		gf.createGraph(beta, true);
+		testExists(alpha);
+		testExists(beta);
+		gf.removeGraph(alpha);
+		testExists(beta);
+		testDoesNotExist(alpha);
+	}
+
+	@Test
+	public void testHasnt() {
+		assertFalse("no such graph", gf.hasGraph("john"));
+		assertFalse("no such graph", gf.hasGraph("paul"));
+		assertFalse("no such graph", gf.hasGraph("george"));
+		/* */
+		gf.createGraph("john", true);
+		assertTrue("john now exists", gf.hasGraph("john"));
+		assertFalse("no such graph", gf.hasGraph("paul"));
+		assertFalse("no such graph", gf.hasGraph("george"));
+		/* */
+		gf.createGraph("paul", true);
+		assertTrue("john still exists", gf.hasGraph("john"));
+		assertTrue("paul now exists", gf.hasGraph("paul"));
+		assertFalse("no such graph", gf.hasGraph("george"));
+		/* */
+		gf.removeGraph("john");
+		assertFalse("john has been removed", gf.hasGraph("john"));
+		assertTrue("paul still exists", gf.hasGraph("paul"));
+		assertFalse("no such graph", gf.hasGraph("george"));
+	}
+
+	@Test
+	public void testCarefulClose() {
+		Graph x = gf.createGraph("x");
+		Graph y = gf.openGraph("x");
+		x.add(GraphTestUtils.triple("a BB c"));
+		x.close();
+		y.add(GraphTestUtils.triple("p RR q"));
+		y.close();
+	}
+
+	/**
+	 * Test that a maker with no graphs lists no names.
+	 */
+	@Test
+	public void testListNoGraphs() {
+		Set<String> s = gf.listGraphs().toSet();
+		if (s.size() > 0)
+			fail("found names from 'empty' graph maker: " + s);
+	}
+
+	/**
+	 * Test that a maker with three graphs inserted lists those three grapsh; we
+	 * don't mind what order they appear in. We also use funny names to ensure
+	 * that the spelling that goes in is the one that comes out [should really
+	 * be in a separate test].
+	 */
+	@Test
+	public void testListThreeGraphs() {
+		String x = "x", y = "y/sub", z = "z:boo";
+		Graph X = gf.createGraph(x);
+		Graph Y = gf.createGraph(y);
+		Graph Z = gf.createGraph(z);
+		Set<String> wanted = TestUtils.setOfStrings(x + " " + y + " " + z);
+		assertEquals(wanted, GraphTestUtils.iteratorToSet(gf.listGraphs()));
+		X.close();
+		Y.close();
+		Z.close();
+	}
+
+	/**
+	 * Test that a maker with some things put in and then some removed gets the
+	 * right things listed.
+	 */
+	@Test
+	public void testListAfterDelete() {
+		String x = "x_y", y = "y//zub", z = "a:b/c";
+		Graph X = gf.createGraph(x);
+		Graph Y = gf.createGraph(y);
+		Graph Z = gf.createGraph(z);
+		gf.removeGraph(x);
+		Set<String> s = GraphTestUtils.iteratorToSet(gf.listGraphs());
+		assertEquals(TestUtils.setOfStrings(y + " " + z), s);
+		X.close();
+		Y.close();
+		Z.close();
+	}
+
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,196 @@
+/*
+ * 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.io.File;
+import java.util.Arrays;
+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.GraphUtil;
+import com.hp.hpl.jena.graph.TransactionHandler;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.shared.Command;
+import com.hp.hpl.jena.shared.JenaException;
+import com.hp.hpl.jena.util.CollectionFactory;
+import com.hp.hpl.jena.util.FileUtils;
+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 AbstractTransactionHandlerTest 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;
+	}
+
+	/**
+	 * Test that Graphs have transaction support methods, and that if they fail
+	 * on some g they fail because they do not support the operation.
+	 */
+	@Test
+	public void testTransactionsExistAsPerTransactionSupported() {
+		Command cmd = new Command() {
+			@Override
+			public Object execute() {
+				return null;
+			}
+		};
+
+		Graph g = getGraphProducer().newGraph();
+
+		TransactionHandler th = g.getTransactionHandler();
+
+		if (th.transactionsSupported()) {
+			th.begin();
+			th.abort();
+			th.begin();
+			th.commit();
+			th.executeInTransaction(cmd);
+		} else {
+			try {
+				th.begin();
+				fail("Should have thrown UnsupportedOperationException");
+			} catch (UnsupportedOperationException x) {
+			}
+		}
+		try {
+			th.abort();
+			fail("Should have thrown UnsupportedOperationException");
+		} catch (UnsupportedOperationException x) {
+		}
+		try {
+			th.commit();
+			fail("Should have thrown UnsupportedOperationException");
+		} catch (UnsupportedOperationException x) {
+		}
+		/* */
+		try {
+			th.executeInTransaction(cmd);
+			fail("Should have thrown UnsupportedOperationException");
+		} catch (UnsupportedOperationException x) {
+		}
+	}
+
+	@Test
+	public void testExecuteInTransactionCatchesThrowable() {
+		Graph g = getGraphProducer().newGraph();
+		TransactionHandler th = g.getTransactionHandler();
+		if (th.transactionsSupported()) {
+			Command cmd = new Command() {
+				@Override
+				public Object execute() throws Error {
+					throw new Error();
+				}
+			};
+			try {
+				th.executeInTransaction(cmd);
+				fail("Should have thrown JenaException");
+			} catch (JenaException x) {
+			}
+		}
+	}
+
+	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));
+
+	@Test
+	public void testTransactionCommit() {
+		Graph g = getGraphProducer().newGraph();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWithTxn("initial hasValue 42; also hasURI hello");
+			Graph extra = graphWithTxn("extra hasValue 17; also hasURI world");
+
+			GraphUtil.addInto(g, initial);
+			g.getTransactionHandler().begin();
+			GraphUtil.addInto(g, extra);
+			g.getTransactionHandler().commit();
+			Graph union = graphWithTxn("");
+			GraphUtil.addInto(union, initial);
+			GraphUtil.addInto(union, extra);
+			assertIsomorphic(union, g);
+			// Model inFile = ModelFactory.createDefaultModel();
+			// inFile.read( "file:///" + foo, "N-TRIPLES" );
+			// assertIsomorphic( union, inFile.getGraph() );
+		}
+	}
+
+	@Test
+	public void testTransactionAbort() {
+		Graph g = getGraphProducer().newGraph();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWithTxn("initial hasValue 42; also hasURI hello");
+			Graph extra = graphWithTxn("extra hasValue 17; also hasURI world");
+			File foo = FileUtils.tempFileName("fileGraph", ".n3");
+			// Graph g = new FileGraph( foo, true, true );
+			GraphUtil.addInto(g, initial);
+			g.getTransactionHandler().begin();
+			GraphUtil.addInto(g, extra);
+			g.getTransactionHandler().abort();
+			assertIsomorphic(initial, g);
+		}
+	}
+
+	@Test
+	public void testTransactionCommitThenAbort() {
+		Graph g = getGraphProducer().newGraph();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWithTxn("A pings B; B pings C");
+			Graph extra = graphWithTxn("C pingedBy B; fileGraph rdf:type Graph");
+			// Graph g = getGraphProducer().newGraph();
+			// File foo = FileUtils.tempFileName( "fileGraph", ".nt" );
+			// Graph g = new FileGraph( foo, true, true );
+			g.getTransactionHandler().begin();
+			GraphUtil.addInto(g, initial);
+			g.getTransactionHandler().commit();
+			g.getTransactionHandler().begin();
+			GraphUtil.addInto(g, extra);
+			g.getTransactionHandler().abort();
+			assertIsomorphic(initial, g);
+			// Model inFile = ModelFactory.createDefaultModel();
+			// inFile.read( "file:///" + foo, "N-TRIPLES" );
+			// assertIsomorphic( initial, inFile.getGraph() );
+		}
+	}
+
+}

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

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphProducerInterface.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphProducerInterface.java?rev=1519171&r1=1519170&r2=1519171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphProducerInterface.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphProducerInterface.java Sat Aug 31 11:01:47 2013
@@ -2,13 +2,20 @@ package com.hp.hpl.jena.graph;
 
 /**
  * Creates the graph for testing
- *
+ * 
  */
 public interface GraphProducerInterface {
 
 	/**
-	 * Returns a Graph to take part in the test. Must be overridden in a subclass.
+	 * Returns a Graph to take part in the test. Must be overridden in a
+	 * subclass.
+	 * 
 	 * @return The graph implementation to test.
 	 */
 	public abstract Graph newGraph();
+
+	/**
+	 * provides a hook to close down graphs.
+	 */
+	public abstract void closeGraphs();
 }

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphTestUtils.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphTestUtils.java?rev=1519171&r1=1519170&r2=1519171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphTestUtils.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/GraphTestUtils.java Sat Aug 31 11:01:47 2013
@@ -19,12 +19,12 @@
 package com.hp.hpl.jena.graph;
 
 /**
-    An extension of JenaTestBase (which see) with Graph-specific methods.
-*/
+ An extension of JenaTestBase (which see) with Graph-specific methods.
+ */
 
 import static org.junit.Assert.*;
 import java.io.FileNotFoundException;
-import java.lang.reflect.Constructor ;
+import java.lang.reflect.Constructor;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -41,391 +41,435 @@ import com.hp.hpl.jena.graph.Graph;
 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.ontology.impl.TestListSyntaxCategories;
-import com.hp.hpl.jena.shared.JenaException ;
-import com.hp.hpl.jena.shared.PrefixMapping ;
+import com.hp.hpl.jena.shared.JenaException;
+import com.hp.hpl.jena.shared.PrefixMapping;
 import com.hp.hpl.jena.test.TestUtils;
-import com.hp.hpl.jena.util.CollectionFactory ;
-import com.hp.hpl.jena.util.IteratorCollection ;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
-
-public class GraphTestUtils extends TestUtils
-    {
-	protected static String getFileName( String fn )
-   	{
-   		URL u = TestListSyntaxCategories.class.getClassLoader().getResource( fn );
-   		if (u == null)
-   		{
-   			throw new RuntimeException( new FileNotFoundException( fn ));
-   		}
-   		try {
-   			return u.toURI().toString();
-   		} catch (URISyntaxException e) {
-   			throw new RuntimeException( e );
-   		}
-   	}
-  	
-    /**
-        Answer a Node as described by <code>x</code>; a shorthand for
-        <code>Node.create(x)</code>, which see.
-    */
-    public static Node node( String x )
-        { return NodeCreateUtils.create( x ); }
-        
-    /**
-        Answer a set containing the elements from the iterator <code>it</code>;
-        a shorthand for <code>IteratorCollection.iteratorToSet(it)</code>,
-        which see.
-    */
-    public static <T> Set<T> iteratorToSet( Iterator<? extends T> it )
-        { return IteratorCollection.iteratorToSet( it ); }
-    
-    /**
-        Answer a list containing the elements from the iterator <code>it</code>,
-        in order; a shorthand for <code>IteratorCollection.iteratorToList(it)</code>,
-        which see.
-    */
-    public static <T> List<T> iteratorToList( Iterator<? extends T> it )
-        { return IteratorCollection.iteratorToList( it ); }
-                
-    /**
-        Answer a set of the nodes described (as per <code>node()</code>) by
-        the space-separated substrings of <code>nodes</code>.
-    */
-    public static Set<Node> nodeSet( String nodes )
-        {
-        Set<Node> result = CollectionFactory.createHashedSet();
-        StringTokenizer st = new StringTokenizer( nodes );
-        while (st.hasMoreTokens()) result.add( node( st.nextToken() ) );
-        return result;
-        }
-    
-    /**
-        Answer a set of the elements of <code>A</code>.
-    */
-    public static <T> Set<T> arrayToSet( T [] A )
-        { return CollectionFactory.createHashedSet( Arrays.asList( A ) ); }
-    
-    /**
-        Answer a triple described by the three space-separated node descriptions
-        in <code>fact</code>; a shorthand for <code>Triple.create(fact)</code>,
-        which see.
-    */
-    public static Triple triple( String fact )
-        { return NodeCreateUtils.createTriple( fact ); }
-    
-    /**
-        Answer a triple described by the three space-separated node descriptions
-        in <code>fact</code>, using prefix-mappings from <code>pm</code>; a 
-        shorthand for <code>Triple.create(pm, fact)</code>, which see.
-    */
-    public static Triple triple( PrefixMapping pm, String fact )
-        { return NodeCreateUtils.createTriple( pm, fact ); }
-        
-    /**
-        Answer an array of triples; each triple is described by one of the
-        semi-separated substrings of <code>facts</code>, as per 
-        <code>triple</code> with prefix-mapping <code>Extended</code>.
-    */
-    public static Triple [] tripleArray( String facts )
-        {
-        ArrayList<Triple> al = new ArrayList<Triple>();
-        StringTokenizer semis = new StringTokenizer( facts, ";" );
-        while (semis.hasMoreTokens()) al.add( triple( PrefixMapping.Extended, semis.nextToken() ) );   
-        return al.toArray( new Triple [al.size()] );
-        }
-    
-    /**
-        Answer a set of triples where the elements are described by the
-        semi-separated substrings of <code>facts</code>, as per 
-        <code>triple</code>.
-    */
-    public static Set<Triple> tripleSet( String facts )
-        {
-        Set<Triple> result = new HashSet<Triple>();
-        StringTokenizer semis = new StringTokenizer( facts, ";" );
-        while (semis.hasMoreTokens()) result.add( triple( semis.nextToken() ) );   
-        return result;
-        }
-       
-    /**
-        Answer a list of nodes, where the nodes are described by the 
-        space-separated substrings of <code>items</code> as per
-        <code>node()</code>.
-    */
-    public static List<Node> nodeList( String items )
-        {
-        ArrayList<Node> nl = new ArrayList<Node>();
-        StringTokenizer nodes = new StringTokenizer( items );
-        while (nodes.hasMoreTokens()) nl.add( node( nodes.nextToken() ) );   
-        return nl;
-        }   
-    
-    /**
-        Answer an array of nodes, where the nodes are described by the 
-        space-separated substrings of <code>items</code> as per
-    */
-    public static Node [] nodeArray( String items )
-        {
-        List<Node> nl = nodeList( items );  
-        return nl.toArray( new Node [nl.size()] );
-        } 
-    
-    /**
-        Answer the graph <code>g</code> after adding to it every triple
-        encoded in <code>s</code> in the fashion of <code>tripleArray</code>,
-        a semi-separated sequence of space-separated node descriptions.
-    */
-    public static Graph graphAdd( Graph g, String s )
-        {
-        StringTokenizer semis = new StringTokenizer( s, ";" );
-        while (semis.hasMoreTokens()) g.add( triple( PrefixMapping.Extended, semis.nextToken() ) );     
-        return g;
-        }
-    
-    /**
-        Answer a new memory-based graph with Extended prefixes.
-    */
-    public static Graph newGraph()
-        {
-        Graph result = Factory.createGraphMem();
-        result.getPrefixMapping().setNsPrefixes( PrefixMapping.Extended );
-        return result;
-        }
-    
-    /**
-        Answer a new memory-based graph with initial contents as described
-        by <code>s</code> in the fashion of <code>graphAdd()</code>.
-        Not over-ridable; do not use for abstraction.
-    */
-    public static Graph graphWith( String s )
-        { return graphAdd( newGraph(), s ); }
-    
-    /**
-        Assert that the graph <code>g</code> is isomorphic to the graph 
-        described by <code>template</code> in the fashion of 
-        <code>graphWith</code>.
-    */
-    public static void assertEqualsTemplate( String title, Graph g, String template )
-        { assertIsomorphic( title, graphWith( template ), g ); }
-                
-    /**
-        Assert that the supplied graph <code>got</code> is isomorphic with the
-        the desired graph <code>expected</code>; if not, display a readable
-        description of both graphs.
-    */
-    public static void assertIsomorphic( String title, Graph expected, Graph got )
-        {
-        if (!expected.isIsomorphicWith( got ))
-            {
-            Map<Node, Object> map = CollectionFactory.createHashedMap();
-            fail( title + ": wanted " + nice( expected, map ) + "\nbut got " + nice( got, map ) );
-            }
-        }
-    
-    /**
-        Answer a string which is a newline-separated list of triples (as
-        produced by niceTriple) in the graph <code>g</code>. The map 
-        <code>bnodes</code> maps already-seen bnodes to their "nice" strings. 
-    */
-    public static String nice( Graph g, Map<Node, Object> bnodes )
-        {
-        StringBuffer b = new StringBuffer( g.size() * 100 );
-        ExtendedIterator<Triple> it = GraphUtil.findAll( g );
-        while (it.hasNext()) niceTriple( b, bnodes, it.next() );
-        return b.toString();
-        }
-    
-    /**
-        Append to the string buffer <code>b</code> a "nice" representation 
-        of the triple <code>t</code> on a new line, using (and updating)
-        <code>bnodes</code> to supply "nice" strings for any blank nodes.
-    */
-    protected static void niceTriple( StringBuffer b, Map<Node, Object> bnodes, Triple t )
-        {
-        b.append( "\n    " );
-        appendNode( b, bnodes, t.getSubject() );
-        appendNode( b, bnodes, t.getPredicate() );
-        appendNode( b, bnodes, t.getObject() );
-        }
-
-    /**
-        A counter for new bnode strings; it starts at 1000 so as to make
-        the bnode strings more uniform (at least for the first 9000 bnodes).
-    */
-    protected static int bnc = 1000;
-    
-    /**
-        Append to the string buffer <code>b</code> a space followed by the
-        "nice" representation of the node <code>n</code>. If <code>n</code>
-        is a bnode, re-use any existing string for it from <code>bnodes</code>
-        or make a new one of the form <i>_bNNNN</i> with NNNN a new integer.
-    */
-    protected static void appendNode( StringBuffer b, Map<Node, Object> bnodes, Node n )
-        {
-        b.append( ' ' );
-        if (n.isBlank())
-            {
-            Object already = bnodes.get( n );
-            if (already == null) bnodes.put( n, already = "_b" + bnc++ );
-            b.append( already );
-            }
-        else
-            b.append( nice( n ) );
-        }
-    
-    /**
-        Answer the "nice" representation of this node, the string returned by
-        <code>n.toString(PrefixMapping.Extended,true)</code>.
-    */
-    protected static String nice( Node n )
-        { return n.toString( PrefixMapping.Extended, true ); }
-            
-    /**
-        Assert that the computed graph <code>got</code> is isomorphic with the
-        desired graph <code>expected</code>; if not, fail with a default
-        message (and pretty output of the graphs).
-    */
-    public static void assertIsomorphic( Graph expected, Graph got )
-        { assertIsomorphic( "graphs must be isomorphic", expected, got ); }
-
-    /**
-        Assert that the graph <code>g</code> must contain the triple described
-        by <code>s</code>; if not, fail with pretty output of both graphs
-        and a message containing <code>name</code>.
-    */
-    public static void assertContains( String name, String s, Graph g )
-        {
-        assertTrue( name + " must contain " + s, g.contains( triple( s ) ) );
-        }
-    
-    /**
-        Assert that the graph <code>g</code> contains all the triples described
-        by the string <code>s</code; if not, fail with a message containing
-        <code>name</code>.
-    */
-    public static void assertContainsAll( String name, Graph g, String s )
-        {
-        StringTokenizer semis = new StringTokenizer( s, ";" );
-        while (semis.hasMoreTokens()) assertContains( name, semis.nextToken(), g );       
-        }
-    
-    /**
-        Assert that the graph <code>g</code> does not contain the triple
-        described by <code>s<code>; if it does, fail with a message containing
+import com.hp.hpl.jena.util.CollectionFactory;
+import com.hp.hpl.jena.util.IteratorCollection;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator;
+
+public class GraphTestUtils extends TestUtils {
+	protected static String getFileName(String fn) {
+		URL u = GraphTestUtils.class.getClassLoader().getResource(fn);
+		if (u == null) {
+			throw new RuntimeException(new FileNotFoundException(fn));
+		}
+		try {
+			return u.toURI().toString();
+		} catch (URISyntaxException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * Answer a Node as described by <code>x</code>; a shorthand for
+	 * <code>Node.create(x)</code>, which see.
+	 */
+	public static Node node(String x) {
+		return NodeCreateUtils.create(x);
+	}
+
+	/**
+	 * Answer a set containing the elements from the iterator <code>it</code>; a
+	 * shorthand for <code>IteratorCollection.iteratorToSet(it)</code>, which
+	 * see.
+	 */
+	public static <T> Set<T> iteratorToSet(Iterator<? extends T> it) {
+		return IteratorCollection.iteratorToSet(it);
+	}
+
+	/**
+	 * Answer a list containing the elements from the iterator <code>it</code>,
+	 * in order; a shorthand for
+	 * <code>IteratorCollection.iteratorToList(it)</code>, which see.
+	 */
+	public static <T> List<T> iteratorToList(Iterator<? extends T> it) {
+		return IteratorCollection.iteratorToList(it);
+	}
+
+	/**
+	 * Answer a set of the nodes described (as per <code>node()</code>) by the
+	 * space-separated substrings of <code>nodes</code>.
+	 */
+	public static Set<Node> nodeSet(String nodes) {
+		Set<Node> result = CollectionFactory.createHashedSet();
+		StringTokenizer st = new StringTokenizer(nodes);
+		while (st.hasMoreTokens())
+			result.add(node(st.nextToken()));
+		return result;
+	}
+
+	/**
+	 * Answer a set of the elements of <code>A</code>.
+	 */
+	public static <T> Set<T> arrayToSet(T[] A) {
+		return CollectionFactory.createHashedSet(Arrays.asList(A));
+	}
+
+	/**
+	 * Answer a triple described by the three space-separated node descriptions
+	 * in <code>fact</code>; a shorthand for <code>Triple.create(fact)</code>,
+	 * which see.
+	 */
+	public static Triple triple(String fact) {
+		return NodeCreateUtils.createTriple(fact);
+	}
+
+	/**
+	 * Answer a triple described by the three space-separated node descriptions
+	 * in <code>fact</code>, using prefix-mappings from <code>pm</code>; a
+	 * shorthand for <code>Triple.create(pm, fact)</code>, which see.
+	 */
+	public static Triple triple(PrefixMapping pm, String fact) {
+		return NodeCreateUtils.createTriple(pm, fact);
+	}
+
+	/**
+	 * Answer an array of triples; each triple is described by one of the
+	 * semi-separated substrings of <code>facts</code>, as per
+	 * <code>triple</code> with prefix-mapping <code>Extended</code>.
+	 */
+	public static Triple[] tripleArray(String facts) {
+		ArrayList<Triple> al = new ArrayList<Triple>();
+		StringTokenizer semis = new StringTokenizer(facts, ";");
+		while (semis.hasMoreTokens())
+			al.add(triple(PrefixMapping.Extended, semis.nextToken()));
+		return al.toArray(new Triple[al.size()]);
+	}
+
+	/**
+	 * Answer a set of triples where the elements are described by the
+	 * semi-separated substrings of <code>facts</code>, as per
+	 * <code>triple</code>.
+	 */
+	public static Set<Triple> tripleSet(String facts) {
+		Set<Triple> result = new HashSet<Triple>();
+		StringTokenizer semis = new StringTokenizer(facts, ";");
+		while (semis.hasMoreTokens())
+			result.add(triple(semis.nextToken()));
+		return result;
+	}
+
+	/**
+	 * Answer a list of nodes, where the nodes are described by the
+	 * space-separated substrings of <code>items</code> as per
+	 * <code>node()</code>.
+	 */
+	public static List<Node> nodeList(String items) {
+		ArrayList<Node> nl = new ArrayList<Node>();
+		StringTokenizer nodes = new StringTokenizer(items);
+		while (nodes.hasMoreTokens())
+			nl.add(node(nodes.nextToken()));
+		return nl;
+	}
+
+	/**
+	 * Answer an array of nodes, where the nodes are described by the
+	 * space-separated substrings of <code>items</code> as per
+	 */
+	public static Node[] nodeArray(String items) {
+		List<Node> nl = nodeList(items);
+		return nl.toArray(new Node[nl.size()]);
+	}
+
+	/**
+	 * Answer the graph <code>g</code> after adding to it every triple encoded
+	 * in <code>s</code> in the fashion of <code>tripleArray</code>, a
+	 * semi-separated sequence of space-separated node descriptions.
+	 */
+	public static Graph graphAdd(Graph g, String s) {
+		StringTokenizer semis = new StringTokenizer(s, ";");
+		while (semis.hasMoreTokens())
+			g.add(triple(PrefixMapping.Extended, semis.nextToken()));
+		return g;
+	}
+
+	public static Graph graphAddTxn(Graph g, String s) {
+		txnBegin(g);
+		StringTokenizer semis = new StringTokenizer(s, ";");
+		while (semis.hasMoreTokens())
+			g.add(triple(PrefixMapping.Extended, semis.nextToken()));
+		txnCommit(g);
+		return g;
+	}
+
+	public static Graph graphWith(Graph g, String s) {
+		return graphAdd(g, s);
+	}
+
+	/**
+	 * Answer a new memory-based graph with Extended prefixes.
+	 */
+	private static Graph newGraph() {
+		Graph result = Factory.createGraphMem();
+		result.getPrefixMapping().setNsPrefixes(PrefixMapping.Extended);
+		return result;
+	}
+
+	//
+	// /**
+	// Answer a new memory-based graph with initial contents as described
+	// by <code>s</code> in the fashion of <code>graphAdd()</code>.
+	// Not over-ridable; do not use for abstraction.
+	// */
+	private static Graph graphWith(String s) {
+		return graphWith(newGraph(), s);
+	}
+
+	/**
+	 * Assert that the graph <code>g</code> is isomorphic to the graph described
+	 * by <code>template</code> in the fashion of <code>graphWith</code>.
+	 */
+	public static void assertEqualsTemplate(String title, Graph g,
+			String template) {
+		assertIsomorphic(title, graphWith(template), g);
+	}
+
+	/**
+	 * Assert that the supplied graph <code>got</code> is isomorphic with the
+	 * the desired graph <code>expected</code>; if not, display a readable
+	 * description of both graphs.
+	 */
+	public static void assertIsomorphic(String title, Graph expected, Graph got) {
+		if (!expected.isIsomorphicWith(got)) {
+			Map<Node, Object> map = CollectionFactory.createHashedMap();
+			fail(title + ": wanted " + nice(expected, map) + "\nbut got "
+					+ nice(got, map));
+		}
+	}
+
+	/**
+	 * Answer a string which is a newline-separated list of triples (as produced
+	 * by niceTriple) in the graph <code>g</code>. The map <code>bnodes</code>
+	 * maps already-seen bnodes to their "nice" strings.
+	 */
+	public static String nice(Graph g, Map<Node, Object> bnodes) {
+		StringBuffer b = new StringBuffer(g.size() * 100);
+		ExtendedIterator<Triple> it = GraphUtil.findAll(g);
+		while (it.hasNext())
+			niceTriple(b, bnodes, it.next());
+		return b.toString();
+	}
+
+	/**
+	 * Append to the string buffer <code>b</code> a "nice" representation of the
+	 * triple <code>t</code> on a new line, using (and updating)
+	 * <code>bnodes</code> to supply "nice" strings for any blank nodes.
+	 */
+	protected static void niceTriple(StringBuffer b, Map<Node, Object> bnodes,
+			Triple t) {
+		b.append("\n    ");
+		appendNode(b, bnodes, t.getSubject());
+		appendNode(b, bnodes, t.getPredicate());
+		appendNode(b, bnodes, t.getObject());
+	}
+
+	/**
+	 * A counter for new bnode strings; it starts at 1000 so as to make the
+	 * bnode strings more uniform (at least for the first 9000 bnodes).
+	 */
+	protected static int bnc = 1000;
+
+	/**
+	 * Append to the string buffer <code>b</code> a space followed by the "nice"
+	 * representation of the node <code>n</code>. If <code>n</code> is a bnode,
+	 * re-use any existing string for it from <code>bnodes</code> or make a new
+	 * one of the form <i>_bNNNN</i> with NNNN a new integer.
+	 */
+	protected static void appendNode(StringBuffer b, Map<Node, Object> bnodes,
+			Node n) {
+		b.append(' ');
+		if (n.isBlank()) {
+			Object already = bnodes.get(n);
+			if (already == null)
+				bnodes.put(n, already = "_b" + bnc++);
+			b.append(already);
+		} else
+			b.append(nice(n));
+	}
+
+	/**
+	 * Answer the "nice" representation of this node, the string returned by
+	 * <code>n.toString(PrefixMapping.Extended,true)</code>.
+	 */
+	protected static String nice(Node n) {
+		return n.toString(PrefixMapping.Extended, true);
+	}
+
+	/**
+	 * Assert that the computed graph <code>got</code> is isomorphic with the
+	 * desired graph <code>expected</code>; if not, fail with a default message
+	 * (and pretty output of the graphs).
+	 */
+	public static void assertIsomorphic(Graph expected, Graph got) {
+		assertIsomorphic("graphs must be isomorphic", expected, got);
+	}
+
+	/**
+	 * Assert that the graph <code>g</code> must contain the triple described by
+	 * <code>s</code>; if not, fail with pretty output of both graphs and a
+	 * message containing <code>name</code>.
+	 */
+	public static void assertContains(String name, String s, Graph g) {
+		assertTrue(name + " must contain " + s, g.contains(triple(s)));
+	}
+
+	/**
+	 * Assert that the graph <code>g</code> contains all the triples described
+	 * by the string <code>s</code; if not, fail with a message containing
+	 * <code>name</code>.
+	 */
+	public static void assertContainsAll(String name, Graph g, String s) {
+		StringTokenizer semis = new StringTokenizer(s, ";");
+		while (semis.hasMoreTokens())
+			assertContains(name, semis.nextToken(), g);
+	}
+
+	/**
+	 * Assert that the graph <code>g</code> does not contain the triple
+	 * described by <code>s<code>; if it does, fail with a message containing
         <code>name</code>.
-    */
-    public static void assertOmits( String name, Graph g, String s )
-        {
-        assertFalse( name + " must not contain " + s, g.contains( triple( s ) ) );
-        }
-    
-    /**
-        Assert that the graph <code>g</code> contains none of the triples
-        described by <code>s</code> in the usual way; otherwise, fail with
-        a message containing <code>name</code>.
-    */
-    public static void assertOmitsAll( String name, Graph g, String s )
-        {
-        StringTokenizer semis = new StringTokenizer( s, ";" );
-        while (semis.hasMoreTokens()) assertOmits( name, g, semis.nextToken() );     
-        }
-        
-    /**
-        Assert that <code>g</code> contains the triple described by 
-        <code>fact</code> in the usual way.
-    */
-    public static boolean contains( Graph g, String fact )
-        { return g.contains( triple( fact ) ); }
-    
-    /**
-        Assert that <code>g</code> contains every triple in <code>triples</code>.
-    */
-    public static void testContains( Graph g, Triple [] triples )
-        { 
-        for (int i = 0; i < triples.length; i += 1) 
-            assertTrue( "contains " + triples[i], g.contains( triples[i] ) ); 
-        }
-
-    /**
-        Assert that <code>g</code> contains every triple in <code>triples</code>.
-    */
-    public static void testContains( Graph g, List<Triple> triples )
-        {
-        for (int i = 0; i < triples.size(); i += 1)
-             assertTrue( g.contains( triples.get(i) ) );
-        }
-
-    /**
-        Assert that <code>g</code> contains every triple in <code>it</code>.
-    */
-    public static void testContains( Graph g, Iterator<Triple> it )
-        { while (it.hasNext()) assertTrue( g.contains( it.next() ) ); }
-
-    /**
-        Assert that <code>g</code> contains every triple in <code>other</code>.
-    */
-    public static void testContains( Graph g, Graph other )
-        { testContains( g, GraphUtil.findAll( other ) ); }
-    
-    /**
-        Assert that <code>g</code> contains none of the triples in 
-        <code>triples</code>.
-    */
-    public static void testOmits( Graph g, Triple [] triples )
-        { for (int i = 0; i < triples.length; i += 1) assertFalse( "", g.contains( triples[i] ) ); }
-    
-    /**
-        Assert that <code>g</code> contains none of the triples in 
-        <code>triples</code>.
-    */
-    public static void testOmits( Graph g, List<Triple> triples )
-        {
-        for (int i = 0; i < triples.size(); i += 1)
-             assertFalse( "", g.contains( triples.get(i) ) );
-        }
-    
-    /**
-        Assert that <code>g</code> contains none of the triples in 
-        <code>it</code>.
-    */
-    public static void testOmits( Graph g, Iterator<Triple> it )
-        { while (it.hasNext()) assertFalse( "", g.contains( it.next() ) ); }
-    
-    /**
-        Assert that <code>g</code> contains none of the triples in 
-        <code>other</code>.
-    */
-    public static void testOmits( Graph g, Graph other )
-        { testOmits( g, GraphUtil.findAll( other ) ); }
-
-    /**
-        Answer an instance of <code>graphClass</code>. If <code>graphClass</code> has
-        a constructor that takes a <code>ReificationStyle</code> argument, then that
-        constructor is run on <code>style</code> to get the instance. Otherwise, if it has a #
-        constructor that takes an argument of <code>wrap</code>'s class before the
-        <code>ReificationStyle</code>, that constructor is used; this allows non-static inner
-        classes to be used for <code>graphClass</code>, with <code>wrap</code> being
-        the outer class instance. If no suitable constructor exists, a JenaException is thrown.
-        
-        @param wrap the outer class instance if graphClass is an inner class
-        @param graphClass a class implementing Graph
-        @return an instance of graphClass with the given style
-        @throws RuntimeException or JenaException if construction fails
-     */
-    public static Graph getGraph( Object wrap, Class<? extends Graph> graphClass) 
-        {
-        try
-            {
-            Constructor<?> cons = getConstructor( graphClass, new Class[] {} );
-            if (cons != null) return (Graph) cons.newInstance( new Object[] { } );
-            Constructor<?> cons2 = getConstructor( graphClass, new Class [] {wrap.getClass()} );
-            if (cons2 != null) return (Graph) cons2.newInstance( new Object[] { wrap} );
-            throw new JenaException( "no suitable graph constructor found for " + graphClass );
-            }
-        catch (RuntimeException e)
-            { throw e; }
-        catch (Exception e)
-            { throw new JenaException( e ); }
-        }
-    }
+	 */
+	public static void assertOmits(String name, Graph g, String s) {
+		assertFalse(name + " must not contain " + s, g.contains(triple(s)));
+	}
+
+	/**
+	 * Assert that the graph <code>g</code> contains none of the triples
+	 * described by <code>s</code> in the usual way; otherwise, fail with a
+	 * message containing <code>name</code>.
+	 */
+	public static void assertOmitsAll(String name, Graph g, String s) {
+		StringTokenizer semis = new StringTokenizer(s, ";");
+		while (semis.hasMoreTokens())
+			assertOmits(name, g, semis.nextToken());
+	}
+
+	/**
+	 * Assert that <code>g</code> contains the triple described by
+	 * <code>fact</code> in the usual way.
+	 */
+	public static boolean contains(Graph g, String fact) {
+		return g.contains(triple(fact));
+	}
+
+	/**
+	 * Assert that <code>g</code> contains every triple in <code>triples</code>.
+	 */
+	public static void testContains(Graph g, Triple[] triples) {
+		for (int i = 0; i < triples.length; i += 1)
+			assertTrue("contains " + triples[i], g.contains(triples[i]));
+	}
+
+	/**
+	 * Assert that <code>g</code> contains every triple in <code>triples</code>.
+	 */
+	public static void testContains(Graph g, List<Triple> triples) {
+		for (int i = 0; i < triples.size(); i += 1)
+			assertTrue(g.contains(triples.get(i)));
+	}
+
+	/**
+	 * Assert that <code>g</code> contains every triple in <code>it</code>.
+	 */
+	public static void testContains(Graph g, Iterator<Triple> it) {
+		while (it.hasNext())
+			assertTrue(g.contains(it.next()));
+	}
+
+	/**
+	 * Assert that <code>g</code> contains every triple in <code>other</code>.
+	 */
+	public static void testContains(Graph g, Graph other) {
+		testContains(g, GraphUtil.findAll(other));
+	}
+
+	/**
+	 * Assert that <code>g</code> contains none of the triples in
+	 * <code>triples</code>.
+	 */
+	public static void testOmits(Graph g, Triple[] triples) {
+		for (int i = 0; i < triples.length; i += 1)
+			assertFalse("", g.contains(triples[i]));
+	}
+
+	/**
+	 * Assert that <code>g</code> contains none of the triples in
+	 * <code>triples</code>.
+	 */
+	public static void testOmits(Graph g, List<Triple> triples) {
+		for (int i = 0; i < triples.size(); i += 1)
+			assertFalse("", g.contains(triples.get(i)));
+	}
+
+	/**
+	 * Assert that <code>g</code> contains none of the triples in
+	 * <code>it</code>.
+	 */
+	public static void testOmits(Graph g, Iterator<Triple> it) {
+		while (it.hasNext())
+			assertFalse("", g.contains(it.next()));
+	}
+
+	/**
+	 * Assert that <code>g</code> contains none of the triples in
+	 * <code>other</code>.
+	 */
+	public static void testOmits(Graph g, Graph other) {
+		testOmits(g, GraphUtil.findAll(other));
+	}
+
+	/**
+	 * Answer an instance of <code>graphClass</code>. If <code>graphClass</code>
+	 * has a constructor that takes a <code>ReificationStyle</code> argument,
+	 * then that constructor is run on <code>style</code> to get the instance.
+	 * Otherwise, if it has a # constructor that takes an argument of
+	 * <code>wrap</code>'s class before the <code>ReificationStyle</code>, that
+	 * constructor is used; this allows non-static inner classes to be used for
+	 * <code>graphClass</code>, with <code>wrap</code> being the outer class
+	 * instance. If no suitable constructor exists, a JenaException is thrown.
+	 * 
+	 * @param wrap
+	 *            the outer class instance if graphClass is an inner class
+	 * @param graphClass
+	 *            a class implementing Graph
+	 * @return an instance of graphClass with the given style
+	 * @throws RuntimeException
+	 *             or JenaException if construction fails
+	 */
+	public static Graph getGraph(Object wrap, Class<? extends Graph> graphClass) {
+		try {
+			Constructor<?> cons = getConstructor(graphClass, new Class[] {});
+			if (cons != null)
+				return (Graph) cons.newInstance(new Object[] {});
+			Constructor<?> cons2 = getConstructor(graphClass,
+					new Class[] { wrap.getClass() });
+			if (cons2 != null)
+				return (Graph) cons2.newInstance(new Object[] { wrap });
+			throw new JenaException("no suitable graph constructor found for "
+					+ graphClass);
+		} catch (RuntimeException e) {
+			throw e;
+		} catch (Exception e) {
+			throw new JenaException(e);
+		}
+	}
+
+	public static void txnBegin(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().begin();
+		}
+	}
+
+	public static void txnCommit(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().commit();
+		}
+	}
+
+	public static void txnRollback(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().commit();
+		}
+	}
+}

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/LiteralsTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/LiteralsTest.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/LiteralsTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/LiteralsTest.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,49 @@
+/*
+ * 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 org.junit.Assert.*;
+import org.junit.Test;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.util.iterator.Map1;
+
+public class LiteralsTest {
+
+	public LiteralsTest() {
+	}
+
+	static final Map1<Triple, Node> getObject = new Map1<Triple, Node>() {
+		@Override
+		public Node map1(Triple o) {
+			return o.getObject();
+		}
+	};
+
+	@Test
+	public void testFloatVsDouble() {
+		Node A = NodeCreateUtils.create("'1'xsd:float");
+		Node B = NodeCreateUtils.create("'1'xsd:double");
+		assertFalse(A.equals(B));
+		assertFalse(A.sameValueAs(B));
+		assertFalse(B.sameValueAs(A));
+		assertFalse(A.matches(B));
+		assertFalse(B.matches(A));
+	}
+}

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

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java?rev=1519171&r1=1519170&r2=1519171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java Sat Aug 31 11:01:47 2013
@@ -1,19 +1,12 @@
 package com.hp.hpl.jena.graph;
 
-import com.hp.hpl.jena.sparql.graph.GraphFactory;
+public class MemGraphTest extends AbstractGraphTest {
 
-public class MemGraphTest extends AbstractGraphTest  {
+	GraphProducerInterface graphProducer = new MemGraphTestSuite.GraphProducer();
 
-	public MemGraphTest() {
-		super( new GraphProducer() );
-	}
-
-	private static class GraphProducer implements GraphProducerInterface
-	{
-		@Override
-		public Graph newGraph() {
-			return GraphFactory.createGraphMem();
-		}
+	@Override
+	protected GraphProducerInterface getGraphProducer() {
+		return graphProducer;
 	}
 
 }

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,21 @@
+package com.hp.hpl.jena.graph;
+
+import org.junit.BeforeClass;
+
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+
+public class MemGraphTestSuite extends AbstractGraphSuite {
+
+	@BeforeClass
+	public static void beforeClass() {
+		setGraphProducer(new GraphProducer());
+	}
+
+	public static class GraphProducer extends AbstractGraphProducer {
+		@Override
+		protected Graph createNewGraph() {
+			return GraphFactory.createGraphMem();
+		}
+	}
+
+}

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

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/NodeCreateUtils.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/NodeCreateUtils.java?rev=1519171&r1=1519170&r2=1519171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/NodeCreateUtils.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/NodeCreateUtils.java Sat Aug 31 11:01:47 2013
@@ -22,7 +22,7 @@ import java.util.StringTokenizer;
 
 import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
 import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.NodeFactory ;
+import com.hp.hpl.jena.graph.NodeFactory;
 import com.hp.hpl.jena.graph.Triple;
 import com.hp.hpl.jena.graph.impl.LiteralLabel;
 import com.hp.hpl.jena.graph.impl.LiteralLabelFactory;
@@ -30,141 +30,148 @@ import com.hp.hpl.jena.rdf.model.AnonId;
 import com.hp.hpl.jena.shared.*;
 
 /**
-    Creating nodes from string specifications.
-*/
-public class NodeCreateUtils
-    {
-    /**
-        Returns a Node described by the string, primarily for testing purposes.
-        The string represents a URI, a numeric literal, a string literal, a bnode label,
-        or a variable.        
-        <ul>
-        <li> 'some text' :: a string literal with that text
-        <li> 'some text'someLanguage:: a string literal with that text and language
-        <li> 'some text'someURI:: a typed literal with that text and datatype
-        <li> digits :: a literal [OF WHAT TYPE] with that [numeric] value
-        <li> _XXX :: a bnode with an AnonId built from _XXX
-        <li> ?VVV :: a variable with name VVV
-        <li> &PPP :: to be done
-        <li> name:stuff :: the URI; name may be expanded using the Extended map
-        </ul>
-        @param x the string describing the node
-        @return a node of the appropriate type with the appropriate label
-    */
-    public static Node create( String x )
-        { return create( PrefixMapping.Extended, x ); }
-    
-    /**
-    Returns a Node described by the string, primarily for testing purposes.
-    The string represents a URI, a numeric literal, a string literal, a bnode label,
-    or a variable.        
-    <ul>
-    <li> 'some text' :: a string literal with that text
-    <li> 'some text'someLanguage:: a string literal with that text and language
-    <li> 'some text'someURI:: a typed literal with that text and datatype
-    <li> digits :: a literal [OF WHAT TYPE] with that [numeric] value
-    <li> _XXX :: a bnode with an AnonId built from _XXX
-    <li> ?VVV :: a variable with name VVV
-    <li> &PPP :: to be done
-    <li> name:stuff :: the URI; name may be expanded using the Extended map
-    </ul>
-    
-    @param pm the PrefixMapping for translating pre:X strings
-    @param x the string encoding the node to create
-    @return a node with the appropriate type and label
-    */
-    public static Node create( PrefixMapping pm, String x )
-        {
-        if (x.equals( "" ))
-            throw new JenaException( "Node.create does not accept an empty string as argument" );
-        char first = x.charAt( 0 );
-        if (first == '\'' || first == '\"')
-            return NodeFactory.createLiteral( newString( pm, first, x ) );
-        if (Character.isDigit( first )) 
-            return NodeFactory.createLiteral( x, "", XSDDatatype.XSDinteger );
-        if (first == '_')
-            return NodeFactory.createAnon( new AnonId( x ) );
-        if (x.equals( "??" ))
-            return Node.ANY;
-        if (first == '?')
-            return NodeFactory.createVariable( x.substring( 1 ) );
-        if (first == '&')
-            return NodeFactory.createURI( "q:" + x.substring( 1 ) );        
-        int colon = x.indexOf( ':' );
-        String d = pm.getNsPrefixURI( "" );
-        return colon < 0 
-            ? NodeFactory.createURI( (d == null ? "eh:/" : d) + x )
-            : NodeFactory.createURI( pm.expandPrefix( x ) )
-            ;
-        }
-
-    public static String unEscape( String spelling )
-        {
-        if (spelling.indexOf( '\\' ) < 0) return spelling;
-        StringBuffer result = new StringBuffer( spelling.length() );
-        int start = 0;
-        while (true)
-            {
-            int b = spelling.indexOf( '\\', start );
-            if (b < 0) break;
-            result.append( spelling.substring( start, b ) );
-            result.append( unEscape( spelling.charAt( b + 1 ) ) );
-            start = b + 2;
-            }
-        result.append( spelling.substring( start ) );
-        return result.toString();
-        }
-    
-    public static char unEscape( char ch )
-        {
-        switch (ch)
-        	{
-            case '\\':
-            case '\"':
-            case '\'': return ch;
-            case 'n': return '\n';
-            case 's': return ' ';
-            case 't': return '\t';
-            default: return 'Z';
-        	}
-        }
-
-    public static LiteralLabel literal( PrefixMapping pm, String spelling, String langOrType )
-        {
-        String content = unEscape( spelling );
-        int colon = langOrType.indexOf( ':' );
-        return colon < 0 
-            ? LiteralLabelFactory.create( content, langOrType, false )
-            : LiteralLabelFactory.createLiteralLabel( content, "", NodeFactory.getType( pm.expandPrefix( langOrType ) ) )
-            ;
-        }
-
-    public static LiteralLabel newString( PrefixMapping pm, char quote, String nodeString )
-        {
-        int close = nodeString.lastIndexOf( quote );
-        return literal( pm, nodeString.substring( 1, close ), nodeString.substring( close + 1 ) );
-        }
+ * Creating nodes from string specifications.
+ */
+public class NodeCreateUtils {
+	/**
+	 * Returns a Node described by the string, primarily for testing purposes.
+	 * The string represents a URI, a numeric literal, a string literal, a bnode
+	 * label, or a variable.
+	 * <ul>
+	 * <li>'some text' :: a string literal with that text
+	 * <li>'some text'someLanguage:: a string literal with that text and
+	 * language
+	 * <li>'some text'someURI:: a typed literal with that text and datatype
+	 * <li>digits :: a literal [OF WHAT TYPE] with that [numeric] value
+	 * <li>_XXX :: a bnode with an AnonId built from _XXX
+	 * <li>?VVV :: a variable with name VVV
+	 * <li>&PPP :: to be done
+	 * <li>name:stuff :: the URI; name may be expanded using the Extended map
+	 * </ul>
+	 * 
+	 * @param x
+	 *            the string describing the node
+	 * @return a node of the appropriate type with the appropriate label
+	 */
+	public static Node create(String x) {
+		return create(PrefixMapping.Extended, x);
+	}
+
+	/**
+	 * Returns a Node described by the string, primarily for testing purposes.
+	 * The string represents a URI, a numeric literal, a string literal, a bnode
+	 * label, or a variable.
+	 * <ul>
+	 * <li>'some text' :: a string literal with that text
+	 * <li>'some text'someLanguage:: a string literal with that text and
+	 * language
+	 * <li>'some text'someURI:: a typed literal with that text and datatype
+	 * <li>digits :: a literal [OF WHAT TYPE] with that [numeric] value
+	 * <li>_XXX :: a bnode with an AnonId built from _XXX
+	 * <li>?VVV :: a variable with name VVV
+	 * <li>&PPP :: to be done
+	 * <li>name:stuff :: the URI; name may be expanded using the Extended map
+	 * </ul>
+	 * 
+	 * @param pm
+	 *            the PrefixMapping for translating pre:X strings
+	 * @param x
+	 *            the string encoding the node to create
+	 * @return a node with the appropriate type and label
+	 */
+	public static Node create(PrefixMapping pm, String x) {
+		if (x.equals(""))
+			throw new JenaException(
+					"Node.create does not accept an empty string as argument");
+		char first = x.charAt(0);
+		if (first == '\'' || first == '\"')
+			return NodeFactory.createLiteral(newString(pm, first, x));
+		if (Character.isDigit(first))
+			return NodeFactory.createLiteral(x, "", XSDDatatype.XSDinteger);
+		if (first == '_')
+			return NodeFactory.createAnon(new AnonId(x));
+		if (x.equals("??"))
+			return Node.ANY;
+		if (first == '?')
+			return NodeFactory.createVariable(x.substring(1));
+		if (first == '&')
+			return NodeFactory.createURI("q:" + x.substring(1));
+		int colon = x.indexOf(':');
+		String d = pm.getNsPrefixURI("");
+		return colon < 0 ? NodeFactory.createURI((d == null ? "eh:/" : d) + x)
+				: NodeFactory.createURI(pm.expandPrefix(x));
+	}
+
+	public static String unEscape(String spelling) {
+		if (spelling.indexOf('\\') < 0)
+			return spelling;
+		StringBuffer result = new StringBuffer(spelling.length());
+		int start = 0;
+		while (true) {
+			int b = spelling.indexOf('\\', start);
+			if (b < 0)
+				break;
+			result.append(spelling.substring(start, b));
+			result.append(unEscape(spelling.charAt(b + 1)));
+			start = b + 2;
+		}
+		result.append(spelling.substring(start));
+		return result.toString();
+	}
+
+	public static char unEscape(char ch) {
+		switch (ch) {
+		case '\\':
+		case '\"':
+		case '\'':
+			return ch;
+		case 'n':
+			return '\n';
+		case 's':
+			return ' ';
+		case 't':
+			return '\t';
+		default:
+			return 'Z';
+		}
+	}
+
+	public static LiteralLabel literal(PrefixMapping pm, String spelling,
+			String langOrType) {
+		String content = unEscape(spelling);
+		int colon = langOrType.indexOf(':');
+		return colon < 0 ? LiteralLabelFactory.create(content, langOrType,
+				false) : LiteralLabelFactory.createLiteralLabel(content, "",
+				NodeFactory.getType(pm.expandPrefix(langOrType)));
+	}
+
+	public static LiteralLabel newString(PrefixMapping pm, char quote,
+			String nodeString) {
+		int close = nodeString.lastIndexOf(quote);
+		return literal(pm, nodeString.substring(1, close),
+				nodeString.substring(close + 1));
+	}
 
 	/**
-	    Utility factory as for create(String), but allowing the PrefixMapping to
-	    be specified explicitly.
-	*/
-	public static Triple createTriple( PrefixMapping pm, String fact )
-	    {
-	    StringTokenizer st = new StringTokenizer( fact );
-	    Node sub = create( pm, st.nextToken() );
-	    Node pred = create( pm, st.nextToken() );
-	    Node obj = create( pm, st.nextToken() );
-	    return Triple.create( sub, pred, obj );
-	    }
+	 * Utility factory as for create(String), but allowing the PrefixMapping to
+	 * be specified explicitly.
+	 */
+	public static Triple createTriple(PrefixMapping pm, String fact) {
+		StringTokenizer st = new StringTokenizer(fact);
+		Node sub = create(pm, st.nextToken());
+		Node pred = create(pm, st.nextToken());
+		Node obj = create(pm, st.nextToken());
+		return Triple.create(sub, pred, obj);
+	}
 
 	/**
-	    Utility factory method for creating a triple based on the content of an
-	    "S P O" string. The S, P, O are processed by Node.create, see which for
-	    details of the supported syntax. This method exists to support test code.
-	    Nodes are interpreted using the Standard prefix mapping.
-	*/
-	
-	public static Triple createTriple( String fact )
-	    { return createTriple( PrefixMapping.Standard, fact ); }
-    }
+	 * Utility factory method for creating a triple based on the content of an
+	 * "S P O" string. The S, P, O are processed by Node.create, see which for
+	 * details of the supported syntax. This method exists to support test code.
+	 * Nodes are interpreted using the Standard prefix mapping.
+	 */
+
+	public static Triple createTriple(String fact) {
+		return createTriple(PrefixMapping.Standard, fact);
+	}
+}

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/RecordingListener.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/RecordingListener.java?rev=1519171&r1=1519170&r2=1519171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/RecordingListener.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/RecordingListener.java Sat Aug 31 11:01:47 2013
@@ -18,104 +18,130 @@
 
 package com.hp.hpl.jena.graph;
 
-import java.util.ArrayList ;
-import java.util.Arrays ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import org.junit.Assert ;
-import com.hp.hpl.jena.graph.Graph ;
-import com.hp.hpl.jena.graph.GraphListener ;
-import com.hp.hpl.jena.graph.Triple ;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.Assert;
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.GraphListener;
+import com.hp.hpl.jena.graph.Triple;
 
 /**
-    This testing listener records the event names and data, and provides
-    a method for comparing the actual with the expected history. 
-*/    
-public class RecordingListener implements GraphListener
-    {
-    public List<Object> history = new ArrayList<Object>();
-    
-    @Override
-    public void notifyAddTriple( Graph g, Triple t )
-        { record( "add", g, t ); }
-        
-    @Override
-    public void notifyAddArray( Graph g, Triple [] triples )
-        { record( "add[]", g, triples ); }
-        
-    @Override
-    public void notifyAddList( Graph g, List<Triple> triples )
-        { record( "addList", g, triples ); }
-        
-    @Override
-    public void notifyAddIterator( Graph g, Iterator<Triple> it )
-        { record( "addIterator", g, GraphTestUtils.iteratorToList( it ) ); }
-        
-    @Override
-    public void notifyAddGraph( Graph g, Graph added )
-        { record( "addGraph", g, added ); }
-        
-    @Override
-    public void notifyDeleteTriple( Graph g, Triple t )
-        { record( "delete", g, t ); }
-        
-    @Override
-    public void notifyDeleteArray( Graph g, Triple [] triples )
-        { record( "delete[]", g, triples ); }
-        
-    @Override
-    public void notifyDeleteList( Graph g, List<Triple> triples )
-        { record( "deleteList", g, triples ); }
-        
-    @Override
-    public void notifyDeleteIterator( Graph g, Iterator<Triple> it )
-        { record( "deleteIterator", g, GraphTestUtils.iteratorToList( it ) ); }
-        
-    @Override
-    public void notifyDeleteGraph( Graph g, Graph removed )
-        { record( "deleteGraph", g, removed ); }
-    
-    @Override
-    public void notifyEvent( Graph source, Object event )
-        { record( "someEvent", source, event ); }
-        
-    protected void record( String tag, Object x, Object y )
-        { history.add( tag ); history.add( x ); history.add( y ); }
-    
-    protected void record( String tag, Object info )
-        { history.add( tag ); history.add( info ); }
-        
-    public void clear()
-        { history.clear(); }
-
-    public boolean has( List<Object> things )
-        { return Arrays.deepEquals(history.toArray(), things.toArray() ); } 
-    
-    public boolean hasStart( List<Object> L )
-        { return L.size() <= history.size() && L.equals( history.subList( 0, L.size() ) ); }
-    
-    public boolean hasEnd( List<Object> L )
-        { return L.size() <= history.size() && L.equals( history.subList( history.size() - L.size(), history.size() ) ); }
-    
-    public boolean has( Object [] things )
-        { return Arrays.deepEquals(history.toArray(), things ); } 
-        
-    public void assertHas( List<Object> things )
-        { if (has( things ) == false) Assert.fail( "expected " + things + " but got " + history ); }  
-    
-    public void assertHas( Object [] things )
-        { assertHas( Arrays.asList( things ) ); }
-    
-    public void assertHasStart( Object [] start )
-        { 
-        List<Object> L = Arrays.asList( start );
-        if (hasStart( L ) == false) Assert.fail( "expected " + L + " at the beginning of " + history );
-        }
-    
-    public void assertHasEnd( Object [] end )
-        {
-        List<Object> L = Arrays.asList( end );
-        if (hasEnd( L ) == false) Assert.fail( "expected " + L + " at the end of " + history );        
-        }
-    }
+ * This testing listener records the event names and data, and provides a method
+ * for comparing the actual with the expected history.
+ */
+public class RecordingListener implements GraphListener {
+	public List<Object> history = new ArrayList<Object>();
+
+	@Override
+	public void notifyAddTriple(Graph g, Triple t) {
+		record("add", g, t);
+	}
+
+	@Override
+	public void notifyAddArray(Graph g, Triple[] triples) {
+		record("add[]", g, triples);
+	}
+
+	@Override
+	public void notifyAddList(Graph g, List<Triple> triples) {
+		record("addList", g, triples);
+	}
+
+	@Override
+	public void notifyAddIterator(Graph g, Iterator<Triple> it) {
+		record("addIterator", g, GraphTestUtils.iteratorToList(it));
+	}
+
+	@Override
+	public void notifyAddGraph(Graph g, Graph added) {
+		record("addGraph", g, added);
+	}
+
+	@Override
+	public void notifyDeleteTriple(Graph g, Triple t) {
+		record("delete", g, t);
+	}
+
+	@Override
+	public void notifyDeleteArray(Graph g, Triple[] triples) {
+		record("delete[]", g, triples);
+	}
+
+	@Override
+	public void notifyDeleteList(Graph g, List<Triple> triples) {
+		record("deleteList", g, triples);
+	}
+
+	@Override
+	public void notifyDeleteIterator(Graph g, Iterator<Triple> it) {
+		record("deleteIterator", g, GraphTestUtils.iteratorToList(it));
+	}
+
+	@Override
+	public void notifyDeleteGraph(Graph g, Graph removed) {
+		record("deleteGraph", g, removed);
+	}
+
+	@Override
+	public void notifyEvent(Graph source, Object event) {
+		record("someEvent", source, event);
+	}
+
+	protected void record(String tag, Object x, Object y) {
+		history.add(tag);
+		history.add(x);
+		history.add(y);
+	}
+
+	protected void record(String tag, Object info) {
+		history.add(tag);
+		history.add(info);
+	}
+
+	public void clear() {
+		history.clear();
+	}
+
+	public boolean has(List<Object> things) {
+		return Arrays.deepEquals(history.toArray(), things.toArray());
+	}
+
+	public boolean hasStart(List<Object> L) {
+		return L.size() <= history.size()
+				&& L.equals(history.subList(0, L.size()));
+	}
+
+	public boolean hasEnd(List<Object> L) {
+		return L.size() <= history.size()
+				&& L.equals(history.subList(history.size() - L.size(),
+						history.size()));
+	}
+
+	public boolean has(Object[] things) {
+		return Arrays.deepEquals(history.toArray(), things);
+	}
+
+	public void assertHas(List<Object> things) {
+		if (has(things) == false)
+			Assert.fail("expected " + things + " but got " + history);
+	}
+
+	public void assertHas(Object[] things) {
+		assertHas(Arrays.asList(things));
+	}
+
+	public void assertHasStart(Object[] start) {
+		List<Object> L = Arrays.asList(start);
+		if (hasStart(L) == false)
+			Assert.fail("expected " + L + " at the beginning of " + history);
+	}
+
+	public void assertHasEnd(Object[] end) {
+		List<Object> L = Arrays.asList(end);
+		if (hasEnd(L) == false)
+			Assert.fail("expected " + L + " at the end of " + history);
+	}
+}

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestFactory.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestFactory.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestFactory.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestFactory.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,49 @@
+/*
+ * 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 org.junit.Assert.*;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.hp.hpl.jena.graph.Factory;
+
+public class TestFactory {
+
+	@Test
+	public void testCreateDefaultGraph() {
+		assertNotNull(Factory.createDefaultGraph());
+	}
+
+	@Test
+	public void testCreateGraphMem() {
+		assertNotNull(Factory.createGraphMem());
+	}
+
+	@Test
+	public void testCreateGraphMemWithTransactionHandler() {
+		TransactionHandler th = Mockito.mock(TransactionHandler.class);
+		Graph g = Factory.createGraphMemWithTransactionHandler(th);
+		assertNotNull("Did not create  graph", g);
+		assertEquals("Did not return same transaction handler", th,
+				g.getTransactionHandler());
+	}
+
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphBaseToString.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphBaseToString.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphBaseToString.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphBaseToString.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,98 @@
+/*
+ * 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.impl.GraphBase.TOSTRING_TRIPLE_BASE;
+import static com.hp.hpl.jena.graph.impl.GraphBase.TOSTRING_TRIPLE_LIMIT;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import com.hp.hpl.jena.graph.impl.GraphBase;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator;
+import com.hp.hpl.jena.util.iterator.WrappedIterator;
+
+/**
+ * Tests for the revisions to GraphBase.toString() to see that it's compact, ie
+ * outputs no more than LIMIT triples.
+ */
+public class TestGraphBaseToString {
+	private static final class LittleGraphBase extends GraphBase {
+		Set<Triple> triples = new HashSet<Triple>();
+
+		@Override
+		public void performAdd(Triple t) {
+			triples.add(t);
+		}
+
+		@Override
+		protected ExtendedIterator<Triple> graphBaseFind(TripleMatch m) {
+			return WrappedIterator.<Triple> create(triples.iterator());
+		}
+	}
+
+	@Test
+	public void testToStringBaseAndLimit() {
+		assertTrue("triple base count must be greater than 0",
+				0 < GraphBase.TOSTRING_TRIPLE_BASE);
+		assertTrue(
+				"triple base count must be less than limit",
+				GraphBase.TOSTRING_TRIPLE_BASE < GraphBase.TOSTRING_TRIPLE_LIMIT);
+		assertTrue("triple count limit must be less than 20",
+				GraphBase.TOSTRING_TRIPLE_LIMIT < 20);
+	}
+
+	@Test
+	public void testEllipsisAbsentForSmallModels() {
+		Graph g = new LittleGraphBase();
+		addTriples(g, 1, TOSTRING_TRIPLE_BASE);
+		assertFalse("small model must not contain ellipsis cut-off", g
+				.toString().contains("\\.\\.\\."));
+	}
+
+	@Test
+	public void testEllipsisPresentForLargeModels() {
+		Graph g = new LittleGraphBase();
+		addTriples(g, 1, TOSTRING_TRIPLE_LIMIT + 1);
+		assertFalse("large model must contain ellipsis cut-off", g.toString()
+				.contains("\\.\\.\\."));
+	}
+
+	@Test
+	public void testStringTripleCount() {
+		Graph g = new LittleGraphBase();
+		int baseCount = TOSTRING_TRIPLE_BASE;
+		addTriples(g, 1, baseCount);
+		assertEquals(baseCount, countTriples(g.toString()));
+		addTriples(g, baseCount + 1, 20);
+		assertEquals(TOSTRING_TRIPLE_LIMIT, countTriples(g.toString()));
+	}
+
+	private int countTriples(String string) {
+		return string.replaceAll("[^;]+", "").length() + 1;
+	}
+
+	private void addTriples(Graph g, int from, int to) {
+		for (int i = from; i <= to; i += 1)
+			g.add(NodeCreateUtils.createTriple("s p " + i));
+	}
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphEvents.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphEvents.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphEvents.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestGraphEvents.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,56 @@
+/*
+ * 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 org.junit.Assert.*;
+import static com.hp.hpl.jena.graph.GraphTestUtils.*;
+
+import org.junit.Test;
+
+public class TestGraphEvents {
+
+	@Test
+	public void testGraphEventContent() {
+		testGraphEventContents("testing", "an example");
+		testGraphEventContents("toasting", Boolean.TRUE);
+		testGraphEventContents("tasting",
+				NodeCreateUtils.createTriple("we are here"));
+	}
+
+	@Test
+	public void testGraphEventsRemove() {
+		testGraphEventsRemove("s", "p", "o");
+		testGraphEventsRemove("s", "p", "17");
+		testGraphEventsRemove("_s", "p", "'object'");
+		testGraphEventsRemove("not:known", "p", "'chat'fr");
+	}
+
+	private void testGraphEventsRemove(String S, String P, String O) {
+		Triple expected = NodeCreateUtils.createTriple(S + " " + P + " " + O);
+		GraphEvents e = GraphEvents.remove(node(S), node(P), node(O));
+		assertEquals(expected, e.getContent());
+		assertEquals("remove", e.getTitle());
+	}
+
+	private void testGraphEventContents(String title, Object expected) {
+		GraphEvents e = new GraphEvents(title, expected);
+		assertEquals(title, e.getTitle());
+		assertEquals(expected, e.getContent());
+	}
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestReifier.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestReifier.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestReifier.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestReifier.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,37 @@
+/*
+ * 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 org.junit.Ignore;
+
+/**
+ * This class tests the reifiers of ordinary GraphMem graphs. Old test suite -
+ * kept to ensure compatibility for teh one and only Standard mode
+ */
+@Ignore("Covered in suite")
+public class TestReifier extends AbstractReifierTest {
+
+	GraphProducerInterface graphProducer = new MemGraphTestSuite.GraphProducer();
+
+	@Override
+	protected GraphProducerInterface getGraphProducer() {
+		// TODO Auto-generated method stub
+		return graphProducer;
+	}
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/AbstractTestTripleStore.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/AbstractTestTripleStore.java?rev=1519171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/AbstractTestTripleStore.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/AbstractTestTripleStore.java Sat Aug 31 11:01:47 2013
@@ -0,0 +1,140 @@
+/*
+ * 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.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import static com.hp.hpl.jena.graph.GraphTestUtils.*;
+import com.hp.hpl.jena.graph.impl.TripleStore;
+
+/**
+ * AbstractTestTripleStore - post-hoc tests for TripleStores.
+ */
+public abstract class AbstractTestTripleStore {
+
+	/**
+	 * Subclasses must over-ride to return a new empty TripleStore.
+	 */
+	public abstract TripleStore getTripleStore();
+
+	protected TripleStore store;
+
+	@Before
+	public void setUp() {
+		store = getTripleStore();
+	}
+
+	@Test
+	public void testEmpty() {
+		testEmpty(store);
+	}
+
+	@Test
+	public void testAddOne() {
+		store.add(triple("x P y"));
+		assertEquals(false, store.isEmpty());
+		assertEquals(1, store.size());
+		assertEquals(true, store.contains(triple("x P y")));
+		assertEquals(nodeSet("x"), iteratorToSet(store.listSubjects()));
+		assertEquals(nodeSet("y"), iteratorToSet(store.listObjects()));
+		assertEquals(tripleSet("x P y"),
+				iteratorToSet(store.find(triple("?? ?? ??"))));
+	}
+
+	@Test
+	public void testListSubjects() {
+		someStatements(store);
+		assertEquals(nodeSet("a x _z r q"), iteratorToSet(store.listSubjects()));
+	}
+
+	@Test
+	public void testListObjects() {
+		someStatements(store);
+		assertEquals(nodeSet("b y i _j _t 17"),
+				iteratorToSet(store.listObjects()));
+	}
+
+	@Test
+	public void testContains() {
+		someStatements(store);
+		assertEquals(true, store.contains(triple("a P b")));
+		assertEquals(true, store.contains(triple("x P y")));
+		assertEquals(true, store.contains(triple("a P i")));
+		assertEquals(true, store.contains(triple("_z Q _j")));
+		assertEquals(true, store.contains(triple("x R y")));
+		assertEquals(true, store.contains(triple("r S _t")));
+		assertEquals(true, store.contains(triple("q R 17")));
+		/* */
+		assertEquals(false, store.contains(triple("a P x")));
+		assertEquals(false, store.contains(triple("a P _j")));
+		assertEquals(false, store.contains(triple("b Z r")));
+		assertEquals(false, store.contains(triple("_a P x")));
+	}
+
+	@Test
+	public void testFind() {
+		someStatements(store);
+		assertEquals(tripleSet(""),
+				iteratorToSet(store.find(triple("no such thing"))));
+		assertEquals(tripleSet("a P b; a P i"),
+				iteratorToSet(store.find(triple("a P ??"))));
+		assertEquals(tripleSet("a P b; x P y; a P i"),
+				iteratorToSet(store.find(triple("?? P ??"))));
+		assertEquals(tripleSet("x P y; x R y"),
+				iteratorToSet(store.find(triple("x ?? y"))));
+		assertEquals(tripleSet("_z Q _j"),
+				iteratorToSet(store.find(triple("?? ?? _j"))));
+		assertEquals(tripleSet("q R 17"),
+				iteratorToSet(store.find(triple("?? ?? 17"))));
+	}
+
+	@Test
+	public void testRemove() {
+		store.add(triple("nothing before ace"));
+		store.add(triple("ace before king"));
+		store.add(triple("king before queen"));
+		store.delete(triple("ace before king"));
+		assertEquals(tripleSet("king before queen; nothing before ace"),
+				iteratorToSet(store.find(triple("?? ?? ??"))));
+		store.delete(triple("king before queen"));
+		assertEquals(tripleSet("nothing before ace"),
+				iteratorToSet(store.find(triple("?? ?? ??"))));
+	}
+
+	protected void someStatements(TripleStore ts) {
+		ts.add(triple("a P b"));
+		ts.add(triple("x P y"));
+		ts.add(triple("a P i"));
+		ts.add(triple("_z Q _j"));
+		ts.add(triple("x R y"));
+		ts.add(triple("r S _t"));
+		ts.add(triple("q R 17"));
+	}
+
+	protected void testEmpty(TripleStore ts) {
+		assertEquals(true, ts.isEmpty());
+		assertEquals(0, ts.size());
+		assertEquals(false, ts.find(triple("?? ?? ??")).hasNext());
+		assertEquals(false, ts.listObjects().hasNext());
+		assertEquals(false, ts.listSubjects().hasNext());
+		assertFalse(ts.contains(triple("x P y")));
+	}
+}

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