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 2015/05/23 08:58:11 UTC

[01/25] jena git commit: Added initial contract tests added testing_framework

Repository: jena
Updated Branches:
  refs/heads/add-contract-tests fe78f4afe -> 7a19eaf1d
  refs/heads/master 5f3510aa6 -> 6419caaf2


http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java
new file mode 100644
index 0000000..7e19122
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java
@@ -0,0 +1,143 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.junit.internal.runners.ErrorReportingRunner;
+import org.junit.runner.Description;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.ParentRunner;
+import org.junit.runners.Suite;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.RunnerBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.jena.shared.JenaException;
+
+/**
+ * Class that runs the Manifest annotated tests.
+ * 
+ * Used with <code>@RunWith( ManifestSuite.class )</code> this class loads a 
+ * manifest test suite file and adds the tests.
+ * <p>
+ * Tests annotated with <code>@RunWith( ManifestSuite.class )</code> must
+ * have a <code>ManifestFile</code> annotation specifying the path to the manifest file
+ * </p>
+ */
+public class ManifestSuite extends ParentRunner<Runner> {
+	private static final Logger LOG = LoggerFactory
+			.getLogger(ManifestSuite.class);
+	private final List<Runner> fRunners;
+	private final ManifestItemHandler itemHandler;
+	private final ManifestFile mf;
+
+	/**
+	 * Called reflectively on classes annotated with
+	 * <code>@RunWith(Suite.class)</code>
+	 * 
+	 * @param cls
+	 *            the root class
+	 * @param builder
+	 *            builds runners for classes in the suite
+	 * @throws Throwable
+	 */
+	public ManifestSuite(Class<? extends ManifestItemHandler> cls,
+			RunnerBuilder builder) throws Throwable {
+		super(cls);
+
+		List<Throwable> errors = new ArrayList<Throwable>();
+
+		mf = cls.getAnnotation(ManifestFile.class);
+		if (mf == null) {
+			throw new IllegalStateException(
+					"ManifestSuite requries ManifestFile annotation");
+		}
+		itemHandler = cls.newInstance();
+
+		Runner[] runner = new Runner[1];
+		try {
+			runner[0] = oneManifest(new Manifest(mf.value()),
+					new ArrayList<Runner>());
+		} catch (JenaException ex) {
+			runner[0] = new ErrorReportingRunner(null, ex);
+		}
+
+		if (!errors.isEmpty()) {
+			throw new InitializationError(errors);
+		}
+		fRunners = Collections.unmodifiableList(Arrays.asList(runner));
+	}
+
+	private Runner oneManifest(final Manifest manifest, List<Runner> r) {
+
+		// Recurse
+		for (Iterator<String> iter = manifest.includedManifests(); iter
+				.hasNext();) {
+			try {
+				r.add(oneManifest(new Manifest(iter.next()),
+						new ArrayList<Runner>()));
+			} catch (JenaException ex) {
+				r.add(new ErrorReportingRunner(null, ex));
+			}
+		}
+		itemHandler.setTestRunnerList(r);
+		manifest.apply(itemHandler);
+		try {
+			return new Suite((Class<?>) null, r) {
+
+				@Override
+				protected String getName() {
+					return manifest.getName();
+				}
+
+			};
+		} catch (InitializationError e) {
+			return new ErrorReportingRunner(null, e);
+		}
+	}
+
+	@Override
+	protected List<Runner> getChildren() {
+		return fRunners;
+	}
+
+	@Override
+	protected Description describeChild(Runner child) {
+		return child.getDescription();
+	}
+
+	@Override
+	protected void runChild(Runner child, RunNotifier notifier) {
+		child.run(notifier);
+	}
+
+	/**
+	 * Returns a name used to describe this Runner
+	 */
+	@Override
+	protected String getName() {
+		return String.format("%s - %s", super.getName(), mf.value());
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
new file mode 100644
index 0000000..cfde240
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
@@ -0,0 +1,13 @@
+package org.apache.jena.testing_framework.manifest;
+
+public abstract class ManifestTest {
+
+	protected ManifestItem manifestItem;
+
+	public final void setManifestItem(ManifestItem manifestItem) {
+		this.manifestItem = manifestItem;
+	}
+
+	abstract public void runTest();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
new file mode 100644
index 0000000..616b444
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
@@ -0,0 +1,75 @@
+package org.apache.jena.testing_framework.manifest;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.runner.Description;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+
+public class ManifestTestRunner extends BlockJUnit4ClassRunner {
+
+	private ManifestItem manifestItem;
+
+	public ManifestTestRunner(ManifestItem manifestItem,
+			Class<? extends ManifestTest> cls) throws InitializationError {
+		super(cls);
+		this.manifestItem = manifestItem;
+	}
+
+	/**
+	 * Returns the name that describes {@code method} for {@link Description}s.
+	 * Default implementation is the method's name
+	 */
+	@Override
+	protected String testName(FrameworkMethod method) {
+		return manifestItem.getTestName();
+	}
+
+	/**
+	 * Returns the methods that run tests. Default implementation returns all
+	 * methods annotated with {@code @Test} on this class and superclasses that
+	 * are not overridden.
+	 */
+	@Override
+	protected List<FrameworkMethod> computeTestMethods() {
+		FrameworkMethod[] lst = new FrameworkMethod[1];
+
+		try {
+			lst[0] = new FrameworkMethod(getTestClass().getJavaClass()
+					.getMethod("runTest")) {
+
+				@Override
+				public String getName() {
+					return manifestItem.getTestName();
+				}
+			};
+		} catch (NoSuchMethodException e) {
+			throw new IllegalStateException(e);
+		} catch (SecurityException e) {
+			throw new IllegalStateException(e);
+		}
+		return Arrays.asList(lst);
+	}
+
+	@Override
+	public Description getDescription() {
+		return Description.createTestDescription(this.getTestClass()
+				.getJavaClass(), manifestItem.getTestName(), new Annotation[0]);
+	}
+
+	/**
+	 * Returns a new fixture for running a test. Default implementation executes
+	 * the test class's no-argument constructor (validation should have ensured
+	 * one exists).
+	 */
+	@Override
+	protected Object createTest() throws Exception {
+		ManifestTest instance = (ManifestTest) super.createTest();
+		instance.setManifestItem(manifestItem);
+		return instance;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/package-info.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/package-info.java b/jena-core/src/test/java/org/apache/jena/testing_framework/package-info.java
new file mode 100644
index 0000000..96f3e42
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/package-info.java
@@ -0,0 +1,109 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+/**
+ * Foo set of classes providing support for testing.
+ * <p>
+ * Testing guidelines/suggestions.
+ * </p><p>
+ * Interface tests are built so that developers may test that implementations meet the contract
+ * set out in the interface and accompanying documentation.
+ * </p>
+ * <h4>Producers</h4>
+ * <p>
+ * The test and suites use an instance of the [INTERFACE]ProducerInterface to create an instance
+ * of the the Object being tested.   
+ * </p>
+ * <h4>Tests</h4>
+ * <p>
+ * Interface tests are noted as Abstract[INTERFACE]Test.  Implementations of [INTERFACE] should
+ * create a concrete implementation of Abstract[INTERFACE]Test with an [INTERFACE]Producer to create
+ * instances of the Object.  Passing the test indicates a compliance with the base interface 
+ * definition.
+ * </p><p>
+ * In general to implement a test requires a few lines of code as is noted in the example below
+ * where the new Foo graph implementation is being tested.</p>
+ * <pre><code>
+ * public class FooGraphTest extends AbstractGraphTest {
+ * 
+ *   // the graph producer to use while running
+ *   GraphProducerInterface graphProducer = new FooGraphTest.GraphProducer();
+ * 
+ *   @Override
+ *   protected GraphProducerInterface getGraphProducer() {
+ *     return graphProducer;
+ *   }
+ * 
+ *   // the implementation of the graph producer.
+ *   public static class GraphProducer extends AbstractGraphProducer {
+ * 
+ *     @Override
+ *     protected Graph createNewGraph() {
+ *       return new FooGraph();
+ *     }
+ *   }
+ * }
+ * </code></pre>
+ * <h4>Suites</h4>
+ * <p>
+ * Test suites are named as Abstract[INTERFACE]Suite.  Suites contain several tests (see above)
+ * that exercise all of the tests for the components of the object under test.  For example the 
+ * graph suite includes tests for the graph itself, the reifier, finding literals, recursive 
+ * subgraph extraction, event manager, and transactions.  Running the suites is a bit more 
+ * complicated then running the tests.
+ * </p>
+ * Suites are created using the JUnit 4 <code>@RunWith(Suite.class)</code and 
+ * <code>@Suite.SuiteClasses({ })</code> annotations.  This has several effects that the developer 
+ * should know about:</p>
+ * <ul>
+ * <li>The suite class does not get instantiated during the run.</li>
+ * <li>The test class names must be known at coding time (not run time) as they are listed in the
+ * annotation.</li>
+ * <li>Configuration of the tests has to occur during the static initialization phase of class 
+ * loading.</li>
+ * </ul>
+ * <p>
+ * To meet these requirements the AbstractGraphSuite has a static variable that holds the instance
+ * of the GraphProducerInterface and a number of local static implementations of the Abstract tests
+ * that implement the "getGraphProducer()" method by returning the static instance.  The names of 
+ * the local graphs are then used in the @Suite.SuiteClasses annotation.  This makes creating an
+ * instance of the AbstractGraphSuite for a graph implementation fairly simple as is noted below.
+ * </p>
+ * <pre><code>
+ * public class FooGraphSuite extends AbstractGraphSuite {
+ *   @BeforeClass
+ *   public static void beforeClass() {
+ *     setGraphProducer(new GraphProducer());
+ *   }
+ *   
+ *   public static class GraphProducer extends AbstractGraphProducer {
+ *     @Override
+ *     protected Graph createNewGraph() {
+ *       return new FooGraph();
+ *     }
+ *   }
+ * }
+ * </code></pre>
+ * <p>
+ * <b>Note:</b> that the beforeClass() method is annotated with @BeforeClass.  the @BeforeClass 
+ * causes it to be run once before any of the test methods in the class. This will set the static
+ * instance of the graph producer before the suite is run so that it is provided to the enclosed
+ * tests.
+ * </p> 
+ */

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleItem.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleItem.java b/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleItem.java
new file mode 100644
index 0000000..65aff5b
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleItem.java
@@ -0,0 +1,84 @@
+/*
+ * 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 org.apache.jena.testing_framework.tuples;
+
+/**
+ * The unit found in a line of a tuple. Can be a string (quoted, possibly with
+ * the datatype, or unquoted) or a URI.
+ */
+public class TupleItem {
+	public static final int URI = 0;
+	public static final int STRING = 1;
+	public static final int UNKNOWN = 2;
+	public static final int UNQUOTED = 3;
+	public static final int ANON = 4;
+
+	String rep;
+	String datatype;
+	String asFound;
+	int itemType;
+
+	TupleItem(String value, String valAsFound, int type, String dt) {
+		rep = value;
+		asFound = valAsFound;
+		itemType = type;
+		datatype = dt;
+	}
+
+	public int getType() {
+		return itemType;
+	}
+
+	public boolean isURI() {
+		return itemType == URI;
+	}
+
+	public boolean isString() {
+		return itemType == STRING;
+	}
+
+	public boolean isUnknown() {
+		return itemType == UNKNOWN;
+	}
+
+	public boolean isUnquoted() {
+		return itemType == UNQUOTED;
+	}
+
+	public boolean isAnon() {
+		return itemType == ANON;
+	}
+
+	public String get() {
+		return rep;
+	}
+
+	public String getDT() {
+		return datatype;
+	}
+
+	public String asQuotedString() {
+		return asFound;
+	}
+
+	@Override
+	public String toString() {
+		return rep;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleSet.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleSet.java b/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleSet.java
new file mode 100644
index 0000000..8e78879
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleSet.java
@@ -0,0 +1,274 @@
+/*
+ * 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 org.apache.jena.testing_framework.tuples;
+
+import java.io.*;
+import java.util.*;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TupleSet implements Iterator<List<TupleItem>> {
+	BufferedReader in;
+	public String line = null;
+	public int lineNumber = 0;
+
+	static final char COMMENTCHAR = '#';
+	List<TupleItem> current = null;
+	boolean finished = false;
+
+	protected static Logger logger = LoggerFactory.getLogger(TupleSet.class);
+
+	/** Creates new TupleSet */
+	public TupleSet(Reader r) {
+		if (!(r instanceof BufferedReader))
+			in = new BufferedReader(r);
+		else
+			in = (BufferedReader) r;
+	}
+
+	@Override
+	public boolean hasNext() {
+		if (finished)
+			return false;
+
+		if (current == null)
+			current = tuple();
+		return current != null;
+	}
+
+	@Override
+	public List<TupleItem> next() {
+		if (hasNext()) {
+			List<TupleItem> x = current;
+			current = null;
+			return x;
+		} else
+			return null;
+	}
+
+	@Override
+	public void remove() {
+		throw new java.lang.UnsupportedOperationException("TupleSet.remove");
+	}
+
+	private List<TupleItem> tuple() {
+
+		try {
+			lineNumber++;
+			line = in.readLine();
+		} catch (IOException e) {
+		}
+
+		if (line == null) {
+			finished = true;
+			return null;
+		}
+
+		// System.out.println("Line: "+line) ;
+		List<TupleItem> tuple = new ArrayList<TupleItem>();
+		int i = 0;
+		int j = 0;
+		boolean errorFound = false;
+
+		tupleLoop: for (;;) {
+			// Move to beginning of next item.
+			i = skipwhitespace(line, j);
+
+			if (i < 0)
+				break;
+
+			int iStart = -2; // Points to the beginning of the item as found
+			int jStart = -2; // Points to the item without quotes
+			int iFinish = -2; // Points after the end of the item as found
+			int jFinish = -2; // Points after the end of the item without quotes
+			int dtStart = -2; // Points to start of datatype (after < quote)
+			int dtFinish = -2; // Points to end of datatype
+			int type = TupleItem.UNKNOWN;
+
+			switch (line.charAt(i)) {
+			case COMMENTCHAR:
+				break tupleLoop;
+			case '<':
+				type = TupleItem.URI;
+				iStart = i;
+				jStart = i + 1;
+				int newPosn = parseURI(i, line);
+				if (newPosn < 0) {
+					errorFound = true;
+					break tupleLoop;
+				}
+				j = newPosn;
+
+				iFinish = j + 1;
+				jFinish = j;
+				break;
+			case '"':
+				type = TupleItem.STRING;
+				iStart = i;
+				jStart = i + 1;
+				boolean inEscape = false;
+				for (j = i + 1; j < line.length(); j++) {
+					char ch = line.charAt(j);
+					if (inEscape) {
+						// ToDo: escape
+						inEscape = false;
+						continue;
+					}
+					// Not an escape
+					if (ch == '"')
+						break;
+
+					if (ch == '\\')
+						inEscape = true;
+					if (ch == '\n' || ch == '\r') {
+						errorFound = true;
+						break tupleLoop;
+
+					}
+				}
+
+				// Malformed
+				if (j == line.length()) {
+					errorFound = true;
+					break tupleLoop;
+				}
+
+				iFinish = j + 1;
+				jFinish = j;
+				// RDF literals may be followed by their type.
+
+				if (j < line.length() - 3 && line.charAt(j + 1) == '^'
+						&& line.charAt(j + 2) == '^'
+						&& line.charAt(j + 3) == '<') {
+					dtFinish = parseURI(j + 3, line);
+					dtStart = j + 4;
+					if (dtFinish < 0) {
+						errorFound = true;
+						break tupleLoop;
+					}
+					j = dtFinish + 1;
+					// String dt = line.substring(dtStart, dtFinish) ;
+					// System.out.println("I see a datatype:"+dt) ;
+				}
+
+				break;
+			case '_':
+				type = TupleItem.ANON;
+				iStart = i;
+				for (j = i + 1; j < line.length(); j++) {
+					char ch = line.charAt(j);
+					if (ch == ' ' || ch == '\t' || ch == '.')
+						break;
+					if (!Character.isLetterOrDigit(ch) && !(ch == '_')
+							&& !(ch == ':')) {
+						errorFound = true;
+						break tupleLoop;
+					}
+				}
+				iFinish = j;
+				jStart = iStart;
+				jFinish = iFinish;
+				break;
+			case '.':
+			case '\n':
+			case '\r':
+				return tuple;
+			default:
+				type = TupleItem.UNQUOTED;
+				iStart = i;
+				jStart = i;
+				for (j = i + 1; j < line.length(); j++) {
+					char ch = line.charAt(j);
+					if (ch == ' ' || ch == '\t' || ch == '.')
+						break;
+
+					// if ( ! Character.isLetterOrDigit(line.charAt(i)) )
+					// {
+					// errorFound = true ;
+					// break tupleLoop;
+					// }
+				}
+				// Malformed
+				if (j == line.length() + 1) {
+					errorFound = true;
+					break tupleLoop;
+				}
+				iFinish = j;
+				jFinish = j;
+				break;
+			}
+			String item = line.substring(jStart, jFinish);
+			String literal = line.substring(iStart, iFinish);
+			String dt = null;
+			if (dtStart > 0)
+				dt = line.substring(dtStart, dtFinish);
+
+			tuple.add(new TupleItem(item, literal, type, dt));
+			j++;
+			// End of item.
+		}
+		// End of this line.
+		if (errorFound) {
+			logger.error("Error in TupleSet.tuple: " + line);
+
+			String s = "";
+			int k = 0;
+			for (; k < i; k++)
+				s = s + " ";
+			s = s + "^";
+			for (; k < j - 1; k++)
+				s = s + " ";
+			s = s + "^";
+			logger.error(s);
+			return null;
+		}
+
+		if (tuple.size() == 0) {
+			// Nothing found : loop by tail recursion
+			return tuple();
+		}
+		return tuple;
+	}
+
+	private int skipwhitespace(String s, int i) {
+		for (; i < s.length(); i++) {
+			char ch = s.charAt(i);
+			// Horizonal whitespace
+			if (ch != ' ' && ch != '\t')
+				return i;
+		}
+		return -1;
+	}
+
+	private int parseURI(int i, String line) {
+		int j;
+		for (j = i + 1; j < line.length(); j++) {
+			char ch = line.charAt(j);
+			if (ch == '>')
+				break;
+			if (ch == '\n' || ch == '\r')
+				return -1;
+		}
+		// Malformed
+		if (j == line.length())
+			return -2;
+		return j;
+	}
+}


[21/25] jena git commit: Merge branch 'master' into add-contract-tests

Posted by cl...@apache.org.
Merge branch 'master' into add-contract-tests


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/be72f497
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/be72f497
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/be72f497

Branch: refs/heads/master
Commit: be72f4971fecb0f4e6c827a3f052b767fd24439f
Parents: dcab5a0 8d5f1cb
Author: Claude Warren <cl...@apache.org>
Authored: Tue May 19 17:20:23 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Tue May 19 17:20:23 2015 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/jena/query/Query.java  |  17 ++++
 .../apache/jena/riot/out/NodeFormatterBase.java |   2 +-
 .../apache/jena/riot/thrift/ThriftConvert.java  |   8 ++
 .../apache/jena/sparql/core/VarExprList.java    |  12 ++-
 .../apache/jena/riot/thrift/TS_RDFThrift.java   |   1 -
 .../apache/jena/riot/thrift/TestThriftTerm.java |  48 ++++++++-
 .../arq/querybuilder/AbstractQueryBuilder.java  |  28 ++++--
 .../jena/arq/querybuilder/AskBuilder.java       |  12 +++
 .../jena/arq/querybuilder/ConstructBuilder.java |  31 +++---
 .../jena/arq/querybuilder/SelectBuilder.java    |  31 +++++-
 .../arq/querybuilder/clauses/SelectClause.java  |  33 ++++++
 .../arq/querybuilder/clauses/WhereClause.java   |  20 ++++
 .../querybuilder/handlers/DatasetHandler.java   |  41 +++-----
 .../jena/arq/querybuilder/handlers/Handler.java |   1 +
 .../querybuilder/handlers/SelectHandler.java    |  48 ++++++---
 .../handlers/SolutionModifierHandler.java       |  12 +--
 .../arq/querybuilder/handlers/WhereHandler.java |  37 +++++--
 .../jena/arq/AbstractRegexpBasedTest.java       |   1 +
 .../querybuilder/clauses/SelectClauseTest.java  |  29 ++++++
 .../querybuilder/clauses/WhereClauseTest.java   | 100 ++++++++++++++-----
 .../handlers/SelectHandlerTest.java             |  25 +++++
 .../querybuilder/handlers/WhereHandlerTest.java |  22 ++++
 22 files changed, 437 insertions(+), 122 deletions(-)
----------------------------------------------------------------------



[04/25] jena git commit: Added initial contract tests added testing_framework

Posted by cl...@apache.org.
Added initial contract tests
added testing_framework


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/4d1b0d96
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/4d1b0d96
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/4d1b0d96

Branch: refs/heads/master
Commit: 4d1b0d96df6339bcb7fdab3f42453b5814c4c2a2
Parents: c32457d
Author: Claude Warren <cl...@apache.org>
Authored: Sun Apr 26 20:41:15 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sun Apr 26 20:41:15 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml                               |  396 ++--
 .../apache/jena/graph/GraphContractTest.java    | 1720 ++++++++++++++++++
 .../graph/GraphEventManagerContractTest.java    |  514 ++++++
 .../jena/graph/GraphMakerContractTest.java      |  314 ++++
 .../graph/GraphWithPerformContractTest.java     |   86 +
 .../jena/graph/RecordingGraphListener.java      |   92 +
 .../graph/TransactionHandlerContractTest.java   |  149 ++
 .../apache/jena/graph/compose/DeltaTest.java    |  110 ++
 .../jena/graph/compose/DifferenceTest.java      |   97 +
 .../jena/graph/compose/IntersectionTest.java    |  109 ++
 .../apache/jena/graph/compose/UnionTest.java    |  185 ++
 .../jena/graph/impl/TestCollectionGraph.java    |   42 +-
 .../jena/graph/impl/TestWrappedGraph.java       |   63 +
 .../graph/impl/TripleStoreContractTest.java     |  176 ++
 .../apache/jena/mem/BunchMapContractTest.java   |  163 ++
 .../java/org/apache/jena/mem/GraphMemTest.java  |  115 ++
 .../apache/jena/mem/GraphTripleStoreTest.java   |   51 +
 .../jena/mem/TripleBunchContractTest.java       |  205 +++
 .../AbstractGraphProducer.java                  |  104 ++
 .../AbstractInfModelProducer.java               |   91 +
 .../AbstractModelProducer.java                  |   88 +
 .../AbstractRecordingListener.java              |  190 ++
 .../testing_framework/ContractTemplate.java     |   17 +
 .../GraphEventManagerProducerInterface.java     |   35 +
 .../jena/testing_framework/GraphHelper.java     |  508 ++++++
 .../GraphProducerInterface.java                 |   41 +
 .../testing_framework/IContainerProducer.java   |   19 +
 .../testing_framework/IIteratorProducer.java    |   42 +
 .../jena/testing_framework/INodeProducer.java   |   39 +
 .../testing_framework/IResourceProducer.java    |   10 +
 .../testing_framework/IStatementProducer.java   |   45 +
 .../testing_framework/ITripleStoreProducer.java |   35 +
 .../jena/testing_framework/ModelHelper.java     |  409 +++++
 .../jena/testing_framework/NodeCreateUtils.java |  177 ++
 .../NodeProducerInterface.java                  |   32 +
 .../jena/testing_framework/TestFileData.java    |  380 ++++
 .../jena/testing_framework/TestUtils.java       |  320 ++++
 .../testing_framework/manifest/Manifest.java    |  228 +++
 .../manifest/ManifestException.java             |   48 +
 .../manifest/ManifestFile.java                  |   38 +
 .../manifest/ManifestItem.java                  |   53 +
 .../manifest/ManifestItemHandler.java           |   35 +
 .../manifest/ManifestSuite.java                 |  143 ++
 .../manifest/ManifestTest.java                  |   13 +
 .../manifest/ManifestTestRunner.java            |   75 +
 .../jena/testing_framework/package-info.java    |  109 ++
 .../testing_framework/tuples/TupleItem.java     |   84 +
 .../jena/testing_framework/tuples/TupleSet.java |  274 +++
 48 files changed, 8062 insertions(+), 207 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index 9deb931..1c2ff5a 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -1,203 +1,199 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--
-   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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>jena-core</artifactId>
-  <packaging>jar</packaging>
-  <name>Apache Jena - Core</name>
-  <version>3.0.0-SNAPSHOT</version>
-
-  <parent>
-    <groupId>org.apache.jena</groupId>
-    <artifactId>jena-parent</artifactId>
-    <version>14-SNAPSHOT</version>
-    <relativePath>../jena-parent</relativePath>
-  </parent>
-
-  <description>Jena is a Java framework for building Semantic Web applications. It provides a programmatic environment for RDF, RDFS and OWL, SPARQL and includes a rule-based inference engine.</description>
-
-  <properties>
-    <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
-    <build.time.xsd>${maven.build.timestamp}</build.time.xsd>
-  </properties>
-
-  <dependencies>
-
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-
-    <dependency>
-       <groupId>org.apache.jena</groupId>
-       <artifactId>jena-iri</artifactId>
-       <version>3.0.0-SNAPSHOT</version>
-    </dependency>
-
-    <dependency>
-      <groupId>xerces</groupId>
-      <artifactId>xercesImpl</artifactId>
-    </dependency>
-
-  </dependencies>
-
-  <build>
-  
-    <resources>
-
-      <!-- Legacy -->
-      <resource>
-	<directory>etc</directory>
-        <targetPath>etc</targetPath>
-        <filtering>false</filtering>
-      </resource>
-
-      <resource>
-        <filtering>false</filtering>
-        <directory>src/main/resources</directory>
-      </resource>
-
-      <resource>
-        <directory>src/main/resources</directory>
-        <includes>
-          <include>org/apache/jena/jena-properties.xml</include>
-        </includes>
-        <filtering>true</filtering>
-      </resource>
-
-    </resources>
-  
-    <plugins>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <systemProperties>
-            <property>
-              <name>log4j.configuration</name>
-              <value>jena-test-log4j.properties</value>
-            </property>
-          </systemProperties>
-          <includes>
-            <include>com/hp/hpl/jena/test/TestPackage.java</include>
-          </includes>
-        </configuration>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-source-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>attach-sources</id>
-            <phase>package</phase>
-            <goals>
-	      <goal>jar-no-fork</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>attach-sources-test</id>
-            <phase>package</phase>
-            <goals>
-              <goal>test-jar-no-fork</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <configuration>
-          <author>true</author>
-          <version>true</version>
-          <show>public</show>
-          <quiet>true</quiet>
-          <encoding>UTF-8</encoding>
-          <windowtitle>Apache Jena</windowtitle>
-          <doctitle>Apache Jena Core ${project.version}</doctitle>
-          <bottom>Licenced under the Apache License, Version 2.0</bottom>
-          <excludePackageNames>com.hp.hpl.jena.shared.*:*.impl:com.hp.hpl.jena.assembler.assemblers:*.exceptions:*.regexptrees:com.hp.hpl.jena.mem:com.hp.hpl.jena.mem.*:com.hp.hpl.jena.n3:com.hp.hpl.jena.n3.*:com.hp.hpl.jena.rdf.arp.*:com.hp.hpl.jena.util.*:jena.cmdline:jena.util</excludePackageNames>
-          <groups>
-            <group>
-              <title>API - Application Programming Interface</title>
-              <packages>com.hp.hpl.jena.db:com.hp.hpl.jena.rdf.model:com.hp.hpl.jena.rdf.listeners:com.hp.hpl.jena.rdf.arp:com.hp.hpl.jena.rdf.arp.lang:com.hp.hpl.jena.datatypes:com.hp.hpl.jena.datatypes.xsd:com.hp.hpl.jena.rdql:com.hp.hpl.jena.shared:com.hp.hpl.jena.vocabulary:com.hp.hpl.jena.xmloutput:com.hp.hpl.jena.ontology:com.hp.hpl.jena.ontology.daml:com.hp.hpl.jena.reasoner:com.hp.hpl.jena.reasoner.rulesys:com.hp.hpl.jena.reasoner.rulesys.builtins:com.hp.hpl.jena.reasoner.transitiveReasoner:com.hp.hpl.jena.reasoner.dig</packages>
-            </group>
-            <group>
-              <title>SPI - System Programming Interface</title>
-              <packages>com.hp.hpl.jena.enhanced:com.hp.hpl.jena.graph:com.hp.hpl.jena.graph.compose:com.hp.hpl.jena.graph.query:com.hp.hpl.jena.util:com.hp.hpl.jena.util.iterator</packages>
-            </group>
-            <group>
-              <title>Command line tools</title>
-              <packages>jena</packages>
-            </group>
-            <group>
-              <title>Other Packages</title>
-              <packages>com.hp.hpl.jena.assembler</packages>
-            </group>
-          </groups>
-        </configuration>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>test-jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-
-      <!--
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-resources-plugin</artifactId>
-      </plugin>
-      <!- - see: http://maven.apache.org/guides/mini/guide-attached-tests.html - ->
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>test-jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-      -->
-    </plugins>
-  </build>
+<!-- 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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>jena-core</artifactId>
+	<packaging>jar</packaging>
+	<name>Apache Jena - Core</name>
+	<version>3.0.0-SNAPSHOT</version>
+
+	<parent>
+		<groupId>org.apache.jena</groupId>
+		<artifactId>jena-parent</artifactId>
+		<version>14-SNAPSHOT</version>
+		<relativePath>../jena-parent</relativePath>
+	</parent>
+
+	<description>Jena is a Java framework for building Semantic Web applications. It provides a programmatic environment for RDF, RDFS and OWL, SPARQL and includes a rule-based inference engine.</description>
+
+	<properties>
+		<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
+		<build.time.xsd>${maven.build.timestamp}</build.time.xsd>
+	</properties>
+
+	<dependencies>
+
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.jena</groupId>
+			<artifactId>jena-iri</artifactId>
+			<version>3.0.0-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>xerces</groupId>
+			<artifactId>xercesImpl</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.xenei</groupId>
+			<artifactId>junit-contracts</artifactId>
+			<version>0.0.5</version>
+			<scope>test</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-all</artifactId>
+			<version>1.9.5</version>
+			<scope>test</scope>
+		</dependency>
+
+	</dependencies>
+
+	<build>
+
+		<resources>
+
+			<!-- Legacy -->
+			<resource>
+				<directory>etc</directory>
+				<targetPath>etc</targetPath>
+				<filtering>false</filtering>
+			</resource>
+
+			<resource>
+				<filtering>false</filtering>
+				<directory>src/main/resources</directory>
+			</resource>
+
+			<resource>
+				<directory>src/main/resources</directory>
+				<includes>
+					<include>org/apache/jena/jena-properties.xml</include>
+				</includes>
+				<filtering>true</filtering>
+			</resource>
+
+		</resources>
+
+		<plugins>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<systemProperties>
+						<property>
+							<name>log4j.configuration</name>
+							<value>jena-test-log4j.properties</value>
+						</property>
+					</systemProperties>
+					<includes>
+						<include>com/hp/hpl/jena/test/TestPackage.java</include>
+					</includes>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-source-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>attach-sources</id>
+						<phase>package</phase>
+						<goals>
+							<goal>jar-no-fork</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>attach-sources-test</id>
+						<phase>package</phase>
+						<goals>
+							<goal>test-jar-no-fork</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-javadoc-plugin</artifactId>
+				<configuration>
+					<author>true</author>
+					<version>true</version>
+					<show>public</show>
+					<quiet>true</quiet>
+					<encoding>UTF-8</encoding>
+					<windowtitle>Apache Jena</windowtitle>
+					<doctitle>Apache Jena Core ${project.version}</doctitle>
+					<bottom>Licenced under the Apache License, Version 2.0</bottom>
+					<excludePackageNames>com.hp.hpl.jena.shared.*:*.impl:com.hp.hpl.jena.assembler.assemblers:*.exceptions:*.regexptrees:com.hp.hpl.jena.mem:com.hp.hpl.jena.mem.*:com.hp.hpl.jena.n3:com.hp.hpl.jena.n3.*:com.hp.hpl.jena.rdf.arp.*:com.hp.hpl.jena.util.*:jena.cmdline:jena.util</excludePackageNames>
+					<groups>
+						<group>
+							<title>API - Application Programming Interface</title>
+							<packages>com.hp.hpl.jena.db:com.hp.hpl.jena.rdf.model:com.hp.hpl.jena.rdf.listeners:com.hp.hpl.jena.rdf.arp:com.hp.hpl.jena.rdf.arp.lang:com.hp.hpl.jena.datatypes:com.hp.hpl.jena.datatypes.xsd:com.hp.hpl.jena.rdql:com.hp.hpl.jena.shared:com.hp.hpl.jena.vocabulary:com.hp.hpl.jena.xmloutput:com.hp.hpl.jena.ontology:com.hp.hpl.jena.ontology.daml:com.hp.hpl.jena.reasoner:com.hp.hpl.jena.reasoner.rulesys:com.hp.hpl.jena.reasoner.rulesys.builtins:com.hp.hpl.jena.reasoner.transitiveReasoner:com.hp.hpl.jena.reasoner.dig</packages>
+						</group>
+						<group>
+							<title>SPI - System Programming Interface</title>
+							<packages>com.hp.hpl.jena.enhanced:com.hp.hpl.jena.graph:com.hp.hpl.jena.graph.compose:com.hp.hpl.jena.graph.query:com.hp.hpl.jena.util:com.hp.hpl.jena.util.iterator</packages>
+						</group>
+						<group>
+							<title>Command line tools</title>
+							<packages>jena</packages>
+						</group>
+						<group>
+							<title>Other Packages</title>
+							<packages>com.hp.hpl.jena.assembler</packages>
+						</group>
+					</groups>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<executions>
+					<execution>
+						<goals>
+							<goal>test-jar</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+
+			<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> 
+				</plugin> <!- - see: http://maven.apache.org/guides/mini/guide-attached-tests.html 
+				- -> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> 
+				<executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> 
+				</executions> </plugin> -->
+		</plugins>
+	</build>
 
 </project>

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
new file mode 100644
index 0000000..cf79da5
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -0,0 +1,1720 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import org.junit.After;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import static org.junit.Assert.*;
+
+import org.apache.jena.graph.Capabilities;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphStatisticsHandler;
+import org.apache.jena.graph.GraphUtil;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.LiteralLabelFactory;
+import org.apache.jena.mem.TrackingTripleIterator;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.impl.ReifierStd;
+import org.apache.jena.shared.ClosedException;
+import org.apache.jena.shared.DeleteDeniedException;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.apache.jena.testing_framework.ContractTemplate;
+import org.apache.jena.testing_framework.NodeCreateUtils;
+import org.apache.jena.util.iterator.ClosableIterator;
+import org.apache.jena.util.iterator.ExtendedIterator;
+import org.apache.jena.util.iterator.Map1;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+/**
+ * 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.
+ */
+@Contract(Graph.class)
+public class GraphContractTest<T extends Graph> extends
+		ContractTemplate<AbstractGraphProducer<T>> {
+
+	private static final Logger LOG = LoggerFactory
+			.getLogger(GraphContractTest.class);
+
+	protected RecordingGraphListener GL = new RecordingGraphListener();
+
+	@Contract.Inject
+	public final void setGraphContractTestProducer(
+			AbstractGraphProducer<T> graphProducer) {
+		super.setProducer(graphProducer);
+	}
+
+	@After
+	public final void afterGraphContractTest() {
+		getProducer().cleanUp();
+		GL.clear();
+	}
+
+	@ContractTest
+	public void testAdd_Triple() {
+		Graph graph = getProducer().newInstance();
+		graph.getEventManager().register(GL);
+		txnBegin(graph);
+		graph.add(triple("S P O"));
+		txnCommit(graph);
+		GL.assertHasStart("add", graph, triple("S P O"));
+		assertTrue("Graph should contain <S P O>",
+				graph.contains(triple("S P O")));
+	}
+
+	/**
+	 * Inference graphs can not be truly empty.
+	 * 
+	 * @param g
+	 * @param b
+	 */
+	private void assertEmpty(Graph g, Graph b) {
+		if (b.isEmpty()) {
+			assertTrue("Graph should be empty", g.isEmpty());
+		} else {
+			assertEquals("Graph should be in base state", b.find(Triple.ANY)
+					.toList(), g.find(Triple.ANY).toList());
+		}
+	}
+
+	/**
+	 * Inference graphs can not be truly empty
+	 * 
+	 * @param g
+	 * @param b
+	 */
+	private void assertNotEmpty(Graph g, Graph b) {
+		if (b.isEmpty()) {
+			assertFalse("Graph not should be empty", g.isEmpty());
+		} else {
+			assertNotEquals("Graph should not be in base state",
+					b.find(Triple.ANY).toList(), g.find(Triple.ANY).toList());
+		}
+	}
+
+	/**
+	 * Test that clear works, in the presence of inferencing graphs that mean
+	 * emptyness isn't available. This is why we go round the houses and test
+	 * that expected ~= initialContent + addedStuff - removed - initialContent.
+	 */
+	@ContractTest
+	public void testClear() {
+		Graph graph = getProducer().newInstance();
+		Graph base = copy(graph);
+
+		graph.getEventManager().register(GL);
+		txnBegin(graph);
+		graph.clear();
+		txnCommit(graph);
+		assertEmpty(graph, base);
+		GL.assertHasStart("someEvent", graph, GraphEvents.removeAll);
+		GL.clear();
+
+		// test after adding
+		graph = graphWith(getProducer().newInstance(),
+				"S P O; S e:ff 27; _1 P P3; S4 P4 'en'");
+		graph.getEventManager().register(GL);
+		txnBegin(graph);
+		graph.clear();
+		txnCommit(graph);
+		assertEmpty(graph, base);
+		if (GL.contains("delete")) {
+			// deletes are listed -- ensure all deletes are listed
+			GL.assertContains("delete", graph, triple("S P O"));
+			GL.assertContains("delete", graph, triple("S e:ff 27"));
+			GL.assertContains("delete", graph, triple("_1 P P3"));
+			GL.assertContains("delete", graph, triple("S4 P4 'en'"));
+		}
+		GL.assertHasEnd("someEvent", graph, GraphEvents.removeAll);
+		GL.clear();
+
+	}
+
+	@ContractTest
+	public void testClose() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S P2 O2; S3 P P3");
+		graph.getEventManager().register(GL);
+		assertFalse("Graph was constructed closed", graph.isClosed());
+
+		graph.close();
+		assertTrue("Graph should be closed", graph.isClosed());
+
+		// exception may be thrown on begin or on execution.
+		try {
+			txnBegin(graph);
+			try {
+				graph.add(triple("S P O"));
+				fail("added when closed");
+			} catch (Exception expected) {
+				GL.assertEmpty();
+				// expected
+			} finally {
+				txnRollback(graph);
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.delete(triple("x R y"));
+				fail("delete when closed");
+			} catch (ClosedException c) {
+				// Expected
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+
+			try {
+				graph.add(triple("x R y"));
+				fail("add when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.contains(triple("x R y"));
+				fail("contains[triple] when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.contains(Node.ANY, Node.ANY, Node.ANY);
+				fail("contains[SPO] when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.find(triple("x R y"));
+				fail("find [triple] when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.find(Node.ANY, Node.ANY, Node.ANY);
+				fail("find[SPO] when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.size();
+				fail("size when closed (" + this.getClass() + ")");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+
+		assertTrue(graph.contains(node("S"), node("P"), node("O")));
+		assertFalse(graph.contains(node("S"), node("P"), node("O2")));
+		assertFalse(graph.contains(node("S"), node("P2"), node("O")));
+		assertFalse(graph.contains(node("S2"), node("P"), node("O")));
+		assertTrue(graph.contains(Node.ANY, Node.ANY, Node.ANY));
+		assertTrue(graph.contains(Node.ANY, Node.ANY, node("O")));
+		assertTrue(graph.contains(Node.ANY, node("P"), Node.ANY));
+		assertTrue(graph.contains(node("S"), Node.ANY, Node.ANY));
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node_RepeatedSubjectDoesNotConceal() {
+
+		Graph g = graphWith(getProducer().newInstance(), "s P o; s Q r");
+		Node s = node("s");
+		Node P = node("P");
+		Node o = node("o");
+		Node Q = node("Q");
+		Node r = node("r");
+		Node any = node("??");
+		assertTrue(g.contains(s, P, o));
+		assertTrue(g.contains(s, Q, r));
+		assertTrue(g.contains(any, P, o));
+		assertTrue(g.contains(any, Q, r));
+		assertTrue(g.contains(any, P, any));
+		assertTrue(g.contains(any, Q, any));
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node_ByValue() {
+		Node x = node("x");
+		Node P = node("P");
+		if (getProducer().newInstance().getCapabilities()
+				.handlesLiteralTyping()) {
+			Graph g1 = graphWith(getProducer().newInstance(),
+					"x P '1'xsd:integer");
+			assertTrue(
+					String.format(
+							"literal type equality failed, does %s really implement literal typing",
+							g1.getClass()), g1.contains(x, P,
+							node("'01'xsd:int")));
+			//
+			Graph g2 = graphWith(getProducer().newInstance(), "x P '1'xsd:int");
+			assertTrue("Literal equality with '1'xsd:integer failed",
+					g2.contains(x, P, node("'1'xsd:integer")));
+			//
+			Graph g3 = graphWith(getProducer().newInstance(),
+					"x P '123'xsd:string");
+			assertTrue("Literal equality with '123' failed",
+					g3.contains(x, P, node("'123'")));
+		}
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node_Concrete() {
+		Node s = node("s");
+		Node P = node("P");
+		Node o = node("o");
+
+		Node _x = node("_x");
+		Node _R = node("_R");
+		Node _y = node("_y");
+
+		Node x = node("x");
+		Node S = node("S");
+
+		Graph g = graphWith(getProducer().newInstance(),
+				"s P o; _x _R _y; x S 0");
+		assertTrue("Graph should have contained s P o", g.contains(s, P, o));
+		assertTrue("Graph should have contained _x _R _y",
+				g.contains(_x, _R, _y));
+		assertTrue("Graph should have contained x S 'O'",
+				g.contains(x, S, node("0")));
+		/* */
+		assertFalse(g.contains(s, P, node("Oh")));
+		assertFalse(g.contains(S, P, node("O")));
+		assertFalse(g.contains(s, node("p"), o));
+		assertFalse(g.contains(_x, node("_r"), _y));
+		assertFalse(g.contains(x, S, node("1")));
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node_Fluid() {
+		Node x = node("x");
+		Node R = node("R");
+		Node P = node("P");
+		Node y = node("y");
+		Node a = node("a");
+		Node b = node("b");
+		Graph g = graphWith(getProducer().newInstance(), "x R y; a P b");
+		assertTrue(g.contains(Node.ANY, R, y));
+		assertTrue(g.contains(x, Node.ANY, y));
+		assertTrue(g.contains(x, R, Node.ANY));
+		assertTrue(g.contains(Node.ANY, P, b));
+		assertTrue(g.contains(a, Node.ANY, b));
+		assertTrue(g.contains(a, P, Node.ANY));
+		assertTrue(g.contains(Node.ANY, R, y));
+		/* */
+		assertFalse(g.contains(Node.ANY, R, b));
+		assertFalse(g.contains(a, Node.ANY, y));
+		assertFalse(g.contains(x, P, Node.ANY));
+		assertFalse(g.contains(Node.ANY, R, x));
+		assertFalse(g.contains(x, Node.ANY, R));
+		assertFalse(g.contains(a, node("S"), Node.ANY));
+	}
+
+	@ContractTest
+	public void testContains_Triple() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+
+		assertTrue(graph.contains(triple("S P O")));
+		assertFalse(graph.contains(triple("S P O2")));
+		assertFalse(graph.contains(triple("S P2 O")));
+		assertFalse(graph.contains(triple("S2 P O")));
+		assertTrue(graph.contains(Triple.ANY));
+		assertTrue(graph.contains(new Triple(Node.ANY, Node.ANY, node("O"))));
+		assertTrue(graph.contains(new Triple(Node.ANY, node("P"), Node.ANY)));
+		assertTrue(graph.contains(new Triple(node("S"), Node.ANY, Node.ANY)));
+
+	}
+
+	@ContractTest
+	public void testContains_Triple_RepeatedSubjectDoesNotConceal() {
+
+		Graph g = graphWith(getProducer().newInstance(), "s P o; s Q r");
+		assertTrue(g.contains(triple("s P o")));
+		assertTrue(g.contains(triple("s Q r")));
+		assertTrue(g.contains(triple("?? P o")));
+		assertTrue(g.contains(triple("?? Q r")));
+		assertTrue(g.contains(triple("?? P ??")));
+		assertTrue(g.contains(triple("?? Q ??")));
+	}
+
+	@ContractTest
+	public void testContains_Triple_ByValue() {
+
+		if (getProducer().newInstance().getCapabilities()
+				.handlesLiteralTyping()) {
+			Graph g1 = graphWith(getProducer().newInstance(),
+					"x P '1'xsd:integer");
+			assertTrue(
+					String.format(
+							"did not find x P '01'xsd:int, does %s really implement literal typing",
+							g1.getClass()),
+					g1.contains(triple("x P '01'xsd:int")));
+			//
+			Graph g2 = graphWith(getProducer().newInstance(), "x P '1'xsd:int");
+			assertTrue("did not find x P '1'xsd:integer",
+					g2.contains(triple("x P '1'xsd:integer")));
+			//
+			Graph g3 = graphWith(getProducer().newInstance(),
+					"x P '123'xsd:string");
+			assertTrue("did not find x P '123'xsd:string",
+					g3.contains(triple("x P '123'")));
+		}
+	}
+
+	@ContractTest
+	public void testContains_Triple_Concrete() {
+		Graph g = graphWith(getProducer().newInstance(),
+				"s P o; _x _R _y; x S 0");
+		assertTrue(g.contains(triple("s P o")));
+		assertTrue(g.contains(triple("_x _R _y")));
+		assertTrue(g.contains(triple("x S 0")));
+		/* */
+		assertFalse(g.contains(triple("s P Oh")));
+		assertFalse(g.contains(triple("S P O")));
+		assertFalse(g.contains(triple("s p o")));
+		assertFalse(g.contains(triple("_x _r _y")));
+		assertFalse(g.contains(triple("x S 1")));
+	}
+
+	@ContractTest
+	public void testContains_Triple_Fluid() {
+		Graph g = graphWith(getProducer().newInstance(), "x R y; a P b");
+		assertTrue(g.contains(triple("?? R y")));
+		assertTrue(g.contains(triple("x ?? y")));
+		assertTrue(g.contains(triple("x R ??")));
+		assertTrue(g.contains(triple("?? P b")));
+		assertTrue(g.contains(triple("a ?? b")));
+		assertTrue(g.contains(triple("a P ??")));
+		assertTrue(g.contains(triple("?? R y")));
+		/* */
+		assertFalse(g.contains(triple("?? R b")));
+		assertFalse(g.contains(triple("a ?? y")));
+		assertFalse(g.contains(triple("x P ??")));
+		assertFalse(g.contains(triple("?? R x")));
+		assertFalse(g.contains(triple("x ?? R")));
+		assertFalse(g.contains(triple("a S ??")));
+	}
+
+	/**
+	 * Inference graphs can not be empty
+	 */
+	@ContractTest
+	public void testDelete_Triple() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+		Graph base = getProducer().newInstance();
+		graph.getEventManager().register(GL);
+		txnBegin(graph);
+		graph.delete(triple("S P O"));
+		txnCommit(graph);
+		GL.assertContains("delete", graph, triple("S P O"));
+		assertFalse("Graph should not contain <S P O>",
+				graph.contains(triple("S P O")));
+		assertNotEmpty(graph, base);
+		assertTrue("Graph should contain <S2 P2 O2>",
+				graph.contains(triple("S2 P2 O2")));
+		assertTrue("Graph should contain <S3 P3 O3>",
+				graph.contains(triple("S3 P3 O3")));
+
+		// should not modify anything on wildcard delete
+		GL.clear();
+		try {
+			txnBegin(graph);
+			graph.delete(new Triple(node("S2"), node("P2"), Node.ANY));
+			txnCommit(graph);
+		} catch (DeleteDeniedException expected) {
+			txnRollback(graph);
+		}
+		assertTrue("Graph should contain <S2 P2 O2>",
+				graph.contains(triple("S2 P2 O2")));
+		assertTrue("Graph should contain <S3 P3 O3>",
+				graph.contains(triple("S3 P3 O3")));
+		GL.assertHas("delete", graph, new Triple(node("S2"), node("P2"),
+				Node.ANY));
+	}
+
+	@ContractTest
+	public void testDelete_Triple_FromNothing() {
+		Graph g = getProducer().newInstance();
+		g.getEventManager().register(GL);
+		txnBegin(g);
+		g.delete(triple("quint rdf:subject S"));
+		txnCommit(g);
+		GL.assertContains("delete", g, triple("quint rdf:subject S"));
+	}
+
+	@ContractTest
+	public void testDependsOn() {
+		Graph g = getProducer().newInstance();
+		Graph[] depGraphs = getProducer().getDependsOn(g);
+		if (depGraphs != null) {
+			for (Graph dg : depGraphs) {
+				assertTrue(
+						String.format("Graph %s should depend upon %s", g, dg),
+						g.dependsOn(dg));
+			}
+		}
+		depGraphs = getProducer().getNotDependsOn(g);
+		if (depGraphs != null) {
+			for (Graph dg : depGraphs) {
+				assertFalse(String.format("Graph %s should not depend upon %s",
+						g, dg), g.dependsOn(dg));
+			}
+		}
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+		List<Triple> s = graph.find(Node.ANY, Node.ANY, Node.ANY).toList();
+		assertEquals(3, s.size());
+		List<Triple> expected = Arrays.asList(new Triple[] { triple("S P O"),
+				triple("S2 P2 O2"), triple("S3 P3 O3") });
+		assertTrue("Missing some values",
+				expected.containsAll(s) && s.containsAll(expected));
+
+		s = graph.find(node("S"), Node.ANY, Node.ANY).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(Node.ANY, node("P"), Node.ANY).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(Node.ANY, Node.ANY, node("O")).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(node("S2"), node("P2"), node("O2")).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S2 P2 O2")));
+
+		s = graph.find(node("S2"), node("P3"), node("O2")).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(Node.ANY, node("P3"), node("O2")).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(node("S3"), Node.ANY, node("O2")).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(node("S3"), node("P2"), Node.ANY).toList();
+		assertEquals(0, s.size());
+
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node_ByFluidTriple() {
+		Node x = node("x");
+		Node y = node("y");
+		Node z = node("z");
+		Graph g = graphWith(getProducer().newInstance(), "x y z ");
+		Set<Triple> expect = tripleSet("x y z");
+		assertEquals(expect, g.find(Node.ANY, y, z).toSet());
+		assertEquals(expect, g.find(x, Node.ANY, z).toSet());
+		assertEquals(expect, g.find(x, y, Node.ANY).toSet());
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node_ProgrammaticValues() {
+		Graph g = getProducer().newInstance();
+		if (g.getCapabilities().handlesLiteralTyping()) {
+			Node ab = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Byte((byte) 42)));
+			Node as = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Short((short) 42)));
+			Node ai = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Integer(42)));
+			Node al = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Long(42)));
+
+			Node SB = NodeCreateUtils.create("SB");
+			Node SS = NodeCreateUtils.create("SS");
+			Node SI = NodeCreateUtils.create("SI");
+			Node SL = NodeCreateUtils.create("SL");
+			Node P = NodeCreateUtils.create("P");
+
+			txnBegin(g);
+			try {
+				g.add(Triple.create(SB, P, ab));
+				g.add(Triple.create(SS, P, as));
+				g.add(Triple.create(SI, P, ai));
+				g.add(Triple.create(SL, P, al));
+			} catch (Exception e) {
+				txnRollback(g);
+				fail(e.getMessage());
+			}
+			txnCommit(g);
+			assertEquals(
+					String.format(
+							"Should have found 4 elements, does %s really implement literal typing",
+							g.getClass()),
+					4,
+					iteratorToSet(
+							g.find(Node.ANY, P, NodeCreateUtils.create("42")))
+							.size());
+		}
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node_MatchLanguagedLiteralCaseInsensitive() {
+		Graph m = graphWith(getProducer().newInstance(), "a p 'chat'en");
+		if (m.getCapabilities().handlesLiteralTyping()) {
+			Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+			assertDiffer(chaten, chatEN);
+			assertTrue(chaten.sameValueAs(chatEN));
+			assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+			assertEquals(1, m.find(Node.ANY, Node.ANY, chaten).toList().size());
+			assertEquals(1, m.find(Node.ANY, Node.ANY, chatEN).toList().size());
+		}
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node_NoMatchAgainstUnlanguagesLiteral() {
+		Graph m = graphWith(getProducer().newInstance(),
+				"a p 'chat'en; a p 'chat'");
+		if (m.getCapabilities().handlesLiteralTyping()) {
+			Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+			assertDiffer(chaten, chatEN);
+			assertTrue(chaten.sameValueAs(chatEN));
+			assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+			assertEquals(1, m.find(Node.ANY, Node.ANY, chaten).toList().size());
+			assertEquals(1, m.find(Node.ANY, Node.ANY, chatEN).toList().size());
+		}
+	}
+
+	@ContractTest
+	public void testFind_Triple() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+		List<Triple> s = graph.find(Triple.ANY).toList();
+		assertEquals(3, s.size());
+		List<Triple> expected = Arrays.asList(new Triple[] { triple("S P O"),
+				triple("S2 P2 O2"), triple("S3 P3 O3") });
+		assertTrue("Missing some values", expected.containsAll(s));
+
+		s = graph.find(new Triple(node("S"), Node.ANY, Node.ANY)).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(new Triple(Node.ANY, node("P"), Node.ANY)).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(new Triple(Node.ANY, Node.ANY, node("O"))).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(new Triple(node("S2"), node("P2"), node("O2"))).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S2 P2 O2")));
+
+		s = graph.find(new Triple(node("S2"), node("P3"), node("O2"))).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(new Triple(Node.ANY, node("P3"), node("O2"))).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(new Triple(node("S3"), Node.ANY, node("O2"))).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(new Triple(node("S3"), node("P2"), Node.ANY)).toList();
+		assertEquals(0, s.size());
+
+	}
+
+	@ContractTest
+	public void testFind_Triple_ByFluidTriple() {
+		Graph g = graphWith(getProducer().newInstance(), "x y z ");
+		Set<Triple> expect = tripleSet("x y z");
+		assertEquals(expect, g.find(triple("?? y z")).toSet());
+		assertEquals(expect, g.find(triple("x ?? z")).toSet());
+		assertEquals(expect, g.find(triple("x y ??")).toSet());
+	}
+
+	@ContractTest
+	public void testFind_Triple_ProgrammaticValues() {
+		Graph g = getProducer().newInstance();
+		if (g.getCapabilities().handlesLiteralTyping()) {
+			Node ab = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Byte((byte) 42)));
+			Node as = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Short((short) 42)));
+			Node ai = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Integer(42)));
+			Node al = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Long(42)));
+
+			Node SB = NodeCreateUtils.create("SB");
+			Node SS = NodeCreateUtils.create("SS");
+			Node SI = NodeCreateUtils.create("SI");
+			Node SL = NodeCreateUtils.create("SL");
+			Node P = NodeCreateUtils.create("P");
+
+			txnBegin(g);
+			try {
+				g.add(Triple.create(SB, P, ab));
+				g.add(Triple.create(SS, P, as));
+				g.add(Triple.create(SI, P, ai));
+				g.add(Triple.create(SL, P, al));
+			} catch (Exception e) {
+				txnRollback(g);
+				fail(e.getMessage());
+			}
+			txnCommit(g);
+			assertEquals(
+					String.format(
+							"Should have found 4 elements, does %s really implement literal typing",
+							g.getClass()),
+					4,
+					iteratorToSet(
+							g.find(new Triple(Node.ANY, P, NodeCreateUtils
+									.create("42")))).size());
+		}
+	}
+
+	@ContractTest
+	public void testFind_Triple_MatchLanguagedLiteralCaseInsensitive() {
+		Graph m = graphWith(getProducer().newInstance(), "a p 'chat'en");
+		//if (m.getCapabilities().handlesLiteralTyping()) {
+			Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+			assertDiffer(chaten, chatEN);
+			assertTrue(chaten.sameValueAs(chatEN));
+			assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+			assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chaten))
+					.toList().size());
+			assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN))
+					.toList().size());
+		//}
+	}
+
+	@ContractTest
+	public void testFind_Triple_NoMatchAgainstUnlanguagesLiteral() {
+		Graph m = graphWith(getProducer().newInstance(),
+				"a p 'chat'en; a p 'chat'");
+		//if (m.getCapabilities().handlesLiteralTyping()) {
+			Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+			assertDiffer(chaten, chatEN);
+			assertTrue(chaten.sameValueAs(chatEN));
+			assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+			assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chaten))
+					.toList().size());
+			assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN))
+					.toList().size());
+		//}
+	}
+
+	@ContractTest
+	public void testGetCapabilities() {
+		Graph g = getProducer().newInstance();
+		Capabilities c = g.getCapabilities();
+		assertNotNull("Capabilities are not returned", c);
+		try {
+			c.sizeAccurate();
+		} catch (Exception e) {
+			fail("sizeAccurate() threw Exception: " + e.toString());
+		}
+		try {
+			c.addAllowed();
+		} catch (Exception e) {
+			fail("addAllowed() threw Exception: " + e.toString());
+		}
+		try {
+			c.addAllowed(true);
+		} catch (Exception e) {
+			fail("addAllowed( boolean ) threw Exception: " + e.toString());
+		}
+		try {
+			c.deleteAllowed();
+		} catch (Exception e) {
+			fail("deleteAllowed() threw Exception: " + e.toString());
+		}
+		try {
+			c.deleteAllowed(true);
+		} catch (Exception e) {
+			fail("deleteAllowed( boolean ) threw Exception: " + e.toString());
+		}
+		try {
+			c.canBeEmpty();
+		} catch (Exception e) {
+			fail("canBeEmpty() threw Exception: " + e.toString());
+		}
+	}
+
+	@ContractTest
+	public void testGetEventManager() {
+		assertNotNull("Must return an EventManager", getProducer()
+				.newInstance().getEventManager());
+	}
+
+	@ContractTest
+	public void testGetPrefixMapping() {
+		Graph g = getProducer().newInstance();
+		PrefixMapping pm = g.getPrefixMapping();
+		assertNotNull("Must return prefix mapping", pm);
+		assertSame("getPrefixMapping must always return the same object", pm,
+				g.getPrefixMapping());
+
+	
+		pm.setNsPrefix("pfx1", "http://example.com/");
+		pm.setNsPrefix("pfx2", "scheme:rope/string#");
+
+		// assert same after adding to other mapl
+		assertSame("getPrefixMapping must always return the same object", pm,
+				g.getPrefixMapping());
+
+	}
+
+	@ContractTest
+	public void testGetStatisticsHandler() {
+		Graph g = getProducer().newInstance();
+		GraphStatisticsHandler sh = g.getStatisticsHandler();
+		if (sh != null) {
+			assertSame(
+					"getStatisticsHandler must always return the same object",
+					sh, g.getStatisticsHandler());
+		}
+	}
+
+	@ContractTest
+	public void testGetTransactionHandler() {
+		Graph g = getProducer().newInstance();
+		assertNotNull("Must return a Transaction handler",
+				g.getTransactionHandler());
+	}
+
+	@ContractTest
+	public void testIsClosed() {
+		Graph g = getProducer().newInstance();
+		assertFalse("Graph created in closed state", g.isClosed());
+		g.close();
+		assertTrue("Graph does not report closed state after close called",
+				g.isClosed());
+	}
+
+	@ContractTest
+	public void testIsEmpty() {
+		Graph g = getProducer().newInstance();
+		if (!g.isEmpty()) {
+			LOG.warn(String.format(
+					"Graph type %s can not be empty (Empty test skipped)",
+					g.getClass()));
+		} else {
+			graphAddTxn(g, "S P O");
+			assertFalse("Graph reports empty after add", g.isEmpty());
+			txnBegin(g);
+			g.add(NodeCreateUtils.createTriple("Foo B C"));
+			g.delete(NodeCreateUtils.createTriple("S P O"));
+			txnCommit(g);
+			assertFalse("Should not report empty", g.isEmpty());
+			txnBegin(g);
+			g.delete(NodeCreateUtils.createTriple("Foo B C"));
+			txnCommit(g);
+			assertTrue("Should report empty after all entries deleted",
+					g.isEmpty());
+		}
+	}
+
+	@ContractTest
+	public void testIsIsomorphicWith_Graph() {
+		Graph graph = getProducer().newInstance();
+		Graph g2 = memGraph();
+		assertTrue("Empty graphs should be isomorphic",
+				graph.isIsomorphicWith(g2));
+
+		graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+		g2 = graphWith("S3 P3 O3; S2 P2 O2; S P O");
+		assertTrue("Should be isomorphic", graph.isIsomorphicWith(g2));
+		txnBegin(graph);
+		graph.add(triple("_1, P4 S4"));
+		txnCommit(graph);
+
+		txnBegin(g2);
+		g2.add(triple("_2, P4 S4"));
+		txnCommit(g2);
+		assertTrue("Should be isomorphic after adding anonymous nodes",
+				graph.isIsomorphicWith(g2));
+
+		txnBegin(graph);
+		graph.add(triple("_1, P3 S4"));
+		txnCommit(graph);
+
+		txnBegin(g2);
+		g2.add(triple("_2, P4 S4"));
+		txnCommit(g2);
+		assertFalse("Should not be isomorphic", graph.isIsomorphicWith(g2));
+	}
+
+	private Graph copy(Graph g) {
+		Graph result = getProducer().newInstance();
+		txnBegin(result);
+		GraphUtil.addInto(result, g);
+		txnCommit(result);
+		return result;
+	}
+
+	private Graph remove(Graph toUpdate, Graph toRemove) {
+		txnBegin(toUpdate);
+		GraphUtil.deleteFrom(toUpdate, toRemove);
+		txnCommit(toUpdate);
+		return toUpdate;
+	}
+
+	/**
+	 * Test that remove(s, p, o) works, in the presence of inferencing graphs
+	 * that mean emptyness isn't available. This is why we go round the houses
+	 * and test that expected ~= initialContent + addedStuff - removed -
+	 * initialContent.
+	 */
+	@ContractTest
+	public void testRemove_Node_Node_Node() {
+		for (int i = 0; i < cases.length; i += 1)
+			for (int j = 0; j < 3; j += 1) {
+				Graph content = getProducer().newInstance();
+
+				Graph baseContent = copy(content);
+				graphAddTxn(content, cases[i][0]);
+				Triple remove = triple(cases[i][1]);
+				Graph expected = graphWith(cases[i][2]);
+				Triple[] removed = tripleArray(cases[i][3]);
+				content.getEventManager().register(GL);
+				GL.clear();
+				txnBegin(content);
+				content.remove(remove.getSubject(), remove.getPredicate(),
+						remove.getObject());
+				txnCommit(content);
+
+				// check for optional delete notifications
+				if (GL.contains("delete")) {
+					// if it contains any it must contain all.
+					for (Triple t : removed) {
+						GL.assertContains("delete", content, t);
+					}
+				}
+				GL.assertHasEnd(
+						"someEvent",
+						content,
+						GraphEvents.remove(remove.getSubject(),
+								remove.getPredicate(), remove.getObject()));
+
+				content.getEventManager().unregister(GL);
+				Graph finalContent = remove(copy(content), baseContent);
+				assertIsomorphic(cases[i][1], expected, finalContent);
+			}
+	}
+
+	@ContractTest
+	public void testRemove_ByIterator() {
+		testRemove("?? ?? ??", "?? ?? ??");
+		testRemove("S ?? ??", "S ?? ??");
+		testRemove("S ?? ??", "?? P ??");
+		testRemove("S ?? ??", "?? ?? O");
+		testRemove("?? P ??", "S ?? ??");
+		testRemove("?? P ??", "?? P ??");
+		testRemove("?? P ??", "?? ?? O");
+		testRemove("?? ?? O", "S ?? ??");
+		testRemove("?? ?? O", "?? P ??");
+		testRemove("?? ?? O", "?? ?? O");
+	}
+
+	private void testRemove(String findRemove, String findCheck) {
+		Graph g = graphWith(getProducer().newInstance(), "S P O");
+		ExtendedIterator<Triple> it = g.find(NodeCreateUtils
+				.createTriple(findRemove));
+		try {
+			it.next();
+			it.remove();
+			it.close();
+			assertEquals("remove with " + findRemove + ":", 0, g.size());
+			assertFalse(g.contains(NodeCreateUtils.createTriple(findCheck)));
+		} catch (UnsupportedOperationException e) {
+			it.close();
+			assertFalse(
+					"delete failed but capailities indicates it should work", g
+							.getCapabilities().iteratorRemoveAllowed());
+		}
+	}
+
+	/**
+	 * This test case was generated by Ian and was caused by GraphMem not
+	 * keeping up with changes to the find interface.
+	 */
+	@ContractTest
+	public void testFindAndContains() {
+		Graph g = getProducer().newInstance();
+		Node r = NodeCreateUtils.create("r"), s = NodeCreateUtils.create("s"), p = NodeCreateUtils
+				.create("P");
+		txnBegin(g);
+		try {
+			g.add(Triple.create(r, p, s));
+			txnCommit(g);
+			assertTrue(g.contains(r, p, Node.ANY));
+			assertEquals(1, g.find(r, p, Node.ANY).toList().size());
+		} catch (Exception e) {
+			txnRollback(g);
+			fail(e.getMessage());
+		}
+	}
+
+	/**
+	 * Check that contains respects by-value semantics.
+	 */
+
+	@ContractTest
+	public void testAGraph() {
+		String title = this.getClass().getName();
+		Graph g = getProducer().newInstance();
+		int baseSize = g.size();
+		graphAddTxn(g, "x R y; p S q; a T b");
+		/* */
+		assertContainsAll(title + ": simple graph", g, "x R y; p S q; a T b");
+		assertEquals(title + ": size", baseSize + 3, g.size());
+
+		graphAddTxn(g,
+				"spindizzies lift cities; Diracs communicate instantaneously");
+		assertEquals(title + ": size after adding", baseSize + 5, g.size());
+		txnBegin(g);
+		g.delete(triple("x R y"));
+		g.delete(triple("a T b"));
+		txnCommit(g);
+		assertEquals(title + ": size after deleting", baseSize + 3, g.size());
+		assertContainsAll(title + ": modified simple graph", g,
+				"p S q; spindizzies lift cities; Diracs communicate instantaneously");
+		assertOmitsAll(title + ": modified simple graph", g, "x R y; a T b");
+		/* */
+		ClosableIterator<Triple> it = g.find(Node.ANY, node("lift"), Node.ANY);
+		assertTrue(title + ": finds some triple(s)", it.hasNext());
+		assertEquals(title + ": finds a 'lift' triple",
+				triple("spindizzies lift cities"), it.next());
+		assertFalse(title + ": finds exactly one triple", it.hasNext());
+		it.close();
+	}
+
+	// public void testStuff()
+	// {
+	// // testAGraph( "StoreMem", new GraphMem() );
+	// // testAGraph( "StoreMemBySubject", new GraphMem() );
+	// // String [] empty = new String [] {};
+	// // Graph g = graphWith( "x R y; p S q; a T b" );
+	// // /* */
+	// // assertContainsAll( "simple graph", g, "x R y; p S q; a T b" );
+	// // graphAdd( g,
+	// "spindizzies lift cities; Diracs communicate instantaneously" );
+	// // g.delete( triple( "x R y" ) );
+	// // g.delete( triple( "a T b" ) );
+	// // assertContainsAll( "modified simple graph", g,
+	// "p S q; spindizzies lift cities; Diracs communicate instantaneously" );
+	// // assertOmitsAll( "modified simple graph", g, "x R y; a T b" );
+	// }
+
+	// /**
+	// Test that Graphs have transaction support methods, and that if they fail
+	// on some g they fail because they do not support the operation.
+	// */
+	// @ContractTest
+	// public void testHasTransactions()
+	// {
+	// Graph g = getProducer().newInstance();
+	// TransactionHandler th = g.getTransactionHandler();
+	// th.transactionsSupported();
+	// try { th.begin(); } catch (UnsupportedOperationException x) {}
+	// try { th.abort(); } catch (UnsupportedOperationException x) {}
+	// try { th.begin(); th.commit(); } catch (UnsupportedOperationException x)
+	// {}
+	// /* */
+	// Command cmd = new Command()
+	// { @Override
+	// public Object execute() { return null; } };
+	// try { th.executeInTransaction( cmd ); }
+	// catch (UnsupportedOperationException x) {}
+	// }
+	//
+	// @ContractTest
+	// public void testExecuteInTransactionCatchesThrowable()
+	// {Graph g = getProducer().newInstance();
+	// TransactionHandler th = g.getTransactionHandler();
+	// if (th.transactionsSupported())
+	// {
+	// Command cmd = new Command()
+	// { @Override
+	// public Object execute() throws Error { throw new Error(); } };
+	// try { th.executeInTransaction( cmd ); }
+	// catch (JenaException x) {}
+	// }
+	// }
+
+	@ContractTest
+	public void testAddWithReificationPreamble() {
+		Graph g = getProducer().newInstance();
+		txnBegin(g);
+		xSPO(g);
+		txnCommit(g);
+		assertFalse(g.isEmpty());
+	}
+
+	protected void xSPOyXYZ(Graph g) {
+		xSPO(g);
+		ReifierStd.reifyAs(g, NodeCreateUtils.create("y"),
+				NodeCreateUtils.createTriple("X Y Z"));
+	}
+
+	protected void aABC(Graph g) {
+		ReifierStd.reifyAs(g, NodeCreateUtils.create("a"),
+				NodeCreateUtils.createTriple("Foo B C"));
+	}
+
+	protected void xSPO(Graph g) {
+		ReifierStd.reifyAs(g, NodeCreateUtils.create("x"),
+				NodeCreateUtils.createTriple("S P O"));
+	}
+
+	@ContractTest
+	public void failingTestDoubleRemoveAll() {
+		final Graph g = getProducer().newInstance();
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				graphAddTxn(g, "c S d; e:ff GGG hhhh; _i J 27; Ell Em 'en'");
+				Iterator<Triple> it = new TrackingTripleIterator(
+						g.find(Triple.ANY)) {
+					@Override
+					public void remove() {
+						super.remove(); // removes current
+						g.delete(current); // no-op.
+					}
+				};
+				while (it.hasNext()) {
+					it.next();
+					it.remove();
+				}
+				assertTrue(g.isEmpty());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	/**
+	 * Test cases for RemoveSPO(); each entry is a triple (add, remove, result).
+	 * <ul>
+	 * <li>add - the triples to add to the graph to start with
+	 * <li>remove - the pattern to use in the removal
+	 * <li>result - the triples that should remain in the graph
+	 * </ul>
+	 */
+	protected static String[][] cases = { { "x R y", "x R y", "", "x R y" },
+			{ "x R y; a P b", "x R y", "a P b", "x R y" },
+			{ "x R y; a P b", "?? R y", "a P b", "x R y" },
+			{ "x R y; a P b", "x R ??", "a P b", "x R y" },
+			{ "x R y; a P b", "x ?? y", "a P b", "x R y" },
+			{ "x R y; a P b", "?? ?? ??", "", "x R y; a P b" },
+			{ "x R y; a P b; c P d", "?? P ??", "x R y", "a P b; c P d" },
+			{ "x R y; a P b; x S y", "x ?? ??", "a P b", "x R y; x S y" }, };
+
+	/**
+	 * testIsomorphism from file data
+	 * 
+	 * @throws FileNotFoundException
+	 */
+	@ContractTest
+	public void testIsomorphismFile() throws URISyntaxException,
+			MalformedURLException {
+		testIsomorphismXMLFile(1, true);
+		testIsomorphismXMLFile(2, true);
+		testIsomorphismXMLFile(3, true);
+		testIsomorphismXMLFile(4, true);
+		testIsomorphismXMLFile(5, false);
+		testIsomorphismXMLFile(6, false);
+		testIsomorphismNTripleFile(7, true);
+		testIsomorphismNTripleFile(8, false);
+
+	}
+
+	private void testIsomorphismNTripleFile(int i, boolean result)
+			throws URISyntaxException, MalformedURLException {
+		testIsomorphismFile(i, "N-TRIPLE", "nt", result);
+	}
+
+	private void testIsomorphismXMLFile(int i, boolean result)
+			throws URISyntaxException, MalformedURLException {
+		testIsomorphismFile(i, "RDF/XML", "rdf", result);
+
+	}
+
+	private InputStream getInputStream(int n, int n2, String suffix)
+			throws URISyntaxException, MalformedURLException {
+		String urlStr = String.format("regression/testModelEquals/%s-%s.%s", n,
+				n2, suffix);
+		return GraphContractTest.class.getClassLoader().getResourceAsStream(
+				urlStr);
+	}
+
+	private void testIsomorphismFile(int n, String lang, String suffix,
+			boolean result) throws URISyntaxException, MalformedURLException {
+
+		Graph g1 = getProducer().newInstance();
+		Graph g2 = getProducer().newInstance();
+		Model m1 = ModelFactory.createModelForGraph(g1);
+		Model m2 = ModelFactory.createModelForGraph(g2);
+
+		m1.read(getInputStream(n, 1, suffix), "http://www.example.org/", lang);
+
+		m2.read(getInputStream(n, 2, suffix), "http://www.example.org/", lang);
+
+		boolean rslt = g1.isIsomorphicWith(g2) == result;
+		if (!rslt) {
+			System.out.println("g1:");
+			m1.write(System.out, "N-TRIPLE");
+			System.out.println("g2:");
+			m2.write(System.out, "N-TRIPLE");
+		}
+		assertTrue("Isomorphism test failed", rslt);
+	}
+
+	protected Graph getClosed() {
+		Graph result = getProducer().newInstance();
+		result.close();
+		return result;
+	}
+
+	// @ContractTest
+	// public void testTransactionCommit()
+	// {
+	// Graph g = getProducer().newInstance();
+	// 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", ".nt" );
+	//
+	// //Graph g = new FileGraph( foo, true, true );
+	//
+	// 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() );
+	// }
+	// }
+	//
+	// @ContractTest
+	// public void testTransactionAbort()
+	// {
+	// Graph g = getProducer().newInstance();
+	// 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 );
+	// }
+	// }
+	//
+	// @ContractTest
+	// public void testTransactionCommitThenAbort()
+	// {
+	// Graph g = getProducer().newInstance();
+	// if (g.getTransactionHandler().transactionsSupported())
+	// {
+	// Graph initial = graphWithTxn( "Foo pings B; B pings C" );
+	// Graph extra = graphWithTxn( "C pingedBy B; fileGraph rdf:type Graph" );
+	// //Graph g = getProducer().newInstance();
+	// //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() );
+	// }
+	// }
+
+	/**
+	 * 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.
+	 */
+	@ContractTest
+	public void testPartialUpdate() {
+		Graph source = graphWith(getProducer().newInstance(), "a R b; b S e");
+		Graph dest = graphWith(getProducer().newInstance(), "b R d");
+		GraphExtract e = new GraphExtract(TripleBoundary.stopNowhere);
+		e.extractInto(dest, node("a"), source);
+		assertIsomorphic(
+				graphWith(getProducer().newInstance(), "a R b; b S e; b R d"),
+				dest);
+	}
+
+	/**
+	 * Ensure that triples removed by calling .remove() on the iterator returned
+	 * by a find() will generate deletion notifications.
+	 */
+	@ContractTest
+	public void testIterator_Remove() {
+		Graph graph = graphWith(getProducer().newInstance(), "a R b; b S e");
+		if (graph.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				graph.getEventManager().register(GL);
+				txnBegin(graph);
+
+				Triple toRemove = triple("a R b");
+				ExtendedIterator<Triple> rtr = graph.find(toRemove);
+				assertTrue("ensure a(t least) one triple", rtr.hasNext());
+				rtr.next();
+				rtr.remove();
+				rtr.close();
+				GL.assertHas("delete", graph, toRemove);
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+
+		}
+	}
+
+	@ContractTest
+	public void testTransactionHandler_Commit() {
+		Graph g = getProducer().newInstance();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWith(getProducer().newInstance(),
+					"initial hasValue 42; also hasURI hello");
+			Graph extra = graphWith(getProducer().newInstance(),
+					"extra hasValue 17; also hasURI world");
+
+			GraphUtil.addInto(g, initial);
+			g.getTransactionHandler().begin();
+			GraphUtil.addInto(g, extra);
+			g.getTransactionHandler().commit();
+			Graph union = memGraph();
+			GraphUtil.addInto(union, initial);
+			GraphUtil.addInto(union, extra);
+			assertIsomorphic(union, g);
+			// Model inFiIProducer<TransactionHandler>le =
+			// ModelFactory.createDefaultModel();
+			// inFile.read( "file:///" + foo, "N-TRIPLES" );
+			// assertIsomorphic( union, inFile.getGraph() );
+		}
+	}
+
+	@ContractTest
+	public void testTransactionHandler_Abort() {
+		Graph g = getProducer().newInstance();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWith(getProducer().newInstance(),
+					"initial hasValue 42; also hasURI hello");
+			Graph extra = graphWith(getProducer().newInstance(),
+					"extra hasValue 17; also hasURI world");
+			GraphUtil.addInto(g, initial);
+			g.getTransactionHandler().begin();
+			GraphUtil.addInto(g, extra);
+			g.getTransactionHandler().abort();
+			assertIsomorphic(initial, g);
+		}
+	}
+
+	@ContractTest
+	public void testTransactionHandler_CommitThenAbort() {
+		Graph g = getProducer().newInstance();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWith(getProducer().newInstance(),
+					"Foo pings B; B pings C");
+			Graph extra = graphWith(getProducer().newInstance(),
+					"C pingedBy B; fileGraph rdf:type Graph");
+			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() );
+		}
+	}
+
+	//
+	// Test that literal typing works when supported
+	//
+
+	// used to find the object set from the returned set for literal testing
+	private static final Map1<Triple, Node> getObject = new Map1<Triple, Node>() {
+		@Override
+		public Node map1(Triple o) {
+			return o.getObject();
+		}
+	};
+
+	private void testLiteralTypingBasedFind(final String data, final int size,
+			final String search, final String results, boolean reqLitType) {
+
+		Graph g = getProducer().newInstance();
+
+		if (!reqLitType || g.getCapabilities().handlesLiteralTyping()) {
+			graphWith(g, 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);
+		}
+	}
+
+	@ContractTest
+	public void testLiteralTypingBasedFind() {
+		testLiteralTypingBasedFind("a P 'simple'", 1, "'simple'", "'simple'",
+				false);
+		testLiteralTypingBasedFind("a P 'simple'xsd:string", 1, "'simple'",
+				"'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 'simple'", 1, "'simple'xsd:string",
+				"'simple'", true);
+		testLiteralTypingBasedFind("a P 'simple'xsd:string", 1,
+				"'simple'xsd:string", "'simple'xsd:string", false);
+//		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 2,
+//				"'simple'", "'simple' 'simple'xsd:string", true);
+//		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 2,
+//				"'simple'xsd:string", "'simple' 'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
+				"'simple'", "'simple'", true);
+		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
+				"'simple'xsd:string", "'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 1", 1, "1", "1", false);
+		testLiteralTypingBasedFind("a P '1'xsd:float", 1, "'1'xsd:float",
+				"'1'xsd:float", false);
+		testLiteralTypingBasedFind("a P '1'xsd:double", 1, "'1'xsd:double",
+				"'1'xsd:double", false);
+		testLiteralTypingBasedFind("a P '1'xsd:float", 1, "'1'xsd:float",
+				"'1'xsd:float", false);
+		testLiteralTypingBasedFind("a P '1.1'xsd:float", 1, "'1'xsd:float", "",
+				false);
+		testLiteralTypingBasedFind("a P '1'xsd:double", 1, "'1'xsd:int", "",
+				false);
+		testLiteralTypingBasedFind("a P 'abc'rdf:XMLLiteral", 1, "'abc'", "",
+				false);
+		testLiteralTypingBasedFind("a P 'abc'", 1, "'abc'rdf:XMLLiteral", "",
+				false);
+		//
+		// floats & doubles are not compatible
+		//
+		testLiteralTypingBasedFind("a P '1'xsd:float", 1, "'1'xsd:double", "",
+				false);
+		testLiteralTypingBasedFind("a P '1'xsd:double", 1, "'1'xsd:float", "",
+				false);
+		testLiteralTypingBasedFind("a P 1", 1, "'1'", "", false);
+		testLiteralTypingBasedFind("a P 1", 1, "'1'xsd:integer",
+				"'1'xsd:integer", false);
+		testLiteralTypingBasedFind("a P 1", 1, "'1'", "", false);
+		testLiteralTypingBasedFind("a P '1'xsd:short", 1, "'1'xsd:integer",
+				"'1'xsd:short", true);
+		testLiteralTypingBasedFind("a P '1'xsd:int", 1, "'1'xsd:integer",
+				"'1'xsd:int", true);
+	}
+
+	@ContractTest
+	public void testQuadRemove() {
+		Graph g = getProducer().newInstance();
+		assertEquals(0, g.size());
+		Triple s = triple("x rdf:subject s");
+		Triple p = triple("x rdf:predicate p");
+		Triple o = triple("x rdf:object o");
+		Triple t = triple("x rdf:type rdf:Statement");
+		txnBegin(g);
+		g.add(s);
+		g.add(p);
+		g.add(o);
+		g.add(t);
+		txnCommit(g);
+		assertEquals(4, g.size());
+		txnBegin(g);
+		g.delete(s);
+		g.delete(p);
+		g.delete(o);
+		g.delete(t);
+		txnCommit(g);
+		assertEquals(0, g.size());
+	}
+
+	@ContractTest
+	public void testSizeAfterRemove() {
+		Graph g = graphWith(getProducer().newInstance(), "x p y");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(triple("x ?? ??"));
+				it.removeNext();
+				assertEquals(0, g.size());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	@ContractTest
+	public void testSingletonStatisticsWithSingleTriple() {
+
+		Graph g = graphWith(getProducer().newInstance(), "a P b");
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			assertEquals(1L, h.getStatistic(node("a"), Node.ANY, Node.ANY));
+			assertEquals(0L, h.getStatistic(node("x"), Node.ANY, Node.ANY));
+			//
+			assertEquals(1L, h.getStatistic(Node.ANY, node("P"), Node.ANY));
+			assertEquals(0L, h.getStatistic(Node.ANY, node("Q"), Node.ANY));
+			//
+			assertEquals(1L, h.getStatistic(Node.ANY, Node.ANY, node("b")));
+			assertEquals(0L, h.getStatistic(Node.ANY, Node.ANY, node("y")));
+		}
+	}
+
+	@ContractTest
+	public void testSingletonStatisticsWithSeveralTriples() {
+
+		Graph g = graphWith(getProducer().newInstance(),
+				"a P b; a P c; a Q b; x S y");
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			assertEquals(3L, h.getStatistic(node("a"), Node.ANY, Node.ANY));
+			assertEquals(1L, h.getStatistic(node("x"), Node.ANY, Node.ANY));
+			assertEquals(0L, h.getStatistic(node("y"), Node.ANY, Node.ANY));
+			//
+			assertEquals(2L, h.getStatistic(Node.ANY, node("P"), Node.ANY));
+			assertEquals(1L, h.getStatistic(Node.ANY, node("Q"), Node.ANY));
+			assertEquals(0L, h.getStatistic(Node.ANY, node("R"), Node.ANY));
+			//
+			assertEquals(2L, h.getStatistic(Node.ANY, Node.ANY, node("b")));
+			assertEquals(1L, h.getStatistic(Node.ANY, Node.ANY, node("c")));
+			assertEquals(0L, h.getStatistic(Node.ANY, Node.ANY, node("d")));
+		}
+	}
+
+	@ContractTest
+	public void testDoubletonStatisticsWithTriples() {
+
+		Graph g = graphWith(getProducer().newInstance(),
+				"a P b; a P c; a Q b; x S y");
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			assertEquals(-1L, h.getStatistic(node("a"), node("P"), Node.ANY));
+			assertEquals(-1L, h.getStatistic(Node.ANY, node("P"), node("b")));
+			assertEquals(-1L, h.getStatistic(node("a"), Node.ANY, node("b")));
+			//
+			assertEquals(0L, h.getStatistic(node("no"), node("P"), Node.ANY));
+		}
+	}
+
+	@ContractTest
+	public void testStatisticsWithOnlyVariables() {
+		testStatsWithAllVariables("");
+		testStatsWithAllVariables("a P b");
+		testStatsWithAllVariables("a P b; a P c");
+		testStatsWithAllVariables("a P b; a P c; a Q b; x S y");
+	}
+
+	private void testStatsWithAllVariables(String triples) {
+		Graph g = graphWith(getProducer().newInstance(), triples);
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			assertEquals(g.size(), h.getStatistic(Node.ANY, Node.ANY, Node.ANY));
+		}
+	}
+
+	@ContractTest
+	public void testStatsWithConcreteTriple() {
+		testStatsWithConcreteTriple(0, "x P y", "");
+	}
+
+	private void testStatsWithConcreteTriple(int expect, String triple,
+			String graph) {
+		Graph g = graphWith(getProducer().newInstance(), graph);
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			Triple t = triple(triple);
+			assertEquals(
+					expect,
+					h.getStatistic(t.getSubject(), t.getPredicate(),
+							t.getObject()));
+		}
+	}
+
+	@ContractTest
+	public void testBrokenIndexes() {
+		Graph g = graphWith(getProducer().newInstance(), "x R y; x S z");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY,
+						Node.ANY);
+				it.removeNext();
+				it.removeNext();
+				assertFalse(g.find(node("x"), Node.ANY, Node.ANY).hasNext());
+				assertFalse(g.find(Node.ANY, node("R"), Node.ANY).hasNext());
+				assertFalse(g.find(Node.ANY, Node.ANY, node("y")).hasNext());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	@ContractTest
+	public void testBrokenSubject() {
+		Graph g = graphWith(getProducer().newInstance(), "x brokenSubject y");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(node("x"), Node.ANY,
+						Node.ANY);
+				it.removeNext();
+				assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	@ContractTest
+	public void testBrokenPredicate() {
+		Graph g = graphWith(getProducer().newInstance(), "x brokenPredicate y");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(Node.ANY,
+						node("brokenPredicate"), Node.ANY);
+				it.removeNext();
+				assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	@ContractTest
+	public void testBrokenObject() {
+		Graph g = graphWith(getProducer().newInstance(), "x brokenObject y");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY,
+						node("y"));
+				it.removeNext();
+				assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
new file mode 100644
index 0000000..426002d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
@@ -0,0 +1,514 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.mockito.Mockito;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import static org.junit.Assert.*;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphEventManager;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.Factory;
+import org.apache.jena.testing_framework.ContractTemplate;
+import org.apache.jena.testing_framework.GraphHelper;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.testing_framework.NodeCreateUtils;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+/**
+ * An abstract test that tests EventManager implementations to ensure they
+ * comply with the EventManager contract.
+ * 
+ * Subclasses of this class must implement the getEventManagerProducer() method
+ * to create a new instance of the EventManager for testing.
+ */
+
+@Contract(GraphEventManager.class)
+public class GraphEventManagerContractTest<T extends GraphEventManager> extends
+		ContractTemplate<IProducer<T>> {
+
+	protected static final Triple[] tripleArray = tripleArray("S P O; Foo R B; X Q Y");
+
+	// the graph that is used as the source of the events.
+	private Graph mockGraph;
+	// The event manager we are working with.
+	private GraphEventManager gem;
+
+	public GraphEventManagerContractTest() {
+//		setProducer(new IProducer<T>() {
+//
+//			@SuppressWarnings("unchecked")
+//			@Override
+//			public T newInstance() {
+//				return (T) Factory.createGraphMem().getEventManager();
+//			}
+//
+//			@Override
+//			public void cleanUp() {
+//			}
+//		});
+
+	}
+
+	@Contract.Inject
+	public final void setGraphEventManagerContractTestProducer(
+			IProducer<T> producer) {
+		super.setProducer(producer);
+	}
+
+	@After
+	public final void afterGraphEventManagerContractTest() {
+		getProducer().cleanUp();
+	}
+
+	@Before
+	public final void beforeGraphEventManagerContractTest() {
+		mockGraph = Mockito.mock(Graph.class);
+		gem = getProducer().newInstance();
+		L = new RecordingGraphListener();
+	}
+
+	/**
+	 * Test that when a listener is registered the same EventManager is
+	 * returned.
+	 */
+	@ContractTest
+	public void testEventRegister() {
+		assertSame(gem, gem.register(new RecordingGraphListener()));
+	}
+
+	/**
+	 * Test that we can safely unregister a listener that isn't registered.
+	 */
+	@ContractTest
+	public void testEventUnregister() {
+		assertSame(gem, gem.unregister(L));
+	}
+
+	/**
+	 * Handy triple for test purposes.
+	 */
+	protected Triple SPO = NodeCreateUtils.createTriple("S P O");
+
+	/**
+	 * The RecordingListener that reports all the events sent from the
+	 * EventManager.
+	 */
+	protected RecordingGraphListener L;
+
+	/**
+	 * Test that adding a triple is reported.
+	 */
+	@ContractTest
+	public void testAddTriple() {
+		gem.register(L);
+		gem.notifyAddTriple(mockGraph, SPO);
+		L.assertHas(new Object[] { "add", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that deleting a triple is reported.
+	 */
+	@ContractTest
+	public void testDeleteTriple() {
+		gem.register(L);
+		gem.notifyDeleteTriple(mockGraph, SPO);
+		L.assertHas(new Object[] { "delete", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that when 2 listeners are added both receive events.
+	 */
+	@ContractTest
+	public void testTwoListeners() {
+		RecordingGraphListener L1 = new RecordingGraphListener();
+		RecordingGraphListener L2 = new RecordingGraphListener();
+		gem.register(L1).register(L2);
+		gem.notifyAddTriple(mockGraph, SPO);
+		L2.assertHas(new Object[] { "add", mockGraph, SPO });
+		L1.assertHas(new Object[] { "add", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that unregistering a listener after registering it results in it not
+	 * receiving messages.
+	 */
+	@ContractTest
+	public void testUnregisterWorks() {
+		gem.register(L).unregister(L);
+		gem.notifyAddTriple(mockGraph, SPO);
+		L.assertHas(new Object[] {});
+	}
+
+	/**
+	 * Test that registering a listener twice results in the listener receiving
+	 * the events twice.
+	 */
+	@ContractTest
+	public void testRegisterTwice() {
+		gem.register(L).register(L);
+		gem.notifyAddTriple(mockGraph, SPO);
+		L.assertHas(new Object[] { "add", mockGraph, SPO, "add", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that registering a listener twice and unregistering it once will
+	 * result in the listener receiving each event one time.
+	 */
+	@ContractTest
+	public void testUnregisterOnce() {
+		gem.register(L).register(L).unregister(L);
+		gem.notifyDeleteTriple(mockGraph, SPO);
+		L.assertHas(new Object[] { "delete", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that adding an array is reported as adding an array.
+	 */
+	@ContractTest
+	public void testAddArray() {
+		gem.register(L);
+		gem.notifyAddArray(mockGraph, tripleArray);
+		L.assertHas(new Object[] { "add[]", mockGraph, tripleArray });
+	}
+
+	/**
+	 * Test that adding a list is reported as adding a list
+	 */
+	@ContractTest
+	public void testAddList() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyAddList(mockGraph, elems);
+		L.assertHas(new Object[] { "addList", mockGraph, elems });
+	}
+
+	/**
+	 * Test that deleting an array is reported as deleting an array.
+	 */
+	@ContractTest
+	public void testDeleteArray() {
+		gem.register(L);
+		gem.notifyDeleteArray(mockGraph, tripleArray);
+		L.assertHas(new Object[] { "delete[]", mockGraph, tripleArray });
+	}
+
+	/**
+	 * Test that deleting a list is reported as deleting a list.
+	 */
+	@ContractTest
+	public void testDeleteList() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyDeleteList(mockGraph, elems);
+		L.assertHas(new Object[] { "deleteList", mockGraph, elems });
+	}
+
+	/**
+	 * Test that adding a list as an iterator is reported as an add iterator.
+	 */
+	@ContractTest
+	public void testAddListAsIterator() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyAddIterator(mockGraph, elems);
+		L.assertHas(new Object[] { "addIterator", mockGraph, elems });
+	}
+
+	/**
+	 * Test that adding an iterator is reported as adding an iterator.
+	 */
+	@ContractTest
+	public void testAddIterator() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyAddIterator(mockGraph, elems.iterator());
+		L.assertHas(new Object[] { "addIterator", mockGraph, elems });
+	}
+
+	/**
+	 * Test that deleting an iterator is reported as a deleting an iterator.
+	 */
+	@ContractTest
+	public void testDeleteIterator() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyDeleteIterator(mockGraph, elems.iterator());
+		L.assertHas(new Object[] { "deleteIterator", mockGraph, elems });
+	}
+
+	/**
+	 * Test that deleting a list as an iterator is reported as deleting an
+	 * iterator.
+	 */
+	@ContractTest
+	public void testDeleteListAsIterator() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyDeleteIterator(mockGraph, elems);
+		L.assertHas(new Object[] { "deleteIterator", mockGraph, elems });
+	}
+
+	/**
+	 * Test that adding a graph is reported as adding a graph.
+	 */
+	@ContractTest
+	public void testAddGraph() {
+		gem.register(L);
+		Graph other = Mockito.mock(Graph.class);
+		gem.notifyAddGraph(mockGraph, other);
+		L.assertHas(new Object[] { "addGraph", mockGraph, other });
+	}
+
+	/**
+	 * Test that deleting a graph is reported as deleting a graph.
+	 */
+	@ContractTest
+	public void testDeleteGraph() {
+		gem.register(L);
+		Graph other = Mockito.mock(Graph.class);
+		gem.notifyDeleteGraph(mockGraph, other);
+		L.assertHas(new Object[] { "deleteGraph", mockGraph, other });
+	}
+
+	/**
+	 * Test that sending a general event is reported as an event and the value
+	 * is saved.
+	 */
+	@ContractTest
+	public void testGeneralEvent() {
+		gem.register(L);
+		Object value = new int[] {};
+		gem.notifyEvent(mockGraph, value);
+		L.assertHas(new Object[] { "someEvent", mockGraph, value });
+	}
+
+	@ContractTest
+	public void testListening() {
+		assertFalse("Should not be listening", gem.listening());
+		gem.register(L);
+		assertTrue("Should be listening", gem.listening());
+		gem.unregister(L);
+		assertFalse("Should not be listening", gem.listening());
+	}
+
+	//
+	// Foo series of tests to check modifying the manger in mid notification
+	//
+
+	private ComeAndGoListener all[];
+
+	abstract private static class ComeAndGoListener implements GraphListener {
+
+		// Was I registered when start() was called, and have not been
+		// unregistered.
+		boolean inPlay = false;
+		// currently registered or not.
+		boolean registered = false;
+		boolean notified = false;
+
+		void register(GraphEventManager gem) {
+			registered = true;
+			gem.register(this);
+		}
+
+		void unregister(GraphEventManager gem) {
+			registered = false;
+			inPlay = false;
+			gem.unregister(this);
+		}
+
+		void start() {
+			if (registered)
+				inPlay = true;
+		}
+
+		void check() {
+			if (inPlay && !notified)
+				fail("listener that was in-play was not notified of adding triple.");
+		}
+
+		@Override
+		final public void notifyAddTriple(Graph g, Triple t) {
+			notified = true;
+			doSomeDamage();
+		}
+
+		abstract void doSomeDamage();
+
+		@Override
+		public void notifyAddArray(Graph g, Triple[] triples) {
+		}
+
+		@Override
+		public void notifyAddGraph(Graph g, Graph added) {
+		}
+
+		@Override
+		public void notifyAddIterator(Graph g, Iterator<Triple> it) {
+		}
+
+		@Override
+		public void notifyAddList(Graph g, List<Triple> triples) {
+		}
+
+		@Override
+		public void notifyDeleteArray(Graph g, Triple[] triples) {
+		}
+
+		@Override
+		public void notifyDeleteGraph(Graph g, Graph removed) {
+		}
+
+		@Override
+		public void notifyDeleteIterator(Graph g, Iterator<Triple> it) {
+		}
+
+		@Override
+		public void notifyDeleteList(Graph g, List<Triple> L) {
+		}
+
+		@Override
+		public void notifyDeleteTriple(Graph g, Triple t) {
+		}
+
+		@Override
+		public void notifyEvent(Graph source, Object value) {
+		}
+
+	}
+
+	/**
+	 * ComeAndGoListener implementation that does no damage
+	 * 
+	 */
+	private static final class SimpleListener extends ComeAndGoListener {
+		@Override
+		void doSomeDamage() {
+		}
+	}
+
+	/**
+	 * Test adding a triple to trigger event.
+	 * 
+	 * @param registerTo
+	 *            Number of listeners to register.
+	 * @param allx
+	 */
+	private void testAddingTriple(int registerTo, ComeAndGoListener... allx) {
+		all = allx;
+		// register addMe
+		for (int i = 0; i < registerTo; i++) {
+			all[i].register(gem);
+		}
+
+		// start them all
+		for (ComeAndGoListener l : all) {
+			l.start();
+		}
+		// send the notification.
+		gem.notifyAddTriple(mockGraph, GraphHelper.triple("make a change"));
+		// check them
+		for (ComeAndGoListener l : all) {
+			l.check();
+		}
+	}
+
+	/**
+	 * Test that a listener added during event processing does not receive the
+	 * event.
+	 */
+	@ContractTest
+	public void testAddOne() {
+		testAddingTriple(2, new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				all[2].register(gem);
+			}
+		}, new SimpleListener(), new SimpleListener());
+	}
+
+	/**
+	 * Test that when a listener that has not yet been handled is removed during
+	 * event processing it receive the event.
+	 */
+	@ContractTest
+	public void testDelete2nd() {
+		testAddingTriple(3, new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				all[1].unregister(gem);
+			}
+		}, new SimpleListener(), new SimpleListener());
+	}
+
+	/**
+	 * Test that when a listener that has been handled is removed during event
+	 * processing it receives the event.
+	 */
+	@ContractTest
+	public void testDelete1st() {
+		testAddingTriple(3, new SimpleListener(), new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				all[0].unregister(gem);
+			}
+		}, new SimpleListener());
+	}
+
+	/**
+	 * Test that when a listener that removes itself during event processing it
+	 * receives the event.
+	 */
+	@ContractTest
+	public void testDeleteSelf() {
+		testAddingTriple(3, new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				unregister(gem);
+			}
+		}, new SimpleListener(), new SimpleListener());
+	}
+
+	/**
+	 * Test that when a listener that removes and adds itself during event
+	 * processing it receives the event.
+	 */
+	@ContractTest
+	public void testDeleteAndAddSelf() {
+		testAddingTriple(3, new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				unregister(gem);
+				register(gem);
+			}
+		}, new SimpleListener(), new SimpleListener());
+	}
+
+}


[20/25] jena git commit: Merge branch 'master' into add-contract-tests

Posted by cl...@apache.org.
Merge branch 'master' into add-contract-tests


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/dcab5a09
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/dcab5a09
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/dcab5a09

Branch: refs/heads/master
Commit: dcab5a0948f78fa33de01d82fe3ac6522541f582
Parents: 6908e1c 8d53fed
Author: Claude Warren <cl...@apache.org>
Authored: Sat May 16 09:57:30 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 16 09:57:30 2015 +0100

----------------------------------------------------------------------
 .../update/UpdateExecuteOperations.java         |  17 +-
 .../arq/examples/update/UpdateProgrammatic.java |   4 +-
 .../arq/examples/update/UpdateReadFromFile.java |   4 +-
 .../src/main/java/arq/cmdline/CmdUpdate.java    |  19 +-
 .../src/main/java/arq/cmdline/ModDataset.java   |   7 +-
 .../main/java/arq/cmdline/ModGraphStore.java    |  95 ---
 jena-arq/src/main/java/arq/load.java            |   4 +-
 jena-arq/src/main/java/arq/update.java          |  69 +-
 .../org/apache/jena/atlas/json/JsonArray.java   |   2 +-
 .../atlas/json/io/parser/TokenizerJSON.java     | 697 +++++++++----------
 .../java/org/apache/jena/query/Dataset.java     |   8 +-
 .../apache/jena/query/ResultSetFormatter.java   |   8 +-
 .../java/org/apache/jena/riot/web/HttpOp.java   | 102 ++-
 .../apache/jena/riot/web/HttpResponseLib.java   |   3 +-
 .../org/apache/jena/sparql/ARQConstants.java    |  11 +-
 .../sparql/core/assembler/AssemblerUtils.java   |   1 -
 .../core/assembler/GraphStoreAssembler.java     |  47 --
 .../jena/sparql/engine/http/HttpQuery.java      |   2 -
 .../apache/jena/sparql/engine/http/Service.java |   2 -
 .../org/apache/jena/sparql/expr/ExprDigest.java |   3 +-
 .../apache/jena/sparql/lang/arq/ARQParser.java  |   2 +-
 .../jena/sparql/modify/GraphStoreBasic.java     |  19 -
 .../jena/sparql/modify/GraphStoreNull.java      |  20 +-
 .../jena/sparql/modify/GraphStoreWrapper.java   |  13 -
 .../jena/sparql/modify/UpdateEngineBase.java    |   9 +-
 .../jena/sparql/modify/UpdateEngineFactory.java |   6 +-
 .../jena/sparql/modify/UpdateEngineMain.java    |  31 +-
 .../sparql/modify/UpdateEngineNonStreaming.java |  32 +-
 .../sparql/modify/UpdateEngineRegistry.java     |   6 +-
 .../jena/sparql/modify/UpdateEngineWorker.java  | 117 ++--
 .../jena/sparql/modify/UpdateProcessRemote.java |   3 +-
 .../sparql/modify/UpdateProcessRemoteBase.java  |  22 +-
 .../sparql/modify/UpdateProcessRemoteForm.java  |   3 +-
 .../jena/sparql/modify/UpdateProcessorBase.java |  23 +-
 .../modify/UpdateProcessorStreamingBase.java    |  42 +-
 .../jena/sparql/resultset/OutputBase.java       |  18 +-
 .../sparql/serializer/FormatterElement.java     |   8 +-
 .../serializer/QuerySerializerFactory.java      |  29 +-
 .../sparql/serializer/SerializerRegistry.java   |  18 +-
 .../apache/jena/sparql/util/MappedLoader.java   |   2 +
 .../java/org/apache/jena/update/GraphStore.java |  15 +-
 .../apache/jena/update/GraphStoreFactory.java   |   7 +
 .../org/apache/jena/update/UpdateAction.java    | 172 +++--
 .../jena/update/UpdateExecutionFactory.java     | 193 +++--
 .../org/apache/jena/update/UpdateProcessor.java |  13 +-
 .../jena/update/UpdateProcessorStreaming.java   |   9 +-
 .../jena/web/DatasetGraphAccessorHTTP.java      |   3 +-
 jena-arq/src/main/java/riotcmd/utf8.java        |  48 +-
 .../query/TestParameterizedSparqlString.java    |   3 +-
 .../org/apache/jena/riot/TestRiotReader.java    |  14 +-
 .../jena/riot/lang/TestPipedRDFIterators.java   |   6 +-
 .../jena/riot/system/TestIO_JenaReaders.java    |   4 +-
 .../jena/riot/system/TestIO_JenaWriters.java    |   4 +-
 .../sparql/core/AbstractTestDynamicDataset.java |   5 +-
 .../sparql/core/TestDatasetGraphWithLock.java   |   4 +-
 .../jena/sparql/core/TestDynamicDatasetMem.java |   8 +-
 .../sparql/engine/index/TestIndexTable.java     |   4 +-
 .../apache/jena/sparql/graph/GraphsTests.java   |  33 +-
 .../apache/jena/sparql/graph/TestDatasets.java  |  20 +-
 .../apache/jena/sparql/junit/EarlTestCase.java  |   8 +-
 .../org/apache/jena/sparql/junit/QueryTest.java |  10 +-
 .../jena/sparql/junit/SurpressedTest.java       |   2 +-
 .../apache/jena/sparql/junit/SyntaxTest.java    |   2 +-
 .../jena/sparql/junit/SyntaxUpdateTest.java     |   2 +-
 .../jena/sparql/junit/TestSerialization.java    |   2 +-
 .../apache/jena/sparql/junit/UpdateTest.java    |   6 +-
 .../sparql/modify/AbstractTestUpdateBase.java   |  50 +-
 .../sparql/modify/AbstractTestUpdateGraph.java  |  49 +-
 .../modify/AbstractTestUpdateGraphMgt.java      |  10 +-
 .../jena/sparql/modify/TestUpdateGraphMem.java  |   9 +-
 .../sparql/modify/TestUpdateGraphMgtMem.java    |  15 +-
 .../sparql/modify/TestUpdateOperations.java     |  17 +-
 .../apache/jena/sparql/util/TestFmtUtils.java   |   6 +-
 jena-arq/testing/ARQ/README                     |   3 +
 jena-arq/testing/ARQ/Serialization/manifest.ttl | 110 ++-
 jena-arq/testing/ARQ/Serialization/serial.sh    |   0
 .../ARQ/Serialization/syntax-subselect-01.arq   |   3 -
 .../ARQ/Serialization/syntax-subselect-01.rq    |   3 +
 .../ARQ/Serialization/syntax-subselect-02.arq   |   3 -
 .../ARQ/Serialization/syntax-subselect-02.rq    |   3 +
 .../ARQ/Serialization/syntax-subselect-03.arq   |   7 -
 .../ARQ/Serialization/syntax-subselect-03.rq    |   7 +
 .../ARQ/Serialization/syntax-subselect-04.arq   |   9 -
 .../ARQ/Serialization/syntax-subselect-04.rq    |   7 +
 .../ARQ/Serialization/syntax-subselect-10.arq   |   3 +
 .../ARQ/Serialization/syntax-subselect-11.arq   |   3 +
 .../ARQ/Serialization/syntax-subselect-12.arq   |   7 +
 .../ARQ/Serialization/syntax-subselect-13.arq   |   9 +
 .../apache/jena/atlas/io/CharStreamReader.java  |  23 +-
 .../main/java/org/apache/jena/atlas/io/IO.java  |  13 +-
 .../org/apache/jena/atlas/io/InStreamASCII.java |   4 +-
 .../org/apache/jena/atlas/io/InStreamUTF8.java  |   5 +-
 .../apache/jena/atlas/io/IndentedWriter.java    |   7 +-
 .../apache/jena/atlas/io/PeekInputStream.java   |  98 ++-
 .../org/apache/jena/atlas/io/PeekReader.java    |   3 +-
 .../org/apache/jena/atlas/iterator/Iter.java    | 152 +---
 .../java/org/apache/jena/atlas/lib/Chars.java   |   2 -
 .../java/org/apache/jena/atlas/lib/IRILib.java  |   1 -
 .../apache/jena/atlas/lib/cache/CacheGuava.java |  14 +-
 .../jena/atlas/lib/cache/CacheSetImpl.java      |   3 +-
 .../jena/atlas/lib/cache/CacheSimple.java       |  24 +-
 .../java/org/apache/jena/atlas/lib/TS_Lib.java  |   2 +
 .../org/apache/jena/atlas/lib/TestCache2.java   |  13 +-
 .../jena/atlas/lib/TestDateTimeUtils.java       |  10 +-
 .../jena/atlas/lib/cache/CacheSimpleTest.java   |  43 ++
 .../jena/atlas/lib/cache/TestCacheSimple.java   |  57 ++
 .../apache/jena/assembler/AssemblerHelp.java    |  33 +-
 .../apache/jena/datatypes/xsd/XSDDatatype.java  |   2 +-
 .../java/org/apache/jena/enhanced/EnhGraph.java |  22 +-
 .../org/apache/jena/n3/N3IndentedWriter.java    |   1 -
 .../org/apache/jena/n3/N3JenaWriterCommon.java  |  17 +-
 .../java/org/apache/jena/n3/N3JenaWriterPP.java |  10 +-
 .../jena/n3/turtle/parser/TurtleParser.java     |   7 +-
 .../jena/ontology/impl/OWLLiteProfile.java      |   2 -
 .../rdfxml/xmlinput/impl/AbsXMLContext.java     |   7 -
 .../jena/reasoner/rulesys/FBRuleInfGraph.java   |   4 +-
 .../jena/reasoner/rulesys/builtins/Bound.java   |   1 -
 .../jena/reasoner/rulesys/builtins/Drop.java    |   1 -
 .../jena/reasoner/rulesys/builtins/Remove.java  |   1 -
 .../jena/reasoner/rulesys/builtins/Unbound.java |   1 -
 .../jena/reasoner/rulesys/impl/Generator.java   |   1 -
 .../jena/reasoner/rulesys/impl/LPRuleStore.java |   1 -
 .../reasoner/rulesys/impl/RuleClauseCode.java   |   4 +-
 .../jena/shared/impl/PrefixMappingImpl.java     |   2 +-
 .../java/org/apache/jena/util/cache/Cache.java  |  49 --
 .../apache/jena/util/cache/CacheControl.java    |  70 --
 .../apache/jena/util/cache/CacheManager.java    |  53 --
 .../jena/util/cache/EnhancedNodeCache.java      | 120 ----
 .../org/apache/jena/util/cache/RandCache.java   | 162 -----
 .../apache/jena/enhanced/test/TestPackage.java  |  33 +-
 .../jena/ontology/impl/TestAllDifferent.java    |   2 +-
 .../jena/ontology/impl/TestClassExpression.java | 112 +--
 .../jena/ontology/impl/TestIndividual.java      |  42 +-
 .../apache/jena/ontology/impl/TestOntTools.java |   3 +-
 .../apache/jena/ontology/impl/TestOntology.java |   8 +-
 .../apache/jena/ontology/impl/TestProperty.java |  54 +-
 .../apache/jena/ontology/impl/TestResource.java |  50 +-
 .../model/test/AbstractContainerMethods.java    |   2 +-
 .../rdf/model/test/AbstractModelTestBase.java   |   4 +-
 .../jena/rdf/model/test/IsomorphicTests.java    |   4 +-
 .../jena/rdf/model/test/TestAddAndContains.java |   4 +-
 .../jena/rdf/model/test/TestAddModel.java       |   4 +-
 .../jena/rdf/model/test/TestConcurrency.java    |   4 +-
 .../rdf/model/test/TestConcurrencyNesting.java  |   2 +-
 .../rdf/model/test/TestConcurrencyParallel.java |   2 +-
 .../rdf/model/test/TestCopyInOutOfModel.java    |   2 +-
 .../org/apache/jena/rdf/model/test/TestGet.java |   4 +-
 .../jena/rdf/model/test/TestIterators.java      |   2 +-
 .../jena/rdf/model/test/TestListStatements.java |   4 +-
 .../jena/rdf/model/test/TestListSubjects.java   |   2 +-
 .../rdf/model/test/TestLiteralsInModel.java     |   2 +-
 .../jena/rdf/model/test/TestModelEvents.java    |   2 +-
 .../rdf/model/test/TestModelSetOperations.java  |   4 +-
 .../rdf/model/test/TestObjectOfProperties.java  |   2 +-
 .../apache/jena/rdf/model/test/TestObjects.java |   4 +-
 .../rdf/model/test/TestReifiedStatements.java   |   2 +-
 .../rdf/model/test/TestResourceMethods.java     |   2 +-
 .../jena/rdf/model/test/TestSelectorUse.java    |   2 +-
 .../jena/rdf/model/test/TestSeqMethods.java     |   2 +-
 .../model/test/TestSimpleListStatements.java    |   2 +-
 .../jena/rdf/model/test/TestSimpleSelector.java |   2 +-
 .../rdf/model/test/TestStatementCreation.java   |   4 +-
 .../rdf/model/test/TestStatementMethods.java    |   2 +-
 .../jena/rdfxml/xmloutput/PrettyWriterTest.java |   2 +-
 .../jena/rdfxml/xmloutput/TestXMLFeatures.java  |   4 +-
 .../java/org/apache/jena/util/TestCache.java    | 125 ----
 .../java/org/apache/jena/util/TestPackage.java  |   1 -
 .../jena/propertytable/graph/GraphCSVTest.java  |   4 +-
 .../org/apache/jena/iri/TestIRIFactory.java     |   2 +-
 .../java/org/apache/jena/sdb/SDBFactory.java    |   2 +-
 .../apache/jena/sdb/modify/UpdateEngineSDB.java |   6 +-
 .../apache/jena/sdb/store/DatasetGraphSDB.java  |  17 -
 .../jena/sdb/test/modify/TestSPARQLUpdate.java  |   7 +-
 .../sdb/test/modify/TestSPARQLUpdateMgt.java    |   8 +-
 .../apache/jena/tdb/modify/UpdateEngineTDB.java |  12 +-
 .../jena/tdb/setup/DatasetBuilderStd.java       |  25 +-
 .../apache/jena/tdb/store/DatasetGraphTDB.java  |  14 -
 .../store/bulkloader2/CmdNodeTableBuilder.java  |  10 +-
 .../transaction/DatasetGraphTransaction.java    | 190 ++---
 .../main/java/tdb/cmdline/ModTDBGraphStore.java |  51 --
 jena-tdb/src/main/java/tdb/tdbupdate.java       |  15 +-
 .../jena/tdb/store/TestDynamicDatasetTDB.java   |   3 +
 .../apache/jena/tdb/store/Test_SPARQL_TDB.java  |   3 +-
 183 files changed, 1674 insertions(+), 2706 deletions(-)
----------------------------------------------------------------------



[15/25] jena git commit: Removed FileGraph tests as FileGraph was deleted. Fixed contract tests

Posted by cl...@apache.org.
Removed FileGraph tests as FileGraph was deleted.
Fixed contract tests


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/335a7617
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/335a7617
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/335a7617

Branch: refs/heads/master
Commit: 335a7617cb73ccf97e3a42f3ae4e9afcc3dbd484
Parents: c004d80
Author: Claude Warren <cl...@apache.org>
Authored: Sun May 10 13:30:17 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sun May 10 13:30:17 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml                               |  2 +-
 .../jena/assembler/test/TestAssemblerGroup.java |  8 +-
 .../apache/jena/graph/GraphContractTest.java    |  9 ++-
 .../jena/graph/impl/FileGraphMaker_CS.java      | 81 --------------------
 .../impl/FileGraphTransactionHandler_CS.java    | 56 --------------
 .../apache/jena/graph/impl/FileGraph_CS.java    | 79 -------------------
 6 files changed, 12 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/335a7617/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index e18d331..d64e195 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -78,7 +78,7 @@
 	<dependency>
 		<groupId>org.xenei</groupId>
 		<artifactId>junit-contracts</artifactId>
-		<version>0.0.5</version>
+		<version>0.1.1</version>
 		<scope>test</scope>
 	</dependency>
 	

http://git-wip-us.apache.org/repos/asf/jena/blob/335a7617/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblerGroup.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblerGroup.java b/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblerGroup.java
index f424993..8b38e5a 100644
--- a/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblerGroup.java
+++ b/jena-core/src/test/java/org/apache/jena/assembler/test/TestAssemblerGroup.java
@@ -18,9 +18,11 @@
 
 package org.apache.jena.assembler.test;
 
+import java.util.Map;
+
 import org.apache.jena.assembler.* ;
 import org.apache.jena.assembler.assemblers.* ;
-import org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup ;
+import org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup;
 import org.apache.jena.assembler.exceptions.* ;
 import org.apache.jena.graph.Graph ;
 import org.apache.jena.mem.GraphMemBase ;
@@ -66,7 +68,9 @@ public class TestAssemblerGroup extends AssemblerTestBase
     
     public static class Trivial
         {
-        static { loaded = true; }
+        static { 
+        	loaded = true;
+        }
         }
     
     public void testLoadsClasses()

http://git-wip-us.apache.org/repos/asf/jena/blob/335a7617/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index 55ad955..589f095 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -25,6 +25,8 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.function.Function;
+
 import org.junit.After;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,7 +54,6 @@ import org.apache.jena.testing_framework.ContractTemplate;
 import org.apache.jena.testing_framework.NodeCreateUtils;
 import org.apache.jena.util.iterator.ClosableIterator;
 import org.apache.jena.util.iterator.ExtendedIterator;
-import org.apache.jena.util.iterator.Map1;
 
 import static org.apache.jena.testing_framework.GraphHelper.*;
 
@@ -1452,10 +1453,10 @@ public class GraphContractTest<T extends Graph> extends
 	//
 
 	// used to find the object set from the returned set for literal testing
-	private static final Map1<Triple, Node> getObject = new Map1<Triple, Node>() {
+	private static final Function<Triple, Node> getObject = new Function<Triple, Node>() {
 		@Override
-		public Node map1(Triple o) {
-			return o.getObject();
+		public Node apply(Triple t) {
+			return t.getObject();
 		}
 	};
 

http://git-wip-us.apache.org/repos/asf/jena/blob/335a7617/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
deleted file mode 100644
index 5f1d36d..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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 org.apache.jena.graph.impl;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.IProducer;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(FileGraphMaker.class)
-public class FileGraphMaker_CS {
-	 
-	protected IProducer<FileGraphMaker> graphProducer;
-	
-	public FileGraphMaker_CS() throws IOException {
-		graphProducer = new FileGraphMakerProducer();
-	}
-
-	@Contract.Inject
-	public final IProducer<FileGraphMaker> getCollectionTestProducer() {
-		return graphProducer;
-	}
-	
-	private static class FileGraphMakerProducer implements IProducer<FileGraphMaker> {
-		private Map<Path,FileGraphMaker> map;
-		
-		public FileGraphMakerProducer () throws IOException {
-			map = new HashMap<Path,FileGraphMaker>();
-		}
-		
-		
-		@Override
-		public FileGraphMaker newInstance() {
-			Path p;
-			try {
-				p = Files.createTempDirectory("fgm_CS");
-			} catch (IOException e) {
-				throw new RuntimeException( "Unable to create temp directory", e );
-			}
-			FileGraphMaker fgm = new FileGraphMaker( p.toString(), true);
-			map.put(p, fgm);
-			return fgm;
-		}
-
-		@Override
-		public void cleanUp() {
-			for (Path p : map.keySet())
-			{
-				map.get(p).close();
-				p.toFile().delete();
-			}
-			map.clear();
-		}
-
-	};
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/335a7617/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
deleted file mode 100644
index 5e0feb4..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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 org.apache.jena.graph.impl;
-
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.IProducer;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(FileGraphTransactionHandler.class)
-public class FileGraphTransactionHandler_CS {
-	 
-	protected IProducer<FileGraphTransactionHandler> graphProducer;
-	
-	public FileGraphTransactionHandler_CS() {
-		graphProducer = new IProducer<FileGraphTransactionHandler>() {
-			
-			private FileGraph_CS.FileGraphProducer fgp = new FileGraph_CS.FileGraphProducer();
-			
-			@Override
-			public FileGraphTransactionHandler newInstance() {
-				return new FileGraphTransactionHandler( fgp.newInstance() );
-			}
-
-			@Override
-			public void cleanUp() {
-				fgp.cleanUp();
-			}
-
-		};
-	}
-
-	@Contract.Inject
-	public final IProducer<FileGraphTransactionHandler> getCollectionTestProducer() {
-		return graphProducer;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/335a7617/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
deleted file mode 100644
index 1b4d321..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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 org.apache.jena.graph.impl;
-
-import static org.apache.jena.testing_framework.GraphHelper.memGraph;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.testing_framework.AbstractGraphProducer;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.IProducer;
-
-//@RunWith(ContractSuite.class)
-//@ContractImpl(FileGraph.class)
-public class FileGraph_CS {
-	 
-	protected IProducer<FileGraph> graphProducer;
-	
-	public FileGraph_CS() {
-		graphProducer = new FileGraphProducer();
-	}
-
-	@Contract.Inject
-	public final IProducer<FileGraph> getCollectionTestProducer() {
-		return graphProducer;
-	}
-	
-	public static class FileGraphProducer extends AbstractGraphProducer<FileGraph> {
-		
-		@Override
-		protected FileGraph createNewGraph() {
-			File f;
-			try {
-				f = File.createTempFile("fgp", ".ttl" );
-				f.delete();
-			} catch (IOException e) {
-				throw new RuntimeException( "Can not create file", e );
-			}
-			return new FileGraph( f, true, true );
-		}
-
-		@Override
-		public Graph[] getDependsOn(Graph d) {
-			return null;
-		}
-
-		@Override
-		public Graph[] getNotDependsOn(Graph g) {
-			return new Graph[] { memGraph() };
-		}
-		
-		@Override
-		protected void afterClose(Graph g) {
-			((FileGraph)g).name.delete();
-		}
-
-	};
-
-}


[17/25] jena git commit: Fixed a merge issue

Posted by cl...@apache.org.
Fixed a merge issue


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/d492e540
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/d492e540
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/d492e540

Branch: refs/heads/master
Commit: d492e540620d52df1e6eb12e7abdaafd847b3991
Parents: b01950b
Author: Claude Warren <cl...@apache.org>
Authored: Sun May 10 17:39:05 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sun May 10 17:39:05 2015 +0100

----------------------------------------------------------------------
 .../test/java/org/apache/jena/graph/GraphContractTest.java   | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/d492e540/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index 16bbc26..bf4ccf2 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -1453,17 +1453,11 @@ public class GraphContractTest<T extends Graph> extends
 	//
 
 	// used to find the object set from the returned set for literal testing
-<<<<<<< HEAD
+
 	private static final Function<Triple, Node> getObject = new Function<Triple, Node>() {
 		@Override
 		public Node apply(Triple t) {
 			return t.getObject();
-=======
-	private static final Map1<Triple, Node> getObject = new Map1<Triple, Node>() {
-		@Override
-		public Node map1(Triple o) {
-			return o.getObject();
->>>>>>> 5bc9578fc31fe58017b80d1a15e41b593ee31074
 		}
 	};
 


[10/25] jena git commit: Added initial contract tests added testing_framework

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/RecordingGraphListener.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/RecordingGraphListener.java b/jena-core/src/test/java/org/apache/jena/graph/RecordingGraphListener.java
new file mode 100644
index 0000000..ed94c8f
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/RecordingGraphListener.java
@@ -0,0 +1,92 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphListener;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.testing_framework.AbstractRecordingListener;
+import org.apache.jena.testing_framework.GraphHelper;
+
+/**
+ * This testing listener records the event names and data, and provides a method
+ * for comparing the actual with the expected history.
+ */
+public class RecordingGraphListener extends AbstractRecordingListener implements
+		GraphListener {
+
+	@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, GraphHelper.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, GraphHelper.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);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
new file mode 100644
index 0000000..d26d7e9
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
@@ -0,0 +1,149 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import static org.junit.Assert.*;
+
+import org.apache.jena.graph.TransactionHandler;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.SimpleTransactionHandler;
+import org.apache.jena.shared.Command;
+import org.apache.jena.shared.JenaException;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.CollectionFactory;
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+/**
+ * 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.
+ */
+@Contract(TransactionHandler.class)
+public class TransactionHandlerContractTest {
+
+	private IProducer<TransactionHandler> producer;
+
+	public TransactionHandlerContractTest() {
+//		producer = new IProducer<TransactionHandler>() {
+//
+//			@Override
+//			public TransactionHandler newInstance() {
+//				return new SimpleTransactionHandler();
+//			}
+//
+//			@Override
+//			public void cleanUp() {
+//
+//			}
+//		};
+	}
+
+	@Contract.Inject
+	public void setProducer(IProducer<TransactionHandler> producer) {
+		this.producer = producer;
+	}
+
+	protected IProducer<TransactionHandler> getTransactionHandlerProducer() {
+		return producer;
+	}
+
+	/**
+	 * Test that Graphs have transaction support methods, and that if they fail
+	 * on some g they fail because they do not support the operation.
+	 */
+	@ContractTest
+	public void testTransactionsExistAsPerTransactionSupported() {
+		Command cmd = new Command() {
+			@Override
+			public Object execute() {
+				return null;
+			}
+		};
+
+		TransactionHandler th = getTransactionHandlerProducer().newInstance();
+
+		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) {
+			}
+		}
+	}
+
+	@ContractTest
+	public void testExecuteInTransactionCatchesThrowable() {
+		TransactionHandler th = getTransactionHandlerProducer().newInstance();
+
+		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; Foo 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));
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/compose/DeltaTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/DeltaTest.java b/jena-core/src/test/java/org/apache/jena/graph/compose/DeltaTest.java
new file mode 100755
index 0000000..a0bf737
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/DeltaTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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 org.apache.jena.graph.compose;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(Delta.class)
+public class DeltaTest  {
+
+	protected IProducer<Delta> graphProducer;
+	
+	public DeltaTest() {
+		super();
+		graphProducer = new AbstractGraphProducer<Delta>() {
+			private Map<Graph, Graph> map = new HashMap<Graph, Graph>();
+
+			@Override
+			protected Delta createNewGraph() {
+				Graph g = memGraph();
+				Delta d = new Delta(g);
+				map.put(d, g);
+				return d;
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+//				Delta dl = (Delta)d;
+//				Graph g = map.get(d);
+//				if (g == null) {
+//					throw new IllegalStateException("graph missing from map");
+//				}
+//				return new Graph[] { g,  (Graph)dl.getL(), (Graph)dl.getR() };
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+			@Override
+			protected void afterClose(Graph g) {
+				map.remove(g);
+			}
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<Delta> getDeltaTestProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testDelta() {
+		Graph x = graphWith(getDeltaTestProducer().newInstance(), "x R y");
+		assertContains("x", "x R y", x);
+		x.delete(triple("x R y"));
+		assertOmits("x", x, "x R y");
+		/* */
+		Graph base = graphWith("x R y; p S q; I like cheese; pins pop balloons");
+		Delta delta = new Delta(base);
+		assertContainsAll("Delta", delta,
+				"x R y; p S q; I like cheese; pins pop balloons");
+		assertContainsAll("Base", base,
+				"x R y; p S q; I like cheese; pins pop balloons");
+		/* */
+		delta.add(triple("pigs fly winglessly"));
+		delta.delete(triple("I like cheese"));
+		/* */
+		assertContainsAll("changed Delta", delta,
+				"x R y; p S q; pins pop balloons; pigs fly winglessly");
+		assertOmits("changed delta", delta, "I like cheese");
+		assertContains("delta additions", "pigs fly winglessly",
+				delta.getAdditions());
+		assertOmits("delta additions", delta.getAdditions(), "I like cheese");
+		assertContains("delta deletions", "I like cheese", delta.getDeletions());
+		assertOmits("delta deletions", delta.getDeletions(),
+				"pigs fly winglessly");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/compose/DifferenceTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/DifferenceTest.java b/jena-core/src/test/java/org/apache/jena/graph/compose/DifferenceTest.java
new file mode 100755
index 0000000..213ae36
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/DifferenceTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 org.apache.jena.graph.compose;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.compose.Difference;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(Difference.class)
+public class DifferenceTest {
+
+	protected IProducer<Difference> graphProducer;
+	
+	public DifferenceTest() {
+		graphProducer = new AbstractGraphProducer<Difference>() {
+			private Map<Graph, Graph[]> map = new HashMap<Graph, Graph[]>();
+
+			@Override
+			protected Difference createNewGraph() {
+				Graph g1 = memGraph();
+				Graph g2 = memGraph();
+				Difference d = new Difference(g1, g2);
+				map.put(d, new Graph[] { g1, g2 });
+				return d;
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				Graph[] dg = map.get(d);
+				if (dg == null) {
+					throw new IllegalStateException("graph not in map");
+				}
+				return dg;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+			@Override
+			protected void afterClose(Graph g) {
+				map.remove(g);
+			}
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<Difference> getDifferenceTestProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testDifference() {
+		Graph g1 = graphWith("x R y; p R q");
+		Graph g2 = graphWith("r Foo s; x R y");
+		Graph d = new Difference(g1, g2);
+		assertOmits("Difference", d, "x R y");
+		assertContains("Difference", "p R q", d);
+		assertOmits("Difference", d, "r Foo s");
+		if (d.size() != 1)
+			fail("oops: size of difference is not 1");
+		d.add(triple("cats eat cheese"));
+		assertContains("Difference.L", "cats eat cheese", g1);
+		assertOmits("Difference.R", g2, "cats eat cheese");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/compose/IntersectionTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/IntersectionTest.java b/jena-core/src/test/java/org/apache/jena/graph/compose/IntersectionTest.java
new file mode 100755
index 0000000..1e6db9b
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/IntersectionTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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 org.apache.jena.graph.compose;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphUtil;
+import org.apache.jena.graph.compose.Intersection;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(Intersection.class)
+public class IntersectionTest {
+
+	protected IProducer<Intersection> graphProducer;
+	
+	public IntersectionTest() {
+		super();
+		graphProducer = new AbstractGraphProducer<Intersection>() {
+			private Map<Graph, Graph[]> dependencyGraph = new HashMap<Graph, Graph[]>();
+
+			@Override
+			protected Intersection createNewGraph() {
+				Graph g1 = memGraph();
+				Graph g2 = memGraph();
+				Intersection retval = new Intersection(g1, g2);
+				dependencyGraph.put(retval, new Graph[] { g1, g2 });
+				return retval;
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph g) {
+				Graph[] dg = dependencyGraph.get(g);
+				if (dg == null) {
+					throw new IllegalStateException("graph missing from map");
+				}
+				return dg;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+			@Override
+			protected void afterClose(Graph g) {
+				dependencyGraph.remove(g);
+			}
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<Intersection> getIntersectionTestProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testIntersection() {
+		Graph g1 = graphWith( "x R y; p R q");
+		Graph g2 = graphWith( "r Foo s; x R y");
+		Intersection i = new Intersection(g1, g2);
+		assertContains("Intersection", "x R y", i);
+		assertOmits("Intersection", i, "p R q");
+		assertOmits("Intersection", i, "r Foo s");
+		if (i.size() != 1)
+			fail("oops: size of intersection is not 1");
+		i.add(triple("cats eat cheese"));
+		assertContains("Intersection.L", "cats eat cheese", g1);
+		assertContains("Intersection.R", "cats eat cheese", g2);
+	}
+
+	@ContractTest
+	public void testDeleteDoesNotUpdateR() {
+		Graph L = graphWith("a pings b; b pings c; c pings a");
+		Graph R = graphWith("c pings a; b pings c; x captures y");
+		Graph join = new Intersection(L, R);
+		GraphUtil.deleteFrom(L, R);
+		assertIsomorphic("R should not change",
+				graphWith("c pings a; b pings c; x captures y"), R);
+		assertIsomorphic(graphWith("a pings b"), L);
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/compose/UnionTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/UnionTest.java b/jena-core/src/test/java/org/apache/jena/graph/compose/UnionTest.java
new file mode 100755
index 0000000..44bf9fb
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/UnionTest.java
@@ -0,0 +1,185 @@
+/*
+ * 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 org.apache.jena.graph.compose;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphStatisticsHandler;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.compose.Union;
+import org.apache.jena.graph.impl.GraphBase;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(Union.class)
+public class UnionTest {
+	
+	protected IProducer<Union> graphProducer;
+	
+	public UnionTest() {
+		graphProducer = new AbstractGraphProducer<Union>() {
+			private Map<Graph, Graph[]> map = new HashMap<Graph, Graph[]>();
+
+			@Override
+			protected Union createNewGraph() {
+				Graph[] g = { memGraph(), memGraph() };
+				Union u = new Union(g[0], g[1]);
+				map.put(u, g);
+				return u;
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				Graph[] dg = map.get(d);
+				if (dg == null) {
+					throw new IllegalStateException("graph not in map");
+				}
+				return dg;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+			@Override
+			protected void afterClose(Graph g) {
+				map.remove(g);
+			}
+		};
+
+	}
+
+	@Contract.Inject
+	public final IProducer<Union> getUnionTestProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testUnion() {
+		Graph g1 = graphWith("x R y; p R q");
+		Graph g2 = graphWith("r Foo s; x R y");
+		Union u = new Union(g1, g2);
+		assertContains("Union", "x R y", u);
+		assertContains("Union", "p R q", u);
+		assertContains("Union", "r Foo s", u);
+		if (u.size() != 3)
+			fail("oops: size of union is not 3");
+		u.add(triple("cats eat cheese"));
+		assertContains("Union", "cats eat cheese", u);
+		if (contains(g1, "cats eat cheese") == false
+				&& contains(g2, "cats eat cheese") == false)
+			fail("oops: neither g1 nor g2 contains `cats eat cheese`");
+	}
+
+	static class AnInteger {
+		public int value = 0;
+
+		public AnInteger(int value) {
+			this.value = value;
+		}
+	}
+
+	@ContractTest
+	public void testUnionValues() {
+		testUnion(0, 0, 0, 0);
+	}
+
+	@ContractTest
+	public void testCopiesSingleNonZeroResult() {
+		testUnion(1, 1, 0, 0);
+		testUnion(1, 0, 1, 0);
+		testUnion(1, 0, 0, 1);
+		testUnion(1, 1, 0, 0);
+		testUnion(2, 0, 2, 0);
+		testUnion(4, 0, 0, 4);
+	}
+
+	@ContractTest
+	public void testResultIsSumOfBaseResults() {
+		testUnion(3, 1, 2, 0);
+		testUnion(5, 1, 0, 4);
+		testUnion(6, 0, 2, 4);
+		testUnion(7, 1, 2, 4);
+		testUnion(3, 0, 2, 1);
+		testUnion(5, 4, 1, 0);
+		testUnion(6, 2, 2, 2);
+		testUnion(7, 6, 0, 1);
+	}
+
+	@ContractTest
+	public void testUnknownOverrulesAll() {
+		testUnion(-1, -1, 0, 0);
+		testUnion(-1, 0, -1, 0);
+		testUnion(-1, 0, 0, -1);
+		testUnion(-1, -1, 1, 1);
+		testUnion(-1, 1, -1, 1);
+		testUnion(-1, 1, 1, -1);
+	}
+
+	/**
+	 * Asserts that the statistic obtained by probing the three-element union
+	 * with statistics <code>av</code>, <code>bv</code>, and <code>cv</code> is
+	 * <code>expected</code>.
+	 */
+	private void testUnion(int expected, int av, int bv, int cv) {
+		AnInteger a = new AnInteger(av), b = new AnInteger(bv), c = new AnInteger(
+				cv);
+		Graph g1 = graphWithGivenStatistic(a);
+		Graph g2 = graphWithGivenStatistic(b);
+		Graph g3 = graphWithGivenStatistic(c);
+		Graph[] graphs = new Graph[] { g1, g2, g3 };
+		MultiUnion mu = new MultiUnion(graphs);
+		GraphStatisticsHandler gs = new MultiUnion.MultiUnionStatisticsHandler(
+				mu);
+		assertEquals(expected, gs.getStatistic(Node.ANY, Node.ANY, Node.ANY));
+	}
+
+	static Graph graphWithGivenStatistic(final AnInteger x) {
+		return new GraphBase() {
+			@Override
+			protected ExtendedIterator<Triple> graphBaseFind(Triple t) {
+				throw new RuntimeException("should never be called");
+			}
+
+			@Override
+			protected GraphStatisticsHandler createStatisticsHandler() {
+				return new GraphStatisticsHandler() {
+					@Override
+					public long getStatistic(Node S, Node P, Node O) {
+						return x.value;
+					}
+				};
+			}
+		};
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
index 3334da7..4d9f40d 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
@@ -18,22 +18,50 @@
 
 package org.apache.jena.graph.impl;
 
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
 import java.util.HashSet;
 
 import org.apache.jena.graph.Graph ;
 import org.apache.jena.graph.Triple ;
 import org.apache.jena.graph.impl.CollectionGraph ;
-import org.apache.jena.graph.test.AbstractTestGraph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
 
-public class TestCollectionGraph extends AbstractTestGraph {
+@RunWith(ContractSuite.class)
+@ContractImpl(CollectionGraph.class)
+public class TestCollectionGraph {
 	 
-	public TestCollectionGraph(String name) {
-		super(name);
+	protected IProducer<CollectionGraph> graphProducer;
+	
+	public TestCollectionGraph() {
+		graphProducer = new AbstractGraphProducer<CollectionGraph>() {
+			
+			@Override
+			protected CollectionGraph createNewGraph() {
+				return new CollectionGraph( new HashSet<Triple>() );
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+		};
 	}
 
-	@Override
-	public Graph getGraph() {
-		return new CollectionGraph( new HashSet<Triple>() );
+	@Contract.Inject
+	public final IProducer<CollectionGraph> getDeltaTestProducer() {
+		return graphProducer;
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
new file mode 100644
index 0000000..7910660
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
@@ -0,0 +1,63 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(WrappedGraph.class)
+public class TestWrappedGraph {
+	 
+	protected IProducer<WrappedGraph> graphProducer;
+	
+	public TestWrappedGraph() {
+		graphProducer = new AbstractGraphProducer<WrappedGraph>() {
+			
+			@Override
+			protected WrappedGraph createNewGraph() {
+				return new WrappedGraph( memGraph() );
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<WrappedGraph> getDeltaTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
new file mode 100644
index 0000000..0b074aa
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
@@ -0,0 +1,176 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import static org.junit.Assert.*;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import org.apache.jena.mem.GraphTripleStore;
+import org.apache.jena.graph.impl.TripleStore;
+import org.apache.jena.testing_framework.ContractTemplate;
+
+import org.xenei.junit.contract.IProducer;
+
+/**
+ * AbstractTestTripleStore - post-hoc tests for TripleStores.
+ */
+
+@Contract(TripleStore.class)
+public class TripleStoreContractTest<T extends TripleStore> extends
+		ContractTemplate<IProducer<T>> {
+
+	protected TripleStore store;
+
+	public TripleStoreContractTest() {
+		IProducer<TripleStore> producer = new IProducer<TripleStore>() {
+
+			@Override
+			public TripleStore newInstance() {
+				return new GraphTripleStore(memGraph());
+			}
+
+			@Override
+			public void cleanUp() {
+				// TODO Auto-generated method stub
+
+			}
+
+		};
+		setProducer((IProducer<T>) producer);
+	}
+
+	/**
+	 * Subclasses must over-ride to return a new empty TripleStore.
+	 */
+	@Contract.Inject
+	public final void setTripleStoreContractTestProducer(IProducer<T> producer) {
+		super.setProducer(producer);
+	}
+
+	@Before
+	public final void beforeAbstractTripleStoreTest() {
+		store = getProducer().newInstance();
+	}
+
+	@After
+	public final void afterAbstractTripleStoreTest() {
+		getProducer().cleanUp();
+	}
+
+	@ContractTest
+	public void testEmpty() {
+		testEmpty(store);
+	}
+
+	@ContractTest
+	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("?? ?? ??"))));
+	}
+
+	@ContractTest
+	public void testListSubjects() {
+		someStatements(store);
+		assertEquals(nodeSet("a x _z r q"), iteratorToSet(store.listSubjects()));
+	}
+
+	@ContractTest
+	public void testListObjects() {
+		someStatements(store);
+		assertEquals(nodeSet("b y i _j _t 17"),
+				iteratorToSet(store.listObjects()));
+	}
+
+	@ContractTest
+	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")));
+	}
+
+	@ContractTest
+	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"))));
+	}
+
+	@ContractTest
+	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")));
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/mem/BunchMapContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/BunchMapContractTest.java b/jena-core/src/test/java/org/apache/jena/mem/BunchMapContractTest.java
new file mode 100644
index 0000000..7807248
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/BunchMapContractTest.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.mem;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+/**
+ * Test triple bunch implementations - NOT YET FINISHED
+ */
+@Contract(BunchMap.class)
+public class BunchMapContractTest {
+	private BunchMap map;
+
+	private IProducer<? extends BunchMap> producer;
+
+	@Contract.Inject
+	public final void setBunchMapProducer(IProducer<? extends BunchMap> producer) {
+		this.producer = producer;
+	}
+
+	protected final IProducer<? extends BunchMap> getBunchMapProducer() {
+		return producer;
+	}
+
+	@Before
+	public final void beforeAbstractBunchMapTest() {
+		map = getBunchMapProducer().newInstance();
+	}
+
+	@After
+	public final void afterAbstractBunchMapTest() {
+		getBunchMapProducer().cleanUp();
+	}
+
+	@ContractTest
+	public void testClear() {
+		for (int i = 0; i < 5; i++) {
+			map.put(i, mock(TripleBunch.class));
+		}
+		assertEquals(5, map.size());
+
+		map.clear();
+		assertEquals(0, map.size());
+	}
+
+	@ContractTest
+	public void testSize() {
+		assertEquals(0, map.size());
+		for (int i = 0; i < 5; i++) {
+			map.put(i, mock(TripleBunch.class));
+			assertEquals(i + 1, map.size());
+		}
+	}
+
+	@ContractTest
+	public void testGet() {
+		List<TripleBunch> lst = new ArrayList<TripleBunch>();
+		for (int i = 0; i < 5; i++) {
+			TripleBunch tb = mock(TripleBunch.class);
+			lst.add(tb);
+			map.put(i, tb);
+		}
+		for (int i = 0; i < 5; i++) {
+			assertEquals(lst.get(i), map.get(i));
+		}
+	}
+
+	@ContractTest
+	public void testPut() {
+		List<TripleBunch> lst = new ArrayList<TripleBunch>();
+		for (int i = 0; i < 5; i++) {
+			map.put(i, mock(TripleBunch.class));
+		}
+		for (int i = 0; i < 5; i++) {
+			TripleBunch tb = mock(TripleBunch.class);
+			lst.add(tb);
+			map.put(i, tb);
+		}
+		for (int i = 0; i < 5; i++) {
+			assertEquals(lst.get(i), map.get(i));
+		}
+	}
+
+	@ContractTest
+	public void testRemove() {
+		List<TripleBunch> lst = new ArrayList<TripleBunch>();
+		for (int i = 0; i < 5; i++) {
+			TripleBunch tb = mock(TripleBunch.class);
+			lst.add(tb);
+			map.put(i, tb);
+		}
+
+		map.remove(0);
+		assertNull(map.get(0));
+		for (int i = 1; i < 5; i++) {
+			assertEquals(lst.get(i), map.get(i));
+		}
+		assertEquals(4, map.size());
+
+		map.remove(2);
+		assertNull(map.get(0));
+		assertEquals(lst.get(1), map.get(1));
+		assertNull(map.get(2));
+		assertEquals(lst.get(3), map.get(3));
+		assertEquals(lst.get(4), map.get(4));
+		assertEquals(3, map.size());
+
+		map.remove(4);
+		assertNull(map.get(0));
+		assertEquals(lst.get(1), map.get(1));
+		assertNull(map.get(2));
+		assertEquals(lst.get(3), map.get(3));
+		assertNull(map.get(4));
+		assertEquals(2, map.size());
+
+	}
+
+	@ContractTest
+	public void testKeyIterator() {
+		List<Integer> lst = new ArrayList<Integer>();
+		for (int i = 0; i < 5; i++) {
+			lst.add(i);
+			map.put(i, mock(TripleBunch.class));
+		}
+		ExtendedIterator<Object> iter = map.keyIterator();
+		while (iter.hasNext()) {
+			assertFalse("List is empty", lst.isEmpty());
+			Integer i = (Integer) iter.next();
+			assertTrue("Missing index: " + i, lst.contains(i));
+			lst.remove(i);
+		}
+		assertTrue("List is not empty", lst.isEmpty());
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java b/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
new file mode 100644
index 0000000..8fed109
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
@@ -0,0 +1,115 @@
+/*
+    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 org.apache.jena.mem;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphStatisticsHandler;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Node_URI;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.JenaException;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphMem.class)
+public class GraphMemTest {
+
+	protected IProducer<GraphMem> graphProducer = new AbstractGraphProducer<GraphMem>() {
+
+		@Override
+		protected GraphMem createNewGraph() {
+			return new GraphMem();
+		}
+
+		@Override
+		public Graph[] getDependsOn(Graph g) {
+			return null;
+		}
+
+		@Override
+		public Graph[] getNotDependsOn(Graph g) {
+			return new Graph[] { memGraph() };
+		}
+
+	};
+
+	@Inject
+	public IProducer<GraphMem> getGraphProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testHasStatistics() {
+		GraphStatisticsHandler h = graphProducer.newInstance()
+				.getStatisticsHandler();
+		assertNotNull(h);
+	}
+
+	@ContractTest
+	public void testContainsConcreteDoesntUseFind() {
+		Graph g = new GraphMemWithoutFind();
+		graphAdd(g, "x P y; a Q b");
+		assertTrue(g.contains(triple("x P y")));
+		assertTrue(g.contains(triple("a Q b")));
+		assertFalse(g.contains(triple("a P y")));
+		assertFalse(g.contains(triple("y R b")));
+	}
+
+	protected final class GraphMemWithoutFind extends GraphMem {
+		@Override
+		public ExtendedIterator<Triple> graphBaseFind(Triple t) {
+			throw new JenaException("find is Not Allowed");
+		}
+	}
+
+	@ContractTest
+	public void testUnnecessaryMatches() {
+		Node special = new Node_URI("eg:foo") {
+			@Override
+			public boolean matches(Node s) {
+				fail("Matched called superfluously.");
+				return true;
+			}
+		};
+		Graph g = graphWith(graphProducer.newInstance(), "x p y");
+		g.add(new Triple(special, special, special));
+		exhaust(g.find(special, Node.ANY, Node.ANY));
+		exhaust(g.find(Node.ANY, special, Node.ANY));
+		exhaust(g.find(Node.ANY, Node.ANY, special));
+
+	}
+
+	protected void exhaust(Iterator<?> it) {
+		while (it.hasNext())
+			it.next();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
new file mode 100644
index 0000000..1f82935
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.mem.GraphTripleStore;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphTripleStore.class)
+public class GraphTripleStoreTest {
+
+	private IProducer<GraphTripleStore> producer = new IProducer<GraphTripleStore>() {
+
+		@Override
+		public GraphTripleStore newInstance() {
+			return new GraphTripleStore(Graph.emptyGraph);
+		}
+
+		@Override
+		public void cleanUp() {
+		}
+
+	};
+
+	@Contract.Inject
+	public IProducer<GraphTripleStore> getTripleStore() {
+		return producer;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/mem/TripleBunchContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/TripleBunchContractTest.java b/jena-core/src/test/java/org/apache/jena/mem/TripleBunchContractTest.java
new file mode 100644
index 0000000..505b57f
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/TripleBunchContractTest.java
@@ -0,0 +1,205 @@
+/*
+ * 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 org.apache.jena.mem;
+
+import static org.junit.Assert.*;
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+import java.util.ArrayList;
+import java.util.ConcurrentModificationException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.Triple;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.testing_framework.NodeCreateUtils;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+/**
+ * Test triple bunch implementations - NOT YET FINISHED
+ */
+@Contract(TripleBunch.class)
+public class TripleBunchContractTest {
+	private IProducer<? extends TripleBunch> producer;
+
+	@Contract.Inject
+	public final void setTripleBunchProducer(
+			IProducer<? extends TripleBunch> producer) {
+		this.producer = producer;
+	}
+
+	protected final IProducer<? extends TripleBunch> getTripleBunchProducer() {
+		return producer;
+	}
+
+	public static final TripleBunch EMPTY_BUNCH = new ArrayBunch();
+
+	protected static final Triple tripleSPO = triple("s P o");
+	protected static final Triple tripleXQY = triple("x Q y");
+
+	private TripleBunch testingBunch;
+
+	@Before
+	public final void beforeAbstractTripleBunchTest() {
+		testingBunch = getTripleBunchProducer().newInstance();
+	}
+
+	@After
+	public final void afterAbstractTripleBunchTest() {
+		getTripleBunchProducer().cleanUp();
+	}
+
+	@ContractTest
+	public void testEmptyBunch() {
+		assertEquals(0, testingBunch.size());
+		assertFalse(testingBunch.contains(tripleSPO));
+		assertFalse(testingBunch.contains(tripleXQY));
+		assertFalse(testingBunch.iterator().hasNext());
+	}
+
+	@ContractTest
+	public void testAddElement() {
+		testingBunch.add(tripleSPO);
+		assertEquals(1, testingBunch.size());
+		assertTrue(testingBunch.contains(tripleSPO));
+		assertEquals(listOf(tripleSPO), iteratorToList(testingBunch.iterator()));
+	}
+
+	@ContractTest
+	public void testAddElements() {
+		testingBunch.add(tripleSPO);
+		testingBunch.add(tripleXQY);
+		assertEquals(2, testingBunch.size());
+		assertTrue(testingBunch.contains(tripleSPO));
+		assertTrue(testingBunch.contains(tripleXQY));
+		assertEquals(setOf(tripleSPO, tripleXQY),
+				iteratorToSet(testingBunch.iterator()));
+	}
+
+	@ContractTest
+	public void testRemoveOnlyElement() {
+		testingBunch.add(tripleSPO);
+		testingBunch.remove(tripleSPO);
+		assertEquals(0, testingBunch.size());
+		assertFalse(testingBunch.contains(tripleSPO));
+		assertFalse(testingBunch.iterator().hasNext());
+	}
+
+	@ContractTest
+	public void testRemoveFirstOfTwo() {
+		testingBunch.add(tripleSPO);
+		testingBunch.add(tripleXQY);
+		testingBunch.remove(tripleSPO);
+		assertEquals(1, testingBunch.size());
+		assertFalse(testingBunch.contains(tripleSPO));
+		assertTrue(testingBunch.contains(tripleXQY));
+		assertEquals(listOf(tripleXQY), iteratorToList(testingBunch.iterator()));
+	}
+
+	@ContractTest
+	public void testTableGrows() {
+		testingBunch.add(tripleSPO);
+		testingBunch.add(tripleXQY);
+		testingBunch.add(triple("a I b"));
+		testingBunch.add(triple("c J d"));
+	}
+
+	@ContractTest
+	public void testIterator() {
+		testingBunch.add(triple("a P b"));
+		testingBunch.add(triple("c Q d"));
+		testingBunch.add(triple("e R f"));
+		assertEquals(tripleSet("a P b; c Q d; e R f"), testingBunch.iterator()
+				.toSet());
+	}
+
+	@ContractTest
+	public void testIteratorRemoveOneItem() {
+		testingBunch.add(triple("a P b"));
+		testingBunch.add(triple("c Q d"));
+		testingBunch.add(triple("e R f"));
+		ExtendedIterator<Triple> it = testingBunch.iterator();
+		while (it.hasNext())
+			if (it.next().equals(triple("c Q d")))
+				it.remove();
+		assertEquals(tripleSet("a P b; e R f"), testingBunch.iterator().toSet());
+	}
+
+	@ContractTest
+	public void testIteratorRemoveAlltems() {
+		testingBunch.add(triple("a P b"));
+		testingBunch.add(triple("c Q d"));
+		testingBunch.add(triple("e R f"));
+		ExtendedIterator<Triple> it = testingBunch.iterator();
+		while (it.hasNext())
+			it.removeNext();
+		assertEquals(tripleSet(""), testingBunch.iterator().toSet());
+	}
+
+	protected List<Triple> listOf(Triple x) {
+		List<Triple> result = new ArrayList<Triple>();
+		result.add(x);
+		return result;
+	}
+
+	protected Set<Triple> setOf(Triple x, Triple y) {
+		Set<Triple> result = setOf(x);
+		result.add(y);
+		return result;
+	}
+
+	protected Set<Triple> setOf(Triple x) {
+		Set<Triple> result = new HashSet<Triple>();
+		result.add(x);
+		return result;
+	}
+
+	public void testAddThenNextThrowsCME() {
+		testingBunch.add(NodeCreateUtils.createTriple("a P b"));
+		testingBunch.add(NodeCreateUtils.createTriple("c Q d"));
+		ExtendedIterator<Triple> it = testingBunch.iterator();
+		it.next();
+		testingBunch.add(NodeCreateUtils.createTriple("change its state"));
+		try {
+			it.next();
+			fail("should have thrown ConcurrentModificationException");
+		} catch (ConcurrentModificationException e) {
+			// expected
+		}
+	}
+
+	public void testDeleteThenNextThrowsCME() {
+		testingBunch.add(NodeCreateUtils.createTriple("a P b"));
+		testingBunch.add(NodeCreateUtils.createTriple("c Q d"));
+		ExtendedIterator<Triple> it = testingBunch.iterator();
+		it.next();
+		testingBunch.remove(NodeCreateUtils.createTriple("a P b"));
+		try {
+			it.next();
+			fail("should have thrown ConcurrentModificationException");
+		} catch (ConcurrentModificationException e) {
+			// expected
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractGraphProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractGraphProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractGraphProducer.java
new file mode 100644
index 0000000..29cf9f0
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractGraphProducer.java
@@ -0,0 +1,104 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xenei.junit.contract.IProducer;
+
+import org.apache.jena.graph.Graph;
+
+/**
+ * An abstract implementation of the GraphProducerInterface.
+ * 
+ * This class handles tracking of the created graphs and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the graph is closed.
+ * 
+ */
+public abstract class AbstractGraphProducer<T extends Graph> implements
+		IProducer<T> {
+
+	/**
+	 * The list of graphs that have been opened in this test.
+	 */
+	protected List<Graph> graphList = new ArrayList<Graph>();
+
+	/**
+	 * The method to create a new graph.
+	 * 
+	 * @return a newly constructed graph of type under test.
+	 */
+	abstract protected T createNewGraph();
+
+	@Override
+	final public T newInstance() {
+		T retval = createNewGraph();
+		graphList.add(retval);
+		return retval;
+	}
+
+	/**
+	 * Method called after the graph is closed. This allows the implementer to
+	 * perform extra cleanup activities, like deleting the file associated with
+	 * a file based graph.
+	 * <p>
+	 * By default this does nothing.
+	 * </p>
+	 * 
+	 * @param g
+	 *            The graph that is closed
+	 */
+	protected void afterClose(Graph g) {
+	};
+
+	@Override
+	final public void cleanUp() {
+		for (Graph g : graphList) {
+			if (!g.isClosed()) {
+				g.close();
+			}
+			afterClose(g);
+		}
+		graphList.clear();
+	}
+
+	/**
+	 * Get a list of graphs that the created graph is dependent upon. The graph
+	 * must return true for each call to dependsOn() with one of the returned
+	 * graphs. Method may return null to disable the check.
+	 * 
+	 * @param g
+	 *            The graph we are looking for.
+	 * @return
+	 */
+	public abstract Graph[] getDependsOn(Graph g);
+
+	/**
+	 * Get a list of graphs that the created graph is not dependent upon. The
+	 * graph must return false for each call to dependsOn() with one of the
+	 * returned graphs. Method may return null to disable the check.
+	 * 
+	 * @param g
+	 *            The graph we are looking for.
+	 * @return
+	 */
+	public abstract Graph[] getNotDependsOn(Graph g);
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractInfModelProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractInfModelProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractInfModelProducer.java
new file mode 100644
index 0000000..898503d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractInfModelProducer.java
@@ -0,0 +1,91 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.apache.jena.rdf.model.InfModel;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.reasoner.Reasoner;
+
+/**
+ * An abstract implementation of the ModelProducerInterface.
+ * 
+ * This class handles tracking of the created models and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the model is closed.
+ * 
+ */
+public abstract class AbstractInfModelProducer<T extends InfModel> extends
+		AbstractModelProducer<T> {
+
+	
+	public boolean canBeEmpty( Model m ) 
+	{
+		return false;
+	}
+	/**
+	 * @return true if the models returned by this poducer are independent,
+	 *         false otherwise.
+	 * 
+	 */
+	abstract public Reasoner getReasoner();
+
+	/**
+	 * Returns the model that was used in the reasoner.bind() call.
+	 * 
+	 * @return
+	 */
+	abstract public Model getBoundModel();
+
+	/**
+	 * Populate the model with test data for the derivation test.
+	 * 
+	 * @param model
+	 */
+	abstract public void populateModel(InfModel model);
+
+	/**
+	 * Using the reasoner and the populated model, this statement should return
+	 * a derivation iterator when getDerivation() is called.
+	 * 
+	 * This is not a complete test but a simple test to show that the system
+	 * works in this specific case. A complete set of tests is left for later
+	 * development.
+	 * 
+	 * @return The Statement that should have at least one derivation.
+	 */
+	abstract public Statement getDerivationStatement();
+
+	/**
+	 * Using the reasoner and the populated model, this statement should return
+	 * an EMPTY derivation iterator when getDerivation() is called.
+	 * 
+	 * This is not a complete test but a simple test to show that the system
+	 * works in this specific case. A complete set of tests is left for later
+	 * development.
+	 * 
+	 * @return The Statement that should have no derivations.
+	 */
+	abstract public Statement getNoDerivationStatement();
+
+	/**
+	 * @return true if the InfModel supports the getDeductionsModel() call.
+	 */
+	abstract public boolean supportsDeductionsModel();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractModelProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractModelProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractModelProducer.java
new file mode 100644
index 0000000..882e9d3
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractModelProducer.java
@@ -0,0 +1,88 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.rdf.model.Model;
+
+/**
+ * An abstract implementation of the ModelProducerInterface.
+ * 
+ * This class handles tracking of the created models and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the model is closed.
+ * 
+ */
+public abstract class AbstractModelProducer<T extends Model> implements
+		IProducer<T> {
+
+	/**
+	 * The list of graphs that have been opened in this test.
+	 */
+	protected List<Model> modelList = new ArrayList<Model>();
+
+	/**
+	 * @return true if the models returned by this poducer are independent,
+	 *         false otherwise.
+	 * 
+	 */
+	abstract public boolean areIndependent();
+
+	/**
+	 * The method to create a new model.
+	 * 
+	 * @return a newly constructed model of type under test.
+	 */
+	abstract protected T createNewModel();
+
+	@Override
+	final public T newInstance() {
+		T retval = createNewModel();
+		modelList.add(retval);
+		return retval;
+	}
+
+	/**
+	 * Method called after the graph is closed. This allows the implementer to
+	 * perform extra cleanup activities, like deleting the file associated with
+	 * a file based graph.
+	 * <p>
+	 * By default this does nothing.
+	 * </p>
+	 * 
+	 * @param g
+	 *            The graph that is closed
+	 */
+	protected void afterClose(T g) {
+	};
+
+	@Override
+	final public void cleanUp() {
+		for (Model m : modelList) {
+			if (!m.isClosed()) {
+				m.close();
+			}
+			afterClose((T) m);
+		}
+		modelList.clear();
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractRecordingListener.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractRecordingListener.java b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractRecordingListener.java
new file mode 100644
index 0000000..e9e26a1
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractRecordingListener.java
@@ -0,0 +1,190 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.Assert;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Statement;
+
+/**
+ * This testing listener records the event names and data, and provides a method
+ * for comparing the actual with the expected history.
+ */
+public class AbstractRecordingListener {
+
+	@SuppressWarnings("unchecked")
+	public static boolean checkEquality(final Object o1, final Object o2) {
+		if (o1 == o2) {
+			return true;
+		}
+		if (o1.getClass().isArray() && o2.getClass().isArray()) {
+			final Object[] o1a = (Object[]) o1;
+			final Object[] o2a = (Object[]) o2;
+
+			if (o1a.length == o2a.length) {
+				for (int i = 0; i < o1a.length; i++) {
+					if (!checkEquality(o1a[i], o2a[i])) {
+						return false;
+					}
+				}
+				return true;
+			}
+			return false;
+		} else if ((o1 instanceof Collection<?>)
+				&& (o2 instanceof Collection<?>)) {
+			return checkEquality(((Collection<Object>) o1).toArray(),
+					((Collection<Object>) o2).toArray());
+
+		} else if ((o1 instanceof Model) && (o2 instanceof Model)) {
+			return checkEquality(((Model) o1).listStatements().toList(),
+					((Model) o2).listStatements().toList());
+
+		} else if ((o1 instanceof Statement) && (o2 instanceof Statement)) {
+			return checkEquality(((Statement) o1).asTriple(),
+					((Statement) o2).asTriple());
+
+		} else {
+			return o1.equals(o2);
+		}
+	}
+
+	private List<Object> history = new ArrayList<Object>();
+
+	protected final void record(String tag, Object x, Object y) {
+		history.add(tag);
+		history.add(x);
+		history.add(y);
+	}
+
+	protected final void record(String tag, Object info) {
+		history.add(tag);
+		history.add(info);
+	}
+
+	public final int differ(Object... things) {
+		for (int i = 0; i < history.size(); i++) {
+			if (!things[i].equals(history.get(i))) {
+				return i;
+			}
+		}
+		return -1;
+	}
+
+	public final boolean has(Object... things) {
+		return history.equals(Arrays.asList(things));
+	}
+
+	public final void assertHas(Object... things) {
+		if (has(things) == false) {
+			int idx = differ(things);
+			Assert.fail("expected " + Arrays.asList(things) + " but got "
+					+ history + " differ at position " + idx);
+		}
+	}
+
+	public final void assertEmpty() {
+		if (history.size() > 0) {
+			Assert.fail("Should be no history but got " + history);
+		}
+	}
+
+	public final int size() {
+		return history.size();
+	}
+
+	public final boolean has(List<?> things) {
+		return history.equals(things);
+	}
+
+	public final boolean hasStart(List<Object> L) {
+		return L.size() <= history.size()
+				&& L.equals(history.subList(0, L.size()));
+	}
+
+	public final boolean hasEnd(List<Object> L) {
+		return L.size() <= history.size()
+				&& L.equals(history.subList(history.size() - L.size(),
+						history.size()));
+	}
+
+	public final void assertHas(List<?> things) {
+		if (has(things) == false)
+			Assert.fail("expected " + things + " but got " + history);
+	}
+
+	public final void assertContains(Object... things) {
+		if (contains(things) == false)
+			Assert.fail(String.format("expected %s but got %s",
+					Arrays.asList(things), history));
+	}
+
+	public final void assertHasStart(Object... start) {
+		List<Object> L = Arrays.asList(start);
+		if (hasStart(L) == false)
+			Assert.fail("expected " + L + " at the beginning of " + history);
+	}
+
+	public final void assertHasEnd(Object... end) {
+		List<Object> L = Arrays.asList(end);
+		if (hasEnd(L) == false)
+			Assert.fail("expected " + L + " at the end of " + history);
+	}
+
+	public final void clear() {
+		history.clear();
+	}
+
+	public final boolean contains(Object... objects) {
+		for (int i = 0; i < history.size(); i++) {
+			if (history.get(i).equals(objects[0])) {
+				boolean found = true;
+				for (int j = 1; j < objects.length; j++) {
+					if (i + j >= history.size()) {
+						found = false;
+						break;
+					}
+					if (!history.get(i + j).equals(objects[j])) {
+						found = false;
+						break;
+					}
+				}
+				if (found) {
+					return true;
+				}
+			}
+
+		}
+		return false;
+
+	}
+
+	public final Iterator<Object> from(Object start) {
+		Iterator<Object> iter = history.iterator();
+		while (iter.hasNext() && !iter.next().equals(start))
+			; // loop
+		return iter;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java b/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
new file mode 100644
index 0000000..f7a16e5
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
@@ -0,0 +1,17 @@
+package org.apache.jena.testing_framework;
+
+import org.xenei.junit.contract.IProducer;
+
+public class ContractTemplate<P extends IProducer<?>> {
+
+	private P producer;
+
+	public final void setProducer(P producer) {
+		this.producer = producer;
+	}
+
+	protected final P getProducer() {
+		return producer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphEventManagerProducerInterface.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphEventManagerProducerInterface.java b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphEventManagerProducerInterface.java
new file mode 100644
index 0000000..70e8182
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphEventManagerProducerInterface.java
@@ -0,0 +1,35 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.apache.jena.graph.GraphEventManager;
+
+/**
+ * Foo producer for GraphEventManager testing.
+ * 
+ */
+public interface GraphEventManagerProducerInterface {
+
+	/**
+	 * Returns a GraphEventManager to take part in the test. Must be overridden
+	 * in a subclass.
+	 * 
+	 * @return The GraphEventManager implementation to test.
+	 */
+	public abstract GraphEventManager newEventManager();
+}


[07/25] jena git commit: file graph test

Posted by cl...@apache.org.
file graph test


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/5bc9578f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/5bc9578f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/5bc9578f

Branch: refs/heads/master
Commit: 5bc9578fc31fe58017b80d1a15e41b593ee31074
Parents: f97d604
Author: Claude Warren <cl...@apache.org>
Authored: Thu Apr 30 18:17:33 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Thu Apr 30 18:17:33 2015 +0100

----------------------------------------------------------------------
 .../test/java/org/apache/jena/graph/impl/FileGraph_CS.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/5bc9578f/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
index b7bb6c3..1b4d321 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
@@ -30,8 +30,8 @@ import org.xenei.junit.contract.ContractImpl;
 import org.xenei.junit.contract.ContractSuite;
 import org.xenei.junit.contract.IProducer;
 
-@RunWith(ContractSuite.class)
-@ContractImpl(FileGraph.class)
+//@RunWith(ContractSuite.class)
+//@ContractImpl(FileGraph.class)
 public class FileGraph_CS {
 	 
 	protected IProducer<FileGraph> graphProducer;
@@ -52,10 +52,11 @@ public class FileGraph_CS {
 			File f;
 			try {
 				f = File.createTempFile("fgp", ".ttl" );
+				f.delete();
 			} catch (IOException e) {
 				throw new RuntimeException( "Can not create file", e );
 			}
-			return new FileGraph( f, false, true );
+			return new FileGraph( f, true, true );
 		}
 
 		@Override


[14/25] jena git commit: file graph test

Posted by cl...@apache.org.
file graph test


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/c004d800
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/c004d800
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/c004d800

Branch: refs/heads/master
Commit: c004d800faa51284954ec353f3266bff6cf7fe67
Parents: 608c2b4
Author: Claude Warren <cl...@apache.org>
Authored: Thu Apr 30 18:17:33 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 9 16:15:32 2015 +0100

----------------------------------------------------------------------
 .../test/java/org/apache/jena/graph/impl/FileGraph_CS.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/c004d800/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
index b7bb6c3..1b4d321 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
@@ -30,8 +30,8 @@ import org.xenei.junit.contract.ContractImpl;
 import org.xenei.junit.contract.ContractSuite;
 import org.xenei.junit.contract.IProducer;
 
-@RunWith(ContractSuite.class)
-@ContractImpl(FileGraph.class)
+//@RunWith(ContractSuite.class)
+//@ContractImpl(FileGraph.class)
 public class FileGraph_CS {
 	 
 	protected IProducer<FileGraph> graphProducer;
@@ -52,10 +52,11 @@ public class FileGraph_CS {
 			File f;
 			try {
 				f = File.createTempFile("fgp", ".ttl" );
+				f.delete();
 			} catch (IOException e) {
 				throw new RuntimeException( "Can not create file", e );
 			}
-			return new FileGraph( f, false, true );
+			return new FileGraph( f, true, true );
 		}
 
 		@Override


[11/25] jena git commit: Added initial contract tests added testing_framework

Posted by cl...@apache.org.
Added initial contract tests
added testing_framework


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/b293ee8a
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/b293ee8a
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/b293ee8a

Branch: refs/heads/master
Commit: b293ee8a928fc8a4f84810f41f3235e5a547c23b
Parents: eb7760d
Author: Claude Warren <cl...@apache.org>
Authored: Sun Apr 26 20:41:15 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 9 15:27:19 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml                               |   14 +
 .../apache/jena/graph/GraphContractTest.java    | 1720 ++++++++++++++++++
 .../graph/GraphEventManagerContractTest.java    |  514 ++++++
 .../jena/graph/GraphMakerContractTest.java      |  314 ++++
 .../graph/GraphWithPerformContractTest.java     |   86 +
 .../jena/graph/RecordingGraphListener.java      |   92 +
 .../graph/TransactionHandlerContractTest.java   |  149 ++
 .../apache/jena/graph/compose/DeltaTest.java    |  110 ++
 .../jena/graph/compose/DifferenceTest.java      |   97 +
 .../jena/graph/compose/IntersectionTest.java    |  109 ++
 .../apache/jena/graph/compose/UnionTest.java    |  185 ++
 .../jena/graph/impl/TestCollectionGraph.java    |   42 +-
 .../jena/graph/impl/TestWrappedGraph.java       |   63 +
 .../graph/impl/TripleStoreContractTest.java     |  176 ++
 .../apache/jena/mem/BunchMapContractTest.java   |  163 ++
 .../java/org/apache/jena/mem/GraphMemTest.java  |  115 ++
 .../apache/jena/mem/GraphTripleStoreTest.java   |   51 +
 .../jena/mem/TripleBunchContractTest.java       |  205 +++
 .../AbstractGraphProducer.java                  |  104 ++
 .../AbstractInfModelProducer.java               |   91 +
 .../AbstractModelProducer.java                  |   88 +
 .../AbstractRecordingListener.java              |  190 ++
 .../testing_framework/ContractTemplate.java     |   17 +
 .../GraphEventManagerProducerInterface.java     |   35 +
 .../jena/testing_framework/GraphHelper.java     |  508 ++++++
 .../GraphProducerInterface.java                 |   41 +
 .../testing_framework/IContainerProducer.java   |   19 +
 .../testing_framework/IIteratorProducer.java    |   42 +
 .../jena/testing_framework/INodeProducer.java   |   39 +
 .../testing_framework/IResourceProducer.java    |   10 +
 .../testing_framework/IStatementProducer.java   |   45 +
 .../testing_framework/ITripleStoreProducer.java |   35 +
 .../jena/testing_framework/ModelHelper.java     |  409 +++++
 .../jena/testing_framework/NodeCreateUtils.java |  177 ++
 .../NodeProducerInterface.java                  |   32 +
 .../jena/testing_framework/TestFileData.java    |  380 ++++
 .../jena/testing_framework/TestUtils.java       |  320 ++++
 .../testing_framework/manifest/Manifest.java    |  228 +++
 .../manifest/ManifestException.java             |   48 +
 .../manifest/ManifestFile.java                  |   38 +
 .../manifest/ManifestItem.java                  |   53 +
 .../manifest/ManifestItemHandler.java           |   35 +
 .../manifest/ManifestSuite.java                 |  143 ++
 .../manifest/ManifestTest.java                  |   13 +
 .../manifest/ManifestTestRunner.java            |   75 +
 .../jena/testing_framework/package-info.java    |  109 ++
 .../testing_framework/tuples/TupleItem.java     |   84 +
 .../jena/testing_framework/tuples/TupleSet.java |  274 +++
 48 files changed, 7880 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index 6cb0722..a29e559 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -75,6 +75,20 @@
       <scope>test</scope>
     </dependency>
 
+	<dependency>
+		<groupId>org.xenei</groupId>
+		<artifactId>junit-contracts</artifactId>
+		<version>0.0.5</version>
+		<scope>test</scope>
+	</dependency>
+	
+	<dependency>
+		<groupId>org.mockito</groupId>
+		<artifactId>mockito-all</artifactId>
+		<version>1.9.5</version>
+		<scope>test</scope>
+	</dependency>
+
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
new file mode 100644
index 0000000..cf79da5
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -0,0 +1,1720 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import org.junit.After;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import static org.junit.Assert.*;
+
+import org.apache.jena.graph.Capabilities;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphStatisticsHandler;
+import org.apache.jena.graph.GraphUtil;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.LiteralLabelFactory;
+import org.apache.jena.mem.TrackingTripleIterator;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.impl.ReifierStd;
+import org.apache.jena.shared.ClosedException;
+import org.apache.jena.shared.DeleteDeniedException;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.apache.jena.testing_framework.ContractTemplate;
+import org.apache.jena.testing_framework.NodeCreateUtils;
+import org.apache.jena.util.iterator.ClosableIterator;
+import org.apache.jena.util.iterator.ExtendedIterator;
+import org.apache.jena.util.iterator.Map1;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+/**
+ * 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.
+ */
+@Contract(Graph.class)
+public class GraphContractTest<T extends Graph> extends
+		ContractTemplate<AbstractGraphProducer<T>> {
+
+	private static final Logger LOG = LoggerFactory
+			.getLogger(GraphContractTest.class);
+
+	protected RecordingGraphListener GL = new RecordingGraphListener();
+
+	@Contract.Inject
+	public final void setGraphContractTestProducer(
+			AbstractGraphProducer<T> graphProducer) {
+		super.setProducer(graphProducer);
+	}
+
+	@After
+	public final void afterGraphContractTest() {
+		getProducer().cleanUp();
+		GL.clear();
+	}
+
+	@ContractTest
+	public void testAdd_Triple() {
+		Graph graph = getProducer().newInstance();
+		graph.getEventManager().register(GL);
+		txnBegin(graph);
+		graph.add(triple("S P O"));
+		txnCommit(graph);
+		GL.assertHasStart("add", graph, triple("S P O"));
+		assertTrue("Graph should contain <S P O>",
+				graph.contains(triple("S P O")));
+	}
+
+	/**
+	 * Inference graphs can not be truly empty.
+	 * 
+	 * @param g
+	 * @param b
+	 */
+	private void assertEmpty(Graph g, Graph b) {
+		if (b.isEmpty()) {
+			assertTrue("Graph should be empty", g.isEmpty());
+		} else {
+			assertEquals("Graph should be in base state", b.find(Triple.ANY)
+					.toList(), g.find(Triple.ANY).toList());
+		}
+	}
+
+	/**
+	 * Inference graphs can not be truly empty
+	 * 
+	 * @param g
+	 * @param b
+	 */
+	private void assertNotEmpty(Graph g, Graph b) {
+		if (b.isEmpty()) {
+			assertFalse("Graph not should be empty", g.isEmpty());
+		} else {
+			assertNotEquals("Graph should not be in base state",
+					b.find(Triple.ANY).toList(), g.find(Triple.ANY).toList());
+		}
+	}
+
+	/**
+	 * Test that clear works, in the presence of inferencing graphs that mean
+	 * emptyness isn't available. This is why we go round the houses and test
+	 * that expected ~= initialContent + addedStuff - removed - initialContent.
+	 */
+	@ContractTest
+	public void testClear() {
+		Graph graph = getProducer().newInstance();
+		Graph base = copy(graph);
+
+		graph.getEventManager().register(GL);
+		txnBegin(graph);
+		graph.clear();
+		txnCommit(graph);
+		assertEmpty(graph, base);
+		GL.assertHasStart("someEvent", graph, GraphEvents.removeAll);
+		GL.clear();
+
+		// test after adding
+		graph = graphWith(getProducer().newInstance(),
+				"S P O; S e:ff 27; _1 P P3; S4 P4 'en'");
+		graph.getEventManager().register(GL);
+		txnBegin(graph);
+		graph.clear();
+		txnCommit(graph);
+		assertEmpty(graph, base);
+		if (GL.contains("delete")) {
+			// deletes are listed -- ensure all deletes are listed
+			GL.assertContains("delete", graph, triple("S P O"));
+			GL.assertContains("delete", graph, triple("S e:ff 27"));
+			GL.assertContains("delete", graph, triple("_1 P P3"));
+			GL.assertContains("delete", graph, triple("S4 P4 'en'"));
+		}
+		GL.assertHasEnd("someEvent", graph, GraphEvents.removeAll);
+		GL.clear();
+
+	}
+
+	@ContractTest
+	public void testClose() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S P2 O2; S3 P P3");
+		graph.getEventManager().register(GL);
+		assertFalse("Graph was constructed closed", graph.isClosed());
+
+		graph.close();
+		assertTrue("Graph should be closed", graph.isClosed());
+
+		// exception may be thrown on begin or on execution.
+		try {
+			txnBegin(graph);
+			try {
+				graph.add(triple("S P O"));
+				fail("added when closed");
+			} catch (Exception expected) {
+				GL.assertEmpty();
+				// expected
+			} finally {
+				txnRollback(graph);
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.delete(triple("x R y"));
+				fail("delete when closed");
+			} catch (ClosedException c) {
+				// Expected
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+
+			try {
+				graph.add(triple("x R y"));
+				fail("add when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.contains(triple("x R y"));
+				fail("contains[triple] when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.contains(Node.ANY, Node.ANY, Node.ANY);
+				fail("contains[SPO] when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.find(triple("x R y"));
+				fail("find [triple] when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.find(Node.ANY, Node.ANY, Node.ANY);
+				fail("find[SPO] when closed");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+
+		try {
+			txnBegin(graph);
+			try {
+				graph.size();
+				fail("size when closed (" + this.getClass() + ")");
+			} catch (ClosedException c) { /* as required */
+			} finally {
+				txnRollback(graph);
+				GL.assertEmpty();
+			}
+		} catch (Exception expected) {
+			GL.assertEmpty();
+			// expected
+		}
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+
+		assertTrue(graph.contains(node("S"), node("P"), node("O")));
+		assertFalse(graph.contains(node("S"), node("P"), node("O2")));
+		assertFalse(graph.contains(node("S"), node("P2"), node("O")));
+		assertFalse(graph.contains(node("S2"), node("P"), node("O")));
+		assertTrue(graph.contains(Node.ANY, Node.ANY, Node.ANY));
+		assertTrue(graph.contains(Node.ANY, Node.ANY, node("O")));
+		assertTrue(graph.contains(Node.ANY, node("P"), Node.ANY));
+		assertTrue(graph.contains(node("S"), Node.ANY, Node.ANY));
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node_RepeatedSubjectDoesNotConceal() {
+
+		Graph g = graphWith(getProducer().newInstance(), "s P o; s Q r");
+		Node s = node("s");
+		Node P = node("P");
+		Node o = node("o");
+		Node Q = node("Q");
+		Node r = node("r");
+		Node any = node("??");
+		assertTrue(g.contains(s, P, o));
+		assertTrue(g.contains(s, Q, r));
+		assertTrue(g.contains(any, P, o));
+		assertTrue(g.contains(any, Q, r));
+		assertTrue(g.contains(any, P, any));
+		assertTrue(g.contains(any, Q, any));
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node_ByValue() {
+		Node x = node("x");
+		Node P = node("P");
+		if (getProducer().newInstance().getCapabilities()
+				.handlesLiteralTyping()) {
+			Graph g1 = graphWith(getProducer().newInstance(),
+					"x P '1'xsd:integer");
+			assertTrue(
+					String.format(
+							"literal type equality failed, does %s really implement literal typing",
+							g1.getClass()), g1.contains(x, P,
+							node("'01'xsd:int")));
+			//
+			Graph g2 = graphWith(getProducer().newInstance(), "x P '1'xsd:int");
+			assertTrue("Literal equality with '1'xsd:integer failed",
+					g2.contains(x, P, node("'1'xsd:integer")));
+			//
+			Graph g3 = graphWith(getProducer().newInstance(),
+					"x P '123'xsd:string");
+			assertTrue("Literal equality with '123' failed",
+					g3.contains(x, P, node("'123'")));
+		}
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node_Concrete() {
+		Node s = node("s");
+		Node P = node("P");
+		Node o = node("o");
+
+		Node _x = node("_x");
+		Node _R = node("_R");
+		Node _y = node("_y");
+
+		Node x = node("x");
+		Node S = node("S");
+
+		Graph g = graphWith(getProducer().newInstance(),
+				"s P o; _x _R _y; x S 0");
+		assertTrue("Graph should have contained s P o", g.contains(s, P, o));
+		assertTrue("Graph should have contained _x _R _y",
+				g.contains(_x, _R, _y));
+		assertTrue("Graph should have contained x S 'O'",
+				g.contains(x, S, node("0")));
+		/* */
+		assertFalse(g.contains(s, P, node("Oh")));
+		assertFalse(g.contains(S, P, node("O")));
+		assertFalse(g.contains(s, node("p"), o));
+		assertFalse(g.contains(_x, node("_r"), _y));
+		assertFalse(g.contains(x, S, node("1")));
+	}
+
+	@ContractTest
+	public void testContains_Node_Node_Node_Fluid() {
+		Node x = node("x");
+		Node R = node("R");
+		Node P = node("P");
+		Node y = node("y");
+		Node a = node("a");
+		Node b = node("b");
+		Graph g = graphWith(getProducer().newInstance(), "x R y; a P b");
+		assertTrue(g.contains(Node.ANY, R, y));
+		assertTrue(g.contains(x, Node.ANY, y));
+		assertTrue(g.contains(x, R, Node.ANY));
+		assertTrue(g.contains(Node.ANY, P, b));
+		assertTrue(g.contains(a, Node.ANY, b));
+		assertTrue(g.contains(a, P, Node.ANY));
+		assertTrue(g.contains(Node.ANY, R, y));
+		/* */
+		assertFalse(g.contains(Node.ANY, R, b));
+		assertFalse(g.contains(a, Node.ANY, y));
+		assertFalse(g.contains(x, P, Node.ANY));
+		assertFalse(g.contains(Node.ANY, R, x));
+		assertFalse(g.contains(x, Node.ANY, R));
+		assertFalse(g.contains(a, node("S"), Node.ANY));
+	}
+
+	@ContractTest
+	public void testContains_Triple() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+
+		assertTrue(graph.contains(triple("S P O")));
+		assertFalse(graph.contains(triple("S P O2")));
+		assertFalse(graph.contains(triple("S P2 O")));
+		assertFalse(graph.contains(triple("S2 P O")));
+		assertTrue(graph.contains(Triple.ANY));
+		assertTrue(graph.contains(new Triple(Node.ANY, Node.ANY, node("O"))));
+		assertTrue(graph.contains(new Triple(Node.ANY, node("P"), Node.ANY)));
+		assertTrue(graph.contains(new Triple(node("S"), Node.ANY, Node.ANY)));
+
+	}
+
+	@ContractTest
+	public void testContains_Triple_RepeatedSubjectDoesNotConceal() {
+
+		Graph g = graphWith(getProducer().newInstance(), "s P o; s Q r");
+		assertTrue(g.contains(triple("s P o")));
+		assertTrue(g.contains(triple("s Q r")));
+		assertTrue(g.contains(triple("?? P o")));
+		assertTrue(g.contains(triple("?? Q r")));
+		assertTrue(g.contains(triple("?? P ??")));
+		assertTrue(g.contains(triple("?? Q ??")));
+	}
+
+	@ContractTest
+	public void testContains_Triple_ByValue() {
+
+		if (getProducer().newInstance().getCapabilities()
+				.handlesLiteralTyping()) {
+			Graph g1 = graphWith(getProducer().newInstance(),
+					"x P '1'xsd:integer");
+			assertTrue(
+					String.format(
+							"did not find x P '01'xsd:int, does %s really implement literal typing",
+							g1.getClass()),
+					g1.contains(triple("x P '01'xsd:int")));
+			//
+			Graph g2 = graphWith(getProducer().newInstance(), "x P '1'xsd:int");
+			assertTrue("did not find x P '1'xsd:integer",
+					g2.contains(triple("x P '1'xsd:integer")));
+			//
+			Graph g3 = graphWith(getProducer().newInstance(),
+					"x P '123'xsd:string");
+			assertTrue("did not find x P '123'xsd:string",
+					g3.contains(triple("x P '123'")));
+		}
+	}
+
+	@ContractTest
+	public void testContains_Triple_Concrete() {
+		Graph g = graphWith(getProducer().newInstance(),
+				"s P o; _x _R _y; x S 0");
+		assertTrue(g.contains(triple("s P o")));
+		assertTrue(g.contains(triple("_x _R _y")));
+		assertTrue(g.contains(triple("x S 0")));
+		/* */
+		assertFalse(g.contains(triple("s P Oh")));
+		assertFalse(g.contains(triple("S P O")));
+		assertFalse(g.contains(triple("s p o")));
+		assertFalse(g.contains(triple("_x _r _y")));
+		assertFalse(g.contains(triple("x S 1")));
+	}
+
+	@ContractTest
+	public void testContains_Triple_Fluid() {
+		Graph g = graphWith(getProducer().newInstance(), "x R y; a P b");
+		assertTrue(g.contains(triple("?? R y")));
+		assertTrue(g.contains(triple("x ?? y")));
+		assertTrue(g.contains(triple("x R ??")));
+		assertTrue(g.contains(triple("?? P b")));
+		assertTrue(g.contains(triple("a ?? b")));
+		assertTrue(g.contains(triple("a P ??")));
+		assertTrue(g.contains(triple("?? R y")));
+		/* */
+		assertFalse(g.contains(triple("?? R b")));
+		assertFalse(g.contains(triple("a ?? y")));
+		assertFalse(g.contains(triple("x P ??")));
+		assertFalse(g.contains(triple("?? R x")));
+		assertFalse(g.contains(triple("x ?? R")));
+		assertFalse(g.contains(triple("a S ??")));
+	}
+
+	/**
+	 * Inference graphs can not be empty
+	 */
+	@ContractTest
+	public void testDelete_Triple() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+		Graph base = getProducer().newInstance();
+		graph.getEventManager().register(GL);
+		txnBegin(graph);
+		graph.delete(triple("S P O"));
+		txnCommit(graph);
+		GL.assertContains("delete", graph, triple("S P O"));
+		assertFalse("Graph should not contain <S P O>",
+				graph.contains(triple("S P O")));
+		assertNotEmpty(graph, base);
+		assertTrue("Graph should contain <S2 P2 O2>",
+				graph.contains(triple("S2 P2 O2")));
+		assertTrue("Graph should contain <S3 P3 O3>",
+				graph.contains(triple("S3 P3 O3")));
+
+		// should not modify anything on wildcard delete
+		GL.clear();
+		try {
+			txnBegin(graph);
+			graph.delete(new Triple(node("S2"), node("P2"), Node.ANY));
+			txnCommit(graph);
+		} catch (DeleteDeniedException expected) {
+			txnRollback(graph);
+		}
+		assertTrue("Graph should contain <S2 P2 O2>",
+				graph.contains(triple("S2 P2 O2")));
+		assertTrue("Graph should contain <S3 P3 O3>",
+				graph.contains(triple("S3 P3 O3")));
+		GL.assertHas("delete", graph, new Triple(node("S2"), node("P2"),
+				Node.ANY));
+	}
+
+	@ContractTest
+	public void testDelete_Triple_FromNothing() {
+		Graph g = getProducer().newInstance();
+		g.getEventManager().register(GL);
+		txnBegin(g);
+		g.delete(triple("quint rdf:subject S"));
+		txnCommit(g);
+		GL.assertContains("delete", g, triple("quint rdf:subject S"));
+	}
+
+	@ContractTest
+	public void testDependsOn() {
+		Graph g = getProducer().newInstance();
+		Graph[] depGraphs = getProducer().getDependsOn(g);
+		if (depGraphs != null) {
+			for (Graph dg : depGraphs) {
+				assertTrue(
+						String.format("Graph %s should depend upon %s", g, dg),
+						g.dependsOn(dg));
+			}
+		}
+		depGraphs = getProducer().getNotDependsOn(g);
+		if (depGraphs != null) {
+			for (Graph dg : depGraphs) {
+				assertFalse(String.format("Graph %s should not depend upon %s",
+						g, dg), g.dependsOn(dg));
+			}
+		}
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+		List<Triple> s = graph.find(Node.ANY, Node.ANY, Node.ANY).toList();
+		assertEquals(3, s.size());
+		List<Triple> expected = Arrays.asList(new Triple[] { triple("S P O"),
+				triple("S2 P2 O2"), triple("S3 P3 O3") });
+		assertTrue("Missing some values",
+				expected.containsAll(s) && s.containsAll(expected));
+
+		s = graph.find(node("S"), Node.ANY, Node.ANY).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(Node.ANY, node("P"), Node.ANY).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(Node.ANY, Node.ANY, node("O")).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(node("S2"), node("P2"), node("O2")).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S2 P2 O2")));
+
+		s = graph.find(node("S2"), node("P3"), node("O2")).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(Node.ANY, node("P3"), node("O2")).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(node("S3"), Node.ANY, node("O2")).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(node("S3"), node("P2"), Node.ANY).toList();
+		assertEquals(0, s.size());
+
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node_ByFluidTriple() {
+		Node x = node("x");
+		Node y = node("y");
+		Node z = node("z");
+		Graph g = graphWith(getProducer().newInstance(), "x y z ");
+		Set<Triple> expect = tripleSet("x y z");
+		assertEquals(expect, g.find(Node.ANY, y, z).toSet());
+		assertEquals(expect, g.find(x, Node.ANY, z).toSet());
+		assertEquals(expect, g.find(x, y, Node.ANY).toSet());
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node_ProgrammaticValues() {
+		Graph g = getProducer().newInstance();
+		if (g.getCapabilities().handlesLiteralTyping()) {
+			Node ab = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Byte((byte) 42)));
+			Node as = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Short((short) 42)));
+			Node ai = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Integer(42)));
+			Node al = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Long(42)));
+
+			Node SB = NodeCreateUtils.create("SB");
+			Node SS = NodeCreateUtils.create("SS");
+			Node SI = NodeCreateUtils.create("SI");
+			Node SL = NodeCreateUtils.create("SL");
+			Node P = NodeCreateUtils.create("P");
+
+			txnBegin(g);
+			try {
+				g.add(Triple.create(SB, P, ab));
+				g.add(Triple.create(SS, P, as));
+				g.add(Triple.create(SI, P, ai));
+				g.add(Triple.create(SL, P, al));
+			} catch (Exception e) {
+				txnRollback(g);
+				fail(e.getMessage());
+			}
+			txnCommit(g);
+			assertEquals(
+					String.format(
+							"Should have found 4 elements, does %s really implement literal typing",
+							g.getClass()),
+					4,
+					iteratorToSet(
+							g.find(Node.ANY, P, NodeCreateUtils.create("42")))
+							.size());
+		}
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node_MatchLanguagedLiteralCaseInsensitive() {
+		Graph m = graphWith(getProducer().newInstance(), "a p 'chat'en");
+		if (m.getCapabilities().handlesLiteralTyping()) {
+			Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+			assertDiffer(chaten, chatEN);
+			assertTrue(chaten.sameValueAs(chatEN));
+			assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+			assertEquals(1, m.find(Node.ANY, Node.ANY, chaten).toList().size());
+			assertEquals(1, m.find(Node.ANY, Node.ANY, chatEN).toList().size());
+		}
+	}
+
+	@ContractTest
+	public void testFind_Node_Node_Node_NoMatchAgainstUnlanguagesLiteral() {
+		Graph m = graphWith(getProducer().newInstance(),
+				"a p 'chat'en; a p 'chat'");
+		if (m.getCapabilities().handlesLiteralTyping()) {
+			Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+			assertDiffer(chaten, chatEN);
+			assertTrue(chaten.sameValueAs(chatEN));
+			assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+			assertEquals(1, m.find(Node.ANY, Node.ANY, chaten).toList().size());
+			assertEquals(1, m.find(Node.ANY, Node.ANY, chatEN).toList().size());
+		}
+	}
+
+	@ContractTest
+	public void testFind_Triple() {
+		Graph graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+		List<Triple> s = graph.find(Triple.ANY).toList();
+		assertEquals(3, s.size());
+		List<Triple> expected = Arrays.asList(new Triple[] { triple("S P O"),
+				triple("S2 P2 O2"), triple("S3 P3 O3") });
+		assertTrue("Missing some values", expected.containsAll(s));
+
+		s = graph.find(new Triple(node("S"), Node.ANY, Node.ANY)).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(new Triple(Node.ANY, node("P"), Node.ANY)).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(new Triple(Node.ANY, Node.ANY, node("O"))).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S P O")));
+
+		s = graph.find(new Triple(node("S2"), node("P2"), node("O2"))).toList();
+		assertEquals(1, s.size());
+		assertTrue("Missing some values", s.contains(triple("S2 P2 O2")));
+
+		s = graph.find(new Triple(node("S2"), node("P3"), node("O2"))).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(new Triple(Node.ANY, node("P3"), node("O2"))).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(new Triple(node("S3"), Node.ANY, node("O2"))).toList();
+		assertEquals(0, s.size());
+
+		s = graph.find(new Triple(node("S3"), node("P2"), Node.ANY)).toList();
+		assertEquals(0, s.size());
+
+	}
+
+	@ContractTest
+	public void testFind_Triple_ByFluidTriple() {
+		Graph g = graphWith(getProducer().newInstance(), "x y z ");
+		Set<Triple> expect = tripleSet("x y z");
+		assertEquals(expect, g.find(triple("?? y z")).toSet());
+		assertEquals(expect, g.find(triple("x ?? z")).toSet());
+		assertEquals(expect, g.find(triple("x y ??")).toSet());
+	}
+
+	@ContractTest
+	public void testFind_Triple_ProgrammaticValues() {
+		Graph g = getProducer().newInstance();
+		if (g.getCapabilities().handlesLiteralTyping()) {
+			Node ab = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Byte((byte) 42)));
+			Node as = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Short((short) 42)));
+			Node ai = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Integer(42)));
+			Node al = NodeFactory.createLiteral(LiteralLabelFactory
+					.createTypedLiteral(new Long(42)));
+
+			Node SB = NodeCreateUtils.create("SB");
+			Node SS = NodeCreateUtils.create("SS");
+			Node SI = NodeCreateUtils.create("SI");
+			Node SL = NodeCreateUtils.create("SL");
+			Node P = NodeCreateUtils.create("P");
+
+			txnBegin(g);
+			try {
+				g.add(Triple.create(SB, P, ab));
+				g.add(Triple.create(SS, P, as));
+				g.add(Triple.create(SI, P, ai));
+				g.add(Triple.create(SL, P, al));
+			} catch (Exception e) {
+				txnRollback(g);
+				fail(e.getMessage());
+			}
+			txnCommit(g);
+			assertEquals(
+					String.format(
+							"Should have found 4 elements, does %s really implement literal typing",
+							g.getClass()),
+					4,
+					iteratorToSet(
+							g.find(new Triple(Node.ANY, P, NodeCreateUtils
+									.create("42")))).size());
+		}
+	}
+
+	@ContractTest
+	public void testFind_Triple_MatchLanguagedLiteralCaseInsensitive() {
+		Graph m = graphWith(getProducer().newInstance(), "a p 'chat'en");
+		//if (m.getCapabilities().handlesLiteralTyping()) {
+			Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+			assertDiffer(chaten, chatEN);
+			assertTrue(chaten.sameValueAs(chatEN));
+			assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+			assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chaten))
+					.toList().size());
+			assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN))
+					.toList().size());
+		//}
+	}
+
+	@ContractTest
+	public void testFind_Triple_NoMatchAgainstUnlanguagesLiteral() {
+		Graph m = graphWith(getProducer().newInstance(),
+				"a p 'chat'en; a p 'chat'");
+		//if (m.getCapabilities().handlesLiteralTyping()) {
+			Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
+			assertDiffer(chaten, chatEN);
+			assertTrue(chaten.sameValueAs(chatEN));
+			assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
+			assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chaten))
+					.toList().size());
+			assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN))
+					.toList().size());
+		//}
+	}
+
+	@ContractTest
+	public void testGetCapabilities() {
+		Graph g = getProducer().newInstance();
+		Capabilities c = g.getCapabilities();
+		assertNotNull("Capabilities are not returned", c);
+		try {
+			c.sizeAccurate();
+		} catch (Exception e) {
+			fail("sizeAccurate() threw Exception: " + e.toString());
+		}
+		try {
+			c.addAllowed();
+		} catch (Exception e) {
+			fail("addAllowed() threw Exception: " + e.toString());
+		}
+		try {
+			c.addAllowed(true);
+		} catch (Exception e) {
+			fail("addAllowed( boolean ) threw Exception: " + e.toString());
+		}
+		try {
+			c.deleteAllowed();
+		} catch (Exception e) {
+			fail("deleteAllowed() threw Exception: " + e.toString());
+		}
+		try {
+			c.deleteAllowed(true);
+		} catch (Exception e) {
+			fail("deleteAllowed( boolean ) threw Exception: " + e.toString());
+		}
+		try {
+			c.canBeEmpty();
+		} catch (Exception e) {
+			fail("canBeEmpty() threw Exception: " + e.toString());
+		}
+	}
+
+	@ContractTest
+	public void testGetEventManager() {
+		assertNotNull("Must return an EventManager", getProducer()
+				.newInstance().getEventManager());
+	}
+
+	@ContractTest
+	public void testGetPrefixMapping() {
+		Graph g = getProducer().newInstance();
+		PrefixMapping pm = g.getPrefixMapping();
+		assertNotNull("Must return prefix mapping", pm);
+		assertSame("getPrefixMapping must always return the same object", pm,
+				g.getPrefixMapping());
+
+	
+		pm.setNsPrefix("pfx1", "http://example.com/");
+		pm.setNsPrefix("pfx2", "scheme:rope/string#");
+
+		// assert same after adding to other mapl
+		assertSame("getPrefixMapping must always return the same object", pm,
+				g.getPrefixMapping());
+
+	}
+
+	@ContractTest
+	public void testGetStatisticsHandler() {
+		Graph g = getProducer().newInstance();
+		GraphStatisticsHandler sh = g.getStatisticsHandler();
+		if (sh != null) {
+			assertSame(
+					"getStatisticsHandler must always return the same object",
+					sh, g.getStatisticsHandler());
+		}
+	}
+
+	@ContractTest
+	public void testGetTransactionHandler() {
+		Graph g = getProducer().newInstance();
+		assertNotNull("Must return a Transaction handler",
+				g.getTransactionHandler());
+	}
+
+	@ContractTest
+	public void testIsClosed() {
+		Graph g = getProducer().newInstance();
+		assertFalse("Graph created in closed state", g.isClosed());
+		g.close();
+		assertTrue("Graph does not report closed state after close called",
+				g.isClosed());
+	}
+
+	@ContractTest
+	public void testIsEmpty() {
+		Graph g = getProducer().newInstance();
+		if (!g.isEmpty()) {
+			LOG.warn(String.format(
+					"Graph type %s can not be empty (Empty test skipped)",
+					g.getClass()));
+		} else {
+			graphAddTxn(g, "S P O");
+			assertFalse("Graph reports empty after add", g.isEmpty());
+			txnBegin(g);
+			g.add(NodeCreateUtils.createTriple("Foo B C"));
+			g.delete(NodeCreateUtils.createTriple("S P O"));
+			txnCommit(g);
+			assertFalse("Should not report empty", g.isEmpty());
+			txnBegin(g);
+			g.delete(NodeCreateUtils.createTriple("Foo B C"));
+			txnCommit(g);
+			assertTrue("Should report empty after all entries deleted",
+					g.isEmpty());
+		}
+	}
+
+	@ContractTest
+	public void testIsIsomorphicWith_Graph() {
+		Graph graph = getProducer().newInstance();
+		Graph g2 = memGraph();
+		assertTrue("Empty graphs should be isomorphic",
+				graph.isIsomorphicWith(g2));
+
+		graph = graphWith(getProducer().newInstance(),
+				"S P O; S2 P2 O2; S3 P3 O3");
+		g2 = graphWith("S3 P3 O3; S2 P2 O2; S P O");
+		assertTrue("Should be isomorphic", graph.isIsomorphicWith(g2));
+		txnBegin(graph);
+		graph.add(triple("_1, P4 S4"));
+		txnCommit(graph);
+
+		txnBegin(g2);
+		g2.add(triple("_2, P4 S4"));
+		txnCommit(g2);
+		assertTrue("Should be isomorphic after adding anonymous nodes",
+				graph.isIsomorphicWith(g2));
+
+		txnBegin(graph);
+		graph.add(triple("_1, P3 S4"));
+		txnCommit(graph);
+
+		txnBegin(g2);
+		g2.add(triple("_2, P4 S4"));
+		txnCommit(g2);
+		assertFalse("Should not be isomorphic", graph.isIsomorphicWith(g2));
+	}
+
+	private Graph copy(Graph g) {
+		Graph result = getProducer().newInstance();
+		txnBegin(result);
+		GraphUtil.addInto(result, g);
+		txnCommit(result);
+		return result;
+	}
+
+	private Graph remove(Graph toUpdate, Graph toRemove) {
+		txnBegin(toUpdate);
+		GraphUtil.deleteFrom(toUpdate, toRemove);
+		txnCommit(toUpdate);
+		return toUpdate;
+	}
+
+	/**
+	 * Test that remove(s, p, o) works, in the presence of inferencing graphs
+	 * that mean emptyness isn't available. This is why we go round the houses
+	 * and test that expected ~= initialContent + addedStuff - removed -
+	 * initialContent.
+	 */
+	@ContractTest
+	public void testRemove_Node_Node_Node() {
+		for (int i = 0; i < cases.length; i += 1)
+			for (int j = 0; j < 3; j += 1) {
+				Graph content = getProducer().newInstance();
+
+				Graph baseContent = copy(content);
+				graphAddTxn(content, cases[i][0]);
+				Triple remove = triple(cases[i][1]);
+				Graph expected = graphWith(cases[i][2]);
+				Triple[] removed = tripleArray(cases[i][3]);
+				content.getEventManager().register(GL);
+				GL.clear();
+				txnBegin(content);
+				content.remove(remove.getSubject(), remove.getPredicate(),
+						remove.getObject());
+				txnCommit(content);
+
+				// check for optional delete notifications
+				if (GL.contains("delete")) {
+					// if it contains any it must contain all.
+					for (Triple t : removed) {
+						GL.assertContains("delete", content, t);
+					}
+				}
+				GL.assertHasEnd(
+						"someEvent",
+						content,
+						GraphEvents.remove(remove.getSubject(),
+								remove.getPredicate(), remove.getObject()));
+
+				content.getEventManager().unregister(GL);
+				Graph finalContent = remove(copy(content), baseContent);
+				assertIsomorphic(cases[i][1], expected, finalContent);
+			}
+	}
+
+	@ContractTest
+	public void testRemove_ByIterator() {
+		testRemove("?? ?? ??", "?? ?? ??");
+		testRemove("S ?? ??", "S ?? ??");
+		testRemove("S ?? ??", "?? P ??");
+		testRemove("S ?? ??", "?? ?? O");
+		testRemove("?? P ??", "S ?? ??");
+		testRemove("?? P ??", "?? P ??");
+		testRemove("?? P ??", "?? ?? O");
+		testRemove("?? ?? O", "S ?? ??");
+		testRemove("?? ?? O", "?? P ??");
+		testRemove("?? ?? O", "?? ?? O");
+	}
+
+	private void testRemove(String findRemove, String findCheck) {
+		Graph g = graphWith(getProducer().newInstance(), "S P O");
+		ExtendedIterator<Triple> it = g.find(NodeCreateUtils
+				.createTriple(findRemove));
+		try {
+			it.next();
+			it.remove();
+			it.close();
+			assertEquals("remove with " + findRemove + ":", 0, g.size());
+			assertFalse(g.contains(NodeCreateUtils.createTriple(findCheck)));
+		} catch (UnsupportedOperationException e) {
+			it.close();
+			assertFalse(
+					"delete failed but capailities indicates it should work", g
+							.getCapabilities().iteratorRemoveAllowed());
+		}
+	}
+
+	/**
+	 * This test case was generated by Ian and was caused by GraphMem not
+	 * keeping up with changes to the find interface.
+	 */
+	@ContractTest
+	public void testFindAndContains() {
+		Graph g = getProducer().newInstance();
+		Node r = NodeCreateUtils.create("r"), s = NodeCreateUtils.create("s"), p = NodeCreateUtils
+				.create("P");
+		txnBegin(g);
+		try {
+			g.add(Triple.create(r, p, s));
+			txnCommit(g);
+			assertTrue(g.contains(r, p, Node.ANY));
+			assertEquals(1, g.find(r, p, Node.ANY).toList().size());
+		} catch (Exception e) {
+			txnRollback(g);
+			fail(e.getMessage());
+		}
+	}
+
+	/**
+	 * Check that contains respects by-value semantics.
+	 */
+
+	@ContractTest
+	public void testAGraph() {
+		String title = this.getClass().getName();
+		Graph g = getProducer().newInstance();
+		int baseSize = g.size();
+		graphAddTxn(g, "x R y; p S q; a T b");
+		/* */
+		assertContainsAll(title + ": simple graph", g, "x R y; p S q; a T b");
+		assertEquals(title + ": size", baseSize + 3, g.size());
+
+		graphAddTxn(g,
+				"spindizzies lift cities; Diracs communicate instantaneously");
+		assertEquals(title + ": size after adding", baseSize + 5, g.size());
+		txnBegin(g);
+		g.delete(triple("x R y"));
+		g.delete(triple("a T b"));
+		txnCommit(g);
+		assertEquals(title + ": size after deleting", baseSize + 3, g.size());
+		assertContainsAll(title + ": modified simple graph", g,
+				"p S q; spindizzies lift cities; Diracs communicate instantaneously");
+		assertOmitsAll(title + ": modified simple graph", g, "x R y; a T b");
+		/* */
+		ClosableIterator<Triple> it = g.find(Node.ANY, node("lift"), Node.ANY);
+		assertTrue(title + ": finds some triple(s)", it.hasNext());
+		assertEquals(title + ": finds a 'lift' triple",
+				triple("spindizzies lift cities"), it.next());
+		assertFalse(title + ": finds exactly one triple", it.hasNext());
+		it.close();
+	}
+
+	// public void testStuff()
+	// {
+	// // testAGraph( "StoreMem", new GraphMem() );
+	// // testAGraph( "StoreMemBySubject", new GraphMem() );
+	// // String [] empty = new String [] {};
+	// // Graph g = graphWith( "x R y; p S q; a T b" );
+	// // /* */
+	// // assertContainsAll( "simple graph", g, "x R y; p S q; a T b" );
+	// // graphAdd( g,
+	// "spindizzies lift cities; Diracs communicate instantaneously" );
+	// // g.delete( triple( "x R y" ) );
+	// // g.delete( triple( "a T b" ) );
+	// // assertContainsAll( "modified simple graph", g,
+	// "p S q; spindizzies lift cities; Diracs communicate instantaneously" );
+	// // assertOmitsAll( "modified simple graph", g, "x R y; a T b" );
+	// }
+
+	// /**
+	// Test that Graphs have transaction support methods, and that if they fail
+	// on some g they fail because they do not support the operation.
+	// */
+	// @ContractTest
+	// public void testHasTransactions()
+	// {
+	// Graph g = getProducer().newInstance();
+	// TransactionHandler th = g.getTransactionHandler();
+	// th.transactionsSupported();
+	// try { th.begin(); } catch (UnsupportedOperationException x) {}
+	// try { th.abort(); } catch (UnsupportedOperationException x) {}
+	// try { th.begin(); th.commit(); } catch (UnsupportedOperationException x)
+	// {}
+	// /* */
+	// Command cmd = new Command()
+	// { @Override
+	// public Object execute() { return null; } };
+	// try { th.executeInTransaction( cmd ); }
+	// catch (UnsupportedOperationException x) {}
+	// }
+	//
+	// @ContractTest
+	// public void testExecuteInTransactionCatchesThrowable()
+	// {Graph g = getProducer().newInstance();
+	// TransactionHandler th = g.getTransactionHandler();
+	// if (th.transactionsSupported())
+	// {
+	// Command cmd = new Command()
+	// { @Override
+	// public Object execute() throws Error { throw new Error(); } };
+	// try { th.executeInTransaction( cmd ); }
+	// catch (JenaException x) {}
+	// }
+	// }
+
+	@ContractTest
+	public void testAddWithReificationPreamble() {
+		Graph g = getProducer().newInstance();
+		txnBegin(g);
+		xSPO(g);
+		txnCommit(g);
+		assertFalse(g.isEmpty());
+	}
+
+	protected void xSPOyXYZ(Graph g) {
+		xSPO(g);
+		ReifierStd.reifyAs(g, NodeCreateUtils.create("y"),
+				NodeCreateUtils.createTriple("X Y Z"));
+	}
+
+	protected void aABC(Graph g) {
+		ReifierStd.reifyAs(g, NodeCreateUtils.create("a"),
+				NodeCreateUtils.createTriple("Foo B C"));
+	}
+
+	protected void xSPO(Graph g) {
+		ReifierStd.reifyAs(g, NodeCreateUtils.create("x"),
+				NodeCreateUtils.createTriple("S P O"));
+	}
+
+	@ContractTest
+	public void failingTestDoubleRemoveAll() {
+		final Graph g = getProducer().newInstance();
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				graphAddTxn(g, "c S d; e:ff GGG hhhh; _i J 27; Ell Em 'en'");
+				Iterator<Triple> it = new TrackingTripleIterator(
+						g.find(Triple.ANY)) {
+					@Override
+					public void remove() {
+						super.remove(); // removes current
+						g.delete(current); // no-op.
+					}
+				};
+				while (it.hasNext()) {
+					it.next();
+					it.remove();
+				}
+				assertTrue(g.isEmpty());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	/**
+	 * Test cases for RemoveSPO(); each entry is a triple (add, remove, result).
+	 * <ul>
+	 * <li>add - the triples to add to the graph to start with
+	 * <li>remove - the pattern to use in the removal
+	 * <li>result - the triples that should remain in the graph
+	 * </ul>
+	 */
+	protected static String[][] cases = { { "x R y", "x R y", "", "x R y" },
+			{ "x R y; a P b", "x R y", "a P b", "x R y" },
+			{ "x R y; a P b", "?? R y", "a P b", "x R y" },
+			{ "x R y; a P b", "x R ??", "a P b", "x R y" },
+			{ "x R y; a P b", "x ?? y", "a P b", "x R y" },
+			{ "x R y; a P b", "?? ?? ??", "", "x R y; a P b" },
+			{ "x R y; a P b; c P d", "?? P ??", "x R y", "a P b; c P d" },
+			{ "x R y; a P b; x S y", "x ?? ??", "a P b", "x R y; x S y" }, };
+
+	/**
+	 * testIsomorphism from file data
+	 * 
+	 * @throws FileNotFoundException
+	 */
+	@ContractTest
+	public void testIsomorphismFile() throws URISyntaxException,
+			MalformedURLException {
+		testIsomorphismXMLFile(1, true);
+		testIsomorphismXMLFile(2, true);
+		testIsomorphismXMLFile(3, true);
+		testIsomorphismXMLFile(4, true);
+		testIsomorphismXMLFile(5, false);
+		testIsomorphismXMLFile(6, false);
+		testIsomorphismNTripleFile(7, true);
+		testIsomorphismNTripleFile(8, false);
+
+	}
+
+	private void testIsomorphismNTripleFile(int i, boolean result)
+			throws URISyntaxException, MalformedURLException {
+		testIsomorphismFile(i, "N-TRIPLE", "nt", result);
+	}
+
+	private void testIsomorphismXMLFile(int i, boolean result)
+			throws URISyntaxException, MalformedURLException {
+		testIsomorphismFile(i, "RDF/XML", "rdf", result);
+
+	}
+
+	private InputStream getInputStream(int n, int n2, String suffix)
+			throws URISyntaxException, MalformedURLException {
+		String urlStr = String.format("regression/testModelEquals/%s-%s.%s", n,
+				n2, suffix);
+		return GraphContractTest.class.getClassLoader().getResourceAsStream(
+				urlStr);
+	}
+
+	private void testIsomorphismFile(int n, String lang, String suffix,
+			boolean result) throws URISyntaxException, MalformedURLException {
+
+		Graph g1 = getProducer().newInstance();
+		Graph g2 = getProducer().newInstance();
+		Model m1 = ModelFactory.createModelForGraph(g1);
+		Model m2 = ModelFactory.createModelForGraph(g2);
+
+		m1.read(getInputStream(n, 1, suffix), "http://www.example.org/", lang);
+
+		m2.read(getInputStream(n, 2, suffix), "http://www.example.org/", lang);
+
+		boolean rslt = g1.isIsomorphicWith(g2) == result;
+		if (!rslt) {
+			System.out.println("g1:");
+			m1.write(System.out, "N-TRIPLE");
+			System.out.println("g2:");
+			m2.write(System.out, "N-TRIPLE");
+		}
+		assertTrue("Isomorphism test failed", rslt);
+	}
+
+	protected Graph getClosed() {
+		Graph result = getProducer().newInstance();
+		result.close();
+		return result;
+	}
+
+	// @ContractTest
+	// public void testTransactionCommit()
+	// {
+	// Graph g = getProducer().newInstance();
+	// 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", ".nt" );
+	//
+	// //Graph g = new FileGraph( foo, true, true );
+	//
+	// 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() );
+	// }
+	// }
+	//
+	// @ContractTest
+	// public void testTransactionAbort()
+	// {
+	// Graph g = getProducer().newInstance();
+	// 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 );
+	// }
+	// }
+	//
+	// @ContractTest
+	// public void testTransactionCommitThenAbort()
+	// {
+	// Graph g = getProducer().newInstance();
+	// if (g.getTransactionHandler().transactionsSupported())
+	// {
+	// Graph initial = graphWithTxn( "Foo pings B; B pings C" );
+	// Graph extra = graphWithTxn( "C pingedBy B; fileGraph rdf:type Graph" );
+	// //Graph g = getProducer().newInstance();
+	// //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() );
+	// }
+	// }
+
+	/**
+	 * 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.
+	 */
+	@ContractTest
+	public void testPartialUpdate() {
+		Graph source = graphWith(getProducer().newInstance(), "a R b; b S e");
+		Graph dest = graphWith(getProducer().newInstance(), "b R d");
+		GraphExtract e = new GraphExtract(TripleBoundary.stopNowhere);
+		e.extractInto(dest, node("a"), source);
+		assertIsomorphic(
+				graphWith(getProducer().newInstance(), "a R b; b S e; b R d"),
+				dest);
+	}
+
+	/**
+	 * Ensure that triples removed by calling .remove() on the iterator returned
+	 * by a find() will generate deletion notifications.
+	 */
+	@ContractTest
+	public void testIterator_Remove() {
+		Graph graph = graphWith(getProducer().newInstance(), "a R b; b S e");
+		if (graph.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				graph.getEventManager().register(GL);
+				txnBegin(graph);
+
+				Triple toRemove = triple("a R b");
+				ExtendedIterator<Triple> rtr = graph.find(toRemove);
+				assertTrue("ensure a(t least) one triple", rtr.hasNext());
+				rtr.next();
+				rtr.remove();
+				rtr.close();
+				GL.assertHas("delete", graph, toRemove);
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+
+		}
+	}
+
+	@ContractTest
+	public void testTransactionHandler_Commit() {
+		Graph g = getProducer().newInstance();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWith(getProducer().newInstance(),
+					"initial hasValue 42; also hasURI hello");
+			Graph extra = graphWith(getProducer().newInstance(),
+					"extra hasValue 17; also hasURI world");
+
+			GraphUtil.addInto(g, initial);
+			g.getTransactionHandler().begin();
+			GraphUtil.addInto(g, extra);
+			g.getTransactionHandler().commit();
+			Graph union = memGraph();
+			GraphUtil.addInto(union, initial);
+			GraphUtil.addInto(union, extra);
+			assertIsomorphic(union, g);
+			// Model inFiIProducer<TransactionHandler>le =
+			// ModelFactory.createDefaultModel();
+			// inFile.read( "file:///" + foo, "N-TRIPLES" );
+			// assertIsomorphic( union, inFile.getGraph() );
+		}
+	}
+
+	@ContractTest
+	public void testTransactionHandler_Abort() {
+		Graph g = getProducer().newInstance();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWith(getProducer().newInstance(),
+					"initial hasValue 42; also hasURI hello");
+			Graph extra = graphWith(getProducer().newInstance(),
+					"extra hasValue 17; also hasURI world");
+			GraphUtil.addInto(g, initial);
+			g.getTransactionHandler().begin();
+			GraphUtil.addInto(g, extra);
+			g.getTransactionHandler().abort();
+			assertIsomorphic(initial, g);
+		}
+	}
+
+	@ContractTest
+	public void testTransactionHandler_CommitThenAbort() {
+		Graph g = getProducer().newInstance();
+		if (g.getTransactionHandler().transactionsSupported()) {
+			Graph initial = graphWith(getProducer().newInstance(),
+					"Foo pings B; B pings C");
+			Graph extra = graphWith(getProducer().newInstance(),
+					"C pingedBy B; fileGraph rdf:type Graph");
+			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() );
+		}
+	}
+
+	//
+	// Test that literal typing works when supported
+	//
+
+	// used to find the object set from the returned set for literal testing
+	private static final Map1<Triple, Node> getObject = new Map1<Triple, Node>() {
+		@Override
+		public Node map1(Triple o) {
+			return o.getObject();
+		}
+	};
+
+	private void testLiteralTypingBasedFind(final String data, final int size,
+			final String search, final String results, boolean reqLitType) {
+
+		Graph g = getProducer().newInstance();
+
+		if (!reqLitType || g.getCapabilities().handlesLiteralTyping()) {
+			graphWith(g, 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);
+		}
+	}
+
+	@ContractTest
+	public void testLiteralTypingBasedFind() {
+		testLiteralTypingBasedFind("a P 'simple'", 1, "'simple'", "'simple'",
+				false);
+		testLiteralTypingBasedFind("a P 'simple'xsd:string", 1, "'simple'",
+				"'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 'simple'", 1, "'simple'xsd:string",
+				"'simple'", true);
+		testLiteralTypingBasedFind("a P 'simple'xsd:string", 1,
+				"'simple'xsd:string", "'simple'xsd:string", false);
+//		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 2,
+//				"'simple'", "'simple' 'simple'xsd:string", true);
+//		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 2,
+//				"'simple'xsd:string", "'simple' 'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
+				"'simple'", "'simple'", true);
+		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
+				"'simple'xsd:string", "'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 1", 1, "1", "1", false);
+		testLiteralTypingBasedFind("a P '1'xsd:float", 1, "'1'xsd:float",
+				"'1'xsd:float", false);
+		testLiteralTypingBasedFind("a P '1'xsd:double", 1, "'1'xsd:double",
+				"'1'xsd:double", false);
+		testLiteralTypingBasedFind("a P '1'xsd:float", 1, "'1'xsd:float",
+				"'1'xsd:float", false);
+		testLiteralTypingBasedFind("a P '1.1'xsd:float", 1, "'1'xsd:float", "",
+				false);
+		testLiteralTypingBasedFind("a P '1'xsd:double", 1, "'1'xsd:int", "",
+				false);
+		testLiteralTypingBasedFind("a P 'abc'rdf:XMLLiteral", 1, "'abc'", "",
+				false);
+		testLiteralTypingBasedFind("a P 'abc'", 1, "'abc'rdf:XMLLiteral", "",
+				false);
+		//
+		// floats & doubles are not compatible
+		//
+		testLiteralTypingBasedFind("a P '1'xsd:float", 1, "'1'xsd:double", "",
+				false);
+		testLiteralTypingBasedFind("a P '1'xsd:double", 1, "'1'xsd:float", "",
+				false);
+		testLiteralTypingBasedFind("a P 1", 1, "'1'", "", false);
+		testLiteralTypingBasedFind("a P 1", 1, "'1'xsd:integer",
+				"'1'xsd:integer", false);
+		testLiteralTypingBasedFind("a P 1", 1, "'1'", "", false);
+		testLiteralTypingBasedFind("a P '1'xsd:short", 1, "'1'xsd:integer",
+				"'1'xsd:short", true);
+		testLiteralTypingBasedFind("a P '1'xsd:int", 1, "'1'xsd:integer",
+				"'1'xsd:int", true);
+	}
+
+	@ContractTest
+	public void testQuadRemove() {
+		Graph g = getProducer().newInstance();
+		assertEquals(0, g.size());
+		Triple s = triple("x rdf:subject s");
+		Triple p = triple("x rdf:predicate p");
+		Triple o = triple("x rdf:object o");
+		Triple t = triple("x rdf:type rdf:Statement");
+		txnBegin(g);
+		g.add(s);
+		g.add(p);
+		g.add(o);
+		g.add(t);
+		txnCommit(g);
+		assertEquals(4, g.size());
+		txnBegin(g);
+		g.delete(s);
+		g.delete(p);
+		g.delete(o);
+		g.delete(t);
+		txnCommit(g);
+		assertEquals(0, g.size());
+	}
+
+	@ContractTest
+	public void testSizeAfterRemove() {
+		Graph g = graphWith(getProducer().newInstance(), "x p y");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(triple("x ?? ??"));
+				it.removeNext();
+				assertEquals(0, g.size());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	@ContractTest
+	public void testSingletonStatisticsWithSingleTriple() {
+
+		Graph g = graphWith(getProducer().newInstance(), "a P b");
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			assertEquals(1L, h.getStatistic(node("a"), Node.ANY, Node.ANY));
+			assertEquals(0L, h.getStatistic(node("x"), Node.ANY, Node.ANY));
+			//
+			assertEquals(1L, h.getStatistic(Node.ANY, node("P"), Node.ANY));
+			assertEquals(0L, h.getStatistic(Node.ANY, node("Q"), Node.ANY));
+			//
+			assertEquals(1L, h.getStatistic(Node.ANY, Node.ANY, node("b")));
+			assertEquals(0L, h.getStatistic(Node.ANY, Node.ANY, node("y")));
+		}
+	}
+
+	@ContractTest
+	public void testSingletonStatisticsWithSeveralTriples() {
+
+		Graph g = graphWith(getProducer().newInstance(),
+				"a P b; a P c; a Q b; x S y");
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			assertEquals(3L, h.getStatistic(node("a"), Node.ANY, Node.ANY));
+			assertEquals(1L, h.getStatistic(node("x"), Node.ANY, Node.ANY));
+			assertEquals(0L, h.getStatistic(node("y"), Node.ANY, Node.ANY));
+			//
+			assertEquals(2L, h.getStatistic(Node.ANY, node("P"), Node.ANY));
+			assertEquals(1L, h.getStatistic(Node.ANY, node("Q"), Node.ANY));
+			assertEquals(0L, h.getStatistic(Node.ANY, node("R"), Node.ANY));
+			//
+			assertEquals(2L, h.getStatistic(Node.ANY, Node.ANY, node("b")));
+			assertEquals(1L, h.getStatistic(Node.ANY, Node.ANY, node("c")));
+			assertEquals(0L, h.getStatistic(Node.ANY, Node.ANY, node("d")));
+		}
+	}
+
+	@ContractTest
+	public void testDoubletonStatisticsWithTriples() {
+
+		Graph g = graphWith(getProducer().newInstance(),
+				"a P b; a P c; a Q b; x S y");
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			assertEquals(-1L, h.getStatistic(node("a"), node("P"), Node.ANY));
+			assertEquals(-1L, h.getStatistic(Node.ANY, node("P"), node("b")));
+			assertEquals(-1L, h.getStatistic(node("a"), Node.ANY, node("b")));
+			//
+			assertEquals(0L, h.getStatistic(node("no"), node("P"), Node.ANY));
+		}
+	}
+
+	@ContractTest
+	public void testStatisticsWithOnlyVariables() {
+		testStatsWithAllVariables("");
+		testStatsWithAllVariables("a P b");
+		testStatsWithAllVariables("a P b; a P c");
+		testStatsWithAllVariables("a P b; a P c; a Q b; x S y");
+	}
+
+	private void testStatsWithAllVariables(String triples) {
+		Graph g = graphWith(getProducer().newInstance(), triples);
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			assertEquals(g.size(), h.getStatistic(Node.ANY, Node.ANY, Node.ANY));
+		}
+	}
+
+	@ContractTest
+	public void testStatsWithConcreteTriple() {
+		testStatsWithConcreteTriple(0, "x P y", "");
+	}
+
+	private void testStatsWithConcreteTriple(int expect, String triple,
+			String graph) {
+		Graph g = graphWith(getProducer().newInstance(), graph);
+		GraphStatisticsHandler h = g.getStatisticsHandler();
+		if (h != null) {
+			Triple t = triple(triple);
+			assertEquals(
+					expect,
+					h.getStatistic(t.getSubject(), t.getPredicate(),
+							t.getObject()));
+		}
+	}
+
+	@ContractTest
+	public void testBrokenIndexes() {
+		Graph g = graphWith(getProducer().newInstance(), "x R y; x S z");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY,
+						Node.ANY);
+				it.removeNext();
+				it.removeNext();
+				assertFalse(g.find(node("x"), Node.ANY, Node.ANY).hasNext());
+				assertFalse(g.find(Node.ANY, node("R"), Node.ANY).hasNext());
+				assertFalse(g.find(Node.ANY, Node.ANY, node("y")).hasNext());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	@ContractTest
+	public void testBrokenSubject() {
+		Graph g = graphWith(getProducer().newInstance(), "x brokenSubject y");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(node("x"), Node.ANY,
+						Node.ANY);
+				it.removeNext();
+				assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	@ContractTest
+	public void testBrokenPredicate() {
+		Graph g = graphWith(getProducer().newInstance(), "x brokenPredicate y");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(Node.ANY,
+						node("brokenPredicate"), Node.ANY);
+				it.removeNext();
+				assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+	@ContractTest
+	public void testBrokenObject() {
+		Graph g = graphWith(getProducer().newInstance(), "x brokenObject y");
+		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
+				ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY,
+						node("y"));
+				it.removeNext();
+				assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+
+			} catch (UnsupportedOperationException e) {
+				fail("Error attempting to remove nodes " + e.getMessage());
+			}
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
new file mode 100644
index 0000000..426002d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
@@ -0,0 +1,514 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.mockito.Mockito;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import static org.junit.Assert.*;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphEventManager;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.Factory;
+import org.apache.jena.testing_framework.ContractTemplate;
+import org.apache.jena.testing_framework.GraphHelper;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.testing_framework.NodeCreateUtils;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+/**
+ * An abstract test that tests EventManager implementations to ensure they
+ * comply with the EventManager contract.
+ * 
+ * Subclasses of this class must implement the getEventManagerProducer() method
+ * to create a new instance of the EventManager for testing.
+ */
+
+@Contract(GraphEventManager.class)
+public class GraphEventManagerContractTest<T extends GraphEventManager> extends
+		ContractTemplate<IProducer<T>> {
+
+	protected static final Triple[] tripleArray = tripleArray("S P O; Foo R B; X Q Y");
+
+	// the graph that is used as the source of the events.
+	private Graph mockGraph;
+	// The event manager we are working with.
+	private GraphEventManager gem;
+
+	public GraphEventManagerContractTest() {
+//		setProducer(new IProducer<T>() {
+//
+//			@SuppressWarnings("unchecked")
+//			@Override
+//			public T newInstance() {
+//				return (T) Factory.createGraphMem().getEventManager();
+//			}
+//
+//			@Override
+//			public void cleanUp() {
+//			}
+//		});
+
+	}
+
+	@Contract.Inject
+	public final void setGraphEventManagerContractTestProducer(
+			IProducer<T> producer) {
+		super.setProducer(producer);
+	}
+
+	@After
+	public final void afterGraphEventManagerContractTest() {
+		getProducer().cleanUp();
+	}
+
+	@Before
+	public final void beforeGraphEventManagerContractTest() {
+		mockGraph = Mockito.mock(Graph.class);
+		gem = getProducer().newInstance();
+		L = new RecordingGraphListener();
+	}
+
+	/**
+	 * Test that when a listener is registered the same EventManager is
+	 * returned.
+	 */
+	@ContractTest
+	public void testEventRegister() {
+		assertSame(gem, gem.register(new RecordingGraphListener()));
+	}
+
+	/**
+	 * Test that we can safely unregister a listener that isn't registered.
+	 */
+	@ContractTest
+	public void testEventUnregister() {
+		assertSame(gem, gem.unregister(L));
+	}
+
+	/**
+	 * Handy triple for test purposes.
+	 */
+	protected Triple SPO = NodeCreateUtils.createTriple("S P O");
+
+	/**
+	 * The RecordingListener that reports all the events sent from the
+	 * EventManager.
+	 */
+	protected RecordingGraphListener L;
+
+	/**
+	 * Test that adding a triple is reported.
+	 */
+	@ContractTest
+	public void testAddTriple() {
+		gem.register(L);
+		gem.notifyAddTriple(mockGraph, SPO);
+		L.assertHas(new Object[] { "add", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that deleting a triple is reported.
+	 */
+	@ContractTest
+	public void testDeleteTriple() {
+		gem.register(L);
+		gem.notifyDeleteTriple(mockGraph, SPO);
+		L.assertHas(new Object[] { "delete", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that when 2 listeners are added both receive events.
+	 */
+	@ContractTest
+	public void testTwoListeners() {
+		RecordingGraphListener L1 = new RecordingGraphListener();
+		RecordingGraphListener L2 = new RecordingGraphListener();
+		gem.register(L1).register(L2);
+		gem.notifyAddTriple(mockGraph, SPO);
+		L2.assertHas(new Object[] { "add", mockGraph, SPO });
+		L1.assertHas(new Object[] { "add", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that unregistering a listener after registering it results in it not
+	 * receiving messages.
+	 */
+	@ContractTest
+	public void testUnregisterWorks() {
+		gem.register(L).unregister(L);
+		gem.notifyAddTriple(mockGraph, SPO);
+		L.assertHas(new Object[] {});
+	}
+
+	/**
+	 * Test that registering a listener twice results in the listener receiving
+	 * the events twice.
+	 */
+	@ContractTest
+	public void testRegisterTwice() {
+		gem.register(L).register(L);
+		gem.notifyAddTriple(mockGraph, SPO);
+		L.assertHas(new Object[] { "add", mockGraph, SPO, "add", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that registering a listener twice and unregistering it once will
+	 * result in the listener receiving each event one time.
+	 */
+	@ContractTest
+	public void testUnregisterOnce() {
+		gem.register(L).register(L).unregister(L);
+		gem.notifyDeleteTriple(mockGraph, SPO);
+		L.assertHas(new Object[] { "delete", mockGraph, SPO });
+	}
+
+	/**
+	 * Test that adding an array is reported as adding an array.
+	 */
+	@ContractTest
+	public void testAddArray() {
+		gem.register(L);
+		gem.notifyAddArray(mockGraph, tripleArray);
+		L.assertHas(new Object[] { "add[]", mockGraph, tripleArray });
+	}
+
+	/**
+	 * Test that adding a list is reported as adding a list
+	 */
+	@ContractTest
+	public void testAddList() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyAddList(mockGraph, elems);
+		L.assertHas(new Object[] { "addList", mockGraph, elems });
+	}
+
+	/**
+	 * Test that deleting an array is reported as deleting an array.
+	 */
+	@ContractTest
+	public void testDeleteArray() {
+		gem.register(L);
+		gem.notifyDeleteArray(mockGraph, tripleArray);
+		L.assertHas(new Object[] { "delete[]", mockGraph, tripleArray });
+	}
+
+	/**
+	 * Test that deleting a list is reported as deleting a list.
+	 */
+	@ContractTest
+	public void testDeleteList() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyDeleteList(mockGraph, elems);
+		L.assertHas(new Object[] { "deleteList", mockGraph, elems });
+	}
+
+	/**
+	 * Test that adding a list as an iterator is reported as an add iterator.
+	 */
+	@ContractTest
+	public void testAddListAsIterator() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyAddIterator(mockGraph, elems);
+		L.assertHas(new Object[] { "addIterator", mockGraph, elems });
+	}
+
+	/**
+	 * Test that adding an iterator is reported as adding an iterator.
+	 */
+	@ContractTest
+	public void testAddIterator() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyAddIterator(mockGraph, elems.iterator());
+		L.assertHas(new Object[] { "addIterator", mockGraph, elems });
+	}
+
+	/**
+	 * Test that deleting an iterator is reported as a deleting an iterator.
+	 */
+	@ContractTest
+	public void testDeleteIterator() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyDeleteIterator(mockGraph, elems.iterator());
+		L.assertHas(new Object[] { "deleteIterator", mockGraph, elems });
+	}
+
+	/**
+	 * Test that deleting a list as an iterator is reported as deleting an
+	 * iterator.
+	 */
+	@ContractTest
+	public void testDeleteListAsIterator() {
+		gem.register(L);
+		List<Triple> elems = Arrays.asList(tripleArray);
+		gem.notifyDeleteIterator(mockGraph, elems);
+		L.assertHas(new Object[] { "deleteIterator", mockGraph, elems });
+	}
+
+	/**
+	 * Test that adding a graph is reported as adding a graph.
+	 */
+	@ContractTest
+	public void testAddGraph() {
+		gem.register(L);
+		Graph other = Mockito.mock(Graph.class);
+		gem.notifyAddGraph(mockGraph, other);
+		L.assertHas(new Object[] { "addGraph", mockGraph, other });
+	}
+
+	/**
+	 * Test that deleting a graph is reported as deleting a graph.
+	 */
+	@ContractTest
+	public void testDeleteGraph() {
+		gem.register(L);
+		Graph other = Mockito.mock(Graph.class);
+		gem.notifyDeleteGraph(mockGraph, other);
+		L.assertHas(new Object[] { "deleteGraph", mockGraph, other });
+	}
+
+	/**
+	 * Test that sending a general event is reported as an event and the value
+	 * is saved.
+	 */
+	@ContractTest
+	public void testGeneralEvent() {
+		gem.register(L);
+		Object value = new int[] {};
+		gem.notifyEvent(mockGraph, value);
+		L.assertHas(new Object[] { "someEvent", mockGraph, value });
+	}
+
+	@ContractTest
+	public void testListening() {
+		assertFalse("Should not be listening", gem.listening());
+		gem.register(L);
+		assertTrue("Should be listening", gem.listening());
+		gem.unregister(L);
+		assertFalse("Should not be listening", gem.listening());
+	}
+
+	//
+	// Foo series of tests to check modifying the manger in mid notification
+	//
+
+	private ComeAndGoListener all[];
+
+	abstract private static class ComeAndGoListener implements GraphListener {
+
+		// Was I registered when start() was called, and have not been
+		// unregistered.
+		boolean inPlay = false;
+		// currently registered or not.
+		boolean registered = false;
+		boolean notified = false;
+
+		void register(GraphEventManager gem) {
+			registered = true;
+			gem.register(this);
+		}
+
+		void unregister(GraphEventManager gem) {
+			registered = false;
+			inPlay = false;
+			gem.unregister(this);
+		}
+
+		void start() {
+			if (registered)
+				inPlay = true;
+		}
+
+		void check() {
+			if (inPlay && !notified)
+				fail("listener that was in-play was not notified of adding triple.");
+		}
+
+		@Override
+		final public void notifyAddTriple(Graph g, Triple t) {
+			notified = true;
+			doSomeDamage();
+		}
+
+		abstract void doSomeDamage();
+
+		@Override
+		public void notifyAddArray(Graph g, Triple[] triples) {
+		}
+
+		@Override
+		public void notifyAddGraph(Graph g, Graph added) {
+		}
+
+		@Override
+		public void notifyAddIterator(Graph g, Iterator<Triple> it) {
+		}
+
+		@Override
+		public void notifyAddList(Graph g, List<Triple> triples) {
+		}
+
+		@Override
+		public void notifyDeleteArray(Graph g, Triple[] triples) {
+		}
+
+		@Override
+		public void notifyDeleteGraph(Graph g, Graph removed) {
+		}
+
+		@Override
+		public void notifyDeleteIterator(Graph g, Iterator<Triple> it) {
+		}
+
+		@Override
+		public void notifyDeleteList(Graph g, List<Triple> L) {
+		}
+
+		@Override
+		public void notifyDeleteTriple(Graph g, Triple t) {
+		}
+
+		@Override
+		public void notifyEvent(Graph source, Object value) {
+		}
+
+	}
+
+	/**
+	 * ComeAndGoListener implementation that does no damage
+	 * 
+	 */
+	private static final class SimpleListener extends ComeAndGoListener {
+		@Override
+		void doSomeDamage() {
+		}
+	}
+
+	/**
+	 * Test adding a triple to trigger event.
+	 * 
+	 * @param registerTo
+	 *            Number of listeners to register.
+	 * @param allx
+	 */
+	private void testAddingTriple(int registerTo, ComeAndGoListener... allx) {
+		all = allx;
+		// register addMe
+		for (int i = 0; i < registerTo; i++) {
+			all[i].register(gem);
+		}
+
+		// start them all
+		for (ComeAndGoListener l : all) {
+			l.start();
+		}
+		// send the notification.
+		gem.notifyAddTriple(mockGraph, GraphHelper.triple("make a change"));
+		// check them
+		for (ComeAndGoListener l : all) {
+			l.check();
+		}
+	}
+
+	/**
+	 * Test that a listener added during event processing does not receive the
+	 * event.
+	 */
+	@ContractTest
+	public void testAddOne() {
+		testAddingTriple(2, new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				all[2].register(gem);
+			}
+		}, new SimpleListener(), new SimpleListener());
+	}
+
+	/**
+	 * Test that when a listener that has not yet been handled is removed during
+	 * event processing it receive the event.
+	 */
+	@ContractTest
+	public void testDelete2nd() {
+		testAddingTriple(3, new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				all[1].unregister(gem);
+			}
+		}, new SimpleListener(), new SimpleListener());
+	}
+
+	/**
+	 * Test that when a listener that has been handled is removed during event
+	 * processing it receives the event.
+	 */
+	@ContractTest
+	public void testDelete1st() {
+		testAddingTriple(3, new SimpleListener(), new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				all[0].unregister(gem);
+			}
+		}, new SimpleListener());
+	}
+
+	/**
+	 * Test that when a listener that removes itself during event processing it
+	 * receives the event.
+	 */
+	@ContractTest
+	public void testDeleteSelf() {
+		testAddingTriple(3, new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				unregister(gem);
+			}
+		}, new SimpleListener(), new SimpleListener());
+	}
+
+	/**
+	 * Test that when a listener that removes and adds itself during event
+	 * processing it receives the event.
+	 */
+	@ContractTest
+	public void testDeleteAndAddSelf() {
+		testAddingTriple(3, new ComeAndGoListener() {
+			@Override
+			void doSomeDamage() {
+				unregister(gem);
+				register(gem);
+			}
+		}, new SimpleListener(), new SimpleListener());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
new file mode 100644
index 0000000..5fbd9c2
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
@@ -0,0 +1,314 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import static org.junit.Assert.*;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphMaker;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.SimpleGraphMaker;
+import org.apache.jena.shared.AlreadyExistsException;
+import org.apache.jena.shared.DoesNotExistException;
+import org.apache.jena.testing_framework.GraphHelper;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.testing_framework.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.)
+ */
+@Contract(GraphMaker.class)
+public class GraphMakerContractTest {
+
+	private IProducer<GraphMaker> producer;
+
+	private GraphMaker graphMaker;
+
+	public GraphMakerContractTest() {
+//		producer = new IProducer<GraphMaker>() {
+//
+//			@Override
+//			public GraphMaker newInstance() {
+//				return new SimpleGraphMaker();
+//			}
+//
+//			@Override
+//			public void cleanUp() {
+//
+//			}
+//		};
+	}
+
+	@Contract.Inject
+	public final void setGraphMaker(IProducer<GraphMaker> producer) {
+		this.producer = producer;
+	}
+
+	protected final IProducer<GraphMaker> getGraphMakerProducer() {
+		return producer;
+	}
+
+	@After
+	public final void afterGraphMakerContractTest() {
+		producer.cleanUp();
+	}
+
+	@Before
+	public final void beforeGraphMakerContractTest() {
+		graphMaker = producer.newInstance();
+	}
+
+	@After
+	public void tearDown() {
+		graphMaker.close();
+		getGraphMakerProducer().cleanUp();
+	}
+
+	/**
+	 * Foo trivial test that getGraph delivers a proper graph, not cheating with
+	 * null, and that getGraph() "always" delivers the same Graph.
+	 */
+	@ContractTest
+	public void testGetGraph() {
+		Graph g1 = graphMaker.getGraph();
+		assertFalse("should deliver a Graph", g1 == null);
+		assertSame(g1, graphMaker.getGraph());
+		g1.close();
+	}
+
+	@ContractTest
+	public void testCreateGraph() {
+		TestUtils.assertDiffer("each created graph must differ",
+				graphMaker.createGraph(), graphMaker.createGraph());
+	}
+
+	@ContractTest
+	public void testAnyName() {
+		graphMaker.createGraph("plain").close();
+		graphMaker.createGraph("with.dot").close();
+		graphMaker.createGraph("http://electric-hedgehog.net/topic#marker")
+				.close();
+	}
+
+	/**
+	 * Test that we can't create a graph with the same name twice.
+	 */
+	@ContractTest
+	public void testCannotCreateTwice() {
+		String name = jName("bonsai");
+		graphMaker.createGraph(name, true);
+		try {
+			graphMaker.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;
+	}
+
+	@ContractTest
+	public void testCanCreateTwice() {
+		String name = jName("bridge");
+		Graph g1 = graphMaker.createGraph(name, true);
+		Graph g2 = graphMaker.createGraph(name, false);
+		assertTrue("graphs should be the same", sameGraph(g1, g2));
+		Graph g3 = graphMaker.createGraph(name);
+		assertTrue("graphs should be the same", sameGraph(g1, g3));
+	}
+
+	/**
+	 * Test that we cannot open a graph that does not exist.
+	 */
+	@ContractTest
+	public void testCannotOpenUncreated() {
+		String name = jName("noSuchGraph");
+		try {
+			graphMaker.openGraph(name, true);
+			fail(name + " should not exist");
+		} catch (DoesNotExistException e) {
+		}
+	}
+
+	/**
+	 * Test that we *can* open a graph that hasn't been created
+	 */
+	@ContractTest
+	public void testCanOpenUncreated() {
+		String name = jName("willBeCreated");
+		Graph g1 = graphMaker.openGraph(name);
+		g1.close();
+		graphMaker.openGraph(name, true);
+	}
+
+	/**
+	 * Utility - test that a graph with the given name exists.
+	 */
+	private void testExists(String name) {
+		assertTrue(name + " should exist", graphMaker.hasGraph(name));
+	}
+
+	/**
+	 * Utility - test that no graph with the given name exists.
+	 */
+	private void testDoesNotExist(String name) {
+		assertFalse(name + " should exist", graphMaker.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.
+	 * 
+	 */
+	@ContractTest
+	public void testCanFindCreatedGraph() {
+		String alpha = jName("alpha"), beta = jName("beta");
+		Graph g1 = graphMaker.createGraph(alpha, true);
+		Graph h1 = graphMaker.createGraph(beta, true);
+		Graph g2 = graphMaker.openGraph(alpha, true);
+		Graph h2 = graphMaker.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 = GraphHelper.node("S"), P = GraphHelper.node("P"), O = GraphHelper
+				.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.
+	 */
+	@ContractTest
+	public void testCanRemoveGraph() {
+		String alpha = jName("bingo"), beta = jName("brillo");
+		graphMaker.createGraph(alpha, true);
+		graphMaker.createGraph(beta, true);
+		testExists(alpha);
+		testExists(beta);
+		graphMaker.removeGraph(alpha);
+		testExists(beta);
+		testDoesNotExist(alpha);
+	}
+
+	@ContractTest
+	public void testHasnt() {
+		assertFalse("no such graph", graphMaker.hasGraph("john"));
+		assertFalse("no such graph", graphMaker.hasGraph("paul"));
+		assertFalse("no such graph", graphMaker.hasGraph("george"));
+		/* */
+		graphMaker.createGraph("john", true);
+		assertTrue("john now exists", graphMaker.hasGraph("john"));
+		assertFalse("no such graph", graphMaker.hasGraph("paul"));
+		assertFalse("no such graph", graphMaker.hasGraph("george"));
+		/* */
+		graphMaker.createGraph("paul", true);
+		assertTrue("john still exists", graphMaker.hasGraph("john"));
+		assertTrue("paul now exists", graphMaker.hasGraph("paul"));
+		assertFalse("no such graph", graphMaker.hasGraph("george"));
+		/* */
+		graphMaker.removeGraph("john");
+		assertFalse("john has been removed", graphMaker.hasGraph("john"));
+		assertTrue("paul still exists", graphMaker.hasGraph("paul"));
+		assertFalse("no such graph", graphMaker.hasGraph("george"));
+	}
+
+	@ContractTest
+	public void testCarefulClose() {
+		Graph x = graphMaker.createGraph("x");
+		Graph y = graphMaker.openGraph("x");
+		x.add(GraphHelper.triple("a BB c"));
+		x.close();
+		y.add(GraphHelper.triple("p RR q"));
+		y.close();
+	}
+
+	/**
+	 * Test that a maker with no graphs lists no names.
+	 */
+	@ContractTest
+	public void testListNoGraphs() {
+		Set<String> s = graphMaker.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].
+	 */
+	@ContractTest
+	public void testListThreeGraphs() {
+		String x = "x", y = "y/sub", z = "z:boo";
+		Graph X = graphMaker.createGraph(x);
+		Graph Y = graphMaker.createGraph(y);
+		Graph Z = graphMaker.createGraph(z);
+		Set<String> wanted = TestUtils.setOfStrings(x + " " + y + " " + z);
+		assertEquals(wanted, GraphHelper.iteratorToSet(graphMaker.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.
+	 */
+	@ContractTest
+	public void testListAfterDelete() {
+		String x = "x_y", y = "y//zub", z = "a:b/c";
+		Graph X = graphMaker.createGraph(x);
+		Graph Y = graphMaker.createGraph(y);
+		Graph Z = graphMaker.createGraph(z);
+		graphMaker.removeGraph(x);
+		Set<String> s = GraphHelper.iteratorToSet(graphMaker.listGraphs());
+		assertEquals(TestUtils.setOfStrings(y + " " + z), s);
+		X.close();
+		Y.close();
+		Z.close();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
new file mode 100644
index 0000000..aaaa85a
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
@@ -0,0 +1,86 @@
+package org.apache.jena.graph;
+
+import static org.apache.jena.testing_framework.GraphHelper.graphWith;
+import static org.apache.jena.testing_framework.GraphHelper.triple;
+import static org.apache.jena.testing_framework.GraphHelper.txnBegin;
+import static org.apache.jena.testing_framework.GraphHelper.txnCommit;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.impl.GraphWithPerform;
+import org.apache.jena.mem.GraphMem;
+import org.apache.jena.testing_framework.ContractTemplate;
+
+import org.xenei.junit.contract.IProducer;
+
+/**
+ * GraphWithPerform is an implementation interface that extends Graph with the
+ * performAdd and performDelete methods used by GraphBase to invoke
+ * non-notifying versions of add and delete.
+ */
+@Contract(GraphWithPerform.class)
+public class GraphWithPerformContractTest<T extends GraphWithPerform> extends
+		ContractTemplate<IProducer<T>> {
+	// Recording listener for tests
+	protected RecordingGraphListener GL = new RecordingGraphListener();
+
+	private static final Logger LOG = LoggerFactory
+			.getLogger(GraphWithPerformContractTest.class);
+
+	@SuppressWarnings("unchecked")
+	public GraphWithPerformContractTest() {
+//		setProducer((IProducer<T>) new IProducer<GraphWithPerform>() {
+//
+//			@Override
+//			public GraphWithPerform newInstance() {
+//				return new GraphMem();
+//			}
+//
+//			@Override
+//			public void cleanUp() {
+//
+//			}
+//		});
+	}
+
+	@Contract.Inject
+	public void setGraphWithPerformContractTestProducer(IProducer<T> producer) {
+		super.setProducer(producer);
+	}
+
+	@After
+	public final void afterGraphWithPerformContractTest() {
+		getProducer().cleanUp();
+	}
+
+	@ContractTest
+	public void testPerformAdd_Triple() {
+		GraphWithPerform g = (GraphWithPerform) graphWith(getProducer()
+				.newInstance(), "S P O; S2 P2 O2");
+		g.getEventManager().register(GL);
+		txnBegin(g);
+		g.performAdd(triple("S3 P3 O3"));
+		txnCommit(g);
+		GL.assertEmpty();
+		assertTrue(g.contains(triple("S3 P3 O3")));
+	}
+
+	@ContractTest
+	public void testPerformDelete_Triple() {
+		GraphWithPerform g = (GraphWithPerform) graphWith(getProducer()
+				.newInstance(), "S P O; S2 P2 O2");
+		g.getEventManager().register(GL);
+		txnBegin(g);
+		g.performDelete(triple("S2 P2 O2"));
+		txnCommit(g);
+		GL.assertEmpty();
+		assertFalse(g.contains(triple("S2 P2 O2")));
+	}
+
+}


[03/25] jena git commit: Added initial contract tests added testing_framework

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
new file mode 100644
index 0000000..5fbd9c2
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
@@ -0,0 +1,314 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import static org.junit.Assert.*;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphMaker;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.SimpleGraphMaker;
+import org.apache.jena.shared.AlreadyExistsException;
+import org.apache.jena.shared.DoesNotExistException;
+import org.apache.jena.testing_framework.GraphHelper;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.testing_framework.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.)
+ */
+@Contract(GraphMaker.class)
+public class GraphMakerContractTest {
+
+	private IProducer<GraphMaker> producer;
+
+	private GraphMaker graphMaker;
+
+	public GraphMakerContractTest() {
+//		producer = new IProducer<GraphMaker>() {
+//
+//			@Override
+//			public GraphMaker newInstance() {
+//				return new SimpleGraphMaker();
+//			}
+//
+//			@Override
+//			public void cleanUp() {
+//
+//			}
+//		};
+	}
+
+	@Contract.Inject
+	public final void setGraphMaker(IProducer<GraphMaker> producer) {
+		this.producer = producer;
+	}
+
+	protected final IProducer<GraphMaker> getGraphMakerProducer() {
+		return producer;
+	}
+
+	@After
+	public final void afterGraphMakerContractTest() {
+		producer.cleanUp();
+	}
+
+	@Before
+	public final void beforeGraphMakerContractTest() {
+		graphMaker = producer.newInstance();
+	}
+
+	@After
+	public void tearDown() {
+		graphMaker.close();
+		getGraphMakerProducer().cleanUp();
+	}
+
+	/**
+	 * Foo trivial test that getGraph delivers a proper graph, not cheating with
+	 * null, and that getGraph() "always" delivers the same Graph.
+	 */
+	@ContractTest
+	public void testGetGraph() {
+		Graph g1 = graphMaker.getGraph();
+		assertFalse("should deliver a Graph", g1 == null);
+		assertSame(g1, graphMaker.getGraph());
+		g1.close();
+	}
+
+	@ContractTest
+	public void testCreateGraph() {
+		TestUtils.assertDiffer("each created graph must differ",
+				graphMaker.createGraph(), graphMaker.createGraph());
+	}
+
+	@ContractTest
+	public void testAnyName() {
+		graphMaker.createGraph("plain").close();
+		graphMaker.createGraph("with.dot").close();
+		graphMaker.createGraph("http://electric-hedgehog.net/topic#marker")
+				.close();
+	}
+
+	/**
+	 * Test that we can't create a graph with the same name twice.
+	 */
+	@ContractTest
+	public void testCannotCreateTwice() {
+		String name = jName("bonsai");
+		graphMaker.createGraph(name, true);
+		try {
+			graphMaker.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;
+	}
+
+	@ContractTest
+	public void testCanCreateTwice() {
+		String name = jName("bridge");
+		Graph g1 = graphMaker.createGraph(name, true);
+		Graph g2 = graphMaker.createGraph(name, false);
+		assertTrue("graphs should be the same", sameGraph(g1, g2));
+		Graph g3 = graphMaker.createGraph(name);
+		assertTrue("graphs should be the same", sameGraph(g1, g3));
+	}
+
+	/**
+	 * Test that we cannot open a graph that does not exist.
+	 */
+	@ContractTest
+	public void testCannotOpenUncreated() {
+		String name = jName("noSuchGraph");
+		try {
+			graphMaker.openGraph(name, true);
+			fail(name + " should not exist");
+		} catch (DoesNotExistException e) {
+		}
+	}
+
+	/**
+	 * Test that we *can* open a graph that hasn't been created
+	 */
+	@ContractTest
+	public void testCanOpenUncreated() {
+		String name = jName("willBeCreated");
+		Graph g1 = graphMaker.openGraph(name);
+		g1.close();
+		graphMaker.openGraph(name, true);
+	}
+
+	/**
+	 * Utility - test that a graph with the given name exists.
+	 */
+	private void testExists(String name) {
+		assertTrue(name + " should exist", graphMaker.hasGraph(name));
+	}
+
+	/**
+	 * Utility - test that no graph with the given name exists.
+	 */
+	private void testDoesNotExist(String name) {
+		assertFalse(name + " should exist", graphMaker.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.
+	 * 
+	 */
+	@ContractTest
+	public void testCanFindCreatedGraph() {
+		String alpha = jName("alpha"), beta = jName("beta");
+		Graph g1 = graphMaker.createGraph(alpha, true);
+		Graph h1 = graphMaker.createGraph(beta, true);
+		Graph g2 = graphMaker.openGraph(alpha, true);
+		Graph h2 = graphMaker.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 = GraphHelper.node("S"), P = GraphHelper.node("P"), O = GraphHelper
+				.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.
+	 */
+	@ContractTest
+	public void testCanRemoveGraph() {
+		String alpha = jName("bingo"), beta = jName("brillo");
+		graphMaker.createGraph(alpha, true);
+		graphMaker.createGraph(beta, true);
+		testExists(alpha);
+		testExists(beta);
+		graphMaker.removeGraph(alpha);
+		testExists(beta);
+		testDoesNotExist(alpha);
+	}
+
+	@ContractTest
+	public void testHasnt() {
+		assertFalse("no such graph", graphMaker.hasGraph("john"));
+		assertFalse("no such graph", graphMaker.hasGraph("paul"));
+		assertFalse("no such graph", graphMaker.hasGraph("george"));
+		/* */
+		graphMaker.createGraph("john", true);
+		assertTrue("john now exists", graphMaker.hasGraph("john"));
+		assertFalse("no such graph", graphMaker.hasGraph("paul"));
+		assertFalse("no such graph", graphMaker.hasGraph("george"));
+		/* */
+		graphMaker.createGraph("paul", true);
+		assertTrue("john still exists", graphMaker.hasGraph("john"));
+		assertTrue("paul now exists", graphMaker.hasGraph("paul"));
+		assertFalse("no such graph", graphMaker.hasGraph("george"));
+		/* */
+		graphMaker.removeGraph("john");
+		assertFalse("john has been removed", graphMaker.hasGraph("john"));
+		assertTrue("paul still exists", graphMaker.hasGraph("paul"));
+		assertFalse("no such graph", graphMaker.hasGraph("george"));
+	}
+
+	@ContractTest
+	public void testCarefulClose() {
+		Graph x = graphMaker.createGraph("x");
+		Graph y = graphMaker.openGraph("x");
+		x.add(GraphHelper.triple("a BB c"));
+		x.close();
+		y.add(GraphHelper.triple("p RR q"));
+		y.close();
+	}
+
+	/**
+	 * Test that a maker with no graphs lists no names.
+	 */
+	@ContractTest
+	public void testListNoGraphs() {
+		Set<String> s = graphMaker.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].
+	 */
+	@ContractTest
+	public void testListThreeGraphs() {
+		String x = "x", y = "y/sub", z = "z:boo";
+		Graph X = graphMaker.createGraph(x);
+		Graph Y = graphMaker.createGraph(y);
+		Graph Z = graphMaker.createGraph(z);
+		Set<String> wanted = TestUtils.setOfStrings(x + " " + y + " " + z);
+		assertEquals(wanted, GraphHelper.iteratorToSet(graphMaker.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.
+	 */
+	@ContractTest
+	public void testListAfterDelete() {
+		String x = "x_y", y = "y//zub", z = "a:b/c";
+		Graph X = graphMaker.createGraph(x);
+		Graph Y = graphMaker.createGraph(y);
+		Graph Z = graphMaker.createGraph(z);
+		graphMaker.removeGraph(x);
+		Set<String> s = GraphHelper.iteratorToSet(graphMaker.listGraphs());
+		assertEquals(TestUtils.setOfStrings(y + " " + z), s);
+		X.close();
+		Y.close();
+		Z.close();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
new file mode 100644
index 0000000..aaaa85a
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
@@ -0,0 +1,86 @@
+package org.apache.jena.graph;
+
+import static org.apache.jena.testing_framework.GraphHelper.graphWith;
+import static org.apache.jena.testing_framework.GraphHelper.triple;
+import static org.apache.jena.testing_framework.GraphHelper.txnBegin;
+import static org.apache.jena.testing_framework.GraphHelper.txnCommit;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.impl.GraphWithPerform;
+import org.apache.jena.mem.GraphMem;
+import org.apache.jena.testing_framework.ContractTemplate;
+
+import org.xenei.junit.contract.IProducer;
+
+/**
+ * GraphWithPerform is an implementation interface that extends Graph with the
+ * performAdd and performDelete methods used by GraphBase to invoke
+ * non-notifying versions of add and delete.
+ */
+@Contract(GraphWithPerform.class)
+public class GraphWithPerformContractTest<T extends GraphWithPerform> extends
+		ContractTemplate<IProducer<T>> {
+	// Recording listener for tests
+	protected RecordingGraphListener GL = new RecordingGraphListener();
+
+	private static final Logger LOG = LoggerFactory
+			.getLogger(GraphWithPerformContractTest.class);
+
+	@SuppressWarnings("unchecked")
+	public GraphWithPerformContractTest() {
+//		setProducer((IProducer<T>) new IProducer<GraphWithPerform>() {
+//
+//			@Override
+//			public GraphWithPerform newInstance() {
+//				return new GraphMem();
+//			}
+//
+//			@Override
+//			public void cleanUp() {
+//
+//			}
+//		});
+	}
+
+	@Contract.Inject
+	public void setGraphWithPerformContractTestProducer(IProducer<T> producer) {
+		super.setProducer(producer);
+	}
+
+	@After
+	public final void afterGraphWithPerformContractTest() {
+		getProducer().cleanUp();
+	}
+
+	@ContractTest
+	public void testPerformAdd_Triple() {
+		GraphWithPerform g = (GraphWithPerform) graphWith(getProducer()
+				.newInstance(), "S P O; S2 P2 O2");
+		g.getEventManager().register(GL);
+		txnBegin(g);
+		g.performAdd(triple("S3 P3 O3"));
+		txnCommit(g);
+		GL.assertEmpty();
+		assertTrue(g.contains(triple("S3 P3 O3")));
+	}
+
+	@ContractTest
+	public void testPerformDelete_Triple() {
+		GraphWithPerform g = (GraphWithPerform) graphWith(getProducer()
+				.newInstance(), "S P O; S2 P2 O2");
+		g.getEventManager().register(GL);
+		txnBegin(g);
+		g.performDelete(triple("S2 P2 O2"));
+		txnCommit(g);
+		GL.assertEmpty();
+		assertFalse(g.contains(triple("S2 P2 O2")));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/RecordingGraphListener.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/RecordingGraphListener.java b/jena-core/src/test/java/org/apache/jena/graph/RecordingGraphListener.java
new file mode 100644
index 0000000..ed94c8f
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/RecordingGraphListener.java
@@ -0,0 +1,92 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphListener;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.testing_framework.AbstractRecordingListener;
+import org.apache.jena.testing_framework.GraphHelper;
+
+/**
+ * This testing listener records the event names and data, and provides a method
+ * for comparing the actual with the expected history.
+ */
+public class RecordingGraphListener extends AbstractRecordingListener implements
+		GraphListener {
+
+	@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, GraphHelper.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, GraphHelper.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);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
new file mode 100644
index 0000000..d26d7e9
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
@@ -0,0 +1,149 @@
+/*
+ * 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 org.apache.jena.graph;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import static org.junit.Assert.*;
+
+import org.apache.jena.graph.TransactionHandler;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.SimpleTransactionHandler;
+import org.apache.jena.shared.Command;
+import org.apache.jena.shared.JenaException;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.CollectionFactory;
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+/**
+ * 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.
+ */
+@Contract(TransactionHandler.class)
+public class TransactionHandlerContractTest {
+
+	private IProducer<TransactionHandler> producer;
+
+	public TransactionHandlerContractTest() {
+//		producer = new IProducer<TransactionHandler>() {
+//
+//			@Override
+//			public TransactionHandler newInstance() {
+//				return new SimpleTransactionHandler();
+//			}
+//
+//			@Override
+//			public void cleanUp() {
+//
+//			}
+//		};
+	}
+
+	@Contract.Inject
+	public void setProducer(IProducer<TransactionHandler> producer) {
+		this.producer = producer;
+	}
+
+	protected IProducer<TransactionHandler> getTransactionHandlerProducer() {
+		return producer;
+	}
+
+	/**
+	 * Test that Graphs have transaction support methods, and that if they fail
+	 * on some g they fail because they do not support the operation.
+	 */
+	@ContractTest
+	public void testTransactionsExistAsPerTransactionSupported() {
+		Command cmd = new Command() {
+			@Override
+			public Object execute() {
+				return null;
+			}
+		};
+
+		TransactionHandler th = getTransactionHandlerProducer().newInstance();
+
+		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) {
+			}
+		}
+	}
+
+	@ContractTest
+	public void testExecuteInTransactionCatchesThrowable() {
+		TransactionHandler th = getTransactionHandlerProducer().newInstance();
+
+		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; Foo 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));
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/compose/DeltaTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/DeltaTest.java b/jena-core/src/test/java/org/apache/jena/graph/compose/DeltaTest.java
new file mode 100755
index 0000000..a0bf737
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/DeltaTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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 org.apache.jena.graph.compose;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(Delta.class)
+public class DeltaTest  {
+
+	protected IProducer<Delta> graphProducer;
+	
+	public DeltaTest() {
+		super();
+		graphProducer = new AbstractGraphProducer<Delta>() {
+			private Map<Graph, Graph> map = new HashMap<Graph, Graph>();
+
+			@Override
+			protected Delta createNewGraph() {
+				Graph g = memGraph();
+				Delta d = new Delta(g);
+				map.put(d, g);
+				return d;
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+//				Delta dl = (Delta)d;
+//				Graph g = map.get(d);
+//				if (g == null) {
+//					throw new IllegalStateException("graph missing from map");
+//				}
+//				return new Graph[] { g,  (Graph)dl.getL(), (Graph)dl.getR() };
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+			@Override
+			protected void afterClose(Graph g) {
+				map.remove(g);
+			}
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<Delta> getDeltaTestProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testDelta() {
+		Graph x = graphWith(getDeltaTestProducer().newInstance(), "x R y");
+		assertContains("x", "x R y", x);
+		x.delete(triple("x R y"));
+		assertOmits("x", x, "x R y");
+		/* */
+		Graph base = graphWith("x R y; p S q; I like cheese; pins pop balloons");
+		Delta delta = new Delta(base);
+		assertContainsAll("Delta", delta,
+				"x R y; p S q; I like cheese; pins pop balloons");
+		assertContainsAll("Base", base,
+				"x R y; p S q; I like cheese; pins pop balloons");
+		/* */
+		delta.add(triple("pigs fly winglessly"));
+		delta.delete(triple("I like cheese"));
+		/* */
+		assertContainsAll("changed Delta", delta,
+				"x R y; p S q; pins pop balloons; pigs fly winglessly");
+		assertOmits("changed delta", delta, "I like cheese");
+		assertContains("delta additions", "pigs fly winglessly",
+				delta.getAdditions());
+		assertOmits("delta additions", delta.getAdditions(), "I like cheese");
+		assertContains("delta deletions", "I like cheese", delta.getDeletions());
+		assertOmits("delta deletions", delta.getDeletions(),
+				"pigs fly winglessly");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/compose/DifferenceTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/DifferenceTest.java b/jena-core/src/test/java/org/apache/jena/graph/compose/DifferenceTest.java
new file mode 100755
index 0000000..213ae36
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/DifferenceTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 org.apache.jena.graph.compose;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.compose.Difference;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(Difference.class)
+public class DifferenceTest {
+
+	protected IProducer<Difference> graphProducer;
+	
+	public DifferenceTest() {
+		graphProducer = new AbstractGraphProducer<Difference>() {
+			private Map<Graph, Graph[]> map = new HashMap<Graph, Graph[]>();
+
+			@Override
+			protected Difference createNewGraph() {
+				Graph g1 = memGraph();
+				Graph g2 = memGraph();
+				Difference d = new Difference(g1, g2);
+				map.put(d, new Graph[] { g1, g2 });
+				return d;
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				Graph[] dg = map.get(d);
+				if (dg == null) {
+					throw new IllegalStateException("graph not in map");
+				}
+				return dg;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+			@Override
+			protected void afterClose(Graph g) {
+				map.remove(g);
+			}
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<Difference> getDifferenceTestProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testDifference() {
+		Graph g1 = graphWith("x R y; p R q");
+		Graph g2 = graphWith("r Foo s; x R y");
+		Graph d = new Difference(g1, g2);
+		assertOmits("Difference", d, "x R y");
+		assertContains("Difference", "p R q", d);
+		assertOmits("Difference", d, "r Foo s");
+		if (d.size() != 1)
+			fail("oops: size of difference is not 1");
+		d.add(triple("cats eat cheese"));
+		assertContains("Difference.L", "cats eat cheese", g1);
+		assertOmits("Difference.R", g2, "cats eat cheese");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/compose/IntersectionTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/IntersectionTest.java b/jena-core/src/test/java/org/apache/jena/graph/compose/IntersectionTest.java
new file mode 100755
index 0000000..1e6db9b
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/IntersectionTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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 org.apache.jena.graph.compose;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphUtil;
+import org.apache.jena.graph.compose.Intersection;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(Intersection.class)
+public class IntersectionTest {
+
+	protected IProducer<Intersection> graphProducer;
+	
+	public IntersectionTest() {
+		super();
+		graphProducer = new AbstractGraphProducer<Intersection>() {
+			private Map<Graph, Graph[]> dependencyGraph = new HashMap<Graph, Graph[]>();
+
+			@Override
+			protected Intersection createNewGraph() {
+				Graph g1 = memGraph();
+				Graph g2 = memGraph();
+				Intersection retval = new Intersection(g1, g2);
+				dependencyGraph.put(retval, new Graph[] { g1, g2 });
+				return retval;
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph g) {
+				Graph[] dg = dependencyGraph.get(g);
+				if (dg == null) {
+					throw new IllegalStateException("graph missing from map");
+				}
+				return dg;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+			@Override
+			protected void afterClose(Graph g) {
+				dependencyGraph.remove(g);
+			}
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<Intersection> getIntersectionTestProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testIntersection() {
+		Graph g1 = graphWith( "x R y; p R q");
+		Graph g2 = graphWith( "r Foo s; x R y");
+		Intersection i = new Intersection(g1, g2);
+		assertContains("Intersection", "x R y", i);
+		assertOmits("Intersection", i, "p R q");
+		assertOmits("Intersection", i, "r Foo s");
+		if (i.size() != 1)
+			fail("oops: size of intersection is not 1");
+		i.add(triple("cats eat cheese"));
+		assertContains("Intersection.L", "cats eat cheese", g1);
+		assertContains("Intersection.R", "cats eat cheese", g2);
+	}
+
+	@ContractTest
+	public void testDeleteDoesNotUpdateR() {
+		Graph L = graphWith("a pings b; b pings c; c pings a");
+		Graph R = graphWith("c pings a; b pings c; x captures y");
+		Graph join = new Intersection(L, R);
+		GraphUtil.deleteFrom(L, R);
+		assertIsomorphic("R should not change",
+				graphWith("c pings a; b pings c; x captures y"), R);
+		assertIsomorphic(graphWith("a pings b"), L);
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/compose/UnionTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/compose/UnionTest.java b/jena-core/src/test/java/org/apache/jena/graph/compose/UnionTest.java
new file mode 100755
index 0000000..44bf9fb
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/compose/UnionTest.java
@@ -0,0 +1,185 @@
+/*
+ * 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 org.apache.jena.graph.compose;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphStatisticsHandler;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.compose.Union;
+import org.apache.jena.graph.impl.GraphBase;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(Union.class)
+public class UnionTest {
+	
+	protected IProducer<Union> graphProducer;
+	
+	public UnionTest() {
+		graphProducer = new AbstractGraphProducer<Union>() {
+			private Map<Graph, Graph[]> map = new HashMap<Graph, Graph[]>();
+
+			@Override
+			protected Union createNewGraph() {
+				Graph[] g = { memGraph(), memGraph() };
+				Union u = new Union(g[0], g[1]);
+				map.put(u, g);
+				return u;
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				Graph[] dg = map.get(d);
+				if (dg == null) {
+					throw new IllegalStateException("graph not in map");
+				}
+				return dg;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+			@Override
+			protected void afterClose(Graph g) {
+				map.remove(g);
+			}
+		};
+
+	}
+
+	@Contract.Inject
+	public final IProducer<Union> getUnionTestProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testUnion() {
+		Graph g1 = graphWith("x R y; p R q");
+		Graph g2 = graphWith("r Foo s; x R y");
+		Union u = new Union(g1, g2);
+		assertContains("Union", "x R y", u);
+		assertContains("Union", "p R q", u);
+		assertContains("Union", "r Foo s", u);
+		if (u.size() != 3)
+			fail("oops: size of union is not 3");
+		u.add(triple("cats eat cheese"));
+		assertContains("Union", "cats eat cheese", u);
+		if (contains(g1, "cats eat cheese") == false
+				&& contains(g2, "cats eat cheese") == false)
+			fail("oops: neither g1 nor g2 contains `cats eat cheese`");
+	}
+
+	static class AnInteger {
+		public int value = 0;
+
+		public AnInteger(int value) {
+			this.value = value;
+		}
+	}
+
+	@ContractTest
+	public void testUnionValues() {
+		testUnion(0, 0, 0, 0);
+	}
+
+	@ContractTest
+	public void testCopiesSingleNonZeroResult() {
+		testUnion(1, 1, 0, 0);
+		testUnion(1, 0, 1, 0);
+		testUnion(1, 0, 0, 1);
+		testUnion(1, 1, 0, 0);
+		testUnion(2, 0, 2, 0);
+		testUnion(4, 0, 0, 4);
+	}
+
+	@ContractTest
+	public void testResultIsSumOfBaseResults() {
+		testUnion(3, 1, 2, 0);
+		testUnion(5, 1, 0, 4);
+		testUnion(6, 0, 2, 4);
+		testUnion(7, 1, 2, 4);
+		testUnion(3, 0, 2, 1);
+		testUnion(5, 4, 1, 0);
+		testUnion(6, 2, 2, 2);
+		testUnion(7, 6, 0, 1);
+	}
+
+	@ContractTest
+	public void testUnknownOverrulesAll() {
+		testUnion(-1, -1, 0, 0);
+		testUnion(-1, 0, -1, 0);
+		testUnion(-1, 0, 0, -1);
+		testUnion(-1, -1, 1, 1);
+		testUnion(-1, 1, -1, 1);
+		testUnion(-1, 1, 1, -1);
+	}
+
+	/**
+	 * Asserts that the statistic obtained by probing the three-element union
+	 * with statistics <code>av</code>, <code>bv</code>, and <code>cv</code> is
+	 * <code>expected</code>.
+	 */
+	private void testUnion(int expected, int av, int bv, int cv) {
+		AnInteger a = new AnInteger(av), b = new AnInteger(bv), c = new AnInteger(
+				cv);
+		Graph g1 = graphWithGivenStatistic(a);
+		Graph g2 = graphWithGivenStatistic(b);
+		Graph g3 = graphWithGivenStatistic(c);
+		Graph[] graphs = new Graph[] { g1, g2, g3 };
+		MultiUnion mu = new MultiUnion(graphs);
+		GraphStatisticsHandler gs = new MultiUnion.MultiUnionStatisticsHandler(
+				mu);
+		assertEquals(expected, gs.getStatistic(Node.ANY, Node.ANY, Node.ANY));
+	}
+
+	static Graph graphWithGivenStatistic(final AnInteger x) {
+		return new GraphBase() {
+			@Override
+			protected ExtendedIterator<Triple> graphBaseFind(Triple t) {
+				throw new RuntimeException("should never be called");
+			}
+
+			@Override
+			protected GraphStatisticsHandler createStatisticsHandler() {
+				return new GraphStatisticsHandler() {
+					@Override
+					public long getStatistic(Node S, Node P, Node O) {
+						return x.value;
+					}
+				};
+			}
+		};
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
index 3334da7..4d9f40d 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
@@ -18,22 +18,50 @@
 
 package org.apache.jena.graph.impl;
 
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
 import java.util.HashSet;
 
 import org.apache.jena.graph.Graph ;
 import org.apache.jena.graph.Triple ;
 import org.apache.jena.graph.impl.CollectionGraph ;
-import org.apache.jena.graph.test.AbstractTestGraph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
 
-public class TestCollectionGraph extends AbstractTestGraph {
+@RunWith(ContractSuite.class)
+@ContractImpl(CollectionGraph.class)
+public class TestCollectionGraph {
 	 
-	public TestCollectionGraph(String name) {
-		super(name);
+	protected IProducer<CollectionGraph> graphProducer;
+	
+	public TestCollectionGraph() {
+		graphProducer = new AbstractGraphProducer<CollectionGraph>() {
+			
+			@Override
+			protected CollectionGraph createNewGraph() {
+				return new CollectionGraph( new HashSet<Triple>() );
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+		};
 	}
 
-	@Override
-	public Graph getGraph() {
-		return new CollectionGraph( new HashSet<Triple>() );
+	@Contract.Inject
+	public final IProducer<CollectionGraph> getDeltaTestProducer() {
+		return graphProducer;
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
new file mode 100644
index 0000000..7910660
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
@@ -0,0 +1,63 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(WrappedGraph.class)
+public class TestWrappedGraph {
+	 
+	protected IProducer<WrappedGraph> graphProducer;
+	
+	public TestWrappedGraph() {
+		graphProducer = new AbstractGraphProducer<WrappedGraph>() {
+			
+			@Override
+			protected WrappedGraph createNewGraph() {
+				return new WrappedGraph( memGraph() );
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<WrappedGraph> getDeltaTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
new file mode 100644
index 0000000..0b074aa
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
@@ -0,0 +1,176 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import static org.junit.Assert.*;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import org.apache.jena.mem.GraphTripleStore;
+import org.apache.jena.graph.impl.TripleStore;
+import org.apache.jena.testing_framework.ContractTemplate;
+
+import org.xenei.junit.contract.IProducer;
+
+/**
+ * AbstractTestTripleStore - post-hoc tests for TripleStores.
+ */
+
+@Contract(TripleStore.class)
+public class TripleStoreContractTest<T extends TripleStore> extends
+		ContractTemplate<IProducer<T>> {
+
+	protected TripleStore store;
+
+	public TripleStoreContractTest() {
+		IProducer<TripleStore> producer = new IProducer<TripleStore>() {
+
+			@Override
+			public TripleStore newInstance() {
+				return new GraphTripleStore(memGraph());
+			}
+
+			@Override
+			public void cleanUp() {
+				// TODO Auto-generated method stub
+
+			}
+
+		};
+		setProducer((IProducer<T>) producer);
+	}
+
+	/**
+	 * Subclasses must over-ride to return a new empty TripleStore.
+	 */
+	@Contract.Inject
+	public final void setTripleStoreContractTestProducer(IProducer<T> producer) {
+		super.setProducer(producer);
+	}
+
+	@Before
+	public final void beforeAbstractTripleStoreTest() {
+		store = getProducer().newInstance();
+	}
+
+	@After
+	public final void afterAbstractTripleStoreTest() {
+		getProducer().cleanUp();
+	}
+
+	@ContractTest
+	public void testEmpty() {
+		testEmpty(store);
+	}
+
+	@ContractTest
+	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("?? ?? ??"))));
+	}
+
+	@ContractTest
+	public void testListSubjects() {
+		someStatements(store);
+		assertEquals(nodeSet("a x _z r q"), iteratorToSet(store.listSubjects()));
+	}
+
+	@ContractTest
+	public void testListObjects() {
+		someStatements(store);
+		assertEquals(nodeSet("b y i _j _t 17"),
+				iteratorToSet(store.listObjects()));
+	}
+
+	@ContractTest
+	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")));
+	}
+
+	@ContractTest
+	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"))));
+	}
+
+	@ContractTest
+	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")));
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/mem/BunchMapContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/BunchMapContractTest.java b/jena-core/src/test/java/org/apache/jena/mem/BunchMapContractTest.java
new file mode 100644
index 0000000..7807248
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/BunchMapContractTest.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.mem;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+/**
+ * Test triple bunch implementations - NOT YET FINISHED
+ */
+@Contract(BunchMap.class)
+public class BunchMapContractTest {
+	private BunchMap map;
+
+	private IProducer<? extends BunchMap> producer;
+
+	@Contract.Inject
+	public final void setBunchMapProducer(IProducer<? extends BunchMap> producer) {
+		this.producer = producer;
+	}
+
+	protected final IProducer<? extends BunchMap> getBunchMapProducer() {
+		return producer;
+	}
+
+	@Before
+	public final void beforeAbstractBunchMapTest() {
+		map = getBunchMapProducer().newInstance();
+	}
+
+	@After
+	public final void afterAbstractBunchMapTest() {
+		getBunchMapProducer().cleanUp();
+	}
+
+	@ContractTest
+	public void testClear() {
+		for (int i = 0; i < 5; i++) {
+			map.put(i, mock(TripleBunch.class));
+		}
+		assertEquals(5, map.size());
+
+		map.clear();
+		assertEquals(0, map.size());
+	}
+
+	@ContractTest
+	public void testSize() {
+		assertEquals(0, map.size());
+		for (int i = 0; i < 5; i++) {
+			map.put(i, mock(TripleBunch.class));
+			assertEquals(i + 1, map.size());
+		}
+	}
+
+	@ContractTest
+	public void testGet() {
+		List<TripleBunch> lst = new ArrayList<TripleBunch>();
+		for (int i = 0; i < 5; i++) {
+			TripleBunch tb = mock(TripleBunch.class);
+			lst.add(tb);
+			map.put(i, tb);
+		}
+		for (int i = 0; i < 5; i++) {
+			assertEquals(lst.get(i), map.get(i));
+		}
+	}
+
+	@ContractTest
+	public void testPut() {
+		List<TripleBunch> lst = new ArrayList<TripleBunch>();
+		for (int i = 0; i < 5; i++) {
+			map.put(i, mock(TripleBunch.class));
+		}
+		for (int i = 0; i < 5; i++) {
+			TripleBunch tb = mock(TripleBunch.class);
+			lst.add(tb);
+			map.put(i, tb);
+		}
+		for (int i = 0; i < 5; i++) {
+			assertEquals(lst.get(i), map.get(i));
+		}
+	}
+
+	@ContractTest
+	public void testRemove() {
+		List<TripleBunch> lst = new ArrayList<TripleBunch>();
+		for (int i = 0; i < 5; i++) {
+			TripleBunch tb = mock(TripleBunch.class);
+			lst.add(tb);
+			map.put(i, tb);
+		}
+
+		map.remove(0);
+		assertNull(map.get(0));
+		for (int i = 1; i < 5; i++) {
+			assertEquals(lst.get(i), map.get(i));
+		}
+		assertEquals(4, map.size());
+
+		map.remove(2);
+		assertNull(map.get(0));
+		assertEquals(lst.get(1), map.get(1));
+		assertNull(map.get(2));
+		assertEquals(lst.get(3), map.get(3));
+		assertEquals(lst.get(4), map.get(4));
+		assertEquals(3, map.size());
+
+		map.remove(4);
+		assertNull(map.get(0));
+		assertEquals(lst.get(1), map.get(1));
+		assertNull(map.get(2));
+		assertEquals(lst.get(3), map.get(3));
+		assertNull(map.get(4));
+		assertEquals(2, map.size());
+
+	}
+
+	@ContractTest
+	public void testKeyIterator() {
+		List<Integer> lst = new ArrayList<Integer>();
+		for (int i = 0; i < 5; i++) {
+			lst.add(i);
+			map.put(i, mock(TripleBunch.class));
+		}
+		ExtendedIterator<Object> iter = map.keyIterator();
+		while (iter.hasNext()) {
+			assertFalse("List is empty", lst.isEmpty());
+			Integer i = (Integer) iter.next();
+			assertTrue("Missing index: " + i, lst.contains(i));
+			lst.remove(i);
+		}
+		assertTrue("List is not empty", lst.isEmpty());
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java b/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
new file mode 100644
index 0000000..8fed109
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
@@ -0,0 +1,115 @@
+/*
+    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 org.apache.jena.mem;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphStatisticsHandler;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Node_URI;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.JenaException;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphMem.class)
+public class GraphMemTest {
+
+	protected IProducer<GraphMem> graphProducer = new AbstractGraphProducer<GraphMem>() {
+
+		@Override
+		protected GraphMem createNewGraph() {
+			return new GraphMem();
+		}
+
+		@Override
+		public Graph[] getDependsOn(Graph g) {
+			return null;
+		}
+
+		@Override
+		public Graph[] getNotDependsOn(Graph g) {
+			return new Graph[] { memGraph() };
+		}
+
+	};
+
+	@Inject
+	public IProducer<GraphMem> getGraphProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testHasStatistics() {
+		GraphStatisticsHandler h = graphProducer.newInstance()
+				.getStatisticsHandler();
+		assertNotNull(h);
+	}
+
+	@ContractTest
+	public void testContainsConcreteDoesntUseFind() {
+		Graph g = new GraphMemWithoutFind();
+		graphAdd(g, "x P y; a Q b");
+		assertTrue(g.contains(triple("x P y")));
+		assertTrue(g.contains(triple("a Q b")));
+		assertFalse(g.contains(triple("a P y")));
+		assertFalse(g.contains(triple("y R b")));
+	}
+
+	protected final class GraphMemWithoutFind extends GraphMem {
+		@Override
+		public ExtendedIterator<Triple> graphBaseFind(Triple t) {
+			throw new JenaException("find is Not Allowed");
+		}
+	}
+
+	@ContractTest
+	public void testUnnecessaryMatches() {
+		Node special = new Node_URI("eg:foo") {
+			@Override
+			public boolean matches(Node s) {
+				fail("Matched called superfluously.");
+				return true;
+			}
+		};
+		Graph g = graphWith(graphProducer.newInstance(), "x p y");
+		g.add(new Triple(special, special, special));
+		exhaust(g.find(special, Node.ANY, Node.ANY));
+		exhaust(g.find(Node.ANY, special, Node.ANY));
+		exhaust(g.find(Node.ANY, Node.ANY, special));
+
+	}
+
+	protected void exhaust(Iterator<?> it) {
+		while (it.hasNext())
+			it.next();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
new file mode 100644
index 0000000..1f82935
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.mem.GraphTripleStore;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphTripleStore.class)
+public class GraphTripleStoreTest {
+
+	private IProducer<GraphTripleStore> producer = new IProducer<GraphTripleStore>() {
+
+		@Override
+		public GraphTripleStore newInstance() {
+			return new GraphTripleStore(Graph.emptyGraph);
+		}
+
+		@Override
+		public void cleanUp() {
+		}
+
+	};
+
+	@Contract.Inject
+	public IProducer<GraphTripleStore> getTripleStore() {
+		return producer;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/mem/TripleBunchContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/TripleBunchContractTest.java b/jena-core/src/test/java/org/apache/jena/mem/TripleBunchContractTest.java
new file mode 100644
index 0000000..505b57f
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/TripleBunchContractTest.java
@@ -0,0 +1,205 @@
+/*
+ * 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 org.apache.jena.mem;
+
+import static org.junit.Assert.*;
+import static org.apache.jena.testing_framework.GraphHelper.*;
+
+import java.util.ArrayList;
+import java.util.ConcurrentModificationException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.Triple;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.testing_framework.NodeCreateUtils;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+/**
+ * Test triple bunch implementations - NOT YET FINISHED
+ */
+@Contract(TripleBunch.class)
+public class TripleBunchContractTest {
+	private IProducer<? extends TripleBunch> producer;
+
+	@Contract.Inject
+	public final void setTripleBunchProducer(
+			IProducer<? extends TripleBunch> producer) {
+		this.producer = producer;
+	}
+
+	protected final IProducer<? extends TripleBunch> getTripleBunchProducer() {
+		return producer;
+	}
+
+	public static final TripleBunch EMPTY_BUNCH = new ArrayBunch();
+
+	protected static final Triple tripleSPO = triple("s P o");
+	protected static final Triple tripleXQY = triple("x Q y");
+
+	private TripleBunch testingBunch;
+
+	@Before
+	public final void beforeAbstractTripleBunchTest() {
+		testingBunch = getTripleBunchProducer().newInstance();
+	}
+
+	@After
+	public final void afterAbstractTripleBunchTest() {
+		getTripleBunchProducer().cleanUp();
+	}
+
+	@ContractTest
+	public void testEmptyBunch() {
+		assertEquals(0, testingBunch.size());
+		assertFalse(testingBunch.contains(tripleSPO));
+		assertFalse(testingBunch.contains(tripleXQY));
+		assertFalse(testingBunch.iterator().hasNext());
+	}
+
+	@ContractTest
+	public void testAddElement() {
+		testingBunch.add(tripleSPO);
+		assertEquals(1, testingBunch.size());
+		assertTrue(testingBunch.contains(tripleSPO));
+		assertEquals(listOf(tripleSPO), iteratorToList(testingBunch.iterator()));
+	}
+
+	@ContractTest
+	public void testAddElements() {
+		testingBunch.add(tripleSPO);
+		testingBunch.add(tripleXQY);
+		assertEquals(2, testingBunch.size());
+		assertTrue(testingBunch.contains(tripleSPO));
+		assertTrue(testingBunch.contains(tripleXQY));
+		assertEquals(setOf(tripleSPO, tripleXQY),
+				iteratorToSet(testingBunch.iterator()));
+	}
+
+	@ContractTest
+	public void testRemoveOnlyElement() {
+		testingBunch.add(tripleSPO);
+		testingBunch.remove(tripleSPO);
+		assertEquals(0, testingBunch.size());
+		assertFalse(testingBunch.contains(tripleSPO));
+		assertFalse(testingBunch.iterator().hasNext());
+	}
+
+	@ContractTest
+	public void testRemoveFirstOfTwo() {
+		testingBunch.add(tripleSPO);
+		testingBunch.add(tripleXQY);
+		testingBunch.remove(tripleSPO);
+		assertEquals(1, testingBunch.size());
+		assertFalse(testingBunch.contains(tripleSPO));
+		assertTrue(testingBunch.contains(tripleXQY));
+		assertEquals(listOf(tripleXQY), iteratorToList(testingBunch.iterator()));
+	}
+
+	@ContractTest
+	public void testTableGrows() {
+		testingBunch.add(tripleSPO);
+		testingBunch.add(tripleXQY);
+		testingBunch.add(triple("a I b"));
+		testingBunch.add(triple("c J d"));
+	}
+
+	@ContractTest
+	public void testIterator() {
+		testingBunch.add(triple("a P b"));
+		testingBunch.add(triple("c Q d"));
+		testingBunch.add(triple("e R f"));
+		assertEquals(tripleSet("a P b; c Q d; e R f"), testingBunch.iterator()
+				.toSet());
+	}
+
+	@ContractTest
+	public void testIteratorRemoveOneItem() {
+		testingBunch.add(triple("a P b"));
+		testingBunch.add(triple("c Q d"));
+		testingBunch.add(triple("e R f"));
+		ExtendedIterator<Triple> it = testingBunch.iterator();
+		while (it.hasNext())
+			if (it.next().equals(triple("c Q d")))
+				it.remove();
+		assertEquals(tripleSet("a P b; e R f"), testingBunch.iterator().toSet());
+	}
+
+	@ContractTest
+	public void testIteratorRemoveAlltems() {
+		testingBunch.add(triple("a P b"));
+		testingBunch.add(triple("c Q d"));
+		testingBunch.add(triple("e R f"));
+		ExtendedIterator<Triple> it = testingBunch.iterator();
+		while (it.hasNext())
+			it.removeNext();
+		assertEquals(tripleSet(""), testingBunch.iterator().toSet());
+	}
+
+	protected List<Triple> listOf(Triple x) {
+		List<Triple> result = new ArrayList<Triple>();
+		result.add(x);
+		return result;
+	}
+
+	protected Set<Triple> setOf(Triple x, Triple y) {
+		Set<Triple> result = setOf(x);
+		result.add(y);
+		return result;
+	}
+
+	protected Set<Triple> setOf(Triple x) {
+		Set<Triple> result = new HashSet<Triple>();
+		result.add(x);
+		return result;
+	}
+
+	public void testAddThenNextThrowsCME() {
+		testingBunch.add(NodeCreateUtils.createTriple("a P b"));
+		testingBunch.add(NodeCreateUtils.createTriple("c Q d"));
+		ExtendedIterator<Triple> it = testingBunch.iterator();
+		it.next();
+		testingBunch.add(NodeCreateUtils.createTriple("change its state"));
+		try {
+			it.next();
+			fail("should have thrown ConcurrentModificationException");
+		} catch (ConcurrentModificationException e) {
+			// expected
+		}
+	}
+
+	public void testDeleteThenNextThrowsCME() {
+		testingBunch.add(NodeCreateUtils.createTriple("a P b"));
+		testingBunch.add(NodeCreateUtils.createTriple("c Q d"));
+		ExtendedIterator<Triple> it = testingBunch.iterator();
+		it.next();
+		testingBunch.remove(NodeCreateUtils.createTriple("a P b"));
+		try {
+			it.next();
+			fail("should have thrown ConcurrentModificationException");
+		} catch (ConcurrentModificationException e) {
+			// expected
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractGraphProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractGraphProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractGraphProducer.java
new file mode 100644
index 0000000..29cf9f0
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractGraphProducer.java
@@ -0,0 +1,104 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xenei.junit.contract.IProducer;
+
+import org.apache.jena.graph.Graph;
+
+/**
+ * An abstract implementation of the GraphProducerInterface.
+ * 
+ * This class handles tracking of the created graphs and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the graph is closed.
+ * 
+ */
+public abstract class AbstractGraphProducer<T extends Graph> implements
+		IProducer<T> {
+
+	/**
+	 * The list of graphs that have been opened in this test.
+	 */
+	protected List<Graph> graphList = new ArrayList<Graph>();
+
+	/**
+	 * The method to create a new graph.
+	 * 
+	 * @return a newly constructed graph of type under test.
+	 */
+	abstract protected T createNewGraph();
+
+	@Override
+	final public T newInstance() {
+		T retval = createNewGraph();
+		graphList.add(retval);
+		return retval;
+	}
+
+	/**
+	 * Method called after the graph is closed. This allows the implementer to
+	 * perform extra cleanup activities, like deleting the file associated with
+	 * a file based graph.
+	 * <p>
+	 * By default this does nothing.
+	 * </p>
+	 * 
+	 * @param g
+	 *            The graph that is closed
+	 */
+	protected void afterClose(Graph g) {
+	};
+
+	@Override
+	final public void cleanUp() {
+		for (Graph g : graphList) {
+			if (!g.isClosed()) {
+				g.close();
+			}
+			afterClose(g);
+		}
+		graphList.clear();
+	}
+
+	/**
+	 * Get a list of graphs that the created graph is dependent upon. The graph
+	 * must return true for each call to dependsOn() with one of the returned
+	 * graphs. Method may return null to disable the check.
+	 * 
+	 * @param g
+	 *            The graph we are looking for.
+	 * @return
+	 */
+	public abstract Graph[] getDependsOn(Graph g);
+
+	/**
+	 * Get a list of graphs that the created graph is not dependent upon. The
+	 * graph must return false for each call to dependsOn() with one of the
+	 * returned graphs. Method may return null to disable the check.
+	 * 
+	 * @param g
+	 *            The graph we are looking for.
+	 * @return
+	 */
+	public abstract Graph[] getNotDependsOn(Graph g);
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractInfModelProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractInfModelProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractInfModelProducer.java
new file mode 100644
index 0000000..898503d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractInfModelProducer.java
@@ -0,0 +1,91 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.apache.jena.rdf.model.InfModel;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.reasoner.Reasoner;
+
+/**
+ * An abstract implementation of the ModelProducerInterface.
+ * 
+ * This class handles tracking of the created models and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the model is closed.
+ * 
+ */
+public abstract class AbstractInfModelProducer<T extends InfModel> extends
+		AbstractModelProducer<T> {
+
+	
+	public boolean canBeEmpty( Model m ) 
+	{
+		return false;
+	}
+	/**
+	 * @return true if the models returned by this poducer are independent,
+	 *         false otherwise.
+	 * 
+	 */
+	abstract public Reasoner getReasoner();
+
+	/**
+	 * Returns the model that was used in the reasoner.bind() call.
+	 * 
+	 * @return
+	 */
+	abstract public Model getBoundModel();
+
+	/**
+	 * Populate the model with test data for the derivation test.
+	 * 
+	 * @param model
+	 */
+	abstract public void populateModel(InfModel model);
+
+	/**
+	 * Using the reasoner and the populated model, this statement should return
+	 * a derivation iterator when getDerivation() is called.
+	 * 
+	 * This is not a complete test but a simple test to show that the system
+	 * works in this specific case. A complete set of tests is left for later
+	 * development.
+	 * 
+	 * @return The Statement that should have at least one derivation.
+	 */
+	abstract public Statement getDerivationStatement();
+
+	/**
+	 * Using the reasoner and the populated model, this statement should return
+	 * an EMPTY derivation iterator when getDerivation() is called.
+	 * 
+	 * This is not a complete test but a simple test to show that the system
+	 * works in this specific case. A complete set of tests is left for later
+	 * development.
+	 * 
+	 * @return The Statement that should have no derivations.
+	 */
+	abstract public Statement getNoDerivationStatement();
+
+	/**
+	 * @return true if the InfModel supports the getDeductionsModel() call.
+	 */
+	abstract public boolean supportsDeductionsModel();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractModelProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractModelProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractModelProducer.java
new file mode 100644
index 0000000..882e9d3
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractModelProducer.java
@@ -0,0 +1,88 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.rdf.model.Model;
+
+/**
+ * An abstract implementation of the ModelProducerInterface.
+ * 
+ * This class handles tracking of the created models and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the model is closed.
+ * 
+ */
+public abstract class AbstractModelProducer<T extends Model> implements
+		IProducer<T> {
+
+	/**
+	 * The list of graphs that have been opened in this test.
+	 */
+	protected List<Model> modelList = new ArrayList<Model>();
+
+	/**
+	 * @return true if the models returned by this poducer are independent,
+	 *         false otherwise.
+	 * 
+	 */
+	abstract public boolean areIndependent();
+
+	/**
+	 * The method to create a new model.
+	 * 
+	 * @return a newly constructed model of type under test.
+	 */
+	abstract protected T createNewModel();
+
+	@Override
+	final public T newInstance() {
+		T retval = createNewModel();
+		modelList.add(retval);
+		return retval;
+	}
+
+	/**
+	 * Method called after the graph is closed. This allows the implementer to
+	 * perform extra cleanup activities, like deleting the file associated with
+	 * a file based graph.
+	 * <p>
+	 * By default this does nothing.
+	 * </p>
+	 * 
+	 * @param g
+	 *            The graph that is closed
+	 */
+	protected void afterClose(T g) {
+	};
+
+	@Override
+	final public void cleanUp() {
+		for (Model m : modelList) {
+			if (!m.isClosed()) {
+				m.close();
+			}
+			afterClose((T) m);
+		}
+		modelList.clear();
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractRecordingListener.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractRecordingListener.java b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractRecordingListener.java
new file mode 100644
index 0000000..e9e26a1
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/AbstractRecordingListener.java
@@ -0,0 +1,190 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.Assert;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Statement;
+
+/**
+ * This testing listener records the event names and data, and provides a method
+ * for comparing the actual with the expected history.
+ */
+public class AbstractRecordingListener {
+
+	@SuppressWarnings("unchecked")
+	public static boolean checkEquality(final Object o1, final Object o2) {
+		if (o1 == o2) {
+			return true;
+		}
+		if (o1.getClass().isArray() && o2.getClass().isArray()) {
+			final Object[] o1a = (Object[]) o1;
+			final Object[] o2a = (Object[]) o2;
+
+			if (o1a.length == o2a.length) {
+				for (int i = 0; i < o1a.length; i++) {
+					if (!checkEquality(o1a[i], o2a[i])) {
+						return false;
+					}
+				}
+				return true;
+			}
+			return false;
+		} else if ((o1 instanceof Collection<?>)
+				&& (o2 instanceof Collection<?>)) {
+			return checkEquality(((Collection<Object>) o1).toArray(),
+					((Collection<Object>) o2).toArray());
+
+		} else if ((o1 instanceof Model) && (o2 instanceof Model)) {
+			return checkEquality(((Model) o1).listStatements().toList(),
+					((Model) o2).listStatements().toList());
+
+		} else if ((o1 instanceof Statement) && (o2 instanceof Statement)) {
+			return checkEquality(((Statement) o1).asTriple(),
+					((Statement) o2).asTriple());
+
+		} else {
+			return o1.equals(o2);
+		}
+	}
+
+	private List<Object> history = new ArrayList<Object>();
+
+	protected final void record(String tag, Object x, Object y) {
+		history.add(tag);
+		history.add(x);
+		history.add(y);
+	}
+
+	protected final void record(String tag, Object info) {
+		history.add(tag);
+		history.add(info);
+	}
+
+	public final int differ(Object... things) {
+		for (int i = 0; i < history.size(); i++) {
+			if (!things[i].equals(history.get(i))) {
+				return i;
+			}
+		}
+		return -1;
+	}
+
+	public final boolean has(Object... things) {
+		return history.equals(Arrays.asList(things));
+	}
+
+	public final void assertHas(Object... things) {
+		if (has(things) == false) {
+			int idx = differ(things);
+			Assert.fail("expected " + Arrays.asList(things) + " but got "
+					+ history + " differ at position " + idx);
+		}
+	}
+
+	public final void assertEmpty() {
+		if (history.size() > 0) {
+			Assert.fail("Should be no history but got " + history);
+		}
+	}
+
+	public final int size() {
+		return history.size();
+	}
+
+	public final boolean has(List<?> things) {
+		return history.equals(things);
+	}
+
+	public final boolean hasStart(List<Object> L) {
+		return L.size() <= history.size()
+				&& L.equals(history.subList(0, L.size()));
+	}
+
+	public final boolean hasEnd(List<Object> L) {
+		return L.size() <= history.size()
+				&& L.equals(history.subList(history.size() - L.size(),
+						history.size()));
+	}
+
+	public final void assertHas(List<?> things) {
+		if (has(things) == false)
+			Assert.fail("expected " + things + " but got " + history);
+	}
+
+	public final void assertContains(Object... things) {
+		if (contains(things) == false)
+			Assert.fail(String.format("expected %s but got %s",
+					Arrays.asList(things), history));
+	}
+
+	public final void assertHasStart(Object... start) {
+		List<Object> L = Arrays.asList(start);
+		if (hasStart(L) == false)
+			Assert.fail("expected " + L + " at the beginning of " + history);
+	}
+
+	public final void assertHasEnd(Object... end) {
+		List<Object> L = Arrays.asList(end);
+		if (hasEnd(L) == false)
+			Assert.fail("expected " + L + " at the end of " + history);
+	}
+
+	public final void clear() {
+		history.clear();
+	}
+
+	public final boolean contains(Object... objects) {
+		for (int i = 0; i < history.size(); i++) {
+			if (history.get(i).equals(objects[0])) {
+				boolean found = true;
+				for (int j = 1; j < objects.length; j++) {
+					if (i + j >= history.size()) {
+						found = false;
+						break;
+					}
+					if (!history.get(i + j).equals(objects[j])) {
+						found = false;
+						break;
+					}
+				}
+				if (found) {
+					return true;
+				}
+			}
+
+		}
+		return false;
+
+	}
+
+	public final Iterator<Object> from(Object start) {
+		Iterator<Object> iter = history.iterator();
+		while (iter.hasNext() && !iter.next().equals(start))
+			; // loop
+		return iter;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java b/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
new file mode 100644
index 0000000..f7a16e5
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
@@ -0,0 +1,17 @@
+package org.apache.jena.testing_framework;
+
+import org.xenei.junit.contract.IProducer;
+
+public class ContractTemplate<P extends IProducer<?>> {
+
+	private P producer;
+
+	public final void setProducer(P producer) {
+		this.producer = producer;
+	}
+
+	protected final P getProducer() {
+		return producer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/GraphEventManagerProducerInterface.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphEventManagerProducerInterface.java b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphEventManagerProducerInterface.java
new file mode 100644
index 0000000..70e8182
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphEventManagerProducerInterface.java
@@ -0,0 +1,35 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.apache.jena.graph.GraphEventManager;
+
+/**
+ * Foo producer for GraphEventManager testing.
+ * 
+ */
+public interface GraphEventManagerProducerInterface {
+
+	/**
+	 * Returns a GraphEventManager to take part in the test. Must be overridden
+	 * in a subclass.
+	 * 
+	 * @return The GraphEventManager implementation to test.
+	 */
+	public abstract GraphEventManager newEventManager();
+}


[19/25] jena git commit: Merge branch 'master' into add-contract-tests

Posted by cl...@apache.org.
Merge branch 'master' into add-contract-tests


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/6908e1c4
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/6908e1c4
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/6908e1c4

Branch: refs/heads/master
Commit: 6908e1c4b921fc8a5c8e5f5c65da0e7cd407aa16
Parents: 2e62ed0 e5035f4
Author: Claude Warren <cl...@apache.org>
Authored: Sat May 16 09:53:34 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 16 09:53:34 2015 +0100

----------------------------------------------------------------------
 .../org/apache/jena/atlas/lib/cache/CacheSimple.java | 15 +++++++++++----
 .../apache/jena/tdb/assembler/SettingAssembler.java  |  4 +---
 2 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------



[08/25] jena git commit: Added initial contract tests added testing_framework

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java
new file mode 100644
index 0000000..7e19122
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java
@@ -0,0 +1,143 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.junit.internal.runners.ErrorReportingRunner;
+import org.junit.runner.Description;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.ParentRunner;
+import org.junit.runners.Suite;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.RunnerBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.jena.shared.JenaException;
+
+/**
+ * Class that runs the Manifest annotated tests.
+ * 
+ * Used with <code>@RunWith( ManifestSuite.class )</code> this class loads a 
+ * manifest test suite file and adds the tests.
+ * <p>
+ * Tests annotated with <code>@RunWith( ManifestSuite.class )</code> must
+ * have a <code>ManifestFile</code> annotation specifying the path to the manifest file
+ * </p>
+ */
+public class ManifestSuite extends ParentRunner<Runner> {
+	private static final Logger LOG = LoggerFactory
+			.getLogger(ManifestSuite.class);
+	private final List<Runner> fRunners;
+	private final ManifestItemHandler itemHandler;
+	private final ManifestFile mf;
+
+	/**
+	 * Called reflectively on classes annotated with
+	 * <code>@RunWith(Suite.class)</code>
+	 * 
+	 * @param cls
+	 *            the root class
+	 * @param builder
+	 *            builds runners for classes in the suite
+	 * @throws Throwable
+	 */
+	public ManifestSuite(Class<? extends ManifestItemHandler> cls,
+			RunnerBuilder builder) throws Throwable {
+		super(cls);
+
+		List<Throwable> errors = new ArrayList<Throwable>();
+
+		mf = cls.getAnnotation(ManifestFile.class);
+		if (mf == null) {
+			throw new IllegalStateException(
+					"ManifestSuite requries ManifestFile annotation");
+		}
+		itemHandler = cls.newInstance();
+
+		Runner[] runner = new Runner[1];
+		try {
+			runner[0] = oneManifest(new Manifest(mf.value()),
+					new ArrayList<Runner>());
+		} catch (JenaException ex) {
+			runner[0] = new ErrorReportingRunner(null, ex);
+		}
+
+		if (!errors.isEmpty()) {
+			throw new InitializationError(errors);
+		}
+		fRunners = Collections.unmodifiableList(Arrays.asList(runner));
+	}
+
+	private Runner oneManifest(final Manifest manifest, List<Runner> r) {
+
+		// Recurse
+		for (Iterator<String> iter = manifest.includedManifests(); iter
+				.hasNext();) {
+			try {
+				r.add(oneManifest(new Manifest(iter.next()),
+						new ArrayList<Runner>()));
+			} catch (JenaException ex) {
+				r.add(new ErrorReportingRunner(null, ex));
+			}
+		}
+		itemHandler.setTestRunnerList(r);
+		manifest.apply(itemHandler);
+		try {
+			return new Suite((Class<?>) null, r) {
+
+				@Override
+				protected String getName() {
+					return manifest.getName();
+				}
+
+			};
+		} catch (InitializationError e) {
+			return new ErrorReportingRunner(null, e);
+		}
+	}
+
+	@Override
+	protected List<Runner> getChildren() {
+		return fRunners;
+	}
+
+	@Override
+	protected Description describeChild(Runner child) {
+		return child.getDescription();
+	}
+
+	@Override
+	protected void runChild(Runner child, RunNotifier notifier) {
+		child.run(notifier);
+	}
+
+	/**
+	 * Returns a name used to describe this Runner
+	 */
+	@Override
+	protected String getName() {
+		return String.format("%s - %s", super.getName(), mf.value());
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
new file mode 100644
index 0000000..cfde240
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
@@ -0,0 +1,13 @@
+package org.apache.jena.testing_framework.manifest;
+
+public abstract class ManifestTest {
+
+	protected ManifestItem manifestItem;
+
+	public final void setManifestItem(ManifestItem manifestItem) {
+		this.manifestItem = manifestItem;
+	}
+
+	abstract public void runTest();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
new file mode 100644
index 0000000..616b444
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
@@ -0,0 +1,75 @@
+package org.apache.jena.testing_framework.manifest;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.runner.Description;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+
+public class ManifestTestRunner extends BlockJUnit4ClassRunner {
+
+	private ManifestItem manifestItem;
+
+	public ManifestTestRunner(ManifestItem manifestItem,
+			Class<? extends ManifestTest> cls) throws InitializationError {
+		super(cls);
+		this.manifestItem = manifestItem;
+	}
+
+	/**
+	 * Returns the name that describes {@code method} for {@link Description}s.
+	 * Default implementation is the method's name
+	 */
+	@Override
+	protected String testName(FrameworkMethod method) {
+		return manifestItem.getTestName();
+	}
+
+	/**
+	 * Returns the methods that run tests. Default implementation returns all
+	 * methods annotated with {@code @Test} on this class and superclasses that
+	 * are not overridden.
+	 */
+	@Override
+	protected List<FrameworkMethod> computeTestMethods() {
+		FrameworkMethod[] lst = new FrameworkMethod[1];
+
+		try {
+			lst[0] = new FrameworkMethod(getTestClass().getJavaClass()
+					.getMethod("runTest")) {
+
+				@Override
+				public String getName() {
+					return manifestItem.getTestName();
+				}
+			};
+		} catch (NoSuchMethodException e) {
+			throw new IllegalStateException(e);
+		} catch (SecurityException e) {
+			throw new IllegalStateException(e);
+		}
+		return Arrays.asList(lst);
+	}
+
+	@Override
+	public Description getDescription() {
+		return Description.createTestDescription(this.getTestClass()
+				.getJavaClass(), manifestItem.getTestName(), new Annotation[0]);
+	}
+
+	/**
+	 * Returns a new fixture for running a test. Default implementation executes
+	 * the test class's no-argument constructor (validation should have ensured
+	 * one exists).
+	 */
+	@Override
+	protected Object createTest() throws Exception {
+		ManifestTest instance = (ManifestTest) super.createTest();
+		instance.setManifestItem(manifestItem);
+		return instance;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/package-info.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/package-info.java b/jena-core/src/test/java/org/apache/jena/testing_framework/package-info.java
new file mode 100644
index 0000000..96f3e42
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/package-info.java
@@ -0,0 +1,109 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+/**
+ * Foo set of classes providing support for testing.
+ * <p>
+ * Testing guidelines/suggestions.
+ * </p><p>
+ * Interface tests are built so that developers may test that implementations meet the contract
+ * set out in the interface and accompanying documentation.
+ * </p>
+ * <h4>Producers</h4>
+ * <p>
+ * The test and suites use an instance of the [INTERFACE]ProducerInterface to create an instance
+ * of the the Object being tested.   
+ * </p>
+ * <h4>Tests</h4>
+ * <p>
+ * Interface tests are noted as Abstract[INTERFACE]Test.  Implementations of [INTERFACE] should
+ * create a concrete implementation of Abstract[INTERFACE]Test with an [INTERFACE]Producer to create
+ * instances of the Object.  Passing the test indicates a compliance with the base interface 
+ * definition.
+ * </p><p>
+ * In general to implement a test requires a few lines of code as is noted in the example below
+ * where the new Foo graph implementation is being tested.</p>
+ * <pre><code>
+ * public class FooGraphTest extends AbstractGraphTest {
+ * 
+ *   // the graph producer to use while running
+ *   GraphProducerInterface graphProducer = new FooGraphTest.GraphProducer();
+ * 
+ *   @Override
+ *   protected GraphProducerInterface getGraphProducer() {
+ *     return graphProducer;
+ *   }
+ * 
+ *   // the implementation of the graph producer.
+ *   public static class GraphProducer extends AbstractGraphProducer {
+ * 
+ *     @Override
+ *     protected Graph createNewGraph() {
+ *       return new FooGraph();
+ *     }
+ *   }
+ * }
+ * </code></pre>
+ * <h4>Suites</h4>
+ * <p>
+ * Test suites are named as Abstract[INTERFACE]Suite.  Suites contain several tests (see above)
+ * that exercise all of the tests for the components of the object under test.  For example the 
+ * graph suite includes tests for the graph itself, the reifier, finding literals, recursive 
+ * subgraph extraction, event manager, and transactions.  Running the suites is a bit more 
+ * complicated then running the tests.
+ * </p>
+ * Suites are created using the JUnit 4 <code>@RunWith(Suite.class)</code and 
+ * <code>@Suite.SuiteClasses({ })</code> annotations.  This has several effects that the developer 
+ * should know about:</p>
+ * <ul>
+ * <li>The suite class does not get instantiated during the run.</li>
+ * <li>The test class names must be known at coding time (not run time) as they are listed in the
+ * annotation.</li>
+ * <li>Configuration of the tests has to occur during the static initialization phase of class 
+ * loading.</li>
+ * </ul>
+ * <p>
+ * To meet these requirements the AbstractGraphSuite has a static variable that holds the instance
+ * of the GraphProducerInterface and a number of local static implementations of the Abstract tests
+ * that implement the "getGraphProducer()" method by returning the static instance.  The names of 
+ * the local graphs are then used in the @Suite.SuiteClasses annotation.  This makes creating an
+ * instance of the AbstractGraphSuite for a graph implementation fairly simple as is noted below.
+ * </p>
+ * <pre><code>
+ * public class FooGraphSuite extends AbstractGraphSuite {
+ *   @BeforeClass
+ *   public static void beforeClass() {
+ *     setGraphProducer(new GraphProducer());
+ *   }
+ *   
+ *   public static class GraphProducer extends AbstractGraphProducer {
+ *     @Override
+ *     protected Graph createNewGraph() {
+ *       return new FooGraph();
+ *     }
+ *   }
+ * }
+ * </code></pre>
+ * <p>
+ * <b>Note:</b> that the beforeClass() method is annotated with @BeforeClass.  the @BeforeClass 
+ * causes it to be run once before any of the test methods in the class. This will set the static
+ * instance of the graph producer before the suite is run so that it is provided to the enclosed
+ * tests.
+ * </p> 
+ */

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleItem.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleItem.java b/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleItem.java
new file mode 100644
index 0000000..65aff5b
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleItem.java
@@ -0,0 +1,84 @@
+/*
+ * 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 org.apache.jena.testing_framework.tuples;
+
+/**
+ * The unit found in a line of a tuple. Can be a string (quoted, possibly with
+ * the datatype, or unquoted) or a URI.
+ */
+public class TupleItem {
+	public static final int URI = 0;
+	public static final int STRING = 1;
+	public static final int UNKNOWN = 2;
+	public static final int UNQUOTED = 3;
+	public static final int ANON = 4;
+
+	String rep;
+	String datatype;
+	String asFound;
+	int itemType;
+
+	TupleItem(String value, String valAsFound, int type, String dt) {
+		rep = value;
+		asFound = valAsFound;
+		itemType = type;
+		datatype = dt;
+	}
+
+	public int getType() {
+		return itemType;
+	}
+
+	public boolean isURI() {
+		return itemType == URI;
+	}
+
+	public boolean isString() {
+		return itemType == STRING;
+	}
+
+	public boolean isUnknown() {
+		return itemType == UNKNOWN;
+	}
+
+	public boolean isUnquoted() {
+		return itemType == UNQUOTED;
+	}
+
+	public boolean isAnon() {
+		return itemType == ANON;
+	}
+
+	public String get() {
+		return rep;
+	}
+
+	public String getDT() {
+		return datatype;
+	}
+
+	public String asQuotedString() {
+		return asFound;
+	}
+
+	@Override
+	public String toString() {
+		return rep;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleSet.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleSet.java b/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleSet.java
new file mode 100644
index 0000000..8e78879
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/tuples/TupleSet.java
@@ -0,0 +1,274 @@
+/*
+ * 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 org.apache.jena.testing_framework.tuples;
+
+import java.io.*;
+import java.util.*;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TupleSet implements Iterator<List<TupleItem>> {
+	BufferedReader in;
+	public String line = null;
+	public int lineNumber = 0;
+
+	static final char COMMENTCHAR = '#';
+	List<TupleItem> current = null;
+	boolean finished = false;
+
+	protected static Logger logger = LoggerFactory.getLogger(TupleSet.class);
+
+	/** Creates new TupleSet */
+	public TupleSet(Reader r) {
+		if (!(r instanceof BufferedReader))
+			in = new BufferedReader(r);
+		else
+			in = (BufferedReader) r;
+	}
+
+	@Override
+	public boolean hasNext() {
+		if (finished)
+			return false;
+
+		if (current == null)
+			current = tuple();
+		return current != null;
+	}
+
+	@Override
+	public List<TupleItem> next() {
+		if (hasNext()) {
+			List<TupleItem> x = current;
+			current = null;
+			return x;
+		} else
+			return null;
+	}
+
+	@Override
+	public void remove() {
+		throw new java.lang.UnsupportedOperationException("TupleSet.remove");
+	}
+
+	private List<TupleItem> tuple() {
+
+		try {
+			lineNumber++;
+			line = in.readLine();
+		} catch (IOException e) {
+		}
+
+		if (line == null) {
+			finished = true;
+			return null;
+		}
+
+		// System.out.println("Line: "+line) ;
+		List<TupleItem> tuple = new ArrayList<TupleItem>();
+		int i = 0;
+		int j = 0;
+		boolean errorFound = false;
+
+		tupleLoop: for (;;) {
+			// Move to beginning of next item.
+			i = skipwhitespace(line, j);
+
+			if (i < 0)
+				break;
+
+			int iStart = -2; // Points to the beginning of the item as found
+			int jStart = -2; // Points to the item without quotes
+			int iFinish = -2; // Points after the end of the item as found
+			int jFinish = -2; // Points after the end of the item without quotes
+			int dtStart = -2; // Points to start of datatype (after < quote)
+			int dtFinish = -2; // Points to end of datatype
+			int type = TupleItem.UNKNOWN;
+
+			switch (line.charAt(i)) {
+			case COMMENTCHAR:
+				break tupleLoop;
+			case '<':
+				type = TupleItem.URI;
+				iStart = i;
+				jStart = i + 1;
+				int newPosn = parseURI(i, line);
+				if (newPosn < 0) {
+					errorFound = true;
+					break tupleLoop;
+				}
+				j = newPosn;
+
+				iFinish = j + 1;
+				jFinish = j;
+				break;
+			case '"':
+				type = TupleItem.STRING;
+				iStart = i;
+				jStart = i + 1;
+				boolean inEscape = false;
+				for (j = i + 1; j < line.length(); j++) {
+					char ch = line.charAt(j);
+					if (inEscape) {
+						// ToDo: escape
+						inEscape = false;
+						continue;
+					}
+					// Not an escape
+					if (ch == '"')
+						break;
+
+					if (ch == '\\')
+						inEscape = true;
+					if (ch == '\n' || ch == '\r') {
+						errorFound = true;
+						break tupleLoop;
+
+					}
+				}
+
+				// Malformed
+				if (j == line.length()) {
+					errorFound = true;
+					break tupleLoop;
+				}
+
+				iFinish = j + 1;
+				jFinish = j;
+				// RDF literals may be followed by their type.
+
+				if (j < line.length() - 3 && line.charAt(j + 1) == '^'
+						&& line.charAt(j + 2) == '^'
+						&& line.charAt(j + 3) == '<') {
+					dtFinish = parseURI(j + 3, line);
+					dtStart = j + 4;
+					if (dtFinish < 0) {
+						errorFound = true;
+						break tupleLoop;
+					}
+					j = dtFinish + 1;
+					// String dt = line.substring(dtStart, dtFinish) ;
+					// System.out.println("I see a datatype:"+dt) ;
+				}
+
+				break;
+			case '_':
+				type = TupleItem.ANON;
+				iStart = i;
+				for (j = i + 1; j < line.length(); j++) {
+					char ch = line.charAt(j);
+					if (ch == ' ' || ch == '\t' || ch == '.')
+						break;
+					if (!Character.isLetterOrDigit(ch) && !(ch == '_')
+							&& !(ch == ':')) {
+						errorFound = true;
+						break tupleLoop;
+					}
+				}
+				iFinish = j;
+				jStart = iStart;
+				jFinish = iFinish;
+				break;
+			case '.':
+			case '\n':
+			case '\r':
+				return tuple;
+			default:
+				type = TupleItem.UNQUOTED;
+				iStart = i;
+				jStart = i;
+				for (j = i + 1; j < line.length(); j++) {
+					char ch = line.charAt(j);
+					if (ch == ' ' || ch == '\t' || ch == '.')
+						break;
+
+					// if ( ! Character.isLetterOrDigit(line.charAt(i)) )
+					// {
+					// errorFound = true ;
+					// break tupleLoop;
+					// }
+				}
+				// Malformed
+				if (j == line.length() + 1) {
+					errorFound = true;
+					break tupleLoop;
+				}
+				iFinish = j;
+				jFinish = j;
+				break;
+			}
+			String item = line.substring(jStart, jFinish);
+			String literal = line.substring(iStart, iFinish);
+			String dt = null;
+			if (dtStart > 0)
+				dt = line.substring(dtStart, dtFinish);
+
+			tuple.add(new TupleItem(item, literal, type, dt));
+			j++;
+			// End of item.
+		}
+		// End of this line.
+		if (errorFound) {
+			logger.error("Error in TupleSet.tuple: " + line);
+
+			String s = "";
+			int k = 0;
+			for (; k < i; k++)
+				s = s + " ";
+			s = s + "^";
+			for (; k < j - 1; k++)
+				s = s + " ";
+			s = s + "^";
+			logger.error(s);
+			return null;
+		}
+
+		if (tuple.size() == 0) {
+			// Nothing found : loop by tail recursion
+			return tuple();
+		}
+		return tuple;
+	}
+
+	private int skipwhitespace(String s, int i) {
+		for (; i < s.length(); i++) {
+			char ch = s.charAt(i);
+			// Horizonal whitespace
+			if (ch != ' ' && ch != '\t')
+				return i;
+		}
+		return -1;
+	}
+
+	private int parseURI(int i, String line) {
+		int j;
+		for (j = i + 1; j < line.length(); j++) {
+			char ch = line.charAt(j);
+			if (ch == '>')
+				break;
+			if (ch == '\n' || ch == '\r')
+				return -1;
+		}
+		// Malformed
+		if (j == line.length())
+			return -2;
+		return j;
+	}
+}


[22/25] jena git commit: Set version on contract-test-maven-plugin added jena-base to the pom.

Posted by cl...@apache.org.
Set version on contract-test-maven-plugin
added jena-base to the pom.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/fe78f4af
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/fe78f4af
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/fe78f4af

Branch: refs/heads/master
Commit: fe78f4afe57863e461ce2d23c88dde998f73aa15
Parents: be72f49
Author: Claude Warren <cl...@apache.org>
Authored: Tue May 19 20:11:57 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Tue May 19 20:11:57 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/fe78f4af/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index 70e0dba..73846b6 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -78,6 +78,11 @@
 			<scope>test</scope>
 		</dependency>
 
+		<dependency>
+			<groupId>org.apache.jena</groupId>
+			<artifactId>jena-base</artifactId>
+			<version>3.0.0-SNAPSHOT</version>
+		</dependency>
 	</dependencies>
 
 	<build>
@@ -200,6 +205,7 @@
 			<plugin>
 				<groupId>org.xenei</groupId>
 				<artifactId>contract-test-maven-plugin</artifactId>
+				<version>0.1.1</version>
 				<configuration>
 					<packages>
 						<package>org.apache.jena.assembler</package>


[13/25] jena git commit: updated contract tests.

Posted by cl...@apache.org.
updated contract tests.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/608c2b40
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/608c2b40
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/608c2b40

Branch: refs/heads/master
Commit: 608c2b402af7bb8367599502cc7e34dd226a77d0
Parents: d12bd57
Author: Claude Warren <cl...@apache.org>
Authored: Mon Apr 27 22:40:03 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 9 16:15:24 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml                               |   1 +
 .../apache/jena/graph/GraphContractTest.java    |   4 +-
 .../graph/GraphEventManagerContractTest.java    |  14 ---
 .../jena/graph/GraphMakerContractTest.java      |  23 +---
 .../graph/GraphWithPerformContractTest.java     |  37 +++---
 .../graph/TransactionHandlerContractTest.java   |  13 ---
 .../jena/graph/impl/CollectionGraph_CS.java     |  67 +++++++++++
 .../jena/graph/impl/FileGraphMaker_CS.java      |  81 +++++++++++++
 .../impl/FileGraphTransactionHandler_CS.java    |  56 +++++++++
 .../apache/jena/graph/impl/FileGraph_CS.java    |  78 +++++++++++++
 .../jena/graph/impl/SimpleEventManager_CS.java  |  54 +++++++++
 .../jena/graph/impl/SimpleGraphMaker_CS.java    |  54 +++++++++
 .../graph/impl/SimpleTransactionHandler_CS.java |  54 +++++++++
 .../jena/graph/impl/TestCollectionGraph.java    |  67 -----------
 .../jena/graph/impl/TestWrappedGraph.java       |  63 ----------
 .../graph/impl/TripleStoreContractTest.java     |  16 ---
 .../apache/jena/graph/impl/WrappedGraph_CS.java |  63 ++++++++++
 .../java/org/apache/jena/mem/ArrayBunch_CS.java |  52 +++++++++
 .../java/org/apache/jena/mem/GraphMemTest.java  | 115 -------------------
 .../java/org/apache/jena/mem/GraphMem_CS.java   | 115 +++++++++++++++++++
 .../apache/jena/mem/GraphTripleStoreMem_CS.java |  51 ++++++++
 .../apache/jena/mem/GraphTripleStoreTest.java   |  51 --------
 .../apache/jena/mem/GraphTripleStore_CS.java    |  51 ++++++++
 .../org/apache/jena/mem/HashedBunchMap_CS.java  |  52 +++++++++
 .../apache/jena/mem/HashedTripleBunch_CS.java   |  50 ++++++++
 .../java/org/apache/jena/mem/SetBunch_CS.java   |  50 ++++++++
 .../org/apache/jena/mem/WrappedHashMap_CS.java  |  52 +++++++++
 .../testing_framework/ContractTemplate.java     |  18 +++
 .../GraphProducerInterface.java                 |  41 -------
 .../testing_framework/IContainerProducer.java   |  18 +++
 .../testing_framework/IIteratorProducer.java    |  18 +++
 .../testing_framework/IResourceProducer.java    |  18 +++
 .../jena/testing_framework/TestFileData.java    |  18 +++
 .../manifest/ManifestItem.java                  |  18 +++
 .../manifest/ManifestTest.java                  |  18 +++
 .../manifest/ManifestTestRunner.java            |  18 +++
 36 files changed, 1146 insertions(+), 423 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index a29e559..e18d331 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -136,6 +136,7 @@
           </systemProperties>
           <includes>
             <include>org/apache/jena/test/TestPackage.java</include>
+						<include>**/*_CS.java</include>
           </includes>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index a989bae..55ad955 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -57,9 +57,7 @@ import org.apache.jena.util.iterator.Map1;
 import static org.apache.jena.testing_framework.GraphHelper.*;
 
 /**
- * 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.
+ * Graph contract test.
  */
 @Contract(Graph.class)
 public class GraphContractTest<T extends Graph> extends

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
index 426002d..d18bd52 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
@@ -33,7 +33,6 @@ import static org.junit.Assert.*;
 import org.apache.jena.graph.Graph;
 import org.apache.jena.graph.GraphEventManager;
 import org.apache.jena.graph.Triple;
-import org.apache.jena.graph.Factory;
 import org.apache.jena.testing_framework.ContractTemplate;
 import org.apache.jena.testing_framework.GraphHelper;
 import org.xenei.junit.contract.IProducer;
@@ -61,19 +60,6 @@ public class GraphEventManagerContractTest<T extends GraphEventManager> extends
 	private GraphEventManager gem;
 
 	public GraphEventManagerContractTest() {
-//		setProducer(new IProducer<T>() {
-//
-//			@SuppressWarnings("unchecked")
-//			@Override
-//			public T newInstance() {
-//				return (T) Factory.createGraphMem().getEventManager();
-//			}
-//
-//			@Override
-//			public void cleanUp() {
-//			}
-//		});
-
 	}
 
 	@Contract.Inject

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
index 5fbd9c2..d5a3657 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
@@ -30,7 +30,6 @@ import org.apache.jena.graph.Graph;
 import org.apache.jena.graph.GraphMaker;
 import org.apache.jena.graph.Node;
 import org.apache.jena.graph.Triple;
-import org.apache.jena.graph.impl.SimpleGraphMaker;
 import org.apache.jena.shared.AlreadyExistsException;
 import org.apache.jena.shared.DoesNotExistException;
 import org.apache.jena.testing_framework.GraphHelper;
@@ -38,14 +37,8 @@ import org.xenei.junit.contract.IProducer;
 import org.apache.jena.testing_framework.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.)
+ * GraphMaker contract test.
+ *
  */
 @Contract(GraphMaker.class)
 public class GraphMakerContractTest {
@@ -55,18 +48,6 @@ public class GraphMakerContractTest {
 	private GraphMaker graphMaker;
 
 	public GraphMakerContractTest() {
-//		producer = new IProducer<GraphMaker>() {
-//
-//			@Override
-//			public GraphMaker newInstance() {
-//				return new SimpleGraphMaker();
-//			}
-//
-//			@Override
-//			public void cleanUp() {
-//
-//			}
-//		};
 	}
 
 	@Contract.Inject

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
index aaaa85a..a4e233f 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.graph;
 
 import static org.apache.jena.testing_framework.GraphHelper.graphWith;
@@ -8,13 +26,10 @@ import static org.apache.jena.testing_framework.GraphHelper.txnCommit;
 import static org.junit.Assert.*;
 
 import org.junit.After;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.xenei.junit.contract.Contract;
 import org.xenei.junit.contract.ContractTest;
 
 import org.apache.jena.graph.impl.GraphWithPerform;
-import org.apache.jena.mem.GraphMem;
 import org.apache.jena.testing_framework.ContractTemplate;
 
 import org.xenei.junit.contract.IProducer;
@@ -30,23 +45,7 @@ public class GraphWithPerformContractTest<T extends GraphWithPerform> extends
 	// Recording listener for tests
 	protected RecordingGraphListener GL = new RecordingGraphListener();
 
-	private static final Logger LOG = LoggerFactory
-			.getLogger(GraphWithPerformContractTest.class);
-
-	@SuppressWarnings("unchecked")
 	public GraphWithPerformContractTest() {
-//		setProducer((IProducer<T>) new IProducer<GraphWithPerform>() {
-//
-//			@Override
-//			public GraphWithPerform newInstance() {
-//				return new GraphMem();
-//			}
-//
-//			@Override
-//			public void cleanUp() {
-//
-//			}
-//		});
 	}
 
 	@Contract.Inject

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
index d26d7e9..8ffddbc 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
@@ -29,7 +29,6 @@ import static org.junit.Assert.*;
 
 import org.apache.jena.graph.TransactionHandler;
 import org.apache.jena.graph.Triple;
-import org.apache.jena.graph.impl.SimpleTransactionHandler;
 import org.apache.jena.shared.Command;
 import org.apache.jena.shared.JenaException;
 import org.xenei.junit.contract.IProducer;
@@ -47,18 +46,6 @@ public class TransactionHandlerContractTest {
 	private IProducer<TransactionHandler> producer;
 
 	public TransactionHandlerContractTest() {
-//		producer = new IProducer<TransactionHandler>() {
-//
-//			@Override
-//			public TransactionHandler newInstance() {
-//				return new SimpleTransactionHandler();
-//			}
-//
-//			@Override
-//			public void cleanUp() {
-//
-//			}
-//		};
 	}
 
 	@Contract.Inject

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/CollectionGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/CollectionGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/CollectionGraph_CS.java
new file mode 100644
index 0000000..b246f2b
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/CollectionGraph_CS.java
@@ -0,0 +1,67 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
+import java.util.HashSet;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.Triple ;
+import org.apache.jena.graph.impl.CollectionGraph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(CollectionGraph.class)
+public class CollectionGraph_CS {
+	 
+	protected IProducer<CollectionGraph> graphProducer;
+	
+	public CollectionGraph_CS() {
+		graphProducer = new AbstractGraphProducer<CollectionGraph>() {
+			
+			@Override
+			protected CollectionGraph createNewGraph() {
+				return new CollectionGraph( new HashSet<Triple>() );
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<CollectionGraph> getCollectionTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
new file mode 100644
index 0000000..5f1d36d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
@@ -0,0 +1,81 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(FileGraphMaker.class)
+public class FileGraphMaker_CS {
+	 
+	protected IProducer<FileGraphMaker> graphProducer;
+	
+	public FileGraphMaker_CS() throws IOException {
+		graphProducer = new FileGraphMakerProducer();
+	}
+
+	@Contract.Inject
+	public final IProducer<FileGraphMaker> getCollectionTestProducer() {
+		return graphProducer;
+	}
+	
+	private static class FileGraphMakerProducer implements IProducer<FileGraphMaker> {
+		private Map<Path,FileGraphMaker> map;
+		
+		public FileGraphMakerProducer () throws IOException {
+			map = new HashMap<Path,FileGraphMaker>();
+		}
+		
+		
+		@Override
+		public FileGraphMaker newInstance() {
+			Path p;
+			try {
+				p = Files.createTempDirectory("fgm_CS");
+			} catch (IOException e) {
+				throw new RuntimeException( "Unable to create temp directory", e );
+			}
+			FileGraphMaker fgm = new FileGraphMaker( p.toString(), true);
+			map.put(p, fgm);
+			return fgm;
+		}
+
+		@Override
+		public void cleanUp() {
+			for (Path p : map.keySet())
+			{
+				map.get(p).close();
+				p.toFile().delete();
+			}
+			map.clear();
+		}
+
+	};
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
new file mode 100644
index 0000000..5e0feb4
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
@@ -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 org.apache.jena.graph.impl;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(FileGraphTransactionHandler.class)
+public class FileGraphTransactionHandler_CS {
+	 
+	protected IProducer<FileGraphTransactionHandler> graphProducer;
+	
+	public FileGraphTransactionHandler_CS() {
+		graphProducer = new IProducer<FileGraphTransactionHandler>() {
+			
+			private FileGraph_CS.FileGraphProducer fgp = new FileGraph_CS.FileGraphProducer();
+			
+			@Override
+			public FileGraphTransactionHandler newInstance() {
+				return new FileGraphTransactionHandler( fgp.newInstance() );
+			}
+
+			@Override
+			public void cleanUp() {
+				fgp.cleanUp();
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<FileGraphTransactionHandler> getCollectionTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
new file mode 100644
index 0000000..b7bb6c3
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
@@ -0,0 +1,78 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(FileGraph.class)
+public class FileGraph_CS {
+	 
+	protected IProducer<FileGraph> graphProducer;
+	
+	public FileGraph_CS() {
+		graphProducer = new FileGraphProducer();
+	}
+
+	@Contract.Inject
+	public final IProducer<FileGraph> getCollectionTestProducer() {
+		return graphProducer;
+	}
+	
+	public static class FileGraphProducer extends AbstractGraphProducer<FileGraph> {
+		
+		@Override
+		protected FileGraph createNewGraph() {
+			File f;
+			try {
+				f = File.createTempFile("fgp", ".ttl" );
+			} catch (IOException e) {
+				throw new RuntimeException( "Can not create file", e );
+			}
+			return new FileGraph( f, false, true );
+		}
+
+		@Override
+		public Graph[] getDependsOn(Graph d) {
+			return null;
+		}
+
+		@Override
+		public Graph[] getNotDependsOn(Graph g) {
+			return new Graph[] { memGraph() };
+		}
+		
+		@Override
+		protected void afterClose(Graph g) {
+			((FileGraph)g).name.delete();
+		}
+
+	};
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleEventManager_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleEventManager_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleEventManager_CS.java
new file mode 100644
index 0000000..bfe7a3c
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleEventManager_CS.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+
+import org.xenei.junit.contract.IProducer;
+
+/**
+ * Test the SimpleGraphFactory by extending AbstractTestGraphFactory and
+ * supplying new SimplGraphFactorys via getGraph.
+ */
+@RunWith(ContractSuite.class)
+@ContractImpl(SimpleEventManager.class)
+public class SimpleEventManager_CS {
+
+	private IProducer<SimpleEventManager> producer = new IProducer<SimpleEventManager>() {
+
+		@Override
+		public SimpleEventManager newInstance() {
+			return new SimpleEventManager();
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do.
+		}
+	};
+
+	@Contract.Inject
+	public IProducer<SimpleEventManager> getEventManagerProducer() {
+		return producer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleGraphMaker_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleGraphMaker_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleGraphMaker_CS.java
new file mode 100644
index 0000000..43dac19
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleGraphMaker_CS.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(SimpleGraphMaker.class)
+public class SimpleGraphMaker_CS {
+	 
+	protected IProducer<SimpleGraphMaker> graphProducer;
+	
+	public SimpleGraphMaker_CS() {
+		graphProducer = new IProducer<SimpleGraphMaker>() {
+			
+			@Override
+			public SimpleGraphMaker newInstance() {
+				return new SimpleGraphMaker();
+			}
+
+			@Override
+			public void cleanUp() {
+				// nothing to do
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<SimpleGraphMaker> getCollectionTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleTransactionHandler_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleTransactionHandler_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleTransactionHandler_CS.java
new file mode 100644
index 0000000..da845ec
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleTransactionHandler_CS.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(SimpleTransactionHandler.class)
+public class SimpleTransactionHandler_CS {
+	 
+	protected IProducer<SimpleTransactionHandler> graphProducer;
+	
+	public SimpleTransactionHandler_CS() {
+		graphProducer = new IProducer<SimpleTransactionHandler>() {
+			
+			@Override
+			public SimpleTransactionHandler newInstance() {
+				return new SimpleTransactionHandler();
+			}
+
+			@Override
+			public void cleanUp() {
+				// nothing to do
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<SimpleTransactionHandler> getCollectionTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
deleted file mode 100644
index 4d9f40d..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 org.apache.jena.graph.impl;
-
-import static org.apache.jena.testing_framework.GraphHelper.memGraph;
-
-import java.util.HashSet;
-
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.graph.impl.CollectionGraph ;
-import org.apache.jena.testing_framework.AbstractGraphProducer;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.IProducer;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(CollectionGraph.class)
-public class TestCollectionGraph {
-	 
-	protected IProducer<CollectionGraph> graphProducer;
-	
-	public TestCollectionGraph() {
-		graphProducer = new AbstractGraphProducer<CollectionGraph>() {
-			
-			@Override
-			protected CollectionGraph createNewGraph() {
-				return new CollectionGraph( new HashSet<Triple>() );
-			}
-
-			@Override
-			public Graph[] getDependsOn(Graph d) {
-				return null;
-			}
-
-			@Override
-			public Graph[] getNotDependsOn(Graph g) {
-				return new Graph[] { memGraph() };
-			}
-
-		};
-	}
-
-	@Contract.Inject
-	public final IProducer<CollectionGraph> getDeltaTestProducer() {
-		return graphProducer;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
deleted file mode 100644
index 7910660..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 org.apache.jena.graph.impl;
-
-import static org.apache.jena.testing_framework.GraphHelper.memGraph;
-
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.testing_framework.AbstractGraphProducer;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.IProducer;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(WrappedGraph.class)
-public class TestWrappedGraph {
-	 
-	protected IProducer<WrappedGraph> graphProducer;
-	
-	public TestWrappedGraph() {
-		graphProducer = new AbstractGraphProducer<WrappedGraph>() {
-			
-			@Override
-			protected WrappedGraph createNewGraph() {
-				return new WrappedGraph( memGraph() );
-			}
-
-			@Override
-			public Graph[] getDependsOn(Graph d) {
-				return null;
-			}
-
-			@Override
-			public Graph[] getNotDependsOn(Graph g) {
-				return new Graph[] { memGraph() };
-			}
-
-		};
-	}
-
-	@Contract.Inject
-	public final IProducer<WrappedGraph> getDeltaTestProducer() {
-		return graphProducer;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
index 0b074aa..815a40d 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
@@ -26,7 +26,6 @@ import org.xenei.junit.contract.ContractTest;
 import static org.junit.Assert.*;
 
 import static org.apache.jena.testing_framework.GraphHelper.*;
-import org.apache.jena.mem.GraphTripleStore;
 import org.apache.jena.graph.impl.TripleStore;
 import org.apache.jena.testing_framework.ContractTemplate;
 
@@ -43,21 +42,6 @@ public class TripleStoreContractTest<T extends TripleStore> extends
 	protected TripleStore store;
 
 	public TripleStoreContractTest() {
-		IProducer<TripleStore> producer = new IProducer<TripleStore>() {
-
-			@Override
-			public TripleStore newInstance() {
-				return new GraphTripleStore(memGraph());
-			}
-
-			@Override
-			public void cleanUp() {
-				// TODO Auto-generated method stub
-
-			}
-
-		};
-		setProducer((IProducer<T>) producer);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/graph/impl/WrappedGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/WrappedGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/WrappedGraph_CS.java
new file mode 100644
index 0000000..3cc5b1c
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/WrappedGraph_CS.java
@@ -0,0 +1,63 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(WrappedGraph.class)
+public class WrappedGraph_CS {
+	 
+	protected IProducer<WrappedGraph> graphProducer;
+	
+	public WrappedGraph_CS() {
+		graphProducer = new AbstractGraphProducer<WrappedGraph>() {
+			
+			@Override
+			protected WrappedGraph createNewGraph() {
+				return new WrappedGraph( memGraph() );
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<WrappedGraph> getDeltaTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/ArrayBunch_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/ArrayBunch_CS.java b/jena-core/src/test/java/org/apache/jena/mem/ArrayBunch_CS.java
new file mode 100644
index 0000000..df8438e
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/ArrayBunch_CS.java
@@ -0,0 +1,52 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(ArrayBunch.class)
+public class ArrayBunch_CS {
+
+	protected IProducer<ArrayBunch> mapProducer = new IProducer<ArrayBunch>() {
+
+		@Override
+		public ArrayBunch newInstance() {
+			return new ArrayBunch();
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+		
+
+	};
+
+	@Inject
+	public IProducer<ArrayBunch> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java b/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
deleted file mode 100644
index 8fed109..0000000
--- a/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-    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 org.apache.jena.mem;
-
-import static org.apache.jena.testing_framework.GraphHelper.*;
-import static org.junit.Assert.*;
-
-import java.util.Iterator;
-
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract.Inject;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.ContractTest;
-
-import org.apache.jena.graph.Graph;
-import org.apache.jena.graph.GraphStatisticsHandler;
-import org.apache.jena.graph.Node;
-import org.apache.jena.graph.Node_URI;
-import org.apache.jena.graph.Triple;
-import org.apache.jena.shared.JenaException;
-import org.apache.jena.testing_framework.AbstractGraphProducer;
-import org.xenei.junit.contract.IProducer;
-import org.apache.jena.util.iterator.ExtendedIterator;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(GraphMem.class)
-public class GraphMemTest {
-
-	protected IProducer<GraphMem> graphProducer = new AbstractGraphProducer<GraphMem>() {
-
-		@Override
-		protected GraphMem createNewGraph() {
-			return new GraphMem();
-		}
-
-		@Override
-		public Graph[] getDependsOn(Graph g) {
-			return null;
-		}
-
-		@Override
-		public Graph[] getNotDependsOn(Graph g) {
-			return new Graph[] { memGraph() };
-		}
-
-	};
-
-	@Inject
-	public IProducer<GraphMem> getGraphProducer() {
-		return graphProducer;
-	}
-
-	@ContractTest
-	public void testHasStatistics() {
-		GraphStatisticsHandler h = graphProducer.newInstance()
-				.getStatisticsHandler();
-		assertNotNull(h);
-	}
-
-	@ContractTest
-	public void testContainsConcreteDoesntUseFind() {
-		Graph g = new GraphMemWithoutFind();
-		graphAdd(g, "x P y; a Q b");
-		assertTrue(g.contains(triple("x P y")));
-		assertTrue(g.contains(triple("a Q b")));
-		assertFalse(g.contains(triple("a P y")));
-		assertFalse(g.contains(triple("y R b")));
-	}
-
-	protected final class GraphMemWithoutFind extends GraphMem {
-		@Override
-		public ExtendedIterator<Triple> graphBaseFind(Triple t) {
-			throw new JenaException("find is Not Allowed");
-		}
-	}
-
-	@ContractTest
-	public void testUnnecessaryMatches() {
-		Node special = new Node_URI("eg:foo") {
-			@Override
-			public boolean matches(Node s) {
-				fail("Matched called superfluously.");
-				return true;
-			}
-		};
-		Graph g = graphWith(graphProducer.newInstance(), "x p y");
-		g.add(new Triple(special, special, special));
-		exhaust(g.find(special, Node.ANY, Node.ANY));
-		exhaust(g.find(Node.ANY, special, Node.ANY));
-		exhaust(g.find(Node.ANY, Node.ANY, special));
-
-	}
-
-	protected void exhaust(Iterator<?> it) {
-		while (it.hasNext())
-			it.next();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/GraphMem_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphMem_CS.java b/jena-core/src/test/java/org/apache/jena/mem/GraphMem_CS.java
new file mode 100644
index 0000000..718432b
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphMem_CS.java
@@ -0,0 +1,115 @@
+/*
+    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 org.apache.jena.mem;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphStatisticsHandler;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Node_URI;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.JenaException;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphMem.class)
+public class GraphMem_CS {
+
+	protected IProducer<GraphMem> graphProducer = new AbstractGraphProducer<GraphMem>() {
+
+		@Override
+		protected GraphMem createNewGraph() {
+			return new GraphMem();
+		}
+
+		@Override
+		public Graph[] getDependsOn(Graph g) {
+			return null;
+		}
+
+		@Override
+		public Graph[] getNotDependsOn(Graph g) {
+			return new Graph[] { memGraph() };
+		}
+
+	};
+
+	@Inject
+	public IProducer<GraphMem> getGraphProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testHasStatistics() {
+		GraphStatisticsHandler h = graphProducer.newInstance()
+				.getStatisticsHandler();
+		assertNotNull(h);
+	}
+
+	@ContractTest
+	public void testContainsConcreteDoesntUseFind() {
+		Graph g = new GraphMemWithoutFind();
+		graphAdd(g, "x P y; a Q b");
+		assertTrue(g.contains(triple("x P y")));
+		assertTrue(g.contains(triple("a Q b")));
+		assertFalse(g.contains(triple("a P y")));
+		assertFalse(g.contains(triple("y R b")));
+	}
+
+	protected final class GraphMemWithoutFind extends GraphMem {
+		@Override
+		public ExtendedIterator<Triple> graphBaseFind(Triple t) {
+			throw new JenaException("find is Not Allowed");
+		}
+	}
+
+	@ContractTest
+	public void testUnnecessaryMatches() {
+		Node special = new Node_URI("eg:foo") {
+			@Override
+			public boolean matches(Node s) {
+				fail("Matched called superfluously.");
+				return true;
+			}
+		};
+		Graph g = graphWith(graphProducer.newInstance(), "x p y");
+		g.add(new Triple(special, special, special));
+		exhaust(g.find(special, Node.ANY, Node.ANY));
+		exhaust(g.find(Node.ANY, special, Node.ANY));
+		exhaust(g.find(Node.ANY, Node.ANY, special));
+
+	}
+
+	protected void exhaust(Iterator<?> it) {
+		while (it.hasNext())
+			it.next();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreMem_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreMem_CS.java b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreMem_CS.java
new file mode 100644
index 0000000..129e706
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreMem_CS.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.mem.GraphTripleStore;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphTripleStore.class)
+public class GraphTripleStoreMem_CS {
+
+	private IProducer<GraphTripleStoreMem> producer = new IProducer<GraphTripleStoreMem>() {
+
+		@Override
+		public GraphTripleStoreMem newInstance() {
+			return new GraphTripleStoreMem(Graph.emptyGraph);
+		}
+
+		@Override
+		public void cleanUp() {
+		}
+
+	};
+
+	@Contract.Inject
+	public IProducer<GraphTripleStoreMem> getTripleStore() {
+		return producer;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
deleted file mode 100644
index 1f82935..0000000
--- a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 org.apache.jena.mem;
-
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-
-import org.apache.jena.graph.Graph;
-import org.apache.jena.mem.GraphTripleStore;
-import org.xenei.junit.contract.IProducer;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(GraphTripleStore.class)
-public class GraphTripleStoreTest {
-
-	private IProducer<GraphTripleStore> producer = new IProducer<GraphTripleStore>() {
-
-		@Override
-		public GraphTripleStore newInstance() {
-			return new GraphTripleStore(Graph.emptyGraph);
-		}
-
-		@Override
-		public void cleanUp() {
-		}
-
-	};
-
-	@Contract.Inject
-	public IProducer<GraphTripleStore> getTripleStore() {
-		return producer;
-	}
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStore_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStore_CS.java b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStore_CS.java
new file mode 100644
index 0000000..c2a2d1c
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStore_CS.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.mem.GraphTripleStore;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphTripleStore.class)
+public class GraphTripleStore_CS {
+
+	private IProducer<GraphTripleStore> producer = new IProducer<GraphTripleStore>() {
+
+		@Override
+		public GraphTripleStore newInstance() {
+			return new GraphTripleStore(Graph.emptyGraph);
+		}
+
+		@Override
+		public void cleanUp() {
+		}
+
+	};
+
+	@Contract.Inject
+	public IProducer<GraphTripleStore> getTripleStore() {
+		return producer;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/HashedBunchMap_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/HashedBunchMap_CS.java b/jena-core/src/test/java/org/apache/jena/mem/HashedBunchMap_CS.java
new file mode 100644
index 0000000..cb64b57
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/HashedBunchMap_CS.java
@@ -0,0 +1,52 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(WrappedHashMap.class)
+public class HashedBunchMap_CS {
+
+	protected IProducer<HashedBunchMap> mapProducer = new IProducer<HashedBunchMap>() {
+
+		@Override
+		public HashedBunchMap newInstance() {
+			return new HashedBunchMap();
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+		
+
+	};
+
+	@Inject
+	public IProducer<HashedBunchMap> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/HashedTripleBunch_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/HashedTripleBunch_CS.java b/jena-core/src/test/java/org/apache/jena/mem/HashedTripleBunch_CS.java
new file mode 100644
index 0000000..5db46a3
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/HashedTripleBunch_CS.java
@@ -0,0 +1,50 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(HashedTripleBunch.class)
+public class HashedTripleBunch_CS {
+
+	protected IProducer<HashedTripleBunch> mapProducer = new IProducer<HashedTripleBunch>() {
+
+		@Override
+		public HashedTripleBunch newInstance() {
+			return new HashedTripleBunch( new ArrayBunch() );
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+	};
+
+	@Inject
+	public IProducer<HashedTripleBunch> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/SetBunch_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/SetBunch_CS.java b/jena-core/src/test/java/org/apache/jena/mem/SetBunch_CS.java
new file mode 100644
index 0000000..b6b1f69
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/SetBunch_CS.java
@@ -0,0 +1,50 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(SetBunch.class)
+public class SetBunch_CS {
+
+	protected IProducer<SetBunch> mapProducer = new IProducer<SetBunch>() {
+
+		@Override
+		public SetBunch newInstance() {
+			return new SetBunch( new ArrayBunch() );
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+	};
+
+	@Inject
+	public IProducer<SetBunch> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/mem/WrappedHashMap_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/WrappedHashMap_CS.java b/jena-core/src/test/java/org/apache/jena/mem/WrappedHashMap_CS.java
new file mode 100644
index 0000000..25c2bb6
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/WrappedHashMap_CS.java
@@ -0,0 +1,52 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(WrappedHashMap.class)
+public class WrappedHashMap_CS {
+
+	protected IProducer<WrappedHashMap> mapProducer = new IProducer<WrappedHashMap>() {
+
+		@Override
+		public WrappedHashMap newInstance() {
+			return new WrappedHashMap();
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+		
+
+	};
+
+	@Inject
+	public IProducer<WrappedHashMap> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java b/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
index f7a16e5..d981b10 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import org.xenei.junit.contract.IProducer;

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
deleted file mode 100644
index 8c33eb1..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-    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 org.apache.jena.testing_framework;
-
-/**
- * Creates the graph for testing. Implementations must track the creation of
- * graphs created with newGraph and close them when closeGraphs is called.
- * 
- */
-//public interface GraphProducerInterface<T> {
-//
-//	/**
-//	 * Returns a new Graph to take part in the test.
-//	 * 
-//	 * @return The graph implementation to test.
-//	 */
-//	public abstract Graph newGraph();
-//
-//	/**
-//	 * provides a hook to close down graphs. When called all graphs created by
-//	 * the newGraph() method should be closed. Note that some graphs may have
-//	 * been closed during the test, so graphs should be tested for being closed
-//	 * prior to closing.
-//	 */
-//	public abstract void closeGraphs();
-// }

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
index 41bc6df..6d43847 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import org.apache.jena.rdf.model.Container;

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
index 3178692..8e17cec 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
index ef9eead..3c74fb2 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import org.apache.jena.rdf.model.Resource;

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java b/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
index 7b46366..d839c82 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import java.io.ByteArrayInputStream;

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
index 81999bd..9ba9028 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
 
 import org.apache.jena.n3.turtle.TurtleTestVocab;

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
index cfde240..f0d66b8 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
 
 public abstract class ManifestTest {

http://git-wip-us.apache.org/repos/asf/jena/blob/608c2b40/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
index 616b444..ef38c7b 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
 
 import java.lang.annotation.Annotation;


[06/25] jena git commit: updated contract tests.

Posted by cl...@apache.org.
updated contract tests.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f97d604c
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f97d604c
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f97d604c

Branch: refs/heads/master
Commit: f97d604c837ec8f0ddf978fa895e70308d7f148a
Parents: 8018ea4
Author: Claude Warren <cl...@apache.org>
Authored: Mon Apr 27 22:40:03 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Mon Apr 27 22:40:03 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml                               |   1 +
 .../apache/jena/graph/GraphContractTest.java    |   4 +-
 .../graph/GraphEventManagerContractTest.java    |  14 ---
 .../jena/graph/GraphMakerContractTest.java      |  23 +---
 .../graph/GraphWithPerformContractTest.java     |  37 +++---
 .../graph/TransactionHandlerContractTest.java   |  13 ---
 .../jena/graph/impl/CollectionGraph_CS.java     |  67 +++++++++++
 .../jena/graph/impl/FileGraphMaker_CS.java      |  81 +++++++++++++
 .../impl/FileGraphTransactionHandler_CS.java    |  56 +++++++++
 .../apache/jena/graph/impl/FileGraph_CS.java    |  78 +++++++++++++
 .../jena/graph/impl/SimpleEventManager_CS.java  |  54 +++++++++
 .../jena/graph/impl/SimpleGraphMaker_CS.java    |  54 +++++++++
 .../graph/impl/SimpleTransactionHandler_CS.java |  54 +++++++++
 .../jena/graph/impl/TestCollectionGraph.java    |  67 -----------
 .../jena/graph/impl/TestWrappedGraph.java       |  63 ----------
 .../graph/impl/TripleStoreContractTest.java     |  16 ---
 .../apache/jena/graph/impl/WrappedGraph_CS.java |  63 ++++++++++
 .../java/org/apache/jena/mem/ArrayBunch_CS.java |  52 +++++++++
 .../java/org/apache/jena/mem/GraphMemTest.java  | 115 -------------------
 .../java/org/apache/jena/mem/GraphMem_CS.java   | 115 +++++++++++++++++++
 .../apache/jena/mem/GraphTripleStoreMem_CS.java |  51 ++++++++
 .../apache/jena/mem/GraphTripleStoreTest.java   |  51 --------
 .../apache/jena/mem/GraphTripleStore_CS.java    |  51 ++++++++
 .../org/apache/jena/mem/HashedBunchMap_CS.java  |  52 +++++++++
 .../apache/jena/mem/HashedTripleBunch_CS.java   |  50 ++++++++
 .../java/org/apache/jena/mem/SetBunch_CS.java   |  50 ++++++++
 .../org/apache/jena/mem/WrappedHashMap_CS.java  |  52 +++++++++
 .../testing_framework/ContractTemplate.java     |  18 +++
 .../GraphProducerInterface.java                 |  41 -------
 .../testing_framework/IContainerProducer.java   |  18 +++
 .../testing_framework/IIteratorProducer.java    |  18 +++
 .../testing_framework/IResourceProducer.java    |  18 +++
 .../jena/testing_framework/TestFileData.java    |  18 +++
 .../manifest/ManifestItem.java                  |  18 +++
 .../manifest/ManifestTest.java                  |  18 +++
 .../manifest/ManifestTestRunner.java            |  18 +++
 36 files changed, 1146 insertions(+), 423 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index 1c2ff5a..6696660 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -117,6 +117,7 @@
 					</systemProperties>
 					<includes>
 						<include>com/hp/hpl/jena/test/TestPackage.java</include>
+						<include>**/*_CS.java</include>
 					</includes>
 				</configuration>
 			</plugin>

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index a989bae..55ad955 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -57,9 +57,7 @@ import org.apache.jena.util.iterator.Map1;
 import static org.apache.jena.testing_framework.GraphHelper.*;
 
 /**
- * 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.
+ * Graph contract test.
  */
 @Contract(Graph.class)
 public class GraphContractTest<T extends Graph> extends

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
index 426002d..d18bd52 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphEventManagerContractTest.java
@@ -33,7 +33,6 @@ import static org.junit.Assert.*;
 import org.apache.jena.graph.Graph;
 import org.apache.jena.graph.GraphEventManager;
 import org.apache.jena.graph.Triple;
-import org.apache.jena.graph.Factory;
 import org.apache.jena.testing_framework.ContractTemplate;
 import org.apache.jena.testing_framework.GraphHelper;
 import org.xenei.junit.contract.IProducer;
@@ -61,19 +60,6 @@ public class GraphEventManagerContractTest<T extends GraphEventManager> extends
 	private GraphEventManager gem;
 
 	public GraphEventManagerContractTest() {
-//		setProducer(new IProducer<T>() {
-//
-//			@SuppressWarnings("unchecked")
-//			@Override
-//			public T newInstance() {
-//				return (T) Factory.createGraphMem().getEventManager();
-//			}
-//
-//			@Override
-//			public void cleanUp() {
-//			}
-//		});
-
 	}
 
 	@Contract.Inject

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
index 5fbd9c2..d5a3657 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphMakerContractTest.java
@@ -30,7 +30,6 @@ import org.apache.jena.graph.Graph;
 import org.apache.jena.graph.GraphMaker;
 import org.apache.jena.graph.Node;
 import org.apache.jena.graph.Triple;
-import org.apache.jena.graph.impl.SimpleGraphMaker;
 import org.apache.jena.shared.AlreadyExistsException;
 import org.apache.jena.shared.DoesNotExistException;
 import org.apache.jena.testing_framework.GraphHelper;
@@ -38,14 +37,8 @@ import org.xenei.junit.contract.IProducer;
 import org.apache.jena.testing_framework.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.)
+ * GraphMaker contract test.
+ *
  */
 @Contract(GraphMaker.class)
 public class GraphMakerContractTest {
@@ -55,18 +48,6 @@ public class GraphMakerContractTest {
 	private GraphMaker graphMaker;
 
 	public GraphMakerContractTest() {
-//		producer = new IProducer<GraphMaker>() {
-//
-//			@Override
-//			public GraphMaker newInstance() {
-//				return new SimpleGraphMaker();
-//			}
-//
-//			@Override
-//			public void cleanUp() {
-//
-//			}
-//		};
 	}
 
 	@Contract.Inject

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
index aaaa85a..a4e233f 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphWithPerformContractTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.graph;
 
 import static org.apache.jena.testing_framework.GraphHelper.graphWith;
@@ -8,13 +26,10 @@ import static org.apache.jena.testing_framework.GraphHelper.txnCommit;
 import static org.junit.Assert.*;
 
 import org.junit.After;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.xenei.junit.contract.Contract;
 import org.xenei.junit.contract.ContractTest;
 
 import org.apache.jena.graph.impl.GraphWithPerform;
-import org.apache.jena.mem.GraphMem;
 import org.apache.jena.testing_framework.ContractTemplate;
 
 import org.xenei.junit.contract.IProducer;
@@ -30,23 +45,7 @@ public class GraphWithPerformContractTest<T extends GraphWithPerform> extends
 	// Recording listener for tests
 	protected RecordingGraphListener GL = new RecordingGraphListener();
 
-	private static final Logger LOG = LoggerFactory
-			.getLogger(GraphWithPerformContractTest.class);
-
-	@SuppressWarnings("unchecked")
 	public GraphWithPerformContractTest() {
-//		setProducer((IProducer<T>) new IProducer<GraphWithPerform>() {
-//
-//			@Override
-//			public GraphWithPerform newInstance() {
-//				return new GraphMem();
-//			}
-//
-//			@Override
-//			public void cleanUp() {
-//
-//			}
-//		});
 	}
 
 	@Contract.Inject

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
index d26d7e9..8ffddbc 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/TransactionHandlerContractTest.java
@@ -29,7 +29,6 @@ import static org.junit.Assert.*;
 
 import org.apache.jena.graph.TransactionHandler;
 import org.apache.jena.graph.Triple;
-import org.apache.jena.graph.impl.SimpleTransactionHandler;
 import org.apache.jena.shared.Command;
 import org.apache.jena.shared.JenaException;
 import org.xenei.junit.contract.IProducer;
@@ -47,18 +46,6 @@ public class TransactionHandlerContractTest {
 	private IProducer<TransactionHandler> producer;
 
 	public TransactionHandlerContractTest() {
-//		producer = new IProducer<TransactionHandler>() {
-//
-//			@Override
-//			public TransactionHandler newInstance() {
-//				return new SimpleTransactionHandler();
-//			}
-//
-//			@Override
-//			public void cleanUp() {
-//
-//			}
-//		};
 	}
 
 	@Contract.Inject

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/CollectionGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/CollectionGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/CollectionGraph_CS.java
new file mode 100644
index 0000000..b246f2b
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/CollectionGraph_CS.java
@@ -0,0 +1,67 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
+import java.util.HashSet;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.Triple ;
+import org.apache.jena.graph.impl.CollectionGraph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(CollectionGraph.class)
+public class CollectionGraph_CS {
+	 
+	protected IProducer<CollectionGraph> graphProducer;
+	
+	public CollectionGraph_CS() {
+		graphProducer = new AbstractGraphProducer<CollectionGraph>() {
+			
+			@Override
+			protected CollectionGraph createNewGraph() {
+				return new CollectionGraph( new HashSet<Triple>() );
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<CollectionGraph> getCollectionTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
new file mode 100644
index 0000000..5f1d36d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphMaker_CS.java
@@ -0,0 +1,81 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(FileGraphMaker.class)
+public class FileGraphMaker_CS {
+	 
+	protected IProducer<FileGraphMaker> graphProducer;
+	
+	public FileGraphMaker_CS() throws IOException {
+		graphProducer = new FileGraphMakerProducer();
+	}
+
+	@Contract.Inject
+	public final IProducer<FileGraphMaker> getCollectionTestProducer() {
+		return graphProducer;
+	}
+	
+	private static class FileGraphMakerProducer implements IProducer<FileGraphMaker> {
+		private Map<Path,FileGraphMaker> map;
+		
+		public FileGraphMakerProducer () throws IOException {
+			map = new HashMap<Path,FileGraphMaker>();
+		}
+		
+		
+		@Override
+		public FileGraphMaker newInstance() {
+			Path p;
+			try {
+				p = Files.createTempDirectory("fgm_CS");
+			} catch (IOException e) {
+				throw new RuntimeException( "Unable to create temp directory", e );
+			}
+			FileGraphMaker fgm = new FileGraphMaker( p.toString(), true);
+			map.put(p, fgm);
+			return fgm;
+		}
+
+		@Override
+		public void cleanUp() {
+			for (Path p : map.keySet())
+			{
+				map.get(p).close();
+				p.toFile().delete();
+			}
+			map.clear();
+		}
+
+	};
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
new file mode 100644
index 0000000..5e0feb4
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraphTransactionHandler_CS.java
@@ -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 org.apache.jena.graph.impl;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(FileGraphTransactionHandler.class)
+public class FileGraphTransactionHandler_CS {
+	 
+	protected IProducer<FileGraphTransactionHandler> graphProducer;
+	
+	public FileGraphTransactionHandler_CS() {
+		graphProducer = new IProducer<FileGraphTransactionHandler>() {
+			
+			private FileGraph_CS.FileGraphProducer fgp = new FileGraph_CS.FileGraphProducer();
+			
+			@Override
+			public FileGraphTransactionHandler newInstance() {
+				return new FileGraphTransactionHandler( fgp.newInstance() );
+			}
+
+			@Override
+			public void cleanUp() {
+				fgp.cleanUp();
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<FileGraphTransactionHandler> getCollectionTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
new file mode 100644
index 0000000..b7bb6c3
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/FileGraph_CS.java
@@ -0,0 +1,78 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(FileGraph.class)
+public class FileGraph_CS {
+	 
+	protected IProducer<FileGraph> graphProducer;
+	
+	public FileGraph_CS() {
+		graphProducer = new FileGraphProducer();
+	}
+
+	@Contract.Inject
+	public final IProducer<FileGraph> getCollectionTestProducer() {
+		return graphProducer;
+	}
+	
+	public static class FileGraphProducer extends AbstractGraphProducer<FileGraph> {
+		
+		@Override
+		protected FileGraph createNewGraph() {
+			File f;
+			try {
+				f = File.createTempFile("fgp", ".ttl" );
+			} catch (IOException e) {
+				throw new RuntimeException( "Can not create file", e );
+			}
+			return new FileGraph( f, false, true );
+		}
+
+		@Override
+		public Graph[] getDependsOn(Graph d) {
+			return null;
+		}
+
+		@Override
+		public Graph[] getNotDependsOn(Graph g) {
+			return new Graph[] { memGraph() };
+		}
+		
+		@Override
+		protected void afterClose(Graph g) {
+			((FileGraph)g).name.delete();
+		}
+
+	};
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleEventManager_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleEventManager_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleEventManager_CS.java
new file mode 100644
index 0000000..bfe7a3c
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleEventManager_CS.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+
+import org.xenei.junit.contract.IProducer;
+
+/**
+ * Test the SimpleGraphFactory by extending AbstractTestGraphFactory and
+ * supplying new SimplGraphFactorys via getGraph.
+ */
+@RunWith(ContractSuite.class)
+@ContractImpl(SimpleEventManager.class)
+public class SimpleEventManager_CS {
+
+	private IProducer<SimpleEventManager> producer = new IProducer<SimpleEventManager>() {
+
+		@Override
+		public SimpleEventManager newInstance() {
+			return new SimpleEventManager();
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do.
+		}
+	};
+
+	@Contract.Inject
+	public IProducer<SimpleEventManager> getEventManagerProducer() {
+		return producer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleGraphMaker_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleGraphMaker_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleGraphMaker_CS.java
new file mode 100644
index 0000000..43dac19
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleGraphMaker_CS.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(SimpleGraphMaker.class)
+public class SimpleGraphMaker_CS {
+	 
+	protected IProducer<SimpleGraphMaker> graphProducer;
+	
+	public SimpleGraphMaker_CS() {
+		graphProducer = new IProducer<SimpleGraphMaker>() {
+			
+			@Override
+			public SimpleGraphMaker newInstance() {
+				return new SimpleGraphMaker();
+			}
+
+			@Override
+			public void cleanUp() {
+				// nothing to do
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<SimpleGraphMaker> getCollectionTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleTransactionHandler_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleTransactionHandler_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleTransactionHandler_CS.java
new file mode 100644
index 0000000..da845ec
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/SimpleTransactionHandler_CS.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(SimpleTransactionHandler.class)
+public class SimpleTransactionHandler_CS {
+	 
+	protected IProducer<SimpleTransactionHandler> graphProducer;
+	
+	public SimpleTransactionHandler_CS() {
+		graphProducer = new IProducer<SimpleTransactionHandler>() {
+			
+			@Override
+			public SimpleTransactionHandler newInstance() {
+				return new SimpleTransactionHandler();
+			}
+
+			@Override
+			public void cleanUp() {
+				// nothing to do
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<SimpleTransactionHandler> getCollectionTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
deleted file mode 100644
index 4d9f40d..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 org.apache.jena.graph.impl;
-
-import static org.apache.jena.testing_framework.GraphHelper.memGraph;
-
-import java.util.HashSet;
-
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.graph.impl.CollectionGraph ;
-import org.apache.jena.testing_framework.AbstractGraphProducer;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.IProducer;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(CollectionGraph.class)
-public class TestCollectionGraph {
-	 
-	protected IProducer<CollectionGraph> graphProducer;
-	
-	public TestCollectionGraph() {
-		graphProducer = new AbstractGraphProducer<CollectionGraph>() {
-			
-			@Override
-			protected CollectionGraph createNewGraph() {
-				return new CollectionGraph( new HashSet<Triple>() );
-			}
-
-			@Override
-			public Graph[] getDependsOn(Graph d) {
-				return null;
-			}
-
-			@Override
-			public Graph[] getNotDependsOn(Graph g) {
-				return new Graph[] { memGraph() };
-			}
-
-		};
-	}
-
-	@Contract.Inject
-	public final IProducer<CollectionGraph> getDeltaTestProducer() {
-		return graphProducer;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
deleted file mode 100644
index 7910660..0000000
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/TestWrappedGraph.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 org.apache.jena.graph.impl;
-
-import static org.apache.jena.testing_framework.GraphHelper.memGraph;
-
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.testing_framework.AbstractGraphProducer;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.IProducer;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(WrappedGraph.class)
-public class TestWrappedGraph {
-	 
-	protected IProducer<WrappedGraph> graphProducer;
-	
-	public TestWrappedGraph() {
-		graphProducer = new AbstractGraphProducer<WrappedGraph>() {
-			
-			@Override
-			protected WrappedGraph createNewGraph() {
-				return new WrappedGraph( memGraph() );
-			}
-
-			@Override
-			public Graph[] getDependsOn(Graph d) {
-				return null;
-			}
-
-			@Override
-			public Graph[] getNotDependsOn(Graph g) {
-				return new Graph[] { memGraph() };
-			}
-
-		};
-	}
-
-	@Contract.Inject
-	public final IProducer<WrappedGraph> getDeltaTestProducer() {
-		return graphProducer;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
index 0b074aa..815a40d 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/TripleStoreContractTest.java
@@ -26,7 +26,6 @@ import org.xenei.junit.contract.ContractTest;
 import static org.junit.Assert.*;
 
 import static org.apache.jena.testing_framework.GraphHelper.*;
-import org.apache.jena.mem.GraphTripleStore;
 import org.apache.jena.graph.impl.TripleStore;
 import org.apache.jena.testing_framework.ContractTemplate;
 
@@ -43,21 +42,6 @@ public class TripleStoreContractTest<T extends TripleStore> extends
 	protected TripleStore store;
 
 	public TripleStoreContractTest() {
-		IProducer<TripleStore> producer = new IProducer<TripleStore>() {
-
-			@Override
-			public TripleStore newInstance() {
-				return new GraphTripleStore(memGraph());
-			}
-
-			@Override
-			public void cleanUp() {
-				// TODO Auto-generated method stub
-
-			}
-
-		};
-		setProducer((IProducer<T>) producer);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/graph/impl/WrappedGraph_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/impl/WrappedGraph_CS.java b/jena-core/src/test/java/org/apache/jena/graph/impl/WrappedGraph_CS.java
new file mode 100644
index 0000000..3cc5b1c
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/graph/impl/WrappedGraph_CS.java
@@ -0,0 +1,63 @@
+/*
+ * 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 org.apache.jena.graph.impl;
+
+import static org.apache.jena.testing_framework.GraphHelper.memGraph;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(WrappedGraph.class)
+public class WrappedGraph_CS {
+	 
+	protected IProducer<WrappedGraph> graphProducer;
+	
+	public WrappedGraph_CS() {
+		graphProducer = new AbstractGraphProducer<WrappedGraph>() {
+			
+			@Override
+			protected WrappedGraph createNewGraph() {
+				return new WrappedGraph( memGraph() );
+			}
+
+			@Override
+			public Graph[] getDependsOn(Graph d) {
+				return null;
+			}
+
+			@Override
+			public Graph[] getNotDependsOn(Graph g) {
+				return new Graph[] { memGraph() };
+			}
+
+		};
+	}
+
+	@Contract.Inject
+	public final IProducer<WrappedGraph> getDeltaTestProducer() {
+		return graphProducer;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/ArrayBunch_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/ArrayBunch_CS.java b/jena-core/src/test/java/org/apache/jena/mem/ArrayBunch_CS.java
new file mode 100644
index 0000000..df8438e
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/ArrayBunch_CS.java
@@ -0,0 +1,52 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(ArrayBunch.class)
+public class ArrayBunch_CS {
+
+	protected IProducer<ArrayBunch> mapProducer = new IProducer<ArrayBunch>() {
+
+		@Override
+		public ArrayBunch newInstance() {
+			return new ArrayBunch();
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+		
+
+	};
+
+	@Inject
+	public IProducer<ArrayBunch> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java b/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
deleted file mode 100644
index 8fed109..0000000
--- a/jena-core/src/test/java/org/apache/jena/mem/GraphMemTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-    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 org.apache.jena.mem;
-
-import static org.apache.jena.testing_framework.GraphHelper.*;
-import static org.junit.Assert.*;
-
-import java.util.Iterator;
-
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract.Inject;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-import org.xenei.junit.contract.ContractTest;
-
-import org.apache.jena.graph.Graph;
-import org.apache.jena.graph.GraphStatisticsHandler;
-import org.apache.jena.graph.Node;
-import org.apache.jena.graph.Node_URI;
-import org.apache.jena.graph.Triple;
-import org.apache.jena.shared.JenaException;
-import org.apache.jena.testing_framework.AbstractGraphProducer;
-import org.xenei.junit.contract.IProducer;
-import org.apache.jena.util.iterator.ExtendedIterator;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(GraphMem.class)
-public class GraphMemTest {
-
-	protected IProducer<GraphMem> graphProducer = new AbstractGraphProducer<GraphMem>() {
-
-		@Override
-		protected GraphMem createNewGraph() {
-			return new GraphMem();
-		}
-
-		@Override
-		public Graph[] getDependsOn(Graph g) {
-			return null;
-		}
-
-		@Override
-		public Graph[] getNotDependsOn(Graph g) {
-			return new Graph[] { memGraph() };
-		}
-
-	};
-
-	@Inject
-	public IProducer<GraphMem> getGraphProducer() {
-		return graphProducer;
-	}
-
-	@ContractTest
-	public void testHasStatistics() {
-		GraphStatisticsHandler h = graphProducer.newInstance()
-				.getStatisticsHandler();
-		assertNotNull(h);
-	}
-
-	@ContractTest
-	public void testContainsConcreteDoesntUseFind() {
-		Graph g = new GraphMemWithoutFind();
-		graphAdd(g, "x P y; a Q b");
-		assertTrue(g.contains(triple("x P y")));
-		assertTrue(g.contains(triple("a Q b")));
-		assertFalse(g.contains(triple("a P y")));
-		assertFalse(g.contains(triple("y R b")));
-	}
-
-	protected final class GraphMemWithoutFind extends GraphMem {
-		@Override
-		public ExtendedIterator<Triple> graphBaseFind(Triple t) {
-			throw new JenaException("find is Not Allowed");
-		}
-	}
-
-	@ContractTest
-	public void testUnnecessaryMatches() {
-		Node special = new Node_URI("eg:foo") {
-			@Override
-			public boolean matches(Node s) {
-				fail("Matched called superfluously.");
-				return true;
-			}
-		};
-		Graph g = graphWith(graphProducer.newInstance(), "x p y");
-		g.add(new Triple(special, special, special));
-		exhaust(g.find(special, Node.ANY, Node.ANY));
-		exhaust(g.find(Node.ANY, special, Node.ANY));
-		exhaust(g.find(Node.ANY, Node.ANY, special));
-
-	}
-
-	protected void exhaust(Iterator<?> it) {
-		while (it.hasNext())
-			it.next();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/GraphMem_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphMem_CS.java b/jena-core/src/test/java/org/apache/jena/mem/GraphMem_CS.java
new file mode 100644
index 0000000..718432b
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphMem_CS.java
@@ -0,0 +1,115 @@
+/*
+    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 org.apache.jena.mem;
+
+import static org.apache.jena.testing_framework.GraphHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.ContractTest;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphStatisticsHandler;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Node_URI;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.JenaException;
+import org.apache.jena.testing_framework.AbstractGraphProducer;
+import org.xenei.junit.contract.IProducer;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphMem.class)
+public class GraphMem_CS {
+
+	protected IProducer<GraphMem> graphProducer = new AbstractGraphProducer<GraphMem>() {
+
+		@Override
+		protected GraphMem createNewGraph() {
+			return new GraphMem();
+		}
+
+		@Override
+		public Graph[] getDependsOn(Graph g) {
+			return null;
+		}
+
+		@Override
+		public Graph[] getNotDependsOn(Graph g) {
+			return new Graph[] { memGraph() };
+		}
+
+	};
+
+	@Inject
+	public IProducer<GraphMem> getGraphProducer() {
+		return graphProducer;
+	}
+
+	@ContractTest
+	public void testHasStatistics() {
+		GraphStatisticsHandler h = graphProducer.newInstance()
+				.getStatisticsHandler();
+		assertNotNull(h);
+	}
+
+	@ContractTest
+	public void testContainsConcreteDoesntUseFind() {
+		Graph g = new GraphMemWithoutFind();
+		graphAdd(g, "x P y; a Q b");
+		assertTrue(g.contains(triple("x P y")));
+		assertTrue(g.contains(triple("a Q b")));
+		assertFalse(g.contains(triple("a P y")));
+		assertFalse(g.contains(triple("y R b")));
+	}
+
+	protected final class GraphMemWithoutFind extends GraphMem {
+		@Override
+		public ExtendedIterator<Triple> graphBaseFind(Triple t) {
+			throw new JenaException("find is Not Allowed");
+		}
+	}
+
+	@ContractTest
+	public void testUnnecessaryMatches() {
+		Node special = new Node_URI("eg:foo") {
+			@Override
+			public boolean matches(Node s) {
+				fail("Matched called superfluously.");
+				return true;
+			}
+		};
+		Graph g = graphWith(graphProducer.newInstance(), "x p y");
+		g.add(new Triple(special, special, special));
+		exhaust(g.find(special, Node.ANY, Node.ANY));
+		exhaust(g.find(Node.ANY, special, Node.ANY));
+		exhaust(g.find(Node.ANY, Node.ANY, special));
+
+	}
+
+	protected void exhaust(Iterator<?> it) {
+		while (it.hasNext())
+			it.next();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreMem_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreMem_CS.java b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreMem_CS.java
new file mode 100644
index 0000000..129e706
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreMem_CS.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.mem.GraphTripleStore;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphTripleStore.class)
+public class GraphTripleStoreMem_CS {
+
+	private IProducer<GraphTripleStoreMem> producer = new IProducer<GraphTripleStoreMem>() {
+
+		@Override
+		public GraphTripleStoreMem newInstance() {
+			return new GraphTripleStoreMem(Graph.emptyGraph);
+		}
+
+		@Override
+		public void cleanUp() {
+		}
+
+	};
+
+	@Contract.Inject
+	public IProducer<GraphTripleStoreMem> getTripleStore() {
+		return producer;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
deleted file mode 100644
index 1f82935..0000000
--- a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStoreTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 org.apache.jena.mem;
-
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.Contract;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-
-import org.apache.jena.graph.Graph;
-import org.apache.jena.mem.GraphTripleStore;
-import org.xenei.junit.contract.IProducer;
-
-@RunWith(ContractSuite.class)
-@ContractImpl(GraphTripleStore.class)
-public class GraphTripleStoreTest {
-
-	private IProducer<GraphTripleStore> producer = new IProducer<GraphTripleStore>() {
-
-		@Override
-		public GraphTripleStore newInstance() {
-			return new GraphTripleStore(Graph.emptyGraph);
-		}
-
-		@Override
-		public void cleanUp() {
-		}
-
-	};
-
-	@Contract.Inject
-	public IProducer<GraphTripleStore> getTripleStore() {
-		return producer;
-	}
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStore_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStore_CS.java b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStore_CS.java
new file mode 100644
index 0000000..c2a2d1c
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/GraphTripleStore_CS.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.mem.GraphTripleStore;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(GraphTripleStore.class)
+public class GraphTripleStore_CS {
+
+	private IProducer<GraphTripleStore> producer = new IProducer<GraphTripleStore>() {
+
+		@Override
+		public GraphTripleStore newInstance() {
+			return new GraphTripleStore(Graph.emptyGraph);
+		}
+
+		@Override
+		public void cleanUp() {
+		}
+
+	};
+
+	@Contract.Inject
+	public IProducer<GraphTripleStore> getTripleStore() {
+		return producer;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/HashedBunchMap_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/HashedBunchMap_CS.java b/jena-core/src/test/java/org/apache/jena/mem/HashedBunchMap_CS.java
new file mode 100644
index 0000000..cb64b57
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/HashedBunchMap_CS.java
@@ -0,0 +1,52 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(WrappedHashMap.class)
+public class HashedBunchMap_CS {
+
+	protected IProducer<HashedBunchMap> mapProducer = new IProducer<HashedBunchMap>() {
+
+		@Override
+		public HashedBunchMap newInstance() {
+			return new HashedBunchMap();
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+		
+
+	};
+
+	@Inject
+	public IProducer<HashedBunchMap> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/HashedTripleBunch_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/HashedTripleBunch_CS.java b/jena-core/src/test/java/org/apache/jena/mem/HashedTripleBunch_CS.java
new file mode 100644
index 0000000..5db46a3
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/HashedTripleBunch_CS.java
@@ -0,0 +1,50 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(HashedTripleBunch.class)
+public class HashedTripleBunch_CS {
+
+	protected IProducer<HashedTripleBunch> mapProducer = new IProducer<HashedTripleBunch>() {
+
+		@Override
+		public HashedTripleBunch newInstance() {
+			return new HashedTripleBunch( new ArrayBunch() );
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+	};
+
+	@Inject
+	public IProducer<HashedTripleBunch> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/SetBunch_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/SetBunch_CS.java b/jena-core/src/test/java/org/apache/jena/mem/SetBunch_CS.java
new file mode 100644
index 0000000..b6b1f69
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/SetBunch_CS.java
@@ -0,0 +1,50 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(SetBunch.class)
+public class SetBunch_CS {
+
+	protected IProducer<SetBunch> mapProducer = new IProducer<SetBunch>() {
+
+		@Override
+		public SetBunch newInstance() {
+			return new SetBunch( new ArrayBunch() );
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+	};
+
+	@Inject
+	public IProducer<SetBunch> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/mem/WrappedHashMap_CS.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/mem/WrappedHashMap_CS.java b/jena-core/src/test/java/org/apache/jena/mem/WrappedHashMap_CS.java
new file mode 100644
index 0000000..25c2bb6
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/mem/WrappedHashMap_CS.java
@@ -0,0 +1,52 @@
+/*
+    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 org.apache.jena.mem;
+
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract.Inject;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(WrappedHashMap.class)
+public class WrappedHashMap_CS {
+
+	protected IProducer<WrappedHashMap> mapProducer = new IProducer<WrappedHashMap>() {
+
+		@Override
+		public WrappedHashMap newInstance() {
+			return new WrappedHashMap();
+		}
+
+		@Override
+		public void cleanUp() {
+			// nothing to do
+		}
+
+		
+
+	};
+
+	@Inject
+	public IProducer<WrappedHashMap> getGraphProducer() {
+		return mapProducer;
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java b/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
index f7a16e5..d981b10 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import org.xenei.junit.contract.IProducer;

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
deleted file mode 100644
index 8c33eb1..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-    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 org.apache.jena.testing_framework;
-
-/**
- * Creates the graph for testing. Implementations must track the creation of
- * graphs created with newGraph and close them when closeGraphs is called.
- * 
- */
-//public interface GraphProducerInterface<T> {
-//
-//	/**
-//	 * Returns a new Graph to take part in the test.
-//	 * 
-//	 * @return The graph implementation to test.
-//	 */
-//	public abstract Graph newGraph();
-//
-//	/**
-//	 * provides a hook to close down graphs. When called all graphs created by
-//	 * the newGraph() method should be closed. Note that some graphs may have
-//	 * been closed during the test, so graphs should be tested for being closed
-//	 * prior to closing.
-//	 */
-//	public abstract void closeGraphs();
-// }

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
index 41bc6df..6d43847 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import org.apache.jena.rdf.model.Container;

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
index 3178692..8e17cec 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
index ef9eead..3c74fb2 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import org.apache.jena.rdf.model.Resource;

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java b/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
index 7b46366..d839c82 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework;
 
 import java.io.ByteArrayInputStream;

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
index 81999bd..9ba9028 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
 
 import org.apache.jena.n3.turtle.TurtleTestVocab;

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
index cfde240..f0d66b8 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
 
 public abstract class ManifestTest {

http://git-wip-us.apache.org/repos/asf/jena/blob/f97d604c/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
index 616b444..ef38c7b 100644
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
@@ -1,3 +1,21 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
 
 import java.lang.annotation.Annotation;


[02/25] jena git commit: Added initial contract tests added testing_framework

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/GraphHelper.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphHelper.java b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphHelper.java
new file mode 100644
index 0000000..c208e8d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphHelper.java
@@ -0,0 +1,508 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+/**
+ * Foo set of static test helpers.  Generally included as a static.
+ */
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.apache.jena.graph.Factory;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphUtil;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.JenaException;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.util.CollectionFactory;
+import org.apache.jena.util.IteratorCollection;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+public class GraphHelper extends TestUtils {
+
+	/**
+	 * 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>Foo</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;
+	}
+
+	/**
+	 * Like graphAdd but does it within a transaction if supported
+	 * 
+	 * @param g
+	 *            The graph to add to
+	 * @param s
+	 *            The string describing the graph
+	 * @return The populated graph.
+	 */
+	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;
+	}
+
+	/**
+	 * Used to create a graph with values.
+	 * 
+	 * @param g
+	 *            The newly created graph
+	 * @param s
+	 *            The string representing the graph data.
+	 * @return The populated graph
+	 */
+	public static Graph graphWith(Graph g, String s) {
+		return graphAddTxn(g, s);
+	}
+
+	/**
+	 * Answer a new memory-based graph with Extended prefixes.
+	 */
+	public static Graph memGraph() {
+		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 graphWith(memGraph(), 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());
+	}
+
+	/**
+	 * Foo 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));
+	}
+
+	// protected static Graph graphWithTxn(IProducer<? extends Graph> producer,
+	// String s) {
+	// Graph g = producer.newInstance();
+	// txnBegin(g);
+	// try {
+	// graphAdd(g, s);
+	// txnCommit(g);
+	// } catch (Exception e) {
+	// txnRollback(g);
+	// fail(e.getMessage());
+	// }
+	// return g;
+	// }
+
+	/**
+	 * 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);
+		}
+	}
+
+	/**
+	 * Begin a transaction on the graph if transactions are supported.
+	 * 
+	 * @param g
+	 */
+	public static void txnBegin(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().begin();
+		}
+	}
+
+	/**
+	 * Commit the transaction on the graph if transactions are supported.
+	 * 
+	 * @param g
+	 */
+	public static void txnCommit(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().commit();
+		}
+	}
+
+	/**
+	 * Rollback (abort) the transaction on the graph if transactions are
+	 * supported.
+	 * 
+	 * @param g
+	 */
+	public static void txnRollback(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().abort();
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
new file mode 100644
index 0000000..8c33eb1
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
@@ -0,0 +1,41 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+/**
+ * Creates the graph for testing. Implementations must track the creation of
+ * graphs created with newGraph and close them when closeGraphs is called.
+ * 
+ */
+//public interface GraphProducerInterface<T> {
+//
+//	/**
+//	 * Returns a new Graph to take part in the test.
+//	 * 
+//	 * @return The graph implementation to test.
+//	 */
+//	public abstract Graph newGraph();
+//
+//	/**
+//	 * provides a hook to close down graphs. When called all graphs created by
+//	 * the newGraph() method should be closed. Note that some graphs may have
+//	 * been closed during the test, so graphs should be tested for being closed
+//	 * prior to closing.
+//	 */
+//	public abstract void closeGraphs();
+// }

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
new file mode 100644
index 0000000..41bc6df
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
@@ -0,0 +1,19 @@
+package org.apache.jena.testing_framework;
+
+import org.apache.jena.rdf.model.Container;
+import org.apache.jena.rdf.model.Resource;
+
+public interface IContainerProducer<T extends Container> extends
+		IResourceProducer<T> {
+
+	/**
+	 * The Resource identifying the continer type. e.g. RDF.seq
+	 */
+	Resource getContainerType();
+
+	/**
+	 * The class of the continaer. e.g. Seq.class
+	 */
+	Class<? extends Container> getContainerClass();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
new file mode 100644
index 0000000..3178692
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
@@ -0,0 +1,42 @@
+package org.apache.jena.testing_framework;
+
+import java.util.List;
+
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+public interface IIteratorProducer<T> {
+
+	/**
+	 * Get a new instance of the iterator.
+	 * 
+	 * @return
+	 */
+	public ExtendedIterator<T> newInstance();
+
+	/**
+	 * Clean up after a test
+	 */
+	public void cleanUp();
+
+	/**
+	 * The list of items found in the iterator. Does not have to be in order.
+	 * 
+	 * @return
+	 */
+	public List<T> getList();
+
+	/**
+	 * True if delete is supported by the iterator
+	 * 
+	 * @return
+	 */
+	public boolean supportsDelete();
+
+	/**
+	 * True if this is an iterator on a copy so that delete works but getting a
+	 * new copy for the iterator test will return the original list.
+	 * 
+	 * @return
+	 */
+	public boolean isCopy();
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/INodeProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/INodeProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/INodeProducer.java
new file mode 100644
index 0000000..2532c32
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/INodeProducer.java
@@ -0,0 +1,39 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.xenei.junit.contract.IProducer;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+
+/**
+ * An abstract implementation of the IProducer<RDFNode> interface.
+ * 
+ * This class handles tracking of the created graphs and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the graph is closed.
+ * 
+ */
+public interface INodeProducer<T extends RDFNode> extends IProducer<T> {
+
+	abstract public T newInstance(String uri);
+
+	abstract public Model getModel();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
new file mode 100644
index 0000000..ef9eead
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
@@ -0,0 +1,10 @@
+package org.apache.jena.testing_framework;
+
+import org.apache.jena.rdf.model.Resource;
+
+public interface IResourceProducer<X extends Resource> extends INodeProducer<X> {
+	/**
+	 * Returns true if the Resource implementation supports non URI values
+	 */
+	boolean supportsAnonymous();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/IStatementProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IStatementProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IStatementProducer.java
new file mode 100644
index 0000000..8830948
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IStatementProducer.java
@@ -0,0 +1,45 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement;
+
+/**
+ * An abstract implementation of the IProducer<RDFNode> interface.
+ * 
+ * This class handles tracking of the created graphs and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the graph is closed.
+ * 
+ */
+public interface IStatementProducer<T extends Statement> {
+
+	abstract public T newInstance(String fact);
+
+	abstract public T newInstance(Resource s, Property p, RDFNode o);
+
+	abstract public Model getModel();
+
+	abstract public void cleanUp();
+
+	abstract public AbstractModelProducer<Model> getModelProducer();
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/ITripleStoreProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/ITripleStoreProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/ITripleStoreProducer.java
new file mode 100644
index 0000000..fe4e25d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/ITripleStoreProducer.java
@@ -0,0 +1,35 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.apache.jena.graph.impl.TripleStore;
+
+/**
+ * Creates the graph for testing
+ * 
+ */
+public interface ITripleStoreProducer {
+
+	/**
+	 * Returns a TripleStore to take part in the test. Must be overridden in a
+	 * subclass.
+	 * 
+	 * @return The TripleStore implementation to test.
+	 */
+	public abstract TripleStore newTripleStore();
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/ModelHelper.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/ModelHelper.java b/jena-core/src/test/java/org/apache/jena/testing_framework/ModelHelper.java
new file mode 100644
index 0000000..2f35203
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/ModelHelper.java
@@ -0,0 +1,409 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.rdf.model.Literal;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.rdf.model.StmtIterator;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.util.CollectionFactory;
+
+import static org.junit.Assert.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.junit.Assert;
+import org.xenei.junit.contract.IProducer;
+
+/**
+ * provides useful functionality for testing models, eg building small models
+ * from strings, testing equality, etc.
+ * 
+ * Currently this class extends GraphHelper and thus TestCase.
+ */
+public class ModelHelper extends GraphHelper {
+
+	private static Model builderModel;
+
+	static {
+		builderModel = ModelFactory.createDefaultModel();
+		builderModel.setNsPrefixes(PrefixMapping.Extended);
+	}
+
+	protected static final Model empty = ModelFactory.createDefaultModel();
+
+	protected static Model extendedModel(IProducer<Model> producer) {
+		Model result = producer.newInstance();
+		result.setNsPrefixes(PrefixMapping.Extended);
+		return result;
+	}
+
+	protected static String nice(RDFNode n) {
+		return nice(n.asNode());
+	}
+
+	public static Statement statement(String fact) {
+		StringTokenizer st = new StringTokenizer(fact);
+		Resource sub = resource(st.nextToken());
+		Property pred = property(st.nextToken());
+		RDFNode obj = rdfNode(st.nextToken());
+		return builderModel.createStatement(sub, pred, obj);
+	}
+
+	public static Statement statement(Resource s, Property p, RDFNode o) {
+		return builderModel.createStatement(s, p, o);
+	}
+
+	public static RDFNode rdfNode(Model m, String s) {
+		return m.asRDFNode(NodeCreateUtils.create(s));
+	}
+
+	public static RDFNode rdfNode(String s) {
+		return rdfNode(builderModel, s);
+	}
+
+	public static <T extends RDFNode> T rdfNode(String s, Class<T> c) {
+		return rdfNode(s).as(c);
+	}
+
+	public static Resource resource() {
+		return ResourceFactory.createResource();
+	}
+
+	public static Resource resource(String s) {
+		return (Resource) rdfNode(s);
+	}
+
+	// public static Resource resource(Model m, String s) {
+	// return (Resource) rdfNode(m, s);
+	// }
+
+	public static Property property(String s) {
+		return rdfNode(s).as(Property.class);
+	}
+
+	public static Property property(Model m, String s) {
+		return rdfNode(m, s).as(Property.class);
+	}
+
+	public static Literal literal(String s, String lang) {
+		return builderModel.createLiteral(s, lang);
+	}
+
+	public static Literal literal(String s) {
+		return rdfNode(s).as(Literal.class);
+	}
+
+	// /**
+	// * Create an array of Statements parsed from a semi-separated string.
+	// *
+	// * @param lockModel
+	// * a model to serve as a statement factory
+	// * @param facts
+	// * a sequence of semicolon-separated "S P O" facts
+	// * @return a Statement[] of the (S P O) statements from the string
+	// */
+	// public static Statement[] statements(Model m, String facts) {
+	// ArrayList<Statement> sl = new ArrayList<Statement>();
+	// StringTokenizer st = new StringTokenizer(facts, ";");
+	// while (st.hasMoreTokens())
+	// sl.add(statement(m, st.nextToken()));
+	// return sl.toArray(new Statement[sl.size()]);
+	// }
+
+	/**
+	 * Create an array of Statements parsed from a semi-separated string.
+	 * 
+	 * @param lockModel
+	 *            a model to serve as a statement factory
+	 * @param facts
+	 *            a sequence of semicolon-separated "S P O" facts
+	 * @return a Statement[] of the (S P O) statements from the string
+	 */
+	public static Statement[] statements(String facts) {
+		ArrayList<Statement> sl = new ArrayList<Statement>();
+		StringTokenizer st = new StringTokenizer(facts, ";");
+		while (st.hasMoreTokens())
+			sl.add(statement(st.nextToken()));
+		return sl.toArray(new Statement[sl.size()]);
+	}
+
+	/**
+	 * Create an array of Resources from a whitespace-separated string
+	 * 
+	 * @param items
+	 *            a whitespace-separated sequence to feed to resource
+	 * @return a Resource[] of the parsed resources
+	 */
+	public static Resource[] resources(String items) {
+		ArrayList<Resource> rl = new ArrayList<Resource>();
+		StringTokenizer st = new StringTokenizer(items);
+		while (st.hasMoreTokens())
+			rl.add(resource(st.nextToken()));
+		return rl.toArray(new Resource[rl.size()]);
+	}
+
+	/**
+	 * Answer the set of resources given by the space-separated
+	 * <code>items</code> string. Each resource specification is interpreted as
+	 * per <code>resource</code>.
+	 */
+	public static Set<Resource> resourceSet(String items) {
+		Set<Resource> result = new HashSet<Resource>();
+		StringTokenizer st = new StringTokenizer(items);
+		while (st.hasMoreTokens())
+			result.add(resource(st.nextToken()));
+		return result;
+	}
+
+	/**
+	 * add to a model all the statements expressed by a string.
+	 * 
+	 * Does not do any transaction manipulation.
+	 * 
+	 * @param m
+	 *            the model to be updated
+	 * @param facts
+	 *            a sequence of semicolon-separated "S P O" facts
+	 * @return the updated model
+	 */
+	public static Model modelAdd(Model m, String facts) {
+		StringTokenizer semis = new StringTokenizer(facts, ";");
+
+		while (semis.hasMoreTokens()) {
+			StringTokenizer st = new StringTokenizer(semis.nextToken());
+			Resource sub = resource(st.nextToken());
+			Property pred = property(st.nextToken());
+			RDFNode obj = rdfNode(st.nextToken());
+			m.add(sub, pred, obj);
+		}
+
+		return m;
+	}
+
+	/**
+	 * create a memory based model with extended prefixes and initialises it
+	 * with statements parsed from a string.
+	 * 
+	 * does all insertions in a transaction.
+	 * 
+	 * @param facts
+	 * @return
+	 */
+	public static Model memModel(String facts) {
+		Model model = ModelFactory.createMemModelMaker().createFreshModel();
+		model.setNsPrefixes(PrefixMapping.Extended);
+		txnBegin(model);
+		modelAdd(model, facts);
+		txnCommit(model);
+		return model;
+	}
+
+	/**
+	 * Creates a model with extended prefixes and initialises it with statements
+	 * parsed from a string.
+	 * 
+	 * does all insertions in a transaction.
+	 * 
+	 * @param facts
+	 *            a string in semicolon-separated "S P O" format
+	 * @return a model containing those facts
+	 */
+	public static Model modelWithStatements(
+			IProducer<? extends Model> producer, String facts) {
+		Model m = createModel(producer);
+		txnBegin(m);
+		modelAdd(m, facts);
+		txnCommit(m);
+		return m;
+	}
+
+	/**
+	 * Creates a model with extended prefixes and initialises it with statements
+	 * parsed from the statement iterator.
+	 * 
+	 * does all insertions in a transaction.
+	 * 
+	 * @param facts
+	 *            a string in semicolon-separated "S P O" format
+	 * @return a model containing those facts
+	 */
+	public static Model modelWithStatements(
+			IProducer<? extends Model> producer, final StmtIterator it) {
+		Model m = createModel(producer);
+		txnBegin(m);
+		while (it.hasNext()) {
+			m.add(it.nextStatement());
+		}
+		txnCommit(m);
+		return m;
+	}
+
+	/**
+	 * make a model and give it Extended prefixes
+	 */
+	public static Model createModel(IProducer<? extends Model> producer) {
+		Model result = producer.newInstance();
+		result.setNsPrefixes(PrefixMapping.Extended);
+		return result;
+	}
+
+	/**
+	 * test that two models are isomorphic and fail if they are not.
+	 * 
+	 * @param title
+	 *            a String appearing at the beginning of the failure message
+	 * @param wanted
+	 *            the model value that is expected
+	 * @param got
+	 *            the model value to check
+	 * @exception if
+	 *                the models are not isomorphic
+	 */
+	public static void assertIsoModels(String title, Model wanted, Model got) {
+		if (wanted.isIsomorphicWith(got) == false) {
+			Map<Node, Object> map = CollectionFactory.createHashedMap();
+			fail(title + ": expected " + nice(wanted.getGraph(), map)
+					+ "\n but had " + nice(got.getGraph(), map));
+		}
+	}
+
+	public static void assertContainsAll(final Model model, final Model model2) {
+		for (final StmtIterator s = model2.listStatements(); s.hasNext();) {
+			Assert.assertTrue(model.contains(s.nextStatement()));
+		}
+	}
+
+	public static void assertSameStatements(final Model model,
+			final Model model2) {
+		assertContainsAll(model, model2);
+		assertContainsAll(model2, model);
+	}
+
+	public static Property prop(final String uri) {
+		return ResourceFactory.createProperty("eh:/" + uri);
+	}
+
+	public static Resource res(final String uri) {
+		return ResourceFactory.createResource("eh:/" + uri);
+	}
+
+	/**
+	 * Fail if the two models are not isomorphic. See
+	 * assertIsoModels(String,Model,Model).
+	 */
+	public static void assertIsoModels(Model wanted, Model got) {
+		assertIsoModels("models must be isomorphic", wanted, got);
+	}
+
+	public static final boolean tvBoolean = true;
+	public static final byte tvByte = 1;
+	public static final short tvShort = 2;
+	public static final int tvInt = -1;
+	public static final long tvLong = -2;
+	public static final char tvChar = '!';
+	public static final float tvFloat = (float) 123.456;
+	public static final double tvDouble = -123.456;
+	public static final String tvString = "test 12 string";
+	public static final double dDelta = 0.000000005;
+
+	public static final float fDelta = 0.000005f;
+
+	public static final Object tvLitObj = new LitTestObj(1234);
+	public static final LitTestObj tvObject = new LitTestObj(12345);
+
+	public static class LitTestObj {
+		protected long content;
+
+		public LitTestObj(final long l) {
+			content = l;
+		}
+
+		public LitTestObj(final String s) {
+			content = Long.parseLong(s.substring(1, s.length() - 1));
+		}
+
+		@Override
+		public boolean equals(final Object o) {
+			return (o instanceof LitTestObj)
+					&& (content == ((LitTestObj) o).content);
+		}
+
+		@Override
+		public int hashCode() {
+			return (int) (content ^ (content >> 32));
+		}
+
+		@Override
+		public String toString() {
+			return "[" + Long.toString(content) + "]";
+		}
+
+		public long getContent() {
+			return content;
+		}
+	}
+
+	/**
+	 * Begin a transaction on the model if transactions are supported.
+	 * 
+	 * @param m
+	 */
+	public static Model txnBegin(Model m) {
+		if (m.supportsTransactions()) {
+			return m.begin();
+		}
+		return m;
+	}
+
+	/**
+	 * Commit the transaction on the model if transactions are supported.
+	 * 
+	 * @param m
+	 */
+	public static Model txnCommit(Model m) {
+		if (m.supportsTransactions()) {
+			return m.commit();
+		}
+		return m;
+	}
+
+	/**
+	 * Rollback (abort) the transaction on the model if transactions are
+	 * supported.
+	 * 
+	 * @param m
+	 */
+	public static Model txnRollback(Model m) {
+		if (m.supportsTransactions()) {
+			return m.abort();
+		}
+		return m;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/NodeCreateUtils.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/NodeCreateUtils.java b/jena-core/src/test/java/org/apache/jena/testing_framework/NodeCreateUtils.java
new file mode 100644
index 0000000..83d42eb
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/NodeCreateUtils.java
@@ -0,0 +1,177 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+import java.util.StringTokenizer;
+
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.LiteralLabel;
+import org.apache.jena.graph.impl.LiteralLabelFactory;
+import org.apache.jena.rdf.model.AnonId;
+import org.apache.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));
+	}
+
+	/**
+	 * 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);
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/NodeProducerInterface.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/NodeProducerInterface.java b/jena-core/src/test/java/org/apache/jena/testing_framework/NodeProducerInterface.java
new file mode 100644
index 0000000..c80d3f4
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/NodeProducerInterface.java
@@ -0,0 +1,32 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+/**
+ * Creates the graph for testing. Implementations must track the creation of
+ * graphs created with newGraph and close them when closeGraphs is called.
+ * 
+ */
+//public interface NodeProducerInterface {
+//
+//	/**
+//	 * Returns a new anonymous RDFNode in an model.
+//	 */
+//	public abstract RDFNode newRDFNode();
+//
+// }

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java b/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
new file mode 100644
index 0000000..7b46366
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
@@ -0,0 +1,380 @@
+package org.apache.jena.testing_framework;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.rdf.model.AnonId;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.graph.Factory;
+
+/**
+ * Class that produces RDF and TTL data, a Graph and a Model that all contain
+ * the same data. This is used for various tests where files are read/written
+ * 
+ */
+public class TestFileData {
+
+	public static final String NS = "uri:urn:x-rdf:test#";
+
+	private static Map<String, String[]> rdfData = new HashMap<String, String[]>();
+	private static Map<String, String[]> ttlData = new HashMap<String, String[]>();
+
+	static {
+		rdfData.put(
+				"", // default set must be equiv to TTL default
+				new String[] {
+						"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
+						"<rdf:RDF",
+						"  xmlns:u=\"uri:\"",
+						"  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
+						String.format("  xmlns:ex=\"%s\">", NS),
+						String.format(
+								"  <rdf:Description rdf:about=\"%ssubject\">",
+								NS),
+						String.format(
+								"    <ex:predicate rdf:resource=\"%sobject\"/>",
+								NS), "  </rdf:Description>",
+						"  <rdf:Description rdf:about=\"uri:e\">",
+						"    <u:p5>verify base works</u:p5>",
+						"  </rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"realtiveURI", // has relative URI in description rdf:about
+				new String[] {
+						"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
+						"<rdf:RDF",
+						"  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
+						"  xmlns:ex=\"http://example.com/\">",
+						"  <rdf:Description rdf:about=\"http://example.com/subject\">",
+						"    <ex:predicate rdf:resource=\"http://example.com/object\"/>",
+						"  </rdf:Description>",
+						"  <rdf:Description rdf:about=\"e\">",
+						"    <ex:p5>verify base works</ex:p5>",
+						"  </rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList0",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList1",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList2",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />",
+						"    <rdf:Description rdf:ID=\"b\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList3",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />",
+						"    <rdf:Description rdf:ID=\"b\" />",
+						"    <rdf:Description rdf:ID=\"c\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList4",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />",
+						"    <rdf:Description rdf:ID=\"b\" />",
+						"    <rdf:Description rdf:ID=\"c\" />",
+						"    <rdf:Description rdf:ID=\"d\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList5",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />",
+						"    <rdf:Description rdf:ID=\"b\" />",
+						"    <rdf:Description rdf:ID=\"c\" />",
+						"    <rdf:Description rdf:ID=\"d\" />",
+						"    <rdf:Description rdf:ID=\"e\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+
+		ttlData.put(
+				"", // default set must be equiv to RDF default and must be
+					// parsable as N-TRIPLE
+				new String[] {
+						String.format("<%ssubject> <%spredicate> <%sobject> .",
+								NS, NS, NS), "<e> <p5> \"verify base works\" ." });
+
+	}
+
+	private static String toDataString(String[] lines) {
+		String eol = System.getProperty("line.separator");
+		StringBuilder sb = new StringBuilder();
+		for (String l : lines) {
+			sb.append(l).append(eol);
+		}
+		return sb.toString();
+	}
+
+	public static Graph getGraph() {
+		
+		Graph g = Factory.createGraphMem();
+
+		g.add(new Triple(NodeFactory.createURI("http://example.com/subject"),
+				NodeFactory.createURI("http://example.com/predicate"),
+				NodeFactory.createURI("http://example.com/object")));
+
+		g.add(new Triple(NodeFactory.createAnon(AnonId.create("a")),
+				NodeFactory.createURI("http://example.com/p1"), NodeFactory
+						.createAnon(AnonId.create("b"))));
+
+		g.add(new Triple(NodeFactory.createAnon(AnonId.create("b")),
+				NodeFactory.createURI("http://example.com/p2"), NodeFactory
+						.createLiteral("foo")));
+
+		g.add(new Triple(NodeFactory.createURI("http://example.com/ns/e"),
+				NodeFactory.createURI("http://example.com/ns/p5"), NodeFactory
+						.createLiteral("verify base works")));
+
+		return g;
+	}
+
+	public static Model getModel() {
+		return ModelFactory.createModelForGraph(getGraph());
+	}
+
+	public static Model populateRDFModel(Model model, String name)
+			throws IOException {
+		ModelHelper.txnBegin(model);
+		model.read(getRDFInput(name), "http://example.com/test/");
+		ModelHelper.txnCommit(model);
+		return model;
+	}
+
+	public static Model getRDFModel(String name) throws IOException {
+		return populateRDFModel(ModelFactory.createDefaultModel(), name);
+	}
+
+	private static String[] getRDFData(String name) throws IOException {
+		String[] data = rdfData.get(name);
+		if (data == null) {
+			throw new IOException("Can not find RDF data " + name);
+		}
+		return data;
+	}
+
+	public static InputStream getRDFInput(String name) throws IOException {
+		return new ByteArrayInputStream(toDataString(getRDFData(name))
+				.getBytes());
+	}
+
+	public static InputStream getRDFInput() throws IOException {
+		return getRDFInput("");
+	}
+
+	private static String[] getTTLData(String name) throws IOException {
+		String[] data = ttlData.get(name);
+		if (data == null) {
+			throw new IOException("Can not find TTL data " + name);
+		}
+		return data;
+	}
+
+	public static InputStream getTTLInput(String name) throws IOException {
+		return new ByteArrayInputStream(toDataString(getTTLData(name))
+				.getBytes());
+	}
+
+	public static InputStream getTTLInput() throws IOException {
+		return getTTLInput("");
+	}
+
+	public static Reader getRDFReader(String name) throws IOException {
+
+		return new StringReader(toDataString(getRDFData(name)));
+	}
+
+	public static Reader getRDFReader() throws IOException {
+
+		return getRDFReader("");
+	}
+
+	public static Reader getTTLReader() throws IOException {
+		return getTTLReader("");
+	}
+
+	public static Reader getTTLReader(String name) throws IOException {
+		return new StringReader(toDataString(getTTLData(name)));
+	}
+
+	public static String getRDFName(String name) throws IOException {
+		return createFile(toDataString(getRDFData(name)), ".rdf");
+	}
+
+	public static String getRDFName() throws IOException {
+		return getRDFName("");
+	}
+
+	private static String createFile(String data, String extension)
+			throws IOException {
+		File f = File.createTempFile("tfd", extension);
+		f.deleteOnExit();
+		FileOutputStream fos = new FileOutputStream(f);
+		// fos.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>".getBytes());
+		// fos.write(System.getProperty("line.separator").getBytes());
+		fos.write(data.getBytes());
+		fos.close();
+		return f.toURI().toURL().toExternalForm();
+	}
+
+	public static String getTTLName() throws IOException {
+		return getTTLName("");
+	}
+
+	public static String getTTLName(String name) throws IOException {
+		return createFile(toDataString(getTTLData(name)), ".ttl");
+	}
+
+	@Test
+	public void testEquality() throws Exception {
+		Model ttl = ModelFactory.createDefaultModel().read(getTTLInput(), NS,
+				"TTL");
+		Model rdf = ModelFactory.createDefaultModel().read(getRDFInput(), NS,
+				"RDF/XML-ABBREV");
+
+		assertTrue(ttl.isIsomorphicWith(rdf));
+		assertTrue(rdf.isIsomorphicWith(ttl));
+	}
+
+	public static void main(String... argv) throws Exception {
+		// //Model model = ModelFactory.createDefaultModel() ;
+		// //String x = "<s> <p> 'verify it works' ." ;
+		//
+		//
+		// //Reader sr = getTTLReader();
+		// //model.read(sr, "http://example/", "TTL") ;
+		// //model.read(sr, "", "TTL") ;
+		// //model.read( getRDFInput() );
+		// Model ttl = ModelFactory.createDefaultModel().read( getTTLInput(),
+		// "", "TTL");
+		// Model rdf = ModelFactory.createDefaultModel().read( getRDFInput(),
+		// "", "RDF/XML-ABBREV");
+		//
+		// ttl.write(System.out, "RDF/XML-ABBREV") ;
+		// System.out.println("-----") ;
+		// // model.setNsPrefix("ex", "http://example/") ;
+		// rdf.write(System.out, "N-TRIPLES") ;
+		// System.out.println("-----") ;
+		// System.out.println( getTTLName() );
+		// System.out.println( "ttl iso rdf: "+ttl.isIsomorphicWith(rdf));
+		//
+		// System.out.println( getRDFName() );
+		// System.out.println( "rdf iso ttl: "+rdf.isIsomorphicWith(ttl));
+
+		String[] lines = { "<rdf:RDF",
+				"  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">",
+				"  <rdf:Description rdf:about=\"e\">",
+				"    <p5>verify base works</p5>", "  </rdf:Description>",
+				"</rdf:RDF>" };
+
+		String eol = System.getProperty("line.separator");
+		StringBuilder sb = new StringBuilder();
+		for (String l : lines) {
+			sb.append(l).append(eol);
+		}
+
+		Model model = ModelFactory.createDefaultModel();
+
+		StringReader sr = new StringReader(sb.toString());
+		model.read(sr, "http://example/");
+		model.write(System.out, "N-TRIPLES");
+		System.out.println("-----");
+		model.setNsPrefix("ex", "http://example/");
+		model.write(System.out, "RDF/XML-ABBREV", "http://another/");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/TestUtils.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/TestUtils.java b/jena-core/src/test/java/org/apache/jena/testing_framework/TestUtils.java
new file mode 100644
index 0000000..78d4bab
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/TestUtils.java
@@ -0,0 +1,320 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.*;
+
+import org.apache.jena.util.CollectionFactory;
+import org.apache.jena.util.iterator.ExtendedIterator;
+import org.apache.jena.util.iterator.WrappedIterator;
+
+/**
+ * Foo basis for Jena test cases which provides assertFalse and assertDiffer.
+ * Often the logic of the names is clearer than using a negation.
+ */
+public class TestUtils {
+	// do not instantiate
+	protected TestUtils() {
+		throw new UnsupportedOperationException("Do not instantiate TestUtils");
+	};
+
+	/**
+	 * assert that the two objects must be unequal according to .equals().
+	 * 
+	 * @param title
+	 *            a labelling string for the assertion failure text
+	 * @param x
+	 *            an object to test; the subject of a .equals()
+	 * @param y
+	 *            the other object; the argument of the .equals()
+	 */
+	public static void assertDiffer(String title, Object x, Object y) {
+		if (x == null ? y == null : x.equals(y))
+			fail((title == null ? "objects should be different, but both were: "
+					: title)
+					+ x);
+	}
+
+	/**
+	 * assert that the two objects must be unequal according to .equals().
+	 * 
+	 * @param x
+	 *            an object to test; the subject of a .equals()
+	 * @param y
+	 *            the other object; the argument of the .equals()
+	 */
+	public static void assertDiffer(Object x, Object y) {
+		assertDiffer(null, x, y);
+	}
+
+	/**
+	 * assert that the object <code>x</code> must be of the class
+	 * <code>expected</code>.
+	 */
+	public static void assertInstanceOf(Class<?> expected, Object x) {
+		if (x == null)
+			fail("expected instance of " + expected + ", but had null");
+		if (!expected.isInstance(x))
+			fail("expected instance of " + expected + ", but had instance of "
+					+ x.getClass());
+	}
+
+	/**
+	 * Answer a Set formed from the elements of the List <code>L</code>.
+	 */
+	public static <T> Set<T> listToSet(List<T> L) {
+		return CollectionFactory.createHashedSet(L);
+	}
+
+	/**
+	 * Answer a List of the substrings of <code>s</code> that are separated by
+	 * spaces.
+	 */
+	public static List<String> listOfStrings(String s) {
+		List<String> result = new ArrayList<String>();
+		StringTokenizer st = new StringTokenizer(s);
+		while (st.hasMoreTokens())
+			result.add(st.nextToken());
+		return result;
+	}
+
+	/**
+	 * Answer a Set of the substrings of <code>s</code> that are separated by
+	 * spaces.
+	 */
+	public static Set<String> setOfStrings(String s) {
+		Set<String> result = new HashSet<String>();
+		StringTokenizer st = new StringTokenizer(s);
+		while (st.hasMoreTokens())
+			result.add(st.nextToken());
+		return result;
+	}
+
+	/**
+	 * Answer a list containing the single object <code>x</code>.
+	 */
+	public static <T> List<T> listOfOne(T x) {
+		List<T> result = new ArrayList<T>();
+		result.add(x);
+		return result;
+	}
+
+	/**
+	 * Answer a Set containing the single object <code>x</code>.
+	 */
+	public static <T> Set<T> setOfOne(T x) {
+		Set<T> result = new HashSet<T>();
+		result.add(x);
+		return result;
+	}
+
+	/**
+	 * Answer a fresh list which is the concatenation of <code>L</code> then
+	 * <code>R</code>. Neither <code>L</code> nor <code>R</code> is updated.
+	 */
+	public static <T> List<T> append(List<? extends T> L, List<? extends T> R) {
+		List<T> result = new ArrayList<T>(L);
+		result.addAll(R);
+		return result;
+	}
+
+	/**
+	 * Answer an iterator over the space-separated substrings of <code>s</code>.
+	 */
+	protected static ExtendedIterator<String> iteratorOfStrings(String s) {
+		return WrappedIterator.create(listOfStrings(s).iterator());
+	}
+
+	/**
+	 * Answer the constructor of the class <code>c</code> which takes arguments
+	 * of the type(s) in <code>args</code>, or <code>null</code> if there isn't
+	 * one.
+	 */
+	public static Constructor<?> getConstructor(Class<?> c, Class<?>[] args) {
+		try {
+			return c.getConstructor(args);
+		} catch (NoSuchMethodException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * Answer true iff <code>subClass</code> is the same class as
+	 * <code>superClass</code>, if its superclass <i>is</i>
+	 * <code>superClass</code>, or if one of its interfaces hasAsInterface that
+	 * class.
+	 */
+	public static boolean hasAsParent(Class<?> subClass, Class<?> superClass) {
+		if (subClass == superClass || subClass.getSuperclass() == superClass)
+			return true;
+		Class<?>[] is = subClass.getInterfaces();
+		for (int i = 0; i < is.length; i += 1)
+			if (hasAsParent(is[i], superClass))
+				return true;
+		return false;
+	}
+
+	/**
+	 * Fail unless <code>subClass</code> has <code>superClass</code> as a
+	 * parent, either a superclass or an implemented (directly or not)
+	 * interface.
+	 */
+	public static void assertHasParent(Class<?> subClass, Class<?> superClass) {
+		if (hasAsParent(subClass, superClass) == false)
+			fail("" + subClass + " should have " + superClass + " as a parent");
+	}
+
+	/**
+	 * Tests o1.equals( o2 ) && o2.equals(o1) && o1.hashCode() == o2.hashCode()
+	 * 
+	 * @param o1
+	 * @param o2
+	 */
+	public static void assertEquivalent(Object o1, Object o2) {
+		assertEquals(o1, o2);
+		assertEquals(o2, o1);
+		assertEquals(o1.hashCode(), o2.hashCode());
+	}
+
+	/**
+	 * Tests o1.equals( o2 ) && o2.equals(o1) && o1.hashCode() == o2.hashCode()
+	 * 
+	 * @param o1
+	 * @param o2
+	 */
+	public static void assertEquivalent(String msg, Object o1, Object o2) {
+		assertEquals(msg, o1, o2);
+		assertEquals(msg, o2, o1);
+		assertEquals(msg, o1.hashCode(), o2.hashCode());
+	}
+
+	/**
+	 * Tests o1.equals( o2 ) && o2.equals(o1) && o1.hashCode() == o2.hashCode()
+	 * 
+	 * @param o1
+	 * @param o2
+	 */
+	public static void assertNotEquivalent(String msg, Object o1, Object o2) {
+		assertNotEquals(msg, o1, o2);
+		assertNotEquals(msg, o2, o1);
+	}
+
+	private static URL getURL(String fn) {
+		URL u = TestUtils.class.getClassLoader().getResource(fn);
+		if (u == null) {
+			throw new RuntimeException(new FileNotFoundException(fn));
+		}
+		return u;
+	}
+
+	public static String getFileName(String fn) {
+
+		try {
+			return getURL(fn).toURI().toString();
+		} catch (URISyntaxException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	public static InputStream getInputStream(String fn) throws IOException {
+		return getURL(fn).openStream();
+	}
+
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertEquals(Class<?> clazz, String msg, Object obj1,
+			Object obj2) {
+		if (obj1 == null && obj2 == null) {
+			return;
+		}
+
+		if (obj1 != null) {
+			if (obj1 == obj2) {
+				return;
+			}
+			if (obj1.equals(obj2)) {
+				return;
+			}
+		}
+		LoggerFactory.getLogger(clazz).warn(
+				String.format("%s expected: %s got: %s", msg, obj1, obj2));
+		System.out.println(String.format("[%sWARNING] %s expected: %s got: %s",
+				clazz, msg, obj1, obj2));
+	}
+
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertTrue(Class<?> clazz, String msg, boolean value) {
+		if (value) {
+			return;
+		}
+
+		LoggerFactory.getLogger(clazz).warn(String.format("%s", msg));
+		System.out.println(String.format("[%s WARNING] %s ", clazz, msg));
+	}
+
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertFalse(Class<?> clazz, String msg, boolean value) {
+		if (!value) {
+			return;
+		}
+
+		LoggerFactory.getLogger(clazz).warn(String.format("%s", msg));
+		System.out.println(String.format("[%s WARNING] %s ", clazz, msg));
+	}
+
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertSame(Class<?> clazz, String msg, Object obj1,
+			Object obj2) {
+		if (obj1 == null && obj2 == null) {
+			return;
+		}
+
+		if (obj1 != null) {
+			if (obj1 == obj2) {
+				return;
+			}
+		}
+		LoggerFactory.getLogger(clazz).warn(
+				String.format("%s expected: %s got: %s", msg, obj1, obj2));
+		System.out
+				.println(String.format("[%s WARNING] %s expected: %s got: %s",
+						clazz, msg, obj1, obj2));
+	}
+
+	public static String safeName(String s) {
+		// Safe from Eclipse
+		s = s.replace('(', '[');
+		s = s.replace(')', ']');
+		return s;
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java
new file mode 100644
index 0000000..79d2fce
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java
@@ -0,0 +1,228 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.jena.n3.IRIResolver;
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.util.FileManager;
+import org.apache.jena.vocabulary.RDF;
+import org.apache.jena.vocabulary.RDFS;
+import org.apache.jena.vocabulary.TestManifest;
+import org.apache.jena.vocabulary.TestManifestX;
+
+/**
+ * A test manifest for a single manifest file.
+ */
+
+public class Manifest {
+	// This class does not know about JUnit.
+	private static Logger log = LoggerFactory.getLogger(Manifest.class);
+	private Model manifest;
+	private String manifestName;
+	private String filename;
+	private List<String> includedFiles = new ArrayList<String>();
+	private Resource manifestRes = null;
+
+	public Manifest(String fn) {
+		log.debug("Manifest = " + fn);
+		filename = IRIResolver.resolveGlobal(fn);
+		log.debug("         = " + filename);
+		manifest = FileManager.get().loadModel(filename);
+		parseIncludes();
+		parseManifest();
+	}
+
+	public String getName() {
+		return manifestName;
+	}
+
+	public Iterator<String> includedManifests() {
+		return includedFiles.iterator();
+	}
+
+	private void parseManifest() {
+		StmtIterator manifestStmts = manifest.listStatements(null, RDF.type,
+				TestManifest.Manifest);
+		if (!manifestStmts.hasNext()) {
+			log.warn("No manifest in manifest file: " + filename);
+			return;
+		}
+
+		Statement manifestItemStmt = manifestStmts.nextStatement();
+		if (manifestStmts.hasNext()) {
+			log.warn("Multiple manifests in manifest file: " + filename);
+			return;
+		}
+
+		manifestRes = manifestItemStmt.getSubject();
+		manifestName = getLiteral(manifestRes, RDFS.label);
+		if (manifestName == null)
+			manifestName = getLiteral(manifestRes, RDFS.comment);
+		manifestStmts.close();
+	}
+
+	// For every test item (does not recurse)
+	public void apply(ManifestItemHandler gen) {
+
+		StmtIterator manifestStmts = manifest.listStatements(null, RDF.type,
+				TestManifest.Manifest);
+
+		for (; manifestStmts.hasNext();) {
+			Statement manifestItemStmt = manifestStmts.nextStatement();
+			Resource manifestRes = manifestItemStmt.getSubject();
+
+			// For each item in this manifest
+			StmtIterator listIter = manifestRes
+					.listProperties(TestManifest.entries);
+			for (; listIter.hasNext();) {
+				// List head
+				Resource listItem = listIter.nextStatement().getResource();
+				for (; !listItem.equals(RDF.nil);) {
+					ManifestItem item = new ManifestItem(listItem
+							.getRequiredProperty(RDF.first).getResource());
+					gen.processManifestItem(item);
+					// Move to next list item
+					listItem = listItem.getRequiredProperty(RDF.rest)
+							.getResource();
+				}
+			}
+			listIter.close();
+		}
+		manifestStmts.close();
+	}
+
+	// -------- included manifests
+	private void parseIncludes() {
+		parseIncludes(TestManifest.include);
+		parseIncludes(TestManifestX.include);
+	}
+
+	private void parseIncludes(Property property) {
+		StmtIterator includeStmts = manifest.listStatements(null, property,
+				(RDFNode) null);
+
+		for (; includeStmts.hasNext();) {
+			Statement s = includeStmts.nextStatement();
+			if (!(s.getObject() instanceof Resource)) {
+				log.warn("Include: not a Resource" + s);
+				continue;
+			}
+			Resource r = s.getResource();
+			parseOneIncludesList(r);
+		}
+		includeStmts.close();
+	}
+
+	private void parseOneIncludesList(Resource r) {
+		if (r == null)
+			return;
+
+		if (r.equals(RDF.nil))
+			return;
+
+		if (!r.isAnon()) {
+			String uri = r.getURI();
+			if (includedFiles.contains(uri))
+				return;
+			includedFiles.add(r.getURI());
+			return;
+		}
+
+		// BNnode => list
+		Resource listItem = r;
+		while (!listItem.equals(RDF.nil)) {
+			r = listItem.getRequiredProperty(RDF.first).getResource();
+			parseOneIncludesList(r);
+			// Move on
+			listItem = listItem.getRequiredProperty(RDF.rest).getResource();
+		}
+	}
+
+	public static Resource getResource(Resource r, Property p) {
+		if (r == null)
+			return null;
+		if (!r.hasProperty(p))
+			return null;
+
+		RDFNode n = r.getProperty(p).getObject();
+		if (n instanceof Resource)
+			return (Resource) n;
+
+		throw new ManifestException("Manifest problem (not a Resource): " + n
+				+ " => " + p);
+	}
+
+	public static Collection<Resource> listResources(Resource r, Property p) {
+		if (r == null)
+			return null;
+		List<Resource> x = new ArrayList<Resource>();
+		StmtIterator sIter = r.listProperties(p);
+		for (; sIter.hasNext();) {
+			RDFNode n = sIter.next().getObject();
+			if (!(n instanceof Resource))
+				throw new ManifestException(
+						"Manifest problem (not a Resource): " + n + " => " + p);
+			x.add((Resource) n);
+		}
+		return x;
+	}
+
+	public static String getLiteral(Resource r, Property p) {
+		if (r == null)
+			return null;
+		if (!r.hasProperty(p))
+			return null;
+
+		RDFNode n = r.getProperty(p).getObject();
+		if (n instanceof Literal)
+			return ((Literal) n).getLexicalForm();
+
+		throw new ManifestException("Manifest problem (not a Literal): " + n
+				+ " => " + p);
+	}
+
+	public static String getLiteralOrURI(Resource r, Property p) {
+		if (r == null)
+			return null;
+
+		if (!r.hasProperty(p))
+			return null;
+
+		RDFNode n = r.getProperty(p).getObject();
+		if (n instanceof Literal)
+			return ((Literal) n).getLexicalForm();
+
+		if (n instanceof Resource) {
+			Resource r2 = (Resource) n;
+			if (!r2.isAnon())
+				return r2.getURI();
+		}
+
+		throw new ManifestException("Manifest problem: " + n + " => " + p);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java
new file mode 100644
index 0000000..14a3d44
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+/**
+ * TestException a root exception for all (intentional) exceptions in tests
+ * setup, not a failure of the test itself (e.g. manifest problems)
+ */
+
+public class ManifestException extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 5601201233175898449L;
+
+	public ManifestException() {
+		super();
+	}
+
+	public ManifestException(Throwable cause) {
+		super(cause);
+	}
+
+	public ManifestException(String msg) {
+		super(msg);
+	}
+
+	public ManifestException(String msg, Throwable cause) {
+		super(msg, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java
new file mode 100644
index 0000000..d7493bb
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java
@@ -0,0 +1,38 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to declare the manifest file for the test.
+ * 
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ManifestFile {
+	/**
+	 * The file that the annotated class should read
+	 */
+	String value();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
new file mode 100644
index 0000000..81999bd
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
@@ -0,0 +1,53 @@
+package org.apache.jena.testing_framework.manifest;
+
+import org.apache.jena.n3.turtle.TurtleTestVocab;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.vocabulary.RDF;
+import org.apache.jena.vocabulary.TestManifest;
+
+public class ManifestItem {
+	private Resource entry;
+
+	public ManifestItem(Resource entry) {
+		this.entry = entry;
+	}
+
+	public Resource getEntry() {
+		return entry;
+	}
+
+	public String getTestName() {
+		return Manifest.getLiteral(entry, TestManifest.name);
+	}
+
+	public Resource getAction() {
+		return Manifest.getResource(entry, TestManifest.action);
+	}
+
+	public Resource getResult() {
+		return Manifest.getResource(entry, TestManifest.result);
+	}
+
+	public Resource getType() {
+		return Manifest.getResource(entry, RDF.type);
+	}
+
+	public Resource getOutput() {
+		Resource result = getResult();
+		return result == null ? null : Manifest.getResource(result,
+				TurtleTestVocab.output);
+	}
+
+	public Resource getInput() {
+		Resource action = getAction();
+		return action == null ? null : Manifest.getResource(action,
+				TurtleTestVocab.input);
+	}
+
+	public String getUriString() {
+		Resource action = getAction();
+		Resource inputIRIr = action == null ? null : Manifest.getResource(
+				action, TurtleTestVocab.inputIRI);
+		return (inputIRIr == null) ? null : inputIRIr.getURI();
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/4d1b0d96/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java
new file mode 100644
index 0000000..08ce69f
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java
@@ -0,0 +1,35 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+import java.util.List;
+
+import org.junit.runner.Runner;
+import org.junit.runners.model.InitializationError;
+
+public interface ManifestItemHandler {
+	/**
+	 * Handle an item in a manifest
+	 * 
+	 * @throws InitializationError
+	 */
+	public void processManifestItem(ManifestItem item);
+
+	public void setTestRunnerList(List<Runner> runners);
+}


[09/25] jena git commit: Added initial contract tests added testing_framework

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphHelper.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphHelper.java b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphHelper.java
new file mode 100644
index 0000000..c208e8d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphHelper.java
@@ -0,0 +1,508 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+/**
+ * Foo set of static test helpers.  Generally included as a static.
+ */
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.apache.jena.graph.Factory;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphUtil;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.JenaException;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.util.CollectionFactory;
+import org.apache.jena.util.IteratorCollection;
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+public class GraphHelper extends TestUtils {
+
+	/**
+	 * 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>Foo</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;
+	}
+
+	/**
+	 * Like graphAdd but does it within a transaction if supported
+	 * 
+	 * @param g
+	 *            The graph to add to
+	 * @param s
+	 *            The string describing the graph
+	 * @return The populated graph.
+	 */
+	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;
+	}
+
+	/**
+	 * Used to create a graph with values.
+	 * 
+	 * @param g
+	 *            The newly created graph
+	 * @param s
+	 *            The string representing the graph data.
+	 * @return The populated graph
+	 */
+	public static Graph graphWith(Graph g, String s) {
+		return graphAddTxn(g, s);
+	}
+
+	/**
+	 * Answer a new memory-based graph with Extended prefixes.
+	 */
+	public static Graph memGraph() {
+		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 graphWith(memGraph(), 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());
+	}
+
+	/**
+	 * Foo 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));
+	}
+
+	// protected static Graph graphWithTxn(IProducer<? extends Graph> producer,
+	// String s) {
+	// Graph g = producer.newInstance();
+	// txnBegin(g);
+	// try {
+	// graphAdd(g, s);
+	// txnCommit(g);
+	// } catch (Exception e) {
+	// txnRollback(g);
+	// fail(e.getMessage());
+	// }
+	// return g;
+	// }
+
+	/**
+	 * 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);
+		}
+	}
+
+	/**
+	 * Begin a transaction on the graph if transactions are supported.
+	 * 
+	 * @param g
+	 */
+	public static void txnBegin(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().begin();
+		}
+	}
+
+	/**
+	 * Commit the transaction on the graph if transactions are supported.
+	 * 
+	 * @param g
+	 */
+	public static void txnCommit(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().commit();
+		}
+	}
+
+	/**
+	 * Rollback (abort) the transaction on the graph if transactions are
+	 * supported.
+	 * 
+	 * @param g
+	 */
+	public static void txnRollback(Graph g) {
+		if (g.getTransactionHandler().transactionsSupported()) {
+			g.getTransactionHandler().abort();
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
new file mode 100644
index 0000000..8c33eb1
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/GraphProducerInterface.java
@@ -0,0 +1,41 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+/**
+ * Creates the graph for testing. Implementations must track the creation of
+ * graphs created with newGraph and close them when closeGraphs is called.
+ * 
+ */
+//public interface GraphProducerInterface<T> {
+//
+//	/**
+//	 * Returns a new Graph to take part in the test.
+//	 * 
+//	 * @return The graph implementation to test.
+//	 */
+//	public abstract Graph newGraph();
+//
+//	/**
+//	 * provides a hook to close down graphs. When called all graphs created by
+//	 * the newGraph() method should be closed. Note that some graphs may have
+//	 * been closed during the test, so graphs should be tested for being closed
+//	 * prior to closing.
+//	 */
+//	public abstract void closeGraphs();
+// }

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
new file mode 100644
index 0000000..41bc6df
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IContainerProducer.java
@@ -0,0 +1,19 @@
+package org.apache.jena.testing_framework;
+
+import org.apache.jena.rdf.model.Container;
+import org.apache.jena.rdf.model.Resource;
+
+public interface IContainerProducer<T extends Container> extends
+		IResourceProducer<T> {
+
+	/**
+	 * The Resource identifying the continer type. e.g. RDF.seq
+	 */
+	Resource getContainerType();
+
+	/**
+	 * The class of the continaer. e.g. Seq.class
+	 */
+	Class<? extends Container> getContainerClass();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
new file mode 100644
index 0000000..3178692
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IIteratorProducer.java
@@ -0,0 +1,42 @@
+package org.apache.jena.testing_framework;
+
+import java.util.List;
+
+import org.apache.jena.util.iterator.ExtendedIterator;
+
+public interface IIteratorProducer<T> {
+
+	/**
+	 * Get a new instance of the iterator.
+	 * 
+	 * @return
+	 */
+	public ExtendedIterator<T> newInstance();
+
+	/**
+	 * Clean up after a test
+	 */
+	public void cleanUp();
+
+	/**
+	 * The list of items found in the iterator. Does not have to be in order.
+	 * 
+	 * @return
+	 */
+	public List<T> getList();
+
+	/**
+	 * True if delete is supported by the iterator
+	 * 
+	 * @return
+	 */
+	public boolean supportsDelete();
+
+	/**
+	 * True if this is an iterator on a copy so that delete works but getting a
+	 * new copy for the iterator test will return the original list.
+	 * 
+	 * @return
+	 */
+	public boolean isCopy();
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/INodeProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/INodeProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/INodeProducer.java
new file mode 100644
index 0000000..2532c32
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/INodeProducer.java
@@ -0,0 +1,39 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.xenei.junit.contract.IProducer;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+
+/**
+ * An abstract implementation of the IProducer<RDFNode> interface.
+ * 
+ * This class handles tracking of the created graphs and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the graph is closed.
+ * 
+ */
+public interface INodeProducer<T extends RDFNode> extends IProducer<T> {
+
+	abstract public T newInstance(String uri);
+
+	abstract public Model getModel();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
new file mode 100644
index 0000000..ef9eead
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IResourceProducer.java
@@ -0,0 +1,10 @@
+package org.apache.jena.testing_framework;
+
+import org.apache.jena.rdf.model.Resource;
+
+public interface IResourceProducer<X extends Resource> extends INodeProducer<X> {
+	/**
+	 * Returns true if the Resource implementation supports non URI values
+	 */
+	boolean supportsAnonymous();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/IStatementProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/IStatementProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/IStatementProducer.java
new file mode 100644
index 0000000..8830948
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/IStatementProducer.java
@@ -0,0 +1,45 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement;
+
+/**
+ * An abstract implementation of the IProducer<RDFNode> interface.
+ * 
+ * This class handles tracking of the created graphs and closing them. It also
+ * provides a callback for the implementing class to perform extra cleanup when
+ * the graph is closed.
+ * 
+ */
+public interface IStatementProducer<T extends Statement> {
+
+	abstract public T newInstance(String fact);
+
+	abstract public T newInstance(Resource s, Property p, RDFNode o);
+
+	abstract public Model getModel();
+
+	abstract public void cleanUp();
+
+	abstract public AbstractModelProducer<Model> getModelProducer();
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/ITripleStoreProducer.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/ITripleStoreProducer.java b/jena-core/src/test/java/org/apache/jena/testing_framework/ITripleStoreProducer.java
new file mode 100644
index 0000000..fe4e25d
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/ITripleStoreProducer.java
@@ -0,0 +1,35 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+import org.apache.jena.graph.impl.TripleStore;
+
+/**
+ * Creates the graph for testing
+ * 
+ */
+public interface ITripleStoreProducer {
+
+	/**
+	 * Returns a TripleStore to take part in the test. Must be overridden in a
+	 * subclass.
+	 * 
+	 * @return The TripleStore implementation to test.
+	 */
+	public abstract TripleStore newTripleStore();
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/ModelHelper.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/ModelHelper.java b/jena-core/src/test/java/org/apache/jena/testing_framework/ModelHelper.java
new file mode 100644
index 0000000..2f35203
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/ModelHelper.java
@@ -0,0 +1,409 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.rdf.model.Literal;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.rdf.model.StmtIterator;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.util.CollectionFactory;
+
+import static org.junit.Assert.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.junit.Assert;
+import org.xenei.junit.contract.IProducer;
+
+/**
+ * provides useful functionality for testing models, eg building small models
+ * from strings, testing equality, etc.
+ * 
+ * Currently this class extends GraphHelper and thus TestCase.
+ */
+public class ModelHelper extends GraphHelper {
+
+	private static Model builderModel;
+
+	static {
+		builderModel = ModelFactory.createDefaultModel();
+		builderModel.setNsPrefixes(PrefixMapping.Extended);
+	}
+
+	protected static final Model empty = ModelFactory.createDefaultModel();
+
+	protected static Model extendedModel(IProducer<Model> producer) {
+		Model result = producer.newInstance();
+		result.setNsPrefixes(PrefixMapping.Extended);
+		return result;
+	}
+
+	protected static String nice(RDFNode n) {
+		return nice(n.asNode());
+	}
+
+	public static Statement statement(String fact) {
+		StringTokenizer st = new StringTokenizer(fact);
+		Resource sub = resource(st.nextToken());
+		Property pred = property(st.nextToken());
+		RDFNode obj = rdfNode(st.nextToken());
+		return builderModel.createStatement(sub, pred, obj);
+	}
+
+	public static Statement statement(Resource s, Property p, RDFNode o) {
+		return builderModel.createStatement(s, p, o);
+	}
+
+	public static RDFNode rdfNode(Model m, String s) {
+		return m.asRDFNode(NodeCreateUtils.create(s));
+	}
+
+	public static RDFNode rdfNode(String s) {
+		return rdfNode(builderModel, s);
+	}
+
+	public static <T extends RDFNode> T rdfNode(String s, Class<T> c) {
+		return rdfNode(s).as(c);
+	}
+
+	public static Resource resource() {
+		return ResourceFactory.createResource();
+	}
+
+	public static Resource resource(String s) {
+		return (Resource) rdfNode(s);
+	}
+
+	// public static Resource resource(Model m, String s) {
+	// return (Resource) rdfNode(m, s);
+	// }
+
+	public static Property property(String s) {
+		return rdfNode(s).as(Property.class);
+	}
+
+	public static Property property(Model m, String s) {
+		return rdfNode(m, s).as(Property.class);
+	}
+
+	public static Literal literal(String s, String lang) {
+		return builderModel.createLiteral(s, lang);
+	}
+
+	public static Literal literal(String s) {
+		return rdfNode(s).as(Literal.class);
+	}
+
+	// /**
+	// * Create an array of Statements parsed from a semi-separated string.
+	// *
+	// * @param lockModel
+	// * a model to serve as a statement factory
+	// * @param facts
+	// * a sequence of semicolon-separated "S P O" facts
+	// * @return a Statement[] of the (S P O) statements from the string
+	// */
+	// public static Statement[] statements(Model m, String facts) {
+	// ArrayList<Statement> sl = new ArrayList<Statement>();
+	// StringTokenizer st = new StringTokenizer(facts, ";");
+	// while (st.hasMoreTokens())
+	// sl.add(statement(m, st.nextToken()));
+	// return sl.toArray(new Statement[sl.size()]);
+	// }
+
+	/**
+	 * Create an array of Statements parsed from a semi-separated string.
+	 * 
+	 * @param lockModel
+	 *            a model to serve as a statement factory
+	 * @param facts
+	 *            a sequence of semicolon-separated "S P O" facts
+	 * @return a Statement[] of the (S P O) statements from the string
+	 */
+	public static Statement[] statements(String facts) {
+		ArrayList<Statement> sl = new ArrayList<Statement>();
+		StringTokenizer st = new StringTokenizer(facts, ";");
+		while (st.hasMoreTokens())
+			sl.add(statement(st.nextToken()));
+		return sl.toArray(new Statement[sl.size()]);
+	}
+
+	/**
+	 * Create an array of Resources from a whitespace-separated string
+	 * 
+	 * @param items
+	 *            a whitespace-separated sequence to feed to resource
+	 * @return a Resource[] of the parsed resources
+	 */
+	public static Resource[] resources(String items) {
+		ArrayList<Resource> rl = new ArrayList<Resource>();
+		StringTokenizer st = new StringTokenizer(items);
+		while (st.hasMoreTokens())
+			rl.add(resource(st.nextToken()));
+		return rl.toArray(new Resource[rl.size()]);
+	}
+
+	/**
+	 * Answer the set of resources given by the space-separated
+	 * <code>items</code> string. Each resource specification is interpreted as
+	 * per <code>resource</code>.
+	 */
+	public static Set<Resource> resourceSet(String items) {
+		Set<Resource> result = new HashSet<Resource>();
+		StringTokenizer st = new StringTokenizer(items);
+		while (st.hasMoreTokens())
+			result.add(resource(st.nextToken()));
+		return result;
+	}
+
+	/**
+	 * add to a model all the statements expressed by a string.
+	 * 
+	 * Does not do any transaction manipulation.
+	 * 
+	 * @param m
+	 *            the model to be updated
+	 * @param facts
+	 *            a sequence of semicolon-separated "S P O" facts
+	 * @return the updated model
+	 */
+	public static Model modelAdd(Model m, String facts) {
+		StringTokenizer semis = new StringTokenizer(facts, ";");
+
+		while (semis.hasMoreTokens()) {
+			StringTokenizer st = new StringTokenizer(semis.nextToken());
+			Resource sub = resource(st.nextToken());
+			Property pred = property(st.nextToken());
+			RDFNode obj = rdfNode(st.nextToken());
+			m.add(sub, pred, obj);
+		}
+
+		return m;
+	}
+
+	/**
+	 * create a memory based model with extended prefixes and initialises it
+	 * with statements parsed from a string.
+	 * 
+	 * does all insertions in a transaction.
+	 * 
+	 * @param facts
+	 * @return
+	 */
+	public static Model memModel(String facts) {
+		Model model = ModelFactory.createMemModelMaker().createFreshModel();
+		model.setNsPrefixes(PrefixMapping.Extended);
+		txnBegin(model);
+		modelAdd(model, facts);
+		txnCommit(model);
+		return model;
+	}
+
+	/**
+	 * Creates a model with extended prefixes and initialises it with statements
+	 * parsed from a string.
+	 * 
+	 * does all insertions in a transaction.
+	 * 
+	 * @param facts
+	 *            a string in semicolon-separated "S P O" format
+	 * @return a model containing those facts
+	 */
+	public static Model modelWithStatements(
+			IProducer<? extends Model> producer, String facts) {
+		Model m = createModel(producer);
+		txnBegin(m);
+		modelAdd(m, facts);
+		txnCommit(m);
+		return m;
+	}
+
+	/**
+	 * Creates a model with extended prefixes and initialises it with statements
+	 * parsed from the statement iterator.
+	 * 
+	 * does all insertions in a transaction.
+	 * 
+	 * @param facts
+	 *            a string in semicolon-separated "S P O" format
+	 * @return a model containing those facts
+	 */
+	public static Model modelWithStatements(
+			IProducer<? extends Model> producer, final StmtIterator it) {
+		Model m = createModel(producer);
+		txnBegin(m);
+		while (it.hasNext()) {
+			m.add(it.nextStatement());
+		}
+		txnCommit(m);
+		return m;
+	}
+
+	/**
+	 * make a model and give it Extended prefixes
+	 */
+	public static Model createModel(IProducer<? extends Model> producer) {
+		Model result = producer.newInstance();
+		result.setNsPrefixes(PrefixMapping.Extended);
+		return result;
+	}
+
+	/**
+	 * test that two models are isomorphic and fail if they are not.
+	 * 
+	 * @param title
+	 *            a String appearing at the beginning of the failure message
+	 * @param wanted
+	 *            the model value that is expected
+	 * @param got
+	 *            the model value to check
+	 * @exception if
+	 *                the models are not isomorphic
+	 */
+	public static void assertIsoModels(String title, Model wanted, Model got) {
+		if (wanted.isIsomorphicWith(got) == false) {
+			Map<Node, Object> map = CollectionFactory.createHashedMap();
+			fail(title + ": expected " + nice(wanted.getGraph(), map)
+					+ "\n but had " + nice(got.getGraph(), map));
+		}
+	}
+
+	public static void assertContainsAll(final Model model, final Model model2) {
+		for (final StmtIterator s = model2.listStatements(); s.hasNext();) {
+			Assert.assertTrue(model.contains(s.nextStatement()));
+		}
+	}
+
+	public static void assertSameStatements(final Model model,
+			final Model model2) {
+		assertContainsAll(model, model2);
+		assertContainsAll(model2, model);
+	}
+
+	public static Property prop(final String uri) {
+		return ResourceFactory.createProperty("eh:/" + uri);
+	}
+
+	public static Resource res(final String uri) {
+		return ResourceFactory.createResource("eh:/" + uri);
+	}
+
+	/**
+	 * Fail if the two models are not isomorphic. See
+	 * assertIsoModels(String,Model,Model).
+	 */
+	public static void assertIsoModels(Model wanted, Model got) {
+		assertIsoModels("models must be isomorphic", wanted, got);
+	}
+
+	public static final boolean tvBoolean = true;
+	public static final byte tvByte = 1;
+	public static final short tvShort = 2;
+	public static final int tvInt = -1;
+	public static final long tvLong = -2;
+	public static final char tvChar = '!';
+	public static final float tvFloat = (float) 123.456;
+	public static final double tvDouble = -123.456;
+	public static final String tvString = "test 12 string";
+	public static final double dDelta = 0.000000005;
+
+	public static final float fDelta = 0.000005f;
+
+	public static final Object tvLitObj = new LitTestObj(1234);
+	public static final LitTestObj tvObject = new LitTestObj(12345);
+
+	public static class LitTestObj {
+		protected long content;
+
+		public LitTestObj(final long l) {
+			content = l;
+		}
+
+		public LitTestObj(final String s) {
+			content = Long.parseLong(s.substring(1, s.length() - 1));
+		}
+
+		@Override
+		public boolean equals(final Object o) {
+			return (o instanceof LitTestObj)
+					&& (content == ((LitTestObj) o).content);
+		}
+
+		@Override
+		public int hashCode() {
+			return (int) (content ^ (content >> 32));
+		}
+
+		@Override
+		public String toString() {
+			return "[" + Long.toString(content) + "]";
+		}
+
+		public long getContent() {
+			return content;
+		}
+	}
+
+	/**
+	 * Begin a transaction on the model if transactions are supported.
+	 * 
+	 * @param m
+	 */
+	public static Model txnBegin(Model m) {
+		if (m.supportsTransactions()) {
+			return m.begin();
+		}
+		return m;
+	}
+
+	/**
+	 * Commit the transaction on the model if transactions are supported.
+	 * 
+	 * @param m
+	 */
+	public static Model txnCommit(Model m) {
+		if (m.supportsTransactions()) {
+			return m.commit();
+		}
+		return m;
+	}
+
+	/**
+	 * Rollback (abort) the transaction on the model if transactions are
+	 * supported.
+	 * 
+	 * @param m
+	 */
+	public static Model txnRollback(Model m) {
+		if (m.supportsTransactions()) {
+			return m.abort();
+		}
+		return m;
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/NodeCreateUtils.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/NodeCreateUtils.java b/jena-core/src/test/java/org/apache/jena/testing_framework/NodeCreateUtils.java
new file mode 100644
index 0000000..83d42eb
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/NodeCreateUtils.java
@@ -0,0 +1,177 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+import java.util.StringTokenizer;
+
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.LiteralLabel;
+import org.apache.jena.graph.impl.LiteralLabelFactory;
+import org.apache.jena.rdf.model.AnonId;
+import org.apache.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));
+	}
+
+	/**
+	 * 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);
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/NodeProducerInterface.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/NodeProducerInterface.java b/jena-core/src/test/java/org/apache/jena/testing_framework/NodeProducerInterface.java
new file mode 100644
index 0000000..c80d3f4
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/NodeProducerInterface.java
@@ -0,0 +1,32 @@
+/*
+    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 org.apache.jena.testing_framework;
+
+/**
+ * Creates the graph for testing. Implementations must track the creation of
+ * graphs created with newGraph and close them when closeGraphs is called.
+ * 
+ */
+//public interface NodeProducerInterface {
+//
+//	/**
+//	 * Returns a new anonymous RDFNode in an model.
+//	 */
+//	public abstract RDFNode newRDFNode();
+//
+// }

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java b/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
new file mode 100644
index 0000000..7b46366
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/TestFileData.java
@@ -0,0 +1,380 @@
+package org.apache.jena.testing_framework;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.rdf.model.AnonId;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.graph.Factory;
+
+/**
+ * Class that produces RDF and TTL data, a Graph and a Model that all contain
+ * the same data. This is used for various tests where files are read/written
+ * 
+ */
+public class TestFileData {
+
+	public static final String NS = "uri:urn:x-rdf:test#";
+
+	private static Map<String, String[]> rdfData = new HashMap<String, String[]>();
+	private static Map<String, String[]> ttlData = new HashMap<String, String[]>();
+
+	static {
+		rdfData.put(
+				"", // default set must be equiv to TTL default
+				new String[] {
+						"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
+						"<rdf:RDF",
+						"  xmlns:u=\"uri:\"",
+						"  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
+						String.format("  xmlns:ex=\"%s\">", NS),
+						String.format(
+								"  <rdf:Description rdf:about=\"%ssubject\">",
+								NS),
+						String.format(
+								"    <ex:predicate rdf:resource=\"%sobject\"/>",
+								NS), "  </rdf:Description>",
+						"  <rdf:Description rdf:about=\"uri:e\">",
+						"    <u:p5>verify base works</u:p5>",
+						"  </rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"realtiveURI", // has relative URI in description rdf:about
+				new String[] {
+						"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
+						"<rdf:RDF",
+						"  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
+						"  xmlns:ex=\"http://example.com/\">",
+						"  <rdf:Description rdf:about=\"http://example.com/subject\">",
+						"    <ex:predicate rdf:resource=\"http://example.com/object\"/>",
+						"  </rdf:Description>",
+						"  <rdf:Description rdf:about=\"e\">",
+						"    <ex:p5>verify base works</ex:p5>",
+						"  </rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList0",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList1",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList2",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />",
+						"    <rdf:Description rdf:ID=\"b\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList3",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />",
+						"    <rdf:Description rdf:ID=\"b\" />",
+						"    <rdf:Description rdf:ID=\"c\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList4",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />",
+						"    <rdf:Description rdf:ID=\"b\" />",
+						"    <rdf:Description rdf:ID=\"c\" />",
+						"    <rdf:Description rdf:ID=\"d\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+		rdfData.put(
+				"OntologyList5",
+				new String[] {
+						"<?xml version='1.0' encoding='ISO-8859-1'?>",
+						"<!DOCTYPE rdf:RDF [",
+						"    <!ENTITY rdf   'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+						"    <!ENTITY rdfs  'http://www.w3.org/2000/01/rdf-schema#'>",
+						"]>",
+						"<rdf:RDF",
+						"    xmlns:rdf   =\"&rdf;\"",
+						"    xmlns:rdfs  =\"&rdfs;\"",
+						String.format("    xml:base    =\"%s\"",
+								NS.substring(0, NS.length() - 1)),
+						String.format("    xmlns       =\"%s\"", NS), ">",
+						"<rdf:Description rdf:ID=\"root\">",
+						"   <p rdf:parseType=\"Collection\">",
+						"    <rdf:Description rdf:ID=\"a\" />",
+						"    <rdf:Description rdf:ID=\"b\" />",
+						"    <rdf:Description rdf:ID=\"c\" />",
+						"    <rdf:Description rdf:ID=\"d\" />",
+						"    <rdf:Description rdf:ID=\"e\" />", "   </p>",
+						"</rdf:Description>", "</rdf:RDF>" });
+
+		ttlData.put(
+				"", // default set must be equiv to RDF default and must be
+					// parsable as N-TRIPLE
+				new String[] {
+						String.format("<%ssubject> <%spredicate> <%sobject> .",
+								NS, NS, NS), "<e> <p5> \"verify base works\" ." });
+
+	}
+
+	private static String toDataString(String[] lines) {
+		String eol = System.getProperty("line.separator");
+		StringBuilder sb = new StringBuilder();
+		for (String l : lines) {
+			sb.append(l).append(eol);
+		}
+		return sb.toString();
+	}
+
+	public static Graph getGraph() {
+		
+		Graph g = Factory.createGraphMem();
+
+		g.add(new Triple(NodeFactory.createURI("http://example.com/subject"),
+				NodeFactory.createURI("http://example.com/predicate"),
+				NodeFactory.createURI("http://example.com/object")));
+
+		g.add(new Triple(NodeFactory.createAnon(AnonId.create("a")),
+				NodeFactory.createURI("http://example.com/p1"), NodeFactory
+						.createAnon(AnonId.create("b"))));
+
+		g.add(new Triple(NodeFactory.createAnon(AnonId.create("b")),
+				NodeFactory.createURI("http://example.com/p2"), NodeFactory
+						.createLiteral("foo")));
+
+		g.add(new Triple(NodeFactory.createURI("http://example.com/ns/e"),
+				NodeFactory.createURI("http://example.com/ns/p5"), NodeFactory
+						.createLiteral("verify base works")));
+
+		return g;
+	}
+
+	public static Model getModel() {
+		return ModelFactory.createModelForGraph(getGraph());
+	}
+
+	public static Model populateRDFModel(Model model, String name)
+			throws IOException {
+		ModelHelper.txnBegin(model);
+		model.read(getRDFInput(name), "http://example.com/test/");
+		ModelHelper.txnCommit(model);
+		return model;
+	}
+
+	public static Model getRDFModel(String name) throws IOException {
+		return populateRDFModel(ModelFactory.createDefaultModel(), name);
+	}
+
+	private static String[] getRDFData(String name) throws IOException {
+		String[] data = rdfData.get(name);
+		if (data == null) {
+			throw new IOException("Can not find RDF data " + name);
+		}
+		return data;
+	}
+
+	public static InputStream getRDFInput(String name) throws IOException {
+		return new ByteArrayInputStream(toDataString(getRDFData(name))
+				.getBytes());
+	}
+
+	public static InputStream getRDFInput() throws IOException {
+		return getRDFInput("");
+	}
+
+	private static String[] getTTLData(String name) throws IOException {
+		String[] data = ttlData.get(name);
+		if (data == null) {
+			throw new IOException("Can not find TTL data " + name);
+		}
+		return data;
+	}
+
+	public static InputStream getTTLInput(String name) throws IOException {
+		return new ByteArrayInputStream(toDataString(getTTLData(name))
+				.getBytes());
+	}
+
+	public static InputStream getTTLInput() throws IOException {
+		return getTTLInput("");
+	}
+
+	public static Reader getRDFReader(String name) throws IOException {
+
+		return new StringReader(toDataString(getRDFData(name)));
+	}
+
+	public static Reader getRDFReader() throws IOException {
+
+		return getRDFReader("");
+	}
+
+	public static Reader getTTLReader() throws IOException {
+		return getTTLReader("");
+	}
+
+	public static Reader getTTLReader(String name) throws IOException {
+		return new StringReader(toDataString(getTTLData(name)));
+	}
+
+	public static String getRDFName(String name) throws IOException {
+		return createFile(toDataString(getRDFData(name)), ".rdf");
+	}
+
+	public static String getRDFName() throws IOException {
+		return getRDFName("");
+	}
+
+	private static String createFile(String data, String extension)
+			throws IOException {
+		File f = File.createTempFile("tfd", extension);
+		f.deleteOnExit();
+		FileOutputStream fos = new FileOutputStream(f);
+		// fos.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>".getBytes());
+		// fos.write(System.getProperty("line.separator").getBytes());
+		fos.write(data.getBytes());
+		fos.close();
+		return f.toURI().toURL().toExternalForm();
+	}
+
+	public static String getTTLName() throws IOException {
+		return getTTLName("");
+	}
+
+	public static String getTTLName(String name) throws IOException {
+		return createFile(toDataString(getTTLData(name)), ".ttl");
+	}
+
+	@Test
+	public void testEquality() throws Exception {
+		Model ttl = ModelFactory.createDefaultModel().read(getTTLInput(), NS,
+				"TTL");
+		Model rdf = ModelFactory.createDefaultModel().read(getRDFInput(), NS,
+				"RDF/XML-ABBREV");
+
+		assertTrue(ttl.isIsomorphicWith(rdf));
+		assertTrue(rdf.isIsomorphicWith(ttl));
+	}
+
+	public static void main(String... argv) throws Exception {
+		// //Model model = ModelFactory.createDefaultModel() ;
+		// //String x = "<s> <p> 'verify it works' ." ;
+		//
+		//
+		// //Reader sr = getTTLReader();
+		// //model.read(sr, "http://example/", "TTL") ;
+		// //model.read(sr, "", "TTL") ;
+		// //model.read( getRDFInput() );
+		// Model ttl = ModelFactory.createDefaultModel().read( getTTLInput(),
+		// "", "TTL");
+		// Model rdf = ModelFactory.createDefaultModel().read( getRDFInput(),
+		// "", "RDF/XML-ABBREV");
+		//
+		// ttl.write(System.out, "RDF/XML-ABBREV") ;
+		// System.out.println("-----") ;
+		// // model.setNsPrefix("ex", "http://example/") ;
+		// rdf.write(System.out, "N-TRIPLES") ;
+		// System.out.println("-----") ;
+		// System.out.println( getTTLName() );
+		// System.out.println( "ttl iso rdf: "+ttl.isIsomorphicWith(rdf));
+		//
+		// System.out.println( getRDFName() );
+		// System.out.println( "rdf iso ttl: "+rdf.isIsomorphicWith(ttl));
+
+		String[] lines = { "<rdf:RDF",
+				"  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">",
+				"  <rdf:Description rdf:about=\"e\">",
+				"    <p5>verify base works</p5>", "  </rdf:Description>",
+				"</rdf:RDF>" };
+
+		String eol = System.getProperty("line.separator");
+		StringBuilder sb = new StringBuilder();
+		for (String l : lines) {
+			sb.append(l).append(eol);
+		}
+
+		Model model = ModelFactory.createDefaultModel();
+
+		StringReader sr = new StringReader(sb.toString());
+		model.read(sr, "http://example/");
+		model.write(System.out, "N-TRIPLES");
+		System.out.println("-----");
+		model.setNsPrefix("ex", "http://example/");
+		model.write(System.out, "RDF/XML-ABBREV", "http://another/");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/TestUtils.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/TestUtils.java b/jena-core/src/test/java/org/apache/jena/testing_framework/TestUtils.java
new file mode 100644
index 0000000..78d4bab
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/TestUtils.java
@@ -0,0 +1,320 @@
+/*
+ * 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 org.apache.jena.testing_framework;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.*;
+
+import org.apache.jena.util.CollectionFactory;
+import org.apache.jena.util.iterator.ExtendedIterator;
+import org.apache.jena.util.iterator.WrappedIterator;
+
+/**
+ * Foo basis for Jena test cases which provides assertFalse and assertDiffer.
+ * Often the logic of the names is clearer than using a negation.
+ */
+public class TestUtils {
+	// do not instantiate
+	protected TestUtils() {
+		throw new UnsupportedOperationException("Do not instantiate TestUtils");
+	};
+
+	/**
+	 * assert that the two objects must be unequal according to .equals().
+	 * 
+	 * @param title
+	 *            a labelling string for the assertion failure text
+	 * @param x
+	 *            an object to test; the subject of a .equals()
+	 * @param y
+	 *            the other object; the argument of the .equals()
+	 */
+	public static void assertDiffer(String title, Object x, Object y) {
+		if (x == null ? y == null : x.equals(y))
+			fail((title == null ? "objects should be different, but both were: "
+					: title)
+					+ x);
+	}
+
+	/**
+	 * assert that the two objects must be unequal according to .equals().
+	 * 
+	 * @param x
+	 *            an object to test; the subject of a .equals()
+	 * @param y
+	 *            the other object; the argument of the .equals()
+	 */
+	public static void assertDiffer(Object x, Object y) {
+		assertDiffer(null, x, y);
+	}
+
+	/**
+	 * assert that the object <code>x</code> must be of the class
+	 * <code>expected</code>.
+	 */
+	public static void assertInstanceOf(Class<?> expected, Object x) {
+		if (x == null)
+			fail("expected instance of " + expected + ", but had null");
+		if (!expected.isInstance(x))
+			fail("expected instance of " + expected + ", but had instance of "
+					+ x.getClass());
+	}
+
+	/**
+	 * Answer a Set formed from the elements of the List <code>L</code>.
+	 */
+	public static <T> Set<T> listToSet(List<T> L) {
+		return CollectionFactory.createHashedSet(L);
+	}
+
+	/**
+	 * Answer a List of the substrings of <code>s</code> that are separated by
+	 * spaces.
+	 */
+	public static List<String> listOfStrings(String s) {
+		List<String> result = new ArrayList<String>();
+		StringTokenizer st = new StringTokenizer(s);
+		while (st.hasMoreTokens())
+			result.add(st.nextToken());
+		return result;
+	}
+
+	/**
+	 * Answer a Set of the substrings of <code>s</code> that are separated by
+	 * spaces.
+	 */
+	public static Set<String> setOfStrings(String s) {
+		Set<String> result = new HashSet<String>();
+		StringTokenizer st = new StringTokenizer(s);
+		while (st.hasMoreTokens())
+			result.add(st.nextToken());
+		return result;
+	}
+
+	/**
+	 * Answer a list containing the single object <code>x</code>.
+	 */
+	public static <T> List<T> listOfOne(T x) {
+		List<T> result = new ArrayList<T>();
+		result.add(x);
+		return result;
+	}
+
+	/**
+	 * Answer a Set containing the single object <code>x</code>.
+	 */
+	public static <T> Set<T> setOfOne(T x) {
+		Set<T> result = new HashSet<T>();
+		result.add(x);
+		return result;
+	}
+
+	/**
+	 * Answer a fresh list which is the concatenation of <code>L</code> then
+	 * <code>R</code>. Neither <code>L</code> nor <code>R</code> is updated.
+	 */
+	public static <T> List<T> append(List<? extends T> L, List<? extends T> R) {
+		List<T> result = new ArrayList<T>(L);
+		result.addAll(R);
+		return result;
+	}
+
+	/**
+	 * Answer an iterator over the space-separated substrings of <code>s</code>.
+	 */
+	protected static ExtendedIterator<String> iteratorOfStrings(String s) {
+		return WrappedIterator.create(listOfStrings(s).iterator());
+	}
+
+	/**
+	 * Answer the constructor of the class <code>c</code> which takes arguments
+	 * of the type(s) in <code>args</code>, or <code>null</code> if there isn't
+	 * one.
+	 */
+	public static Constructor<?> getConstructor(Class<?> c, Class<?>[] args) {
+		try {
+			return c.getConstructor(args);
+		} catch (NoSuchMethodException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * Answer true iff <code>subClass</code> is the same class as
+	 * <code>superClass</code>, if its superclass <i>is</i>
+	 * <code>superClass</code>, or if one of its interfaces hasAsInterface that
+	 * class.
+	 */
+	public static boolean hasAsParent(Class<?> subClass, Class<?> superClass) {
+		if (subClass == superClass || subClass.getSuperclass() == superClass)
+			return true;
+		Class<?>[] is = subClass.getInterfaces();
+		for (int i = 0; i < is.length; i += 1)
+			if (hasAsParent(is[i], superClass))
+				return true;
+		return false;
+	}
+
+	/**
+	 * Fail unless <code>subClass</code> has <code>superClass</code> as a
+	 * parent, either a superclass or an implemented (directly or not)
+	 * interface.
+	 */
+	public static void assertHasParent(Class<?> subClass, Class<?> superClass) {
+		if (hasAsParent(subClass, superClass) == false)
+			fail("" + subClass + " should have " + superClass + " as a parent");
+	}
+
+	/**
+	 * Tests o1.equals( o2 ) && o2.equals(o1) && o1.hashCode() == o2.hashCode()
+	 * 
+	 * @param o1
+	 * @param o2
+	 */
+	public static void assertEquivalent(Object o1, Object o2) {
+		assertEquals(o1, o2);
+		assertEquals(o2, o1);
+		assertEquals(o1.hashCode(), o2.hashCode());
+	}
+
+	/**
+	 * Tests o1.equals( o2 ) && o2.equals(o1) && o1.hashCode() == o2.hashCode()
+	 * 
+	 * @param o1
+	 * @param o2
+	 */
+	public static void assertEquivalent(String msg, Object o1, Object o2) {
+		assertEquals(msg, o1, o2);
+		assertEquals(msg, o2, o1);
+		assertEquals(msg, o1.hashCode(), o2.hashCode());
+	}
+
+	/**
+	 * Tests o1.equals( o2 ) && o2.equals(o1) && o1.hashCode() == o2.hashCode()
+	 * 
+	 * @param o1
+	 * @param o2
+	 */
+	public static void assertNotEquivalent(String msg, Object o1, Object o2) {
+		assertNotEquals(msg, o1, o2);
+		assertNotEquals(msg, o2, o1);
+	}
+
+	private static URL getURL(String fn) {
+		URL u = TestUtils.class.getClassLoader().getResource(fn);
+		if (u == null) {
+			throw new RuntimeException(new FileNotFoundException(fn));
+		}
+		return u;
+	}
+
+	public static String getFileName(String fn) {
+
+		try {
+			return getURL(fn).toURI().toString();
+		} catch (URISyntaxException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	public static InputStream getInputStream(String fn) throws IOException {
+		return getURL(fn).openStream();
+	}
+
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertEquals(Class<?> clazz, String msg, Object obj1,
+			Object obj2) {
+		if (obj1 == null && obj2 == null) {
+			return;
+		}
+
+		if (obj1 != null) {
+			if (obj1 == obj2) {
+				return;
+			}
+			if (obj1.equals(obj2)) {
+				return;
+			}
+		}
+		LoggerFactory.getLogger(clazz).warn(
+				String.format("%s expected: %s got: %s", msg, obj1, obj2));
+		System.out.println(String.format("[%sWARNING] %s expected: %s got: %s",
+				clazz, msg, obj1, obj2));
+	}
+
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertTrue(Class<?> clazz, String msg, boolean value) {
+		if (value) {
+			return;
+		}
+
+		LoggerFactory.getLogger(clazz).warn(String.format("%s", msg));
+		System.out.println(String.format("[%s WARNING] %s ", clazz, msg));
+	}
+
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertFalse(Class<?> clazz, String msg, boolean value) {
+		if (!value) {
+			return;
+		}
+
+		LoggerFactory.getLogger(clazz).warn(String.format("%s", msg));
+		System.out.println(String.format("[%s WARNING] %s ", clazz, msg));
+	}
+
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertSame(Class<?> clazz, String msg, Object obj1,
+			Object obj2) {
+		if (obj1 == null && obj2 == null) {
+			return;
+		}
+
+		if (obj1 != null) {
+			if (obj1 == obj2) {
+				return;
+			}
+		}
+		LoggerFactory.getLogger(clazz).warn(
+				String.format("%s expected: %s got: %s", msg, obj1, obj2));
+		System.out
+				.println(String.format("[%s WARNING] %s expected: %s got: %s",
+						clazz, msg, obj1, obj2));
+	}
+
+	public static String safeName(String s) {
+		// Safe from Eclipse
+		s = s.replace('(', '[');
+		s = s.replace(')', ']');
+		return s;
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java
new file mode 100644
index 0000000..79d2fce
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java
@@ -0,0 +1,228 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.jena.n3.IRIResolver;
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.util.FileManager;
+import org.apache.jena.vocabulary.RDF;
+import org.apache.jena.vocabulary.RDFS;
+import org.apache.jena.vocabulary.TestManifest;
+import org.apache.jena.vocabulary.TestManifestX;
+
+/**
+ * A test manifest for a single manifest file.
+ */
+
+public class Manifest {
+	// This class does not know about JUnit.
+	private static Logger log = LoggerFactory.getLogger(Manifest.class);
+	private Model manifest;
+	private String manifestName;
+	private String filename;
+	private List<String> includedFiles = new ArrayList<String>();
+	private Resource manifestRes = null;
+
+	public Manifest(String fn) {
+		log.debug("Manifest = " + fn);
+		filename = IRIResolver.resolveGlobal(fn);
+		log.debug("         = " + filename);
+		manifest = FileManager.get().loadModel(filename);
+		parseIncludes();
+		parseManifest();
+	}
+
+	public String getName() {
+		return manifestName;
+	}
+
+	public Iterator<String> includedManifests() {
+		return includedFiles.iterator();
+	}
+
+	private void parseManifest() {
+		StmtIterator manifestStmts = manifest.listStatements(null, RDF.type,
+				TestManifest.Manifest);
+		if (!manifestStmts.hasNext()) {
+			log.warn("No manifest in manifest file: " + filename);
+			return;
+		}
+
+		Statement manifestItemStmt = manifestStmts.nextStatement();
+		if (manifestStmts.hasNext()) {
+			log.warn("Multiple manifests in manifest file: " + filename);
+			return;
+		}
+
+		manifestRes = manifestItemStmt.getSubject();
+		manifestName = getLiteral(manifestRes, RDFS.label);
+		if (manifestName == null)
+			manifestName = getLiteral(manifestRes, RDFS.comment);
+		manifestStmts.close();
+	}
+
+	// For every test item (does not recurse)
+	public void apply(ManifestItemHandler gen) {
+
+		StmtIterator manifestStmts = manifest.listStatements(null, RDF.type,
+				TestManifest.Manifest);
+
+		for (; manifestStmts.hasNext();) {
+			Statement manifestItemStmt = manifestStmts.nextStatement();
+			Resource manifestRes = manifestItemStmt.getSubject();
+
+			// For each item in this manifest
+			StmtIterator listIter = manifestRes
+					.listProperties(TestManifest.entries);
+			for (; listIter.hasNext();) {
+				// List head
+				Resource listItem = listIter.nextStatement().getResource();
+				for (; !listItem.equals(RDF.nil);) {
+					ManifestItem item = new ManifestItem(listItem
+							.getRequiredProperty(RDF.first).getResource());
+					gen.processManifestItem(item);
+					// Move to next list item
+					listItem = listItem.getRequiredProperty(RDF.rest)
+							.getResource();
+				}
+			}
+			listIter.close();
+		}
+		manifestStmts.close();
+	}
+
+	// -------- included manifests
+	private void parseIncludes() {
+		parseIncludes(TestManifest.include);
+		parseIncludes(TestManifestX.include);
+	}
+
+	private void parseIncludes(Property property) {
+		StmtIterator includeStmts = manifest.listStatements(null, property,
+				(RDFNode) null);
+
+		for (; includeStmts.hasNext();) {
+			Statement s = includeStmts.nextStatement();
+			if (!(s.getObject() instanceof Resource)) {
+				log.warn("Include: not a Resource" + s);
+				continue;
+			}
+			Resource r = s.getResource();
+			parseOneIncludesList(r);
+		}
+		includeStmts.close();
+	}
+
+	private void parseOneIncludesList(Resource r) {
+		if (r == null)
+			return;
+
+		if (r.equals(RDF.nil))
+			return;
+
+		if (!r.isAnon()) {
+			String uri = r.getURI();
+			if (includedFiles.contains(uri))
+				return;
+			includedFiles.add(r.getURI());
+			return;
+		}
+
+		// BNnode => list
+		Resource listItem = r;
+		while (!listItem.equals(RDF.nil)) {
+			r = listItem.getRequiredProperty(RDF.first).getResource();
+			parseOneIncludesList(r);
+			// Move on
+			listItem = listItem.getRequiredProperty(RDF.rest).getResource();
+		}
+	}
+
+	public static Resource getResource(Resource r, Property p) {
+		if (r == null)
+			return null;
+		if (!r.hasProperty(p))
+			return null;
+
+		RDFNode n = r.getProperty(p).getObject();
+		if (n instanceof Resource)
+			return (Resource) n;
+
+		throw new ManifestException("Manifest problem (not a Resource): " + n
+				+ " => " + p);
+	}
+
+	public static Collection<Resource> listResources(Resource r, Property p) {
+		if (r == null)
+			return null;
+		List<Resource> x = new ArrayList<Resource>();
+		StmtIterator sIter = r.listProperties(p);
+		for (; sIter.hasNext();) {
+			RDFNode n = sIter.next().getObject();
+			if (!(n instanceof Resource))
+				throw new ManifestException(
+						"Manifest problem (not a Resource): " + n + " => " + p);
+			x.add((Resource) n);
+		}
+		return x;
+	}
+
+	public static String getLiteral(Resource r, Property p) {
+		if (r == null)
+			return null;
+		if (!r.hasProperty(p))
+			return null;
+
+		RDFNode n = r.getProperty(p).getObject();
+		if (n instanceof Literal)
+			return ((Literal) n).getLexicalForm();
+
+		throw new ManifestException("Manifest problem (not a Literal): " + n
+				+ " => " + p);
+	}
+
+	public static String getLiteralOrURI(Resource r, Property p) {
+		if (r == null)
+			return null;
+
+		if (!r.hasProperty(p))
+			return null;
+
+		RDFNode n = r.getProperty(p).getObject();
+		if (n instanceof Literal)
+			return ((Literal) n).getLexicalForm();
+
+		if (n instanceof Resource) {
+			Resource r2 = (Resource) n;
+			if (!r2.isAnon())
+				return r2.getURI();
+		}
+
+		throw new ManifestException("Manifest problem: " + n + " => " + p);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java
new file mode 100644
index 0000000..14a3d44
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+/**
+ * TestException a root exception for all (intentional) exceptions in tests
+ * setup, not a failure of the test itself (e.g. manifest problems)
+ */
+
+public class ManifestException extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 5601201233175898449L;
+
+	public ManifestException() {
+		super();
+	}
+
+	public ManifestException(Throwable cause) {
+		super(cause);
+	}
+
+	public ManifestException(String msg) {
+		super(msg);
+	}
+
+	public ManifestException(String msg, Throwable cause) {
+		super(msg, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java
new file mode 100644
index 0000000..d7493bb
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java
@@ -0,0 +1,38 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to declare the manifest file for the test.
+ * 
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ManifestFile {
+	/**
+	 * The file that the annotated class should read
+	 */
+	String value();
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
new file mode 100644
index 0000000..81999bd
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
@@ -0,0 +1,53 @@
+package org.apache.jena.testing_framework.manifest;
+
+import org.apache.jena.n3.turtle.TurtleTestVocab;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.vocabulary.RDF;
+import org.apache.jena.vocabulary.TestManifest;
+
+public class ManifestItem {
+	private Resource entry;
+
+	public ManifestItem(Resource entry) {
+		this.entry = entry;
+	}
+
+	public Resource getEntry() {
+		return entry;
+	}
+
+	public String getTestName() {
+		return Manifest.getLiteral(entry, TestManifest.name);
+	}
+
+	public Resource getAction() {
+		return Manifest.getResource(entry, TestManifest.action);
+	}
+
+	public Resource getResult() {
+		return Manifest.getResource(entry, TestManifest.result);
+	}
+
+	public Resource getType() {
+		return Manifest.getResource(entry, RDF.type);
+	}
+
+	public Resource getOutput() {
+		Resource result = getResult();
+		return result == null ? null : Manifest.getResource(result,
+				TurtleTestVocab.output);
+	}
+
+	public Resource getInput() {
+		Resource action = getAction();
+		return action == null ? null : Manifest.getResource(action,
+				TurtleTestVocab.input);
+	}
+
+	public String getUriString() {
+		Resource action = getAction();
+		Resource inputIRIr = action == null ? null : Manifest.getResource(
+				action, TurtleTestVocab.inputIRI);
+		return (inputIRIr == null) ? null : inputIRIr.getURI();
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b293ee8a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java
new file mode 100644
index 0000000..08ce69f
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java
@@ -0,0 +1,35 @@
+/*
+ * 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 org.apache.jena.testing_framework.manifest;
+
+import java.util.List;
+
+import org.junit.runner.Runner;
+import org.junit.runners.model.InitializationError;
+
+public interface ManifestItemHandler {
+	/**
+	 * Handle an item in a manifest
+	 * 
+	 * @throws InitializationError
+	 */
+	public void processManifestItem(ManifestItem item);
+
+	public void setTestRunnerList(List<Runner> runners);
+}


[12/25] jena git commit: added comments to contract test added additional string type tests.

Posted by cl...@apache.org.
added comments to contract test
added additional string type tests.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/d12bd572
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/d12bd572
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/d12bd572

Branch: refs/heads/master
Commit: d12bd572bef6320eb193c946bafafa47a0e489ab
Parents: b293ee8
Author: Claude Warren <cl...@apache.org>
Authored: Sun Apr 26 21:16:14 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 9 15:27:40 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/jena/graph/GraphContractTest.java     | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/d12bd572/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index cf79da5..a989bae 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -1486,12 +1486,14 @@ public class GraphContractTest<T extends Graph> extends
 				"'simple'xsd:string", true);
 		testLiteralTypingBasedFind("a P 'simple'", 1, "'simple'xsd:string",
 				"'simple'", true);
+		// ensure that adding identical strings one with type yields single result
+		// and that querying with or without type works
 		testLiteralTypingBasedFind("a P 'simple'xsd:string", 1,
 				"'simple'xsd:string", "'simple'xsd:string", false);
-//		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 2,
-//				"'simple'", "'simple' 'simple'xsd:string", true);
-//		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 2,
-//				"'simple'xsd:string", "'simple' 'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
+				"'simple'", "'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
+				"'simple'xsd:string", "'simple'", true);
 		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
 				"'simple'", "'simple'", true);
 		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,


[24/25] jena git commit: .

Posted by cl...@apache.org.
.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/7a19eaf1
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/7a19eaf1
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/7a19eaf1

Branch: refs/heads/add-contract-tests
Commit: 7a19eaf1d02fc48b780f39c1bf24fc82685a65b6
Parents: fe78f4a
Author: Claude Warren <cl...@apache.org>
Authored: Fri May 22 22:59:39 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Fri May 22 22:59:39 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/7a19eaf1/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index 73846b6..cb83a09 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -83,6 +83,14 @@
 			<artifactId>jena-base</artifactId>
 			<version>3.0.0-SNAPSHOT</version>
 		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.jena</groupId>
+			<artifactId>jena-base</artifactId>
+			<version>3.0.0-SNAPSHOT</version>
+			<classifier>tests</classifier>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 
 	<build>


[16/25] jena git commit: Merge branch 'add-contract-tests' of https://git-wip-us.apache.org/repos/asf/jena into add-contract-tests

Posted by cl...@apache.org.
Merge branch 'add-contract-tests' of https://git-wip-us.apache.org/repos/asf/jena into add-contract-tests

Conflicts:
	jena-core/pom.xml
	jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
	jena-core/src/test/java/org/apache/jena/graph/impl/TestCollectionGraph.java
	jena-core/src/test/java/org/apache/jena/testing_framework/ContractTemplate.java
	jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/b01950b9
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/b01950b9
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/b01950b9

Branch: refs/heads/master
Commit: b01950b9096113761986c4a604103b142e06f342
Parents: 335a761 5bc9578
Author: Claude Warren <cl...@apache.org>
Authored: Sun May 10 14:02:17 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sun May 10 14:02:17 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml                               | 425 +++++++++----------
 .../apache/jena/graph/GraphContractTest.java    |   7 +
 2 files changed, 204 insertions(+), 228 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/b01950b9/jena-core/pom.xml
----------------------------------------------------------------------
diff --cc jena-core/pom.xml
index d64e195,6696660..ab2be30
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@@ -1,232 -1,200 +1,201 @@@
  <?xml version="1.0" encoding="utf-8"?>
- <!--
-    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.
- -->
- 
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-   <modelVersion>4.0.0</modelVersion>
-   <artifactId>jena-core</artifactId>
-   <packaging>jar</packaging>
-   <name>Apache Jena - Core</name>
-   <version>3.0.0-SNAPSHOT</version>
- 
-   <parent>
-     <groupId>org.apache.jena</groupId>
-     <artifactId>jena-parent</artifactId>
-     <version>14-SNAPSHOT</version>
-     <relativePath>../jena-parent</relativePath>
-   </parent>
- 
-   <description>Jena is a Java framework for building Semantic Web applications. It provides a programmatic environment for RDF, RDFS and OWL, SPARQL and includes a rule-based inference engine.</description>
- 
-   <properties>
-     <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
-     <build.time.xsd>${maven.build.timestamp}</build.time.xsd>
-   </properties>
- 
-   <dependencies>
- 
-     <dependency>
-       <groupId>org.apache.jena</groupId>
-       <artifactId>jena-base</artifactId>
-       <version>3.0.0-SNAPSHOT</version>
-     </dependency>
- 
-     <dependency>
-       <groupId>org.apache.jena</groupId>
-       <artifactId>jena-base</artifactId>
-       <version>3.0.0-SNAPSHOT</version>
-       <scope>test</scope>
-       <classifier>tests</classifier>
-     </dependency>
-     
-     <dependency>
-        <groupId>org.apache.jena</groupId>
-        <artifactId>jena-iri</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
-     </dependency>
- 
-     <dependency>
-       <groupId>xerces</groupId>
-       <artifactId>xercesImpl</artifactId>
-     </dependency>
-     
-     <dependency>
-       <groupId>org.slf4j</groupId>
-       <artifactId>slf4j-api</artifactId>
-     </dependency>   
- 
-     <dependency>
-       <groupId>junit</groupId>
-       <artifactId>junit</artifactId>
-       <scope>test</scope>
-     </dependency>
- 
- 	<dependency>
- 		<groupId>org.xenei</groupId>
- 		<artifactId>junit-contracts</artifactId>
- 		<version>0.1.1</version>
- 		<scope>test</scope>
- 	</dependency>
- 	
- 	<dependency>
- 		<groupId>org.mockito</groupId>
- 		<artifactId>mockito-all</artifactId>
- 		<version>1.9.5</version>
- 		<scope>test</scope>
- 	</dependency>
- 
-   </dependencies>
- 
-   <build>
-   
-     <resources>
- 
-       <!-- Legacy -->
-       <resource>
- 	<directory>etc</directory>
-         <targetPath>etc</targetPath>
-         <filtering>false</filtering>
-       </resource>
- 
-       <resource>
-         <filtering>false</filtering>
-         <directory>src/main/resources</directory>
-       </resource>
- 
-       <resource>
-         <directory>src/main/resources</directory>
-         <includes>
-           <include>org/apache/jena/jena-properties.xml</include>
-         </includes>
-         <filtering>true</filtering>
-       </resource>
- 
-     </resources>
-   
-     <plugins>
- 
-       <plugin>
-         <groupId>org.apache.maven.plugins</groupId>
-         <artifactId>maven-compiler-plugin</artifactId>
-       </plugin>
- 
-       <plugin>
-         <groupId>org.apache.maven.plugins</groupId>
-         <artifactId>maven-surefire-plugin</artifactId>
-         <configuration>
-           <systemProperties>
-             <property>
-               <name>log4j.configuration</name>
-               <value>jena-test-log4j.properties</value>
-             </property>
-           </systemProperties>
-           <includes>
-             <include>org/apache/jena/test/TestPackage.java</include>
++
+ <!-- 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. -->
+ 
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 	<modelVersion>4.0.0</modelVersion>
+ 	<artifactId>jena-core</artifactId>
+ 	<packaging>jar</packaging>
+ 	<name>Apache Jena - Core</name>
+ 	<version>3.0.0-SNAPSHOT</version>
+ 
+ 	<parent>
+ 		<groupId>org.apache.jena</groupId>
+ 		<artifactId>jena-parent</artifactId>
+ 		<version>14-SNAPSHOT</version>
+ 		<relativePath>../jena-parent</relativePath>
+ 	</parent>
+ 
+ 	<description>Jena is a Java framework for building Semantic Web applications. It provides a programmatic environment for RDF, RDFS and OWL, SPARQL and includes a rule-based inference engine.</description>
+ 
+ 	<properties>
+ 		<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
+ 		<build.time.xsd>${maven.build.timestamp}</build.time.xsd>
+ 	</properties>
+ 
+ 	<dependencies>
+ 
+ 		<dependency>
+ 			<groupId>junit</groupId>
+ 			<artifactId>junit</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 
+ 		<dependency>
+ 			<groupId>org.slf4j</groupId>
+ 			<artifactId>slf4j-api</artifactId>
+ 		</dependency>
+ 
+ 		<dependency>
+ 			<groupId>org.apache.jena</groupId>
+ 			<artifactId>jena-iri</artifactId>
+ 			<version>3.0.0-SNAPSHOT</version>
+ 		</dependency>
+ 
+ 		<dependency>
+ 			<groupId>xerces</groupId>
+ 			<artifactId>xercesImpl</artifactId>
+ 		</dependency>
+ 
+ 		<dependency>
+ 			<groupId>org.xenei</groupId>
+ 			<artifactId>junit-contracts</artifactId>
+ 			<version>0.0.5</version>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		
+ 		<dependency>
+ 			<groupId>org.mockito</groupId>
+ 			<artifactId>mockito-all</artifactId>
+ 			<version>1.9.5</version>
+ 			<scope>test</scope>
+ 		</dependency>
+ 
+ 	</dependencies>
+ 
+ 	<build>
+ 
+ 		<resources>
+ 
+ 			<!-- Legacy -->
+ 			<resource>
+ 				<directory>etc</directory>
+ 				<targetPath>etc</targetPath>
+ 				<filtering>false</filtering>
+ 			</resource>
+ 
+ 			<resource>
+ 				<filtering>false</filtering>
+ 				<directory>src/main/resources</directory>
+ 			</resource>
+ 
+ 			<resource>
+ 				<directory>src/main/resources</directory>
+ 				<includes>
+ 					<include>org/apache/jena/jena-properties.xml</include>
+ 				</includes>
+ 				<filtering>true</filtering>
+ 			</resource>
+ 
+ 		</resources>
+ 
+ 		<plugins>
+ 
+ 			<plugin>
+ 				<groupId>org.apache.maven.plugins</groupId>
+ 				<artifactId>maven-compiler-plugin</artifactId>
+ 			</plugin>
+ 
+ 			<plugin>
+ 				<groupId>org.apache.maven.plugins</groupId>
+ 				<artifactId>maven-surefire-plugin</artifactId>
+ 				<configuration>
+ 					<systemProperties>
+ 						<property>
+ 							<name>log4j.configuration</name>
+ 							<value>jena-test-log4j.properties</value>
+ 						</property>
+ 					</systemProperties>
+ 					<includes>
+ 						<include>com/hp/hpl/jena/test/TestPackage.java</include>
  						<include>**/*_CS.java</include>
-           </includes>
-         </configuration>
-       </plugin>
- 
-       <plugin>
-         <groupId>org.apache.maven.plugins</groupId>
-         <artifactId>maven-source-plugin</artifactId>
-         <executions>
-           <execution>
-             <id>attach-sources</id>
-             <phase>package</phase>
-             <goals>
- 	      <goal>jar-no-fork</goal>
-             </goals>
-           </execution>
-           <execution>
-             <id>attach-sources-test</id>
-             <phase>package</phase>
-             <goals>
-               <goal>test-jar-no-fork</goal>
-             </goals>
-           </execution>
-         </executions>
-       </plugin>
- 
-       <plugin>
-         <groupId>org.apache.maven.plugins</groupId>
-         <artifactId>maven-javadoc-plugin</artifactId>
-         <configuration>
-           <author>true</author>
-           <version>true</version>
-           <show>public</show>
-           <quiet>true</quiet>
-           <encoding>UTF-8</encoding>
-           <windowtitle>Apache Jena</windowtitle>
-           <doctitle>Apache Jena Core ${project.version}</doctitle>
-           <bottom>Licenced under the Apache License, Version 2.0</bottom>
-           <excludePackageNames>org.apache.jena.shared.*:*.impl:org.apache.jena.assembler.assemblers:*.exceptions:*.regexptrees:org.apache.jena.mem:org.apache.jena.mem.*:org.apache.jena.n3:org.apache.jena.n3.*:org.apache.jena.rdf.arp.*:org.apache.jena.util.*:jena.cmdline:jena.util</excludePackageNames>
-           <groups>
-             <group>
-               <title>API - Application Programming Interface</title>
-               <packages>org.apache.jena.db:org.apache.jena.rdf.model:org.apache.jena.rdf.listeners:org.apache.jena.rdf.arp:org.apache.jena.rdf.arp.lang:org.apache.jena.datatypes:org.apache.jena.datatypes.xsd:org.apache.jena.rdql:org.apache.jena.shared:org.apache.jena.vocabulary:org.apache.jena.xmloutput:org.apache.jena.ontology:org.apache.jena.ontology.daml:org.apache.jena.reasoner:org.apache.jena.reasoner.rulesys:org.apache.jena.reasoner.rulesys.builtins:org.apache.jena.reasoner.transitiveReasoner:org.apache.jena.reasoner.dig</packages>
-             </group>
-             <group>
-               <title>SPI - System Programming Interface</title>
-               <packages>org.apache.jena.enhanced:org.apache.jena.graph:org.apache.jena.graph.compose:org.apache.jena.graph.query:org.apache.jena.util:org.apache.jena.util.iterator</packages>
-             </group>
-             <group>
-               <title>Command line tools</title>
-               <packages>jena</packages>
-             </group>
-             <group>
-               <title>Other Packages</title>
-               <packages>org.apache.jena.assembler</packages>
-             </group>
-           </groups>
-         </configuration>
-       </plugin>
- 
-       <plugin>
-         <groupId>org.apache.maven.plugins</groupId>
-         <artifactId>maven-jar-plugin</artifactId>
-         <executions>
-           <execution>
-             <goals>
-               <goal>test-jar</goal>
-             </goals>
-           </execution>
-         </executions>
-       </plugin>
- 
-       <!--
-       <plugin>
-         <groupId>org.apache.maven.plugins</groupId>
-         <artifactId>maven-resources-plugin</artifactId>
-       </plugin>
-       <!- - see: http://maven.apache.org/guides/mini/guide-attached-tests.html - ->
-       <plugin>
-         <groupId>org.apache.maven.plugins</groupId>
-         <artifactId>maven-jar-plugin</artifactId>
-         <executions>
-           <execution>
-             <goals>
-               <goal>test-jar</goal>
-             </goals>
-           </execution>
-         </executions>
-       </plugin>
-       -->
-     </plugins>
-   </build>
+ 					</includes>
+ 				</configuration>
+ 			</plugin>
+ 
+ 			<plugin>
+ 				<groupId>org.apache.maven.plugins</groupId>
+ 				<artifactId>maven-source-plugin</artifactId>
+ 				<executions>
+ 					<execution>
+ 						<id>attach-sources</id>
+ 						<phase>package</phase>
+ 						<goals>
+ 							<goal>jar-no-fork</goal>
+ 						</goals>
+ 					</execution>
+ 					<execution>
+ 						<id>attach-sources-test</id>
+ 						<phase>package</phase>
+ 						<goals>
+ 							<goal>test-jar-no-fork</goal>
+ 						</goals>
+ 					</execution>
+ 				</executions>
+ 			</plugin>
+ 
+ 			<plugin>
+ 				<groupId>org.apache.maven.plugins</groupId>
+ 				<artifactId>maven-javadoc-plugin</artifactId>
+ 				<configuration>
+ 					<author>true</author>
+ 					<version>true</version>
+ 					<show>public</show>
+ 					<quiet>true</quiet>
+ 					<encoding>UTF-8</encoding>
+ 					<windowtitle>Apache Jena</windowtitle>
+ 					<doctitle>Apache Jena Core ${project.version}</doctitle>
+ 					<bottom>Licenced under the Apache License, Version 2.0</bottom>
+ 					<excludePackageNames>com.hp.hpl.jena.shared.*:*.impl:com.hp.hpl.jena.assembler.assemblers:*.exceptions:*.regexptrees:com.hp.hpl.jena.mem:com.hp.hpl.jena.mem.*:com.hp.hpl.jena.n3:com.hp.hpl.jena.n3.*:com.hp.hpl.jena.rdf.arp.*:com.hp.hpl.jena.util.*:jena.cmdline:jena.util</excludePackageNames>
+ 					<groups>
+ 						<group>
+ 							<title>API - Application Programming Interface</title>
+ 							<packages>com.hp.hpl.jena.db:com.hp.hpl.jena.rdf.model:com.hp.hpl.jena.rdf.listeners:com.hp.hpl.jena.rdf.arp:com.hp.hpl.jena.rdf.arp.lang:com.hp.hpl.jena.datatypes:com.hp.hpl.jena.datatypes.xsd:com.hp.hpl.jena.rdql:com.hp.hpl.jena.shared:com.hp.hpl.jena.vocabulary:com.hp.hpl.jena.xmloutput:com.hp.hpl.jena.ontology:com.hp.hpl.jena.ontology.daml:com.hp.hpl.jena.reasoner:com.hp.hpl.jena.reasoner.rulesys:com.hp.hpl.jena.reasoner.rulesys.builtins:com.hp.hpl.jena.reasoner.transitiveReasoner:com.hp.hpl.jena.reasoner.dig</packages>
+ 						</group>
+ 						<group>
+ 							<title>SPI - System Programming Interface</title>
+ 							<packages>com.hp.hpl.jena.enhanced:com.hp.hpl.jena.graph:com.hp.hpl.jena.graph.compose:com.hp.hpl.jena.graph.query:com.hp.hpl.jena.util:com.hp.hpl.jena.util.iterator</packages>
+ 						</group>
+ 						<group>
+ 							<title>Command line tools</title>
+ 							<packages>jena</packages>
+ 						</group>
+ 						<group>
+ 							<title>Other Packages</title>
+ 							<packages>com.hp.hpl.jena.assembler</packages>
+ 						</group>
+ 					</groups>
+ 				</configuration>
+ 			</plugin>
+ 
+ 			<plugin>
+ 				<groupId>org.apache.maven.plugins</groupId>
+ 				<artifactId>maven-jar-plugin</artifactId>
+ 				<executions>
+ 					<execution>
+ 						<goals>
+ 							<goal>test-jar</goal>
+ 						</goals>
+ 					</execution>
+ 				</executions>
+ 			</plugin>
+ 
+ 			<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> 
+ 				</plugin> <!- - see: http://maven.apache.org/guides/mini/guide-attached-tests.html 
+ 				- -> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> 
+ 				<executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> 
+ 				</executions> </plugin> -->
+ 		</plugins>
+ 	</build>
  
  </project>

http://git-wip-us.apache.org/repos/asf/jena/blob/b01950b9/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --cc jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index 589f095,55ad955..16bbc26
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@@ -1453,10 -1452,10 +1453,17 @@@ public class GraphContractTest<T extend
  	//
  
  	// used to find the object set from the returned set for literal testing
++<<<<<<< HEAD
 +	private static final Function<Triple, Node> getObject = new Function<Triple, Node>() {
 +		@Override
 +		public Node apply(Triple t) {
 +			return t.getObject();
++=======
+ 	private static final Map1<Triple, Node> getObject = new Map1<Triple, Node>() {
+ 		@Override
+ 		public Node map1(Triple o) {
+ 			return o.getObject();
++>>>>>>> 5bc9578fc31fe58017b80d1a15e41b593ee31074
  		}
  	};
  


[18/25] jena git commit: added contract-test module to pom

Posted by cl...@apache.org.
added contract-test module to pom


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/2e62ed0f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/2e62ed0f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/2e62ed0f

Branch: refs/heads/master
Commit: 2e62ed0f8635601c8adbddbf2e043128e018f1a8
Parents: d492e54
Author: Claude Warren <cl...@apache.org>
Authored: Sat May 16 09:52:11 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 16 09:52:11 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/2e62ed0f/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index ab2be30..70e0dba 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -60,7 +60,14 @@
 		<dependency>
 			<groupId>org.xenei</groupId>
 			<artifactId>junit-contracts</artifactId>
-			<version>0.0.5</version>
+			<version>0.1.1</version>
+			<scope>test</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.xenei</groupId>
+			<artifactId>contract-test-maven-plugin</artifactId>
+			<version>0.1.1</version>
 			<scope>test</scope>
 		</dependency>
 		
@@ -189,6 +196,47 @@
 					</execution>
 				</executions>
 			</plugin>
+			
+			<plugin>
+				<groupId>org.xenei</groupId>
+				<artifactId>contract-test-maven-plugin</artifactId>
+				<configuration>
+					<packages>
+						<package>org.apache.jena.assembler</package>
+						<package>org.apache.jena.datatypes</package>
+						<package>org.apache.jena.enhanced</package>
+						<package>org.apache.jena.graph</package>
+						<package>org.apache.jena.mem</package>
+						<package>org.apache.jena.n3</package>
+						<package>org.apache.jena.ontology</package>
+						<package>org.apache.jena.rdf</package>
+						<package>org.apache.jena.rdfxml</package>
+						<package>org.apache.jena.reasoner</package>
+						<package>org.apache.jena.shared</package>
+						<package>org.apache.jena.util</package>
+						<package>org.apache.jena.vocabulary</package>
+					</packages>
+					<unimplemented>
+						<report>true</report>
+      					<failOnError>false</failOnError>
+					</unimplemented>
+					<untested>
+						<report>true</report>
+      					<failOnError>false</failOnError>
+					</untested>
+					<errors>
+						<report>true</report>
+      					<failOnError>false</failOnError>
+					</errors>
+				</configuration>
+				<executions>
+					<execution>
+						<goals>
+							<goal>contract-test</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
 
 			<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> 
 				</plugin> <!- - see: http://maven.apache.org/guides/mini/guide-attached-tests.html 


[23/25] jena git commit: .

Posted by cl...@apache.org.
.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/7a19eaf1
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/7a19eaf1
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/7a19eaf1

Branch: refs/heads/master
Commit: 7a19eaf1d02fc48b780f39c1bf24fc82685a65b6
Parents: fe78f4a
Author: Claude Warren <cl...@apache.org>
Authored: Fri May 22 22:59:39 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Fri May 22 22:59:39 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/7a19eaf1/jena-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-core/pom.xml b/jena-core/pom.xml
index 73846b6..cb83a09 100644
--- a/jena-core/pom.xml
+++ b/jena-core/pom.xml
@@ -83,6 +83,14 @@
 			<artifactId>jena-base</artifactId>
 			<version>3.0.0-SNAPSHOT</version>
 		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.jena</groupId>
+			<artifactId>jena-base</artifactId>
+			<version>3.0.0-SNAPSHOT</version>
+			<classifier>tests</classifier>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 
 	<build>


[25/25] jena git commit: Merge branch 'add-contract-tests' Merging the Contract tests and associated helper classes into the main line code.

Posted by cl...@apache.org.
Merge branch 'add-contract-tests'
Merging the Contract tests and associated helper classes into the main line
code.

This is part of JENA-380


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/6419caaf
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/6419caaf
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/6419caaf

Branch: refs/heads/master
Commit: 6419caaf24dd66f63bfd8fbde83e439cf96d1fb6
Parents: 5f3510a 7a19eaf
Author: Claude Warren <cl...@apache.org>
Authored: Fri May 22 23:03:59 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 23 07:41:29 2015 +0100

----------------------------------------------------------------------
 jena-core/pom.xml                               |  474 ++---
 .../jena/assembler/test/TestAssemblerGroup.java |    8 +-
 .../apache/jena/graph/GraphContractTest.java    | 1722 ++++++++++++++++++
 .../graph/GraphEventManagerContractTest.java    |  500 +++++
 .../jena/graph/GraphMakerContractTest.java      |  295 +++
 .../graph/GraphWithPerformContractTest.java     |   85 +
 .../jena/graph/RecordingGraphListener.java      |   92 +
 .../graph/TransactionHandlerContractTest.java   |  136 ++
 .../apache/jena/graph/compose/DeltaTest.java    |  110 ++
 .../jena/graph/compose/DifferenceTest.java      |   97 +
 .../jena/graph/compose/IntersectionTest.java    |  109 ++
 .../apache/jena/graph/compose/UnionTest.java    |  185 ++
 .../jena/graph/impl/CollectionGraph_CS.java     |   67 +
 .../jena/graph/impl/SimpleEventManager_CS.java  |   54 +
 .../jena/graph/impl/SimpleGraphMaker_CS.java    |   54 +
 .../graph/impl/SimpleTransactionHandler_CS.java |   54 +
 .../jena/graph/impl/TestCollectionGraph.java    |   39 -
 .../graph/impl/TripleStoreContractTest.java     |  160 ++
 .../apache/jena/graph/impl/WrappedGraph_CS.java |   63 +
 .../java/org/apache/jena/mem/ArrayBunch_CS.java |   52 +
 .../apache/jena/mem/BunchMapContractTest.java   |  163 ++
 .../java/org/apache/jena/mem/GraphMem_CS.java   |  115 ++
 .../apache/jena/mem/GraphTripleStoreMem_CS.java |   51 +
 .../apache/jena/mem/GraphTripleStore_CS.java    |   51 +
 .../org/apache/jena/mem/HashedBunchMap_CS.java  |   52 +
 .../apache/jena/mem/HashedTripleBunch_CS.java   |   50 +
 .../java/org/apache/jena/mem/SetBunch_CS.java   |   50 +
 .../jena/mem/TripleBunchContractTest.java       |  205 +++
 .../org/apache/jena/mem/WrappedHashMap_CS.java  |   52 +
 .../AbstractGraphProducer.java                  |  104 ++
 .../AbstractInfModelProducer.java               |   91 +
 .../AbstractModelProducer.java                  |   88 +
 .../AbstractRecordingListener.java              |  190 ++
 .../testing_framework/ContractTemplate.java     |   35 +
 .../GraphEventManagerProducerInterface.java     |   35 +
 .../jena/testing_framework/GraphHelper.java     |  508 ++++++
 .../testing_framework/IContainerProducer.java   |   37 +
 .../testing_framework/IIteratorProducer.java    |   60 +
 .../jena/testing_framework/INodeProducer.java   |   39 +
 .../testing_framework/IResourceProducer.java    |   28 +
 .../testing_framework/IStatementProducer.java   |   45 +
 .../testing_framework/ITripleStoreProducer.java |   35 +
 .../jena/testing_framework/ModelHelper.java     |  409 +++++
 .../jena/testing_framework/NodeCreateUtils.java |  177 ++
 .../NodeProducerInterface.java                  |   32 +
 .../jena/testing_framework/TestFileData.java    |  398 ++++
 .../jena/testing_framework/TestUtils.java       |  320 ++++
 .../testing_framework/manifest/Manifest.java    |  228 +++
 .../manifest/ManifestException.java             |   48 +
 .../manifest/ManifestFile.java                  |   38 +
 .../manifest/ManifestItem.java                  |   71 +
 .../manifest/ManifestItemHandler.java           |   35 +
 .../manifest/ManifestSuite.java                 |  143 ++
 .../manifest/ManifestTest.java                  |   31 +
 .../manifest/ManifestTestRunner.java            |   93 +
 .../jena/testing_framework/package-info.java    |  109 ++
 .../testing_framework/tuples/TupleItem.java     |   84 +
 .../jena/testing_framework/tuples/TupleSet.java |  274 +++
 58 files changed, 8675 insertions(+), 255 deletions(-)
----------------------------------------------------------------------



[05/25] jena git commit: added comments to contract test added additional string type tests.

Posted by cl...@apache.org.
added comments to contract test
added additional string type tests.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/8018ea47
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/8018ea47
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/8018ea47

Branch: refs/heads/master
Commit: 8018ea479e8145a29ac81c6bcf72b7c8da2ca1f1
Parents: 4d1b0d9
Author: Claude Warren <cl...@apache.org>
Authored: Sun Apr 26 21:16:14 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sun Apr 26 21:16:14 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/jena/graph/GraphContractTest.java     | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/8018ea47/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index cf79da5..a989bae 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -1486,12 +1486,14 @@ public class GraphContractTest<T extends Graph> extends
 				"'simple'xsd:string", true);
 		testLiteralTypingBasedFind("a P 'simple'", 1, "'simple'xsd:string",
 				"'simple'", true);
+		// ensure that adding identical strings one with type yields single result
+		// and that querying with or without type works
 		testLiteralTypingBasedFind("a P 'simple'xsd:string", 1,
 				"'simple'xsd:string", "'simple'xsd:string", false);
-//		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 2,
-//				"'simple'", "'simple' 'simple'xsd:string", true);
-//		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 2,
-//				"'simple'xsd:string", "'simple' 'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
+				"'simple'", "'simple'xsd:string", true);
+		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
+				"'simple'xsd:string", "'simple'", true);
 		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,
 				"'simple'", "'simple'", true);
 		testLiteralTypingBasedFind("a P 'simple'; a P 'simple'xsd:string", 1,