// statement manipulation //////////////////////////////////////////////////
@Test
public void testGetStatementsS_POG() throws Exception {
SailConnection sc = sail.getConnection();
try {
sc.begin();
URI uriA = sail.getValueFactory().createURI("http://example.org/test/S_POG#a");
URI uriB = sail.getValueFactory().createURI("http://example.org/test/S_POG#b");
URI uriC = sail.getValueFactory().createURI("http://example.org/test/S_POG#c");
URI uriD = sail.getValueFactory().createURI("http://example.org/test/S_POG#d");
int before, after;
// default context, different S,P,O
sc.removeStatements(uriA, null, null);
sc.commit();
sc.begin();
before = countStatements(sc, uriA, null, null, false);
sc.addStatement(uriA, uriB, uriC);
sc.commit();
sc.begin();
after = countStatements(sc, uriA, null, null, false);
assertEquals(0, before);
System.out.flush();
assertEquals(1, after);
// one specific context, different S,P,O
sc.removeStatements(uriA, null, null, uriD);
sc.commit();
sc.begin();
before = countStatements(sc, uriA, null, null, false, uriD);
sc.addStatement(uriA, uriB, uriC, uriD);
sc.commit();
sc.begin();
after = countStatements(sc, uriA, null, null, false, uriD);
assertEquals(0, before);
assertEquals(1, after);
// one specific context, same S,P,O,G
sc.removeStatements(uriA, null, null, uriA);
sc.commit();
sc.begin();
before = countStatements(sc, uriA, null, null, false, uriA);
sc.addStatement(uriA, uriB, uriC, uriA);
sc.commit();
sc.begin();
after = countStatements(sc, uriA, null, null, false, uriA);
assertEquals(0, before);
assertEquals(1, after);
// default context, same S,P,O
sc.removeStatements(uriA, null, null);
sc.commit();
sc.begin();
before = countStatements(sc, uriA, null, null, false);
sc.addStatement(uriA, uriB, uriC);
sc.commit();
sc.begin();
after = countStatements(sc, uriA, null, null, false);
assertEquals(0, before);
assertEquals(1, after);
} finally {
sc.rollback();
sc.close();
}
}