use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphMakerContractTest method testListAfterDelete.
/**
* 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();
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphMakerContractTest method testGetGraph.
/**
* 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();
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphMakerContractTest method testListThreeGraphs.
/**
* 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();
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class TransactionHandlerContractTest method testTransactionsExistAsPerTransactionSupported.
/**
* Test that Graphs have transaction support methods, and that if they fail
* on some g they fail because they do not support the operation.
*/
@SuppressWarnings("deprecation")
@ContractTest
public void testTransactionsExistAsPerTransactionSupported() {
// Write out explicitly
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.execute(() -> {
});
th.calculate(() -> null);
th.executeInTransaction(cmd);
th.executeInTransaction(() -> null);
} 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.execute(() -> {
});
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.calculate(() -> null);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.executeInTransaction(cmd);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.executeInTransaction(() -> null);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testGetStatisticsHandler.
@ContractTest
public void testGetStatisticsHandler() {
Graph g = producer.newInstance();
GraphStatisticsHandler sh = g.getStatisticsHandler();
if (sh != null) {
assertSame("getStatisticsHandler must always return the same object", sh, g.getStatisticsHandler());
}
}
Aggregations