PoolingStorageConnector extends AbstractConnector { @Override public boolean executeBooleanQuery(String query) throws SesameDriverException { if (transaction.isActive()) { return new ConnectionStatementExecutor(wrapConnection()).executeBooleanQuery(query); } READ.lock(); try { return centralConnector.executeBooleanQuery(query); } finally { READ.unlock(); } } PoolingStorageConnector(StorageConnector centralConnector); @Override TupleQueryResult executeSelectQuery(String query); @Override boolean executeBooleanQuery(String query); @Override void executeUpdate(String query); @Override List<Resource> getContexts(); @Override ValueFactory getValueFactory(); @Override void begin(); @Override void commit(); @Override void rollback(); @Override void close(); @Override void addStatements(Collection<Statement> statements); @Override void removeStatements(Collection<Statement> statements); @Override Collection<Statement> findStatements(Resource subject, IRI property, Value value, boolean includeInferred); @Override Collection<Statement> findStatements(Resource subject, IRI property, Value value,
                                                boolean includeInferred, IRI context); @Override boolean containsStatement(Resource subject, IRI property, Value value, boolean includeInferred); @Override boolean containsStatement(Resource subject, IRI property, Value value, boolean includeInferred, IRI context); @Override T unwrap(Class<T> cls);  }
@Test public void executeBooleanQueryRunsOnCentralConnectionWhenNoTransactionIsActive() throws Exception { final String query = "ASK some query"; connector.executeBooleanQuery(query); InOrder inOrder = inOrder(readLock, centralMock); inOrder.verify(readLock).lock(); inOrder.verify(centralMock).executeBooleanQuery(query); inOrder.verify(readLock).unlock(); }
@Test(expected = SesameDriverException.class) public void unlocksReadLockWhenExecuteBooleanQueryThrowsException() throws Exception { final String query = "ASK some query"; when(centralMock.executeBooleanQuery(query)).thenThrow(new SesameDriverException()); try { connector.executeBooleanQuery(query); } finally { verify(readLock).unlock(); } }