use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testPartialUpdate.
// @ContractTest
// public void testTransactionCommit()
// {
// Graph g = producer.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 = producer.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 = producer.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 = producer.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(producer.newInstance(), "a R b; b S e");
Graph dest = graphWith(producer.newInstance(), "b R d");
GraphExtract e = new GraphExtract(TripleBoundary.stopNowhere);
e.extractInto(dest, node("a"), source);
assertIsomorphic(graphWith(producer.newInstance(), "a R b; b S e; b R d"), dest);
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class DeltaTest method testDelta.
@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");
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testContains_Node_Node_Node_RepeatedSubjectDoesNotConceal.
@ContractTest
public void testContains_Node_Node_Node_RepeatedSubjectDoesNotConceal() {
Graph g = graphWith(producer.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));
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testGetCapabilities.
@ContractTest
public void testGetCapabilities() {
Graph g = producer.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.deleteAllowed();
} catch (Exception e) {
fail("deleteAllowed() threw Exception: " + e.toString());
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphMakerContractTest method testCanCreateTwice.
@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));
}
Aggregations