use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphMakerContractTest method testCanFindCreatedGraph.
/**
* 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));
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testDoubletonStatisticsWithTriples.
@ContractTest
public void testDoubletonStatisticsWithTriples() {
Graph g = graphWith(producer.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));
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testContains_Triple_Fluid.
@ContractTest
public void testContains_Triple_Fluid() {
Graph g = graphWith(producer.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 ??")));
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testAddWithReificationPreamble.
@ContractTest
public void testAddWithReificationPreamble() {
Graph g = producer.newInstance();
txnBegin(g);
xSPO(g);
txnCommit(g);
assertFalse(g.isEmpty());
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class TransactionHandlerContractTest method testExecuteInTransactionCatchesThrowable.
@SuppressWarnings("deprecation")
@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) {
}
try {
th.execute(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.calculate(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
}
}
Aggregations