StorageConnector extends AbstractConnector { RepositoryConnection acquireConnection() throws SesameDriverException { if (!repository.isInitialized()) { initialize(); } LOG.trace("Acquiring repository connection."); return acquire(1); } StorageConnector(DriverConfiguration configuration); @Override void close(); @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 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, org.eclipse.rdf4j.model.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); void setRepository(Repository newRepository);  }
@Test void getConnectionRetriesOnErrorConfiguredNumberOfTimes() throws Exception { final int attempts = 3; final DriverConfiguration conf = TestUtils.createDriverConfig("urn:test"); conf.setProperty(SesameConfigParam.USE_VOLATILE_STORAGE, Boolean.TRUE.toString()); conf.setProperty(SesameConfigParam.RECONNECT_ATTEMPTS, Integer.toString(attempts)); this.connector = new StorageConnector(conf); final Repository repoMock = mock(Repository.class); final Field repoField = StorageConnector.class.getDeclaredField("repository"); repoField.setAccessible(true); ((Repository) repoField.get(connector)).shutDown(); repoField.set(connector, repoMock); when(repoMock.getConnection()).thenThrow(RepositoryException.class); when(repoMock.isInitialized()).thenReturn(true); assertThrows(SesameDriverException.class, () -> connector.acquireConnection()); verify(repoMock, times(attempts)).getConnection(); }