You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2013/09/01 00:24:09 UTC
svn commit: r1519233 - in
/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph: ./ impl/
Author: claude
Date: Sat Aug 31 22:24:08 2013
New Revision: 1519233
URL: http://svn.apache.org/r1519233
Log:
Added filegraph tests
Added:
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphSuite.java
- copied, changed from r1519171, jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite.java
- copied, changed from r1519171, jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraph.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite2.java (with props)
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphTest.java (with props)
Removed:
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/TestReifier.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraph.java
Modified:
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestCollectionGraph.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraphMaker.java
jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractFindLiteralsTest.java Sat Aug 31 22:24:08 2013
@@ -41,16 +41,18 @@ abstract public class AbstractFindLitera
private final int size;
private final String search;
private final String results;
+ private final boolean reqLitType;
protected static GraphProducerInterface graphProducer;
public AbstractFindLiteralsTest(final String data, final int size,
- final String search, final String results) {
+ final String search, final String results, boolean reqLitType) {
this.data = data;
this.size = size;
this.search = search;
this.results = results;
+ this.reqLitType = reqLitType;
}
@@ -63,14 +65,19 @@ abstract public class AbstractFindLitera
@Test
public void testFind() {
- Graph g = graphWith(graphProducer.newGraph(), data);
-
- Node literal = NodeCreateUtils.create(search);
- //
- assertEquals("graph has wrong size", size, g.size());
- Set<Node> got = g.find(Node.ANY, Node.ANY, literal).mapWith(getObject)
- .toSet();
- assertEquals(nodeSet(results), got);
+ Graph g = graphProducer.newGraph();
+
+ 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);
+ }
}
@After
@@ -78,41 +85,42 @@ abstract public class AbstractFindLitera
graphProducer.closeGraphs();
}
+
@Parameters(name = "TestFindLiterals: graph '{'{0}'}' size {1} search {2} expecting '{'{3}'}'")
public static Iterable<Object[]> data() {
Object[][] result = {
- { "a P 'simple'", 1, "'simple'", "'simple'" },
+ { "a P 'simple'", 1, "'simple'", "'simple'", false },
- { "a P 'simple'xsd:string", 1, "'simple'", "'simple'xsd:string" },
- { "a P 'simple'", 1, "'simple'xsd:string", "'simple'" },
+ { "a P 'simple'xsd:string", 1, "'simple'", "'simple'xsd:string", true },
+ { "a P 'simple'", 1, "'simple'xsd:string", "'simple'", true },
{ "a P 'simple'xsd:string", 1, "'simple'xsd:string",
- "'simple'xsd:string" },
+ "'simple'xsd:string", false },
//
{ "a P 'simple'; a P 'simple'xsd:string", 2, "'simple'",
- "'simple' 'simple'xsd:string" },
+ "'simple' 'simple'xsd:string", true },
{ "a P 'simple'; a P 'simple'xsd:string", 2,
- "'simple'xsd:string", "'simple' 'simple'xsd:string" },
+ "'simple'xsd:string", "'simple' 'simple'xsd:string", true },
//
- { "a P 1", 1, "1", "1" },
- { "a P '1'xsd:float", 1, "'1'xsd:float", "'1'xsd:float" },
- { "a P '1'xsd:double", 1, "'1'xsd:double", "'1'xsd:double" },
- { "a P '1'xsd:float", 1, "'1'xsd:float", "'1'xsd:float" },
- { "a P '1.1'xsd:float", 1, "'1'xsd:float", "" },
- { "a P '1'xsd:double", 1, "'1'xsd:int", "" },
+ { "a P 1", 1, "1", "1", false },
+ { "a P '1'xsd:float", 1, "'1'xsd:float", "'1'xsd:float" , false},
+ { "a P '1'xsd:double", 1, "'1'xsd:double", "'1'xsd:double", false },
+ { "a P '1'xsd:float", 1, "'1'xsd:float", "'1'xsd:float", false },
+ { "a P '1.1'xsd:float", 1, "'1'xsd:float", "", false },
+ { "a P '1'xsd:double", 1, "'1'xsd:int", "", false },
//
- { "a P 'abc'rdf:XMLLiteral", 1, "'abc'", "" },
- { "a P 'abc'", 1, "'abc'rdf:XMLLiteral", "" },
+ { "a P 'abc'rdf:XMLLiteral", 1, "'abc'", "", false },
+ { "a P 'abc'", 1, "'abc'rdf:XMLLiteral", "", false },
//
// floats & doubles are not compatible
//
- { "a P '1'xsd:float", 1, "'1'xsd:double", "" },
- { "a P '1'xsd:double", 1, "'1'xsd:float", "" },
+ { "a P '1'xsd:float", 1, "'1'xsd:double", "", false },
+ { "a P '1'xsd:double", 1, "'1'xsd:float", "", false },
//
- { "a P 1", 1, "'1'", "" },
- { "a P 1", 1, "'1'xsd:integer", "'1'xsd:integer" },
- { "a P 1", 1, "'1'", "" },
- { "a P '1'xsd:short", 1, "'1'xsd:integer", "'1'xsd:short" },
- { "a P '1'xsd:int", 1, "'1'xsd:integer", "'1'xsd:int" }, };
+ { "a P 1", 1, "'1'", "", false },
+ { "a P 1", 1, "'1'xsd:integer", "'1'xsd:integer", false },
+ { "a P 1", 1, "'1'", "", false },
+ { "a P '1'xsd:short", 1, "'1'xsd:integer", "'1'xsd:short", true },
+ { "a P '1'xsd:int", 1, "'1'xsd:integer", "'1'xsd:int", true }, };
return Arrays.asList(result);
}
}
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphExtractTest.java Sat Aug 31 22:24:08 2013
@@ -79,6 +79,7 @@ public abstract class AbstractGraphExtra
assertFalse(TripleBoundary.stopAtAnonObject.stopAt(triple("_a R b")));
}
+ @Test
public void testExtractBoundary() {
testExtract("a R b; b S _c", "a", "a R b; b S _c; _c T d",
TripleBoundary.stopAtAnonObject);
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphProducer.java Sat Aug 31 22:24:08 2013
@@ -5,7 +5,7 @@ import java.util.List;
public abstract class AbstractGraphProducer implements GraphProducerInterface {
- public List<Graph> graphList = new ArrayList<Graph>();
+ protected List<Graph> graphList = new ArrayList<Graph>();
abstract protected Graph createNewGraph();
@@ -15,11 +15,28 @@ public abstract class AbstractGraphProdu
graphList.add(retval);
return retval;
}
+
+ /**
+ * Method called before the graph is closed
+ * @param g The graph to be closed
+ */
+ protected void beforeClose( Graph g ) {};
+
+ /**
+ * Method called after the graph is closed
+ * @param g The graph that is closed
+ */
+ protected void afterClose( Graph g ) {};
@Override
final public void closeGraphs() {
for (Graph g : graphList) {
- g.close();
+ if (!g.isClosed())
+ {
+ beforeClose( g );
+ g.close();
+ }
+ afterClose( g );
}
graphList.clear();
}
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphSuite.java Sat Aug 31 22:24:08 2013
@@ -1,8 +1,10 @@
package com.hp.hpl.jena.graph;
+import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
+
/*
TestSuite result = new TestSuite( WrappedGraphTest.class );
result.addTest( suite( MetaTestGraph.class, GraphMem.class ) );
@@ -19,11 +21,12 @@ import org.junit.runners.Suite;
AbstractGraphSuite.ExtractTest.class,
AbstractGraphSuite.EventManagerTest.class,
AbstractGraphSuite.TransactionTest.class, })
+@Ignore
public abstract class AbstractGraphSuite {
static protected GraphProducerInterface graphProducer;
- protected static void setGraphProducer(GraphProducerInterface graphProducer) {
+ public static void setGraphProducer(GraphProducerInterface graphProducer) {
AbstractGraphSuite.graphProducer = graphProducer;
}
@@ -43,8 +46,8 @@ public abstract class AbstractGraphSuite
}
public static class FindLiterals extends AbstractFindLiteralsTest {
- public FindLiterals(String data, int size, String search, String results) {
- super(data, size, search, results);
+ public FindLiterals(String data, int size, String search, String results, boolean litReq) {
+ super(data, size, search, results, litReq);
AbstractFindLiteralsTest.graphProducer = AbstractGraphSuite.graphProducer;
}
}
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java Sat Aug 31 22:24:08 2013
@@ -122,9 +122,9 @@ public abstract class AbstractGraphTest
@Test
public void testContainsConcrete() {
- Graph g = graphWithTxn("s P o; _x _R _y; x S 0");
+ Graph g = graphWithTxn("s P o; _x p2 _y; x S 0");
assertTrue(g.contains(triple("s P o")));
- assertTrue(g.contains(triple("_x _R _y")));
+ assertTrue(g.contains(triple("_x p2 _y")));
assertTrue(g.contains(triple("x S 0")));
/* */
assertFalse(g.contains(triple("s P Oh")));
@@ -173,36 +173,40 @@ public abstract class AbstractGraphTest
@Test
public void testProgrammaticValues() {
- Node ab = NodeFactory.createLiteral(LiteralLabelFactory
- .create(new Byte((byte) 42)));
- Node as = NodeFactory.createLiteral(LiteralLabelFactory
- .create(new Short((short) 42)));
- Node ai = NodeFactory.createLiteral(LiteralLabelFactory
- .create(new Integer(42)));
- Node al = NodeFactory.createLiteral(LiteralLabelFactory
- .create(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");
Graph g = getGraphProducer().newGraph();
- 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());
+ if (g.getCapabilities().handlesLiteralTyping()) {
+ Node ab = NodeFactory.createLiteral(LiteralLabelFactory
+ .create(new Byte((byte) 42)));
+ Node as = NodeFactory.createLiteral(LiteralLabelFactory
+ .create(new Short((short) 42)));
+ Node ai = NodeFactory.createLiteral(LiteralLabelFactory
+ .create(new Integer(42)));
+ Node al = NodeFactory.createLiteral(LiteralLabelFactory
+ .create(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(
+ 4,
+ iteratorToSet(
+ g.find(Node.ANY, P, NodeCreateUtils.create("42")))
+ .size());
}
- txnCommit(g);
- assertEquals(
- 4,
- iteratorToSet(g.find(Node.ANY, P, NodeCreateUtils.create("42")))
- .size());
}
@Test
@@ -562,15 +566,15 @@ public abstract class AbstractGraphTest
*/
@Test
public void testContainsNode() {
- Graph g = graphWithTxn("a P b; _c _Q _d; a 11 12");
+ Graph g = graphWithTxn( "a P b; _c p1 _D; a P2 12");
assertTrue(containsNode(g, node("a")));
assertTrue(containsNode(g, node("P")));
assertTrue(containsNode(g, node("b")));
assertTrue(containsNode(g, node("_c")));
- assertTrue(containsNode(g, node("_Q")));
- assertTrue(containsNode(g, node("_d")));
+ assertTrue(containsNode(g, node("p1")));
+ assertTrue(containsNode(g, node("_D")));
// assertTrue( qh.containsNode( node( "10" ) ) );
- assertTrue(containsNode(g, node("11")));
+ //assertTrue(containsNode(g, node("11")));
assertTrue(containsNode(g, node("12")));
/* */
assertFalse(containsNode(g, node("x")));
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractTransactionHandlerTest.java Sat Aug 31 22:24:08 2013
@@ -86,22 +86,23 @@ public abstract class AbstractTransactio
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) {
+
+ 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) {
+ }
}
}
Copied: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphSuite.java (from r1519171, jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java)
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphSuite.java?p2=jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphSuite.java&p1=jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java&r1=1519171&r2=1519233&rev=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTestSuite.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphSuite.java Sat Aug 31 22:24:08 2013
@@ -4,7 +4,7 @@ import org.junit.BeforeClass;
import com.hp.hpl.jena.sparql.graph.GraphFactory;
-public class MemGraphTestSuite extends AbstractGraphSuite {
+public class MemGraphSuite extends AbstractGraphSuite {
@BeforeClass
public static void beforeClass() {
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/MemGraphTest.java Sat Aug 31 22:24:08 2013
@@ -2,7 +2,7 @@ package com.hp.hpl.jena.graph;
public class MemGraphTest extends AbstractGraphTest {
- GraphProducerInterface graphProducer = new MemGraphTestSuite.GraphProducer();
+ GraphProducerInterface graphProducer = new MemGraphSuite.GraphProducer();
@Override
protected GraphProducerInterface getGraphProducer() {
Copied: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite.java (from r1519171, jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraph.java)
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite.java?p2=jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite.java&p1=jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraph.java&r1=1519171&r2=1519233&rev=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraph.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite.java Sat Aug 31 22:24:08 2013
@@ -20,14 +20,27 @@ package com.hp.hpl.jena.graph.impl;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
-import junit.framework.TestSuite;
+import static org.junit.Assert.*;
-import com.hp.hpl.jena.graph.AbstractGraphTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Suite;
+import org.junit.runners.Parameterized.Parameters;
+
+import static com.hp.hpl.jena.graph.GraphTestUtils.*;
+
+import com.hp.hpl.jena.graph.AbstractGraphProducer;
+import com.hp.hpl.jena.graph.AbstractGraphProducerUser;
+import com.hp.hpl.jena.graph.AbstractGraphSuite;
import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.graph.GraphProducerInterface;
import com.hp.hpl.jena.graph.GraphUtil;
+import com.hp.hpl.jena.graph.MemGraphSuite.GraphProducer;
import com.hp.hpl.jena.graph.impl.FileGraph;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
@@ -37,120 +50,50 @@ import com.hp.hpl.jena.util.FileUtils;
* Test FileGraph by seeing if we can make some file graphs and then read them
* back.
*/
+@RunWith( Suite.class )
+@Suite.SuiteClasses({
+ FileGraphSuite.TestNames.class, FileGraphSuite.FileNameTests.class,
+ FileGraphSuite.FileNameTransactionTests.class
+ })
+public class FileGraphSuite {
+
+ public static class GraphProducer extends AbstractGraphProducer {
+ private String suffix = ".ttl";
+ private String prefix = "tfg";
+ private boolean strict = true;
-public class TestFileGraph extends AbstractGraphTest {
-
- public TestFileGraph(GraphProducerInterface graphProducer) {
- super(graphProducer);
- // TODO Auto-generated constructor stub
- }
-
- // TODO want a wider variety of cases, now we've discovered how to abstract.
- public static TestSuite suite() {
- TestSuite result = new TestSuite(TestFileGraph.class);
- result.addTest(new Case("x /R y", "xxxA", ".rdf"));
- result.addTest(new Case("x /R y", "xxxB", ".n3"));
- result.addTest(new Case("x /R y", "xxxC", ".nt"));
- result.addTest(new Case("x /R y; p /R q", "xxxD", ".rdf"));
- result.addTest(new Case("x /R y; p /R q", "xxxE", ".n3"));
- result.addTest(new Case("x /R y; p /R q", "xxxF", ".nt"));
- result.addTest(new Case("http://domain/S ftp:ftp/P O", "xxxG", ".rdf"));
- result.addTest(new Case("http://domain/S ftp:ftp/P O", "xxxH", ".nt"));
- result.addTest(new Case("http://domain/S ftp:ftp/P O", "xxxI", ".n3"));
- return result;
- }
-
- public void testPlausibleGraphname() {
- assertTrue(FileGraph.isPlausibleGraphName("agnessi.rdf"));
- assertTrue(FileGraph.isPlausibleGraphName("parabola.nt"));
- assertTrue(FileGraph.isPlausibleGraphName("hyperbola.n3"));
- assertTrue(FileGraph.isPlausibleGraphName("chris.dollin.n3"));
- assertTrue(FileGraph.isPlausibleGraphName("hedgehog.spine.end.rdf"));
- }
-
- public void testisPlausibleUppercaseGraphname() {
- assertTrue(FileGraph.isPlausibleGraphName("LOUDER.RDF"));
- assertTrue(FileGraph.isPlausibleGraphName("BRIDGE.NT"));
- assertTrue(FileGraph.isPlausibleGraphName("NOTN2.N3"));
- assertTrue(FileGraph.isPlausibleGraphName("chris.dollin.N3"));
- assertTrue(FileGraph.isPlausibleGraphName("hedgehog.spine.end.RDF"));
- }
-
- public void testImPlausibleGraphName() {
- assertFalse(FileGraph.isPlausibleGraphName("undecorated"));
- assertFalse(FileGraph.isPlausibleGraphName("danger.exe"));
- assertFalse(FileGraph.isPlausibleGraphName("pretty.jpg"));
- assertFalse(FileGraph.isPlausibleGraphName("FileGraph.java"));
- assertFalse(FileGraph.isPlausibleGraphName("infix.rdf.c"));
- }
-
- public void testTransactionCommit() {
- 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());
- }
+ public void setSuffix(String suffix) {
+ this.suffix = suffix;
+ }
- public void testTransactionAbort() {
- 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);
- }
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
- public void testTransactionCommitThenAbort() {
- Graph initial = graphWithTxn("A pings B; B pings C");
- Graph extra = graphWithTxn("C pingedBy B; fileGraph rdf:type Graph");
- 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());
- }
+ public void setStrict(boolean strict) {
+ this.strict = strict;
+ }
- public void testClosingNotifys() {
- final List<File> history = new ArrayList<File>();
- FileGraph.NotifyOnClose n = new FileGraph.NotifyOnClose() {
- @Override
- public void notifyClosed(File f) {
- history.add(f);
- }
- };
- File file = FileUtils.tempFileName("fileGraph", ".nt");
- Graph g = new FileGraph(n, file, true, true);
- assertEquals(new ArrayList<File>(), history);
- g.close();
- assertEquals(oneElementList(file), history);
- }
+ @Override
+ protected void afterClose(Graph g) {
+ ((FileGraph) g).name.delete();
+ }
- protected List<Object> oneElementList(Object x) {
- List<Object> result = new ArrayList<Object>();
- result.add(x);
- return result;
+ @Override
+ protected Graph createNewGraph() {
+ File foo = FileUtils.tempFileName(prefix, suffix);
+ foo.deleteOnExit();
+ return new FileGraph(foo, true, strict);
+ }
+
+ final public FileGraph newGraph(FileGraph.NotifyOnClose notifyOnClose) {
+ File foo = FileUtils.tempFileName(prefix, suffix);
+ foo.deleteOnExit();
+ FileGraph retval = new FileGraph(notifyOnClose, foo, true, strict);
+ graphList.add(retval);
+ return retval;
+ }
+
}
/**
@@ -159,29 +102,160 @@ public class TestFileGraph extends Abstr
* back correctly. The temporary files are marked as delete-on-exit to try
* and avoid cluttering the user's filespace ...
*/
- private static class Case extends TestFileGraph {
- String content;
- String prefix;
- String suffix;
+ @RunWith(Parameterized.class)
+ public static class TestNames extends AbstractGraphProducerUser {
+ private GraphProducer graphProducer = new GraphProducer();
+
+ @Override
+ protected GraphProducerInterface getGraphProducer() {
+ return graphProducer;
+ }
+
+ // TODO want a wider variety of cases, now we've discovered how to
+ // abstract.
+ @Parameters(name = "TestNames: content '{'{0}'}' prefix {1} suffix {2}")
+ public static Iterable<Object[]> data() {
+ Object[][] result = { { "x /R y", "xxxA", ".rdf" },
+ { "x /R y", "xxxB", ".n3" }, { "x /R y", "xxxC", ".nt" },
+ { "x /R y; p /R q", "xxxD", ".rdf" },
+ { "x /R y; p /R q", "xxxE", ".n3" },
+ { "x /R y; p /R q", "xxxF", ".nt" },
+ { "http://domain/S ftp:ftp/P O", "xxxG", ".rdf" },
+ { "http://domain/S ftp:ftp/P O", "xxxH", ".nt" },
+ { "http://domain/S ftp:ftp/P O", "xxxI", ".n3" }, };
+ return Arrays.asList(result);
+ }
+
+ private final String content;
- Case(String content, String prefix, String suffix) {
- super("Case: " + content + " in " + prefix + "*" + suffix);
+ public TestNames(String content, String prefix, String suffix) {
this.content = content;
- this.prefix = prefix;
- this.suffix = suffix;
+ ((GraphProducer) graphProducer).setPrefix(prefix);
+ ((GraphProducer) graphProducer).setSuffix(suffix);
}
- @Override
- public void runTest() {
- File foo = FileUtils.tempFileName(prefix, suffix);
- Graph original = graphWithTxn(content);
- Graph g = new FileGraph(foo, true, true);
+ @Test
+ public void test() {
+ Graph original = graphWith(graphProducer.newGraph(), content);
+ FileGraph g = (FileGraph) graphProducer.newGraph();
GraphUtil.addInto(g, original);
g.close();
- Graph g2 = new FileGraph(foo, false, true);
+ Graph g2 = new FileGraph(g.name, false, true);
assertIsomorphic(original, g2);
g2.close();
}
+
+
+ }
+
+ public static class FileNameTests extends AbstractGraphProducerUser {
+ private GraphProducer graphProducer = new GraphProducer();
+
+ @Override
+ protected GraphProducerInterface getGraphProducer() {
+ return graphProducer;
+ }
+
+ @Test
+ public void testPlausibleGraphname() {
+ assertTrue(FileGraph.isPlausibleGraphName("agnessi.rdf"));
+ assertTrue(FileGraph.isPlausibleGraphName("parabola.nt"));
+ assertTrue(FileGraph.isPlausibleGraphName("hyperbola.n3"));
+ assertTrue(FileGraph.isPlausibleGraphName("chris.dollin.n3"));
+ assertTrue(FileGraph.isPlausibleGraphName("hedgehog.spine.end.rdf"));
+ }
+
+ @Test
+ public void testisPlausibleUppercaseGraphname() {
+ assertTrue(FileGraph.isPlausibleGraphName("LOUDER.RDF"));
+ assertTrue(FileGraph.isPlausibleGraphName("BRIDGE.NT"));
+ assertTrue(FileGraph.isPlausibleGraphName("NOTN2.N3"));
+ assertTrue(FileGraph.isPlausibleGraphName("chris.dollin.N3"));
+ assertTrue(FileGraph.isPlausibleGraphName("hedgehog.spine.end.RDF"));
+ }
+
+ @Test
+ public void testImPlausibleGraphName() {
+ assertFalse(FileGraph.isPlausibleGraphName("undecorated"));
+ assertFalse(FileGraph.isPlausibleGraphName("danger.exe"));
+ assertFalse(FileGraph.isPlausibleGraphName("pretty.jpg"));
+ assertFalse(FileGraph.isPlausibleGraphName("FileGraph.java"));
+ assertFalse(FileGraph.isPlausibleGraphName("infix.rdf.c"));
+ }
+ }
+
+ public static class FileNameTransactionTests extends AbstractGraphProducerUser {
+
+ private GraphProducer graphProducer = new GraphProducer();
+
+ @Override
+ protected GraphProducerInterface getGraphProducer() {
+ return graphProducer;
+ }
+
+ @Test
+ public void testTransactionCommit() {
+ Graph initial = graphWith(graphProducer.newGraph(),
+ "initial hasValue 42; also hasURI hello");
+ Graph extra = graphWith(graphProducer.newGraph(),
+ "extra hasValue 17; also hasURI world");
+ FileGraph g = (FileGraph) graphProducer.newGraph();
+
+ GraphUtil.addInto(g, initial);
+ g.getTransactionHandler().begin();
+ GraphUtil.addInto(g, extra);
+ g.getTransactionHandler().commit();
+ Graph union = graphWith(graphProducer.newGraph(), "");
+ GraphUtil.addInto(union, initial);
+ GraphUtil.addInto(union, extra);
+ assertIsomorphic(union, g);
+ Model inFile = ModelFactory.createDefaultModel();
+ inFile.read("file:///" + g.name, "N-TRIPLES");
+ assertIsomorphic(union, inFile.getGraph());
+ }
+
+ @Test
+ public void testTransactionCommitThenAbort() {
+ Graph initial = graphWith(graphProducer.newGraph(),
+ "A pings B; B pings C");
+ Graph extra = graphWith(graphProducer.newGraph(),
+ "C pingedBy B; fileGraph rdf:type Graph");
+ File foo = FileUtils.tempFileName("fileGraph", ".nt");
+ FileGraph g = (FileGraph) graphProducer.newGraph();
+
+ 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:///" + g.name, "N-TRIPLES");
+ assertIsomorphic(initial, inFile.getGraph());
+ }
+
+ @Test
+ public void testClosingNotifys() {
+ final List<File> history = new ArrayList<File>();
+ FileGraph.NotifyOnClose n = new FileGraph.NotifyOnClose() {
+ @Override
+ public void notifyClosed(File f) {
+ history.add(f);
+ }
+ };
+ ((GraphProducer) graphProducer).setSuffix(".nt");
+ FileGraph g = ((GraphProducer) graphProducer).newGraph(n);
+ assertEquals(new ArrayList<File>(), history);
+ g.close();
+ assertEquals(oneElementList(g.name), history);
+ }
+
+ protected List<Object> oneElementList(Object x) {
+ List<Object> result = new ArrayList<Object>();
+ result.add(x);
+ return result;
+ }
}
}
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite2.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite2.java?rev=1519233&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite2.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite2.java Sat Aug 31 22:24:08 2013
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.graph.impl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Suite;
+import org.junit.runners.Parameterized.Parameters;
+
+import static com.hp.hpl.jena.graph.GraphTestUtils.*;
+
+import com.hp.hpl.jena.graph.AbstractGraphProducer;
+import com.hp.hpl.jena.graph.AbstractGraphSuite;
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.GraphProducerInterface;
+import com.hp.hpl.jena.graph.GraphUtil;
+import com.hp.hpl.jena.graph.MemGraphSuite.GraphProducer;
+import com.hp.hpl.jena.graph.impl.FileGraph;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+import com.hp.hpl.jena.util.FileUtils;
+
+/**
+ * Test FileGraph by seeing if we can make some file graphs and then read them
+ * back.
+ */
+
+public class FileGraphSuite2 extends AbstractGraphSuite {
+
+ @BeforeClass
+ public static void beforeClass() {
+ setGraphProducer(new GraphProducer());
+ }
+
+
+ public static class GraphProducer extends AbstractGraphProducer {
+ private String suffix = ".ttl";
+ private String prefix = "tfg";
+ private boolean strict = true;
+
+ public void setSuffix(String suffix) {
+ this.suffix = suffix;
+ }
+
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public void setStrict(boolean strict) {
+ this.strict = strict;
+ }
+
+ @Override
+ protected void afterClose(Graph g) {
+ ((FileGraph) g).name.delete();
+ }
+
+ @Override
+ protected Graph createNewGraph() {
+ File foo = FileUtils.tempFileName(prefix, suffix);
+ foo.deleteOnExit();
+ return new FileGraph(foo, true, strict);
+ }
+
+ final public FileGraph newGraph(FileGraph.NotifyOnClose notifyOnClose) {
+ File foo = FileUtils.tempFileName(prefix, suffix);
+ foo.deleteOnExit();
+ FileGraph retval = new FileGraph(notifyOnClose, foo, true, strict);
+ graphList.add(retval);
+ return retval;
+ }
+
+ }
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphSuite2.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphTest.java?rev=1519233&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphTest.java Sat Aug 31 22:24:08 2013
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.graph.impl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestSuite;
+
+import com.hp.hpl.jena.graph.AbstractGraphSuite;
+import com.hp.hpl.jena.graph.AbstractGraphTest;
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.GraphProducerInterface;
+import com.hp.hpl.jena.graph.GraphUtil;
+import com.hp.hpl.jena.graph.MemGraphSuite;
+import com.hp.hpl.jena.graph.impl.FileGraph;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.util.FileUtils;
+
+/**
+ * Test FileGraph by seeing if we can make some file graphs and then read them
+ * back.
+ */
+
+public class FileGraphTest extends AbstractGraphTest {
+
+ GraphProducerInterface graphProducer = new FileGraphSuite.GraphProducer();
+
+ @Override
+ protected GraphProducerInterface getGraphProducer() {
+ return graphProducer;
+ }
+
+
+//
+// // TODO want a wider variety of cases, now we've discovered how to abstract.
+// public static TestSuite suite() {
+// TestSuite result = new TestSuite(FileGraphTestSuite.class);
+// result.addTest(new Case("x /R y", "xxxA", ".rdf"));
+// result.addTest(new Case("x /R y", "xxxB", ".n3"));
+// result.addTest(new Case("x /R y", "xxxC", ".nt"));
+// result.addTest(new Case("x /R y; p /R q", "xxxD", ".rdf"));
+// result.addTest(new Case("x /R y; p /R q", "xxxE", ".n3"));
+// result.addTest(new Case("x /R y; p /R q", "xxxF", ".nt"));
+// result.addTest(new Case("http://domain/S ftp:ftp/P O", "xxxG", ".rdf"));
+// result.addTest(new Case("http://domain/S ftp:ftp/P O", "xxxH", ".nt"));
+// result.addTest(new Case("http://domain/S ftp:ftp/P O", "xxxI", ".n3"));
+// return result;
+// }
+//
+// public void testPlausibleGraphname() {
+// assertTrue(FileGraph.isPlausibleGraphName("agnessi.rdf"));
+// assertTrue(FileGraph.isPlausibleGraphName("parabola.nt"));
+// assertTrue(FileGraph.isPlausibleGraphName("hyperbola.n3"));
+// assertTrue(FileGraph.isPlausibleGraphName("chris.dollin.n3"));
+// assertTrue(FileGraph.isPlausibleGraphName("hedgehog.spine.end.rdf"));
+// }
+//
+// public void testisPlausibleUppercaseGraphname() {
+// assertTrue(FileGraph.isPlausibleGraphName("LOUDER.RDF"));
+// assertTrue(FileGraph.isPlausibleGraphName("BRIDGE.NT"));
+// assertTrue(FileGraph.isPlausibleGraphName("NOTN2.N3"));
+// assertTrue(FileGraph.isPlausibleGraphName("chris.dollin.N3"));
+// assertTrue(FileGraph.isPlausibleGraphName("hedgehog.spine.end.RDF"));
+// }
+//
+// public void testImPlausibleGraphName() {
+// assertFalse(FileGraph.isPlausibleGraphName("undecorated"));
+// assertFalse(FileGraph.isPlausibleGraphName("danger.exe"));
+// assertFalse(FileGraph.isPlausibleGraphName("pretty.jpg"));
+// assertFalse(FileGraph.isPlausibleGraphName("FileGraph.java"));
+// assertFalse(FileGraph.isPlausibleGraphName("infix.rdf.c"));
+// }
+//
+// public void testTransactionCommit() {
+// 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());
+// }
+//
+// public void testTransactionAbort() {
+// 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);
+// }
+//
+// public void testTransactionCommitThenAbort() {
+// Graph initial = graphWithTxn("A pings B; B pings C");
+// Graph extra = graphWithTxn("C pingedBy B; fileGraph rdf:type Graph");
+// 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());
+// }
+//
+// public void testClosingNotifys() {
+// final List<File> history = new ArrayList<File>();
+// FileGraph.NotifyOnClose n = new FileGraph.NotifyOnClose() {
+// @Override
+// public void notifyClosed(File f) {
+// history.add(f);
+// }
+// };
+// File file = FileUtils.tempFileName("fileGraph", ".nt");
+// Graph g = new FileGraph(n, file, true, true);
+// assertEquals(new ArrayList<File>(), history);
+// g.close();
+// assertEquals(oneElementList(file), history);
+// }
+//
+// protected List<Object> oneElementList(Object x) {
+// List<Object> result = new ArrayList<Object>();
+// result.add(x);
+// return result;
+// }
+//
+// /**
+// * Test that the graph encoded as the test-string content can be written out
+// * to a temporary file generated from the prefix and suffix, and then read
+// * back correctly. The temporary files are marked as delete-on-exit to try
+// * and avoid cluttering the user's filespace ...
+// */
+// private static class Case extends FileGraphTestSuite {
+// String content;
+// String prefix;
+// String suffix;
+//
+// Case(String content, String prefix, String suffix) {
+// super("Case: " + content + " in " + prefix + "*" + suffix);
+// this.content = content;
+// this.prefix = prefix;
+// this.suffix = suffix;
+// }
+//
+// @Override
+// public void runTest() {
+// File foo = FileUtils.tempFileName(prefix, suffix);
+// Graph original = graphWithTxn(content);
+// Graph g = new FileGraph(foo, true, true);
+// GraphUtil.addInto(g, original);
+// g.close();
+// Graph g2 = new FileGraph(foo, false, true);
+// assertIsomorphic(original, g2);
+// g2.close();
+// }
+// }
+
+
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/FileGraphTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestCollectionGraph.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestCollectionGraph.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestCollectionGraph.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestCollectionGraph.java Sat Aug 31 22:24:08 2013
@@ -29,10 +29,11 @@ import com.hp.hpl.jena.graph.impl.Collec
public class TestCollectionGraph extends AbstractGraphTest {
+ private GraphProducerInterface graphProducer = new GraphProducer();
+
@Override
protected GraphProducerInterface getGraphProducer() {
- // TODO Auto-generated method stub
- return null;
+ return graphProducer;
}
public static class GraphProducer extends AbstractGraphProducer {
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraphMaker.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraphMaker.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraphMaker.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/TestFileGraphMaker.java Sat Aug 31 22:24:08 2013
@@ -1,128 +1,128 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hp.hpl.jena.graph.impl;
-
-import java.io.File;
-import java.util.HashSet;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-import static com.hp.hpl.jena.graph.GraphTestUtils.*;
-
-import com.hp.hpl.jena.graph.AbstractTestGraphMaker;
-import com.hp.hpl.jena.graph.Graph;
-import com.hp.hpl.jena.graph.GraphMaker;
-import com.hp.hpl.jena.graph.GraphUtil;
-import com.hp.hpl.jena.graph.impl.FileGraph;
-import com.hp.hpl.jena.graph.impl.FileGraphMaker;
-import com.hp.hpl.jena.util.FileUtils;
-
-/**
- * Test a FileGraphMaker; use the abstract tests, plus specialised ones for the
- * name conversion routines.
- */
-public class TestFileGraphMaker extends AbstractTestGraphMaker {
-
- @Override
- public GraphMaker getGraphMaker() {
- String scratch = FileUtils.getScratchDirectory(
- "jena-test-FileGraphMaker").getPath();
- return new FileGraphMaker(scratch, true);
- }
-
- @Test
- public void testToFilename() {
- assertEquals("plain", FileGraphMaker.toFilename("plain"));
- assertEquals("with_Sslash", FileGraphMaker.toFilename("with/slash"));
- assertEquals("with_Ccolon", FileGraphMaker.toFilename("with:colon"));
- assertEquals("with_Uunderbar",
- FileGraphMaker.toFilename("with_underbar"));
- assertEquals("with_Stwo_Sslashes",
- FileGraphMaker.toFilename("with/two/slashes"));
- assertEquals("with_Sa_Cmixture_U...",
- FileGraphMaker.toFilename("with/a:mixture_..."));
- }
-
- @Test
- public void testToGraphname() {
- assertEquals("plain", FileGraphMaker.toGraphname("plain"));
- assertEquals("with/slash", FileGraphMaker.toGraphname("with_Sslash"));
- assertEquals("with:colon", FileGraphMaker.toGraphname("with_Ccolon"));
- assertEquals("with_underbar",
- FileGraphMaker.toGraphname("with_Uunderbar"));
- assertEquals("a/mixture_of:things",
- FileGraphMaker.toGraphname("a_Smixture_Uof_Cthings"));
- assertEquals("with/two/slashes",
- FileGraphMaker.toGraphname("with_Stwo_Sslashes"));
- }
-
- @Test
- public void testDetectsExistingFiles() {
- File scratch = FileUtils
- .getScratchDirectory("jena-test-FileGraphMaker-already");
- Graph content = graphWith("something hasProperty someValue");
- FileGraphMaker A = new FileGraphMaker(scratch.getPath(), true);
- FileGraphMaker B = new FileGraphMaker(scratch.getPath(), true);
- FileGraph gA = (FileGraph) A.createGraph("already", true);
- GraphUtil.addInto(gA, content);
- gA.close();
- FileGraph gB = (FileGraph) B.openGraph("already", false);
- assertIsomorphic(content, gB);
- gB.close();
- gB.delete();
- gA.delete();
- }
-
- @Test
- public void testDeletesFilesOfClosedMaker() {
- File scratch = FileUtils
- .getScratchDirectory("jena-test-FileGraphMaker-forgets");
- FileGraphMaker A = new FileGraphMaker(scratch.getPath(), true);
- A.createGraph("empty").close();
- assertTrue("file 'empty' should exist in '" + scratch + "'", new File(
- scratch, "empty").exists());
- A.close();
- assertFalse("file 'empty' should no longer exist in '" + scratch + "'",
- new File(scratch, "empty").exists());
- }
-
- @Test
- public void testForgetsClosedGraphs() {
- File scratch = FileUtils
- .getScratchDirectory("jena-test-FileGraphMaker-forgets");
- FileGraphMaker m = new FileGraphMaker(scratch.getPath(), true);
- m.createGraph("example").close();
- assertEquals(new HashSet<String>(), m.listGraphs().toSet());
- m.close();
- }
-
- @Test
- public void testDoesntReusedClosedGraphs() {
- File scratch = FileUtils
- .getScratchDirectory("jena-test-FileGraphMaker-noReuse");
- FileGraphMaker m = new FileGraphMaker(scratch.getPath(), true);
- Graph m1 = m.createGraph("hello");
- m1.close();
- Graph m2 = m.createGraph("hello");
- assertNotSame(m1, m2);
- m2.add(triple("this graph isOpen"));
- m.close();
- }
-}
+///*
+// * Licensed to the Apache Software Foundation (ASF) under one
+// * or more contributor license agreements. See the NOTICE file
+// * distributed with this work for additional information
+// * regarding copyright ownership. The ASF licenses this file
+// * to you under the Apache License, Version 2.0 (the
+// * "License"); you may not use this file except in compliance
+// * with the License. You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//
+//package com.hp.hpl.jena.graph.impl;
+//
+//import java.io.File;
+//import java.util.HashSet;
+//
+//import org.junit.Test;
+//
+//import static org.junit.Assert.*;
+//import static com.hp.hpl.jena.graph.GraphTestUtils.*;
+//
+//import com.hp.hpl.jena.graph.AbstractTestGraphMaker;
+//import com.hp.hpl.jena.graph.Graph;
+//import com.hp.hpl.jena.graph.GraphMaker;
+//import com.hp.hpl.jena.graph.GraphUtil;
+//import com.hp.hpl.jena.graph.impl.FileGraph;
+//import com.hp.hpl.jena.graph.impl.FileGraphMaker;
+//import com.hp.hpl.jena.util.FileUtils;
+//
+///**
+// * Test a FileGraphMaker; use the abstract tests, plus specialised ones for the
+// * name conversion routines.
+// */
+//public class TestFileGraphMaker extends AbstractTestGraphMaker {
+//
+// @Override
+// public GraphMaker getGraphMaker() {
+// String scratch = FileUtils.getScratchDirectory(
+// "jena-test-FileGraphMaker").getPath();
+// return new FileGraphMaker(scratch, true);
+// }
+//
+// @Test
+// public void testToFilename() {
+// assertEquals("plain", FileGraphMaker.toFilename("plain"));
+// assertEquals("with_Sslash", FileGraphMaker.toFilename("with/slash"));
+// assertEquals("with_Ccolon", FileGraphMaker.toFilename("with:colon"));
+// assertEquals("with_Uunderbar",
+// FileGraphMaker.toFilename("with_underbar"));
+// assertEquals("with_Stwo_Sslashes",
+// FileGraphMaker.toFilename("with/two/slashes"));
+// assertEquals("with_Sa_Cmixture_U...",
+// FileGraphMaker.toFilename("with/a:mixture_..."));
+// }
+//
+// @Test
+// public void testToGraphname() {
+// assertEquals("plain", FileGraphMaker.toGraphname("plain"));
+// assertEquals("with/slash", FileGraphMaker.toGraphname("with_Sslash"));
+// assertEquals("with:colon", FileGraphMaker.toGraphname("with_Ccolon"));
+// assertEquals("with_underbar",
+// FileGraphMaker.toGraphname("with_Uunderbar"));
+// assertEquals("a/mixture_of:things",
+// FileGraphMaker.toGraphname("a_Smixture_Uof_Cthings"));
+// assertEquals("with/two/slashes",
+// FileGraphMaker.toGraphname("with_Stwo_Sslashes"));
+// }
+//
+// @Test
+// public void testDetectsExistingFiles() {
+// File scratch = FileUtils
+// .getScratchDirectory("jena-test-FileGraphMaker-already");
+// Graph content = graphWith("something hasProperty someValue");
+// FileGraphMaker A = new FileGraphMaker(scratch.getPath(), true);
+// FileGraphMaker B = new FileGraphMaker(scratch.getPath(), true);
+// FileGraph gA = (FileGraph) A.createGraph("already", true);
+// GraphUtil.addInto(gA, content);
+// gA.close();
+// FileGraph gB = (FileGraph) B.openGraph("already", false);
+// assertIsomorphic(content, gB);
+// gB.close();
+// gB.delete();
+// gA.delete();
+// }
+//
+// @Test
+// public void testDeletesFilesOfClosedMaker() {
+// File scratch = FileUtils
+// .getScratchDirectory("jena-test-FileGraphMaker-forgets");
+// FileGraphMaker A = new FileGraphMaker(scratch.getPath(), true);
+// A.createGraph("empty").close();
+// assertTrue("file 'empty' should exist in '" + scratch + "'", new File(
+// scratch, "empty").exists());
+// A.close();
+// assertFalse("file 'empty' should no longer exist in '" + scratch + "'",
+// new File(scratch, "empty").exists());
+// }
+//
+// @Test
+// public void testForgetsClosedGraphs() {
+// File scratch = FileUtils
+// .getScratchDirectory("jena-test-FileGraphMaker-forgets");
+// FileGraphMaker m = new FileGraphMaker(scratch.getPath(), true);
+// m.createGraph("example").close();
+// assertEquals(new HashSet<String>(), m.listGraphs().toSet());
+// m.close();
+// }
+//
+// @Test
+// public void testDoesntReusedClosedGraphs() {
+// File scratch = FileUtils
+// .getScratchDirectory("jena-test-FileGraphMaker-noReuse");
+// FileGraphMaker m = new FileGraphMaker(scratch.getPath(), true);
+// Graph m1 = m.createGraph("hello");
+// m1.close();
+// Graph m2 = m.createGraph("hello");
+// assertNotSame(m1, m2);
+// m2.add(triple("this graph isOpen"));
+// m.close();
+// }
+//}
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java?rev=1519233&r1=1519232&r2=1519233&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java Sat Aug 31 22:24:08 2013
@@ -1,84 +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 com.hp.hpl.jena.graph.impl;
-
-/**
- Tests that check GraphMem and WrappedGraph for correctness against the Graph
- and reifier test suites.
- */
-
-import org.junit.Test;
-
-import com.hp.hpl.jena.graph.AbstractGraphSuite;
-import com.hp.hpl.jena.graph.AbstractGraphTest;
-import com.hp.hpl.jena.graph.Factory;
-import com.hp.hpl.jena.graph.Graph;
-import com.hp.hpl.jena.graph.GraphProducerInterface;
-import com.hp.hpl.jena.graph.impl.WrappedGraph;
-import com.hp.hpl.jena.mem.GraphMem;
-import com.hp.hpl.jena.sparql.graph.GraphFactory;
-
-public class WrappedGraphTest extends AbstractGraphSuite {
- public WrappedGraphTest(String name) {
- super(name);
- }
-
- /**
- * Answer a test suite that runs the Graph tests on GraphMem and on
- * WrappedGraphMem, the latter standing in for testing WrappedGraph.
- */
- public static TestSuite suite() {
- TestSuite result = new TestSuite(WrappedGraphTest.class);
- result.addTest(suite(MetaTestGraph.class, GraphMem.class));
- result.addTest(suite(TestReifier.class, GraphMem.class));
- result.addTest(suite(MetaTestGraph.class, WrappedGraphMem.class));
- result.addTest(suite(TestReifier.class, WrappedGraphMem.class));
- result.addTest(TestGraphListener.suite());
- result.addTestSuite(TestRegisterGraphListener.class);
- return result;
- }
-
- public static TestSuite suite(Class<? extends Test> classWithTests,
- Class<? extends Graph> graphClass) {
- return MetaTestGraph.suite(classWithTests, graphClass);
- }
-
- /**
- * Trivial [incomplete] test that a Wrapped graph pokes through to the
- * underlying graph. Really want something using mock classes. Will think
- * about it.
- */
- @Test
- public void testWrappedSame() {
- Graph m = Factory.createGraphMem();
- Graph w = new WrappedGraph(m);
- graphAdd(m, "a trumps b; c eats d");
- assertIsomorphic(m, w);
- graphAdd(w, "i write this; you read that");
- assertIsomorphic(w, m);
- }
-
- public static class GraphProducer implements GraphProducerInterface {
- @Override
- public Graph newGraph() {
- return new WrappedGraph(GraphFactory.createGraphMem());
- }
- }
-
-}
+///*
+// * Licensed to the Apache Software Foundation (ASF) under one
+// * or more contributor license agreements. See the NOTICE file
+// * distributed with this work for additional information
+// * regarding copyright ownership. The ASF licenses this file
+// * to you under the Apache License, Version 2.0 (the
+// * "License"); you may not use this file except in compliance
+// * with the License. You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//
+//package com.hp.hpl.jena.graph.impl;
+//
+///**
+// Tests that check GraphMem and WrappedGraph for correctness against the Graph
+// and reifier test suites.
+// */
+//
+//import org.junit.Test;
+//
+//import com.hp.hpl.jena.graph.AbstractGraphSuite;
+//import com.hp.hpl.jena.graph.AbstractGraphTest;
+//import com.hp.hpl.jena.graph.Factory;
+//import com.hp.hpl.jena.graph.Graph;
+//import com.hp.hpl.jena.graph.GraphProducerInterface;
+//import com.hp.hpl.jena.graph.impl.WrappedGraph;
+//import com.hp.hpl.jena.mem.GraphMem;
+//import com.hp.hpl.jena.sparql.graph.GraphFactory;
+//
+//public class WrappedGraphTest extends AbstractGraphSuite {
+// public WrappedGraphTest(String name) {
+// super(name);
+// }
+//
+// /**
+// * Answer a test suite that runs the Graph tests on GraphMem and on
+// * WrappedGraphMem, the latter standing in for testing WrappedGraph.
+// */
+// public static TestSuite suite() {
+// TestSuite result = new TestSuite(WrappedGraphTest.class);
+// result.addTest(suite(MetaTestGraph.class, GraphMem.class));
+// result.addTest(suite(TestReifier.class, GraphMem.class));
+// result.addTest(suite(MetaTestGraph.class, WrappedGraphMem.class));
+// result.addTest(suite(TestReifier.class, WrappedGraphMem.class));
+// result.addTest(TestGraphListener.suite());
+// result.addTestSuite(TestRegisterGraphListener.class);
+// return result;
+// }
+//
+// public static TestSuite suite(Class<? extends Test> classWithTests,
+// Class<? extends Graph> graphClass) {
+// return MetaTestGraph.suite(classWithTests, graphClass);
+// }
+//
+// /**
+// * Trivial [incomplete] test that a Wrapped graph pokes through to the
+// * underlying graph. Really want something using mock classes. Will think
+// * about it.
+// */
+// @Test
+// public void testWrappedSame() {
+// Graph m = Factory.createGraphMem();
+// Graph w = new WrappedGraph(m);
+// graphAdd(m, "a trumps b; c eats d");
+// assertIsomorphic(m, w);
+// graphAdd(w, "i write this; you read that");
+// assertIsomorphic(w, m);
+// }
+//
+// public static class GraphProducer implements GraphProducerInterface {
+// @Override
+// public Graph newGraph() {
+// return new WrappedGraph(GraphFactory.createGraphMem());
+// }
+// }
+//
+//}