SharedStorageConnector extends AbstractStorageConnector { @Override public AbstractResultSet executeSelectQuery(Query query, StatementOntology target) throws JenaDriverException { ensureOpen(); try { QueryExecution exec = QueryExecutionFactory.create(query, storage.getDataset()); final org.apache.jena.query.ResultSet rs = exec.execSelect(); return new SelectResultSet(exec, rs); } catch (RuntimeException e) { throw queryFailed(query, e); } } SharedStorageConnector(DriverConfiguration configuration); @Override synchronized void begin(); @Override synchronized void commit(); @Override void rollback(); @Override Collection<Statement> find(Resource subject, Property property, RDFNode value, String context); @Override boolean contains(Resource subject, Property property, RDFNode value, String context); @Override List<String> getContexts(); @Override void add(List<Statement> statements, String context); @Override void remove(List<Statement> statements, String context); @Override void remove(Resource subject, Property property, RDFNode object, String context); @Override AbstractResultSet executeSelectQuery(Query query, StatementOntology target); @Override AbstractResultSet executeAskQuery(Query query, StatementOntology target); @Override void executeUpdate(String query, StatementOntology target); @Override synchronized void close(); synchronized void reloadStorage(); synchronized void setDataset(Dataset dataset);  }
@Test public void executeSelectQueryReturnsQueryResultSet() throws Exception { final SharedStorageConnector connector = initConnector(); generateTestData(connector.storage.getDataset()); final Query query = QueryFactory.create("SELECT * WHERE { ?x a <" + TYPE_ONE + "> . }"); try (ResultSet result = connector.executeSelectQuery(query, StatementOntology.CENTRAL)) { assertNotNull(result); assertTrue(result.hasNext()); result.next(); assertEquals(SUBJECT, result.getString("x")); } }
@Test public void executeSelectQueryThrowsJenaDriverExceptionWhenQueryFails() throws Exception { final SharedStorageConnector connector = initConnector(); generateTestData(connector.storage.getDataset()); final Query query = QueryFactory.create("SELECT * WHERE { ?x a <" + TYPE_ONE + "> . }"); thrown.expect(JenaDriverException.class); thrown.expectMessage(containsString("Execution of query " + query + " failed")); doReturn(null).when(connector.storage).getDataset(); connector.executeSelectQuery(query, StatementOntology.CENTRAL); }