SesameDataSource implements DataSource { @Override public synchronized Connection getConnection() throws OntoDriverException { ensureOpen(); ensureConnected(); return driver.acquireConnection(); }  @Override synchronized void close(); @Override boolean isOpen(); @Override synchronized Connection getConnection(); @Override void setStorageProperties(OntologyStorageProperties storageProperties); @Override void setProperties(Map<String, String> properties); synchronized void setRepository(Repository repository);  }
@Test public void testGetConnection() throws Exception { Field connected = dataSource.getClass().getDeclaredField("connected"); connected.setAccessible(true); connected.set(dataSource, true); final Connection res = dataSource.getConnection(); verify(driverMock).acquireConnection(); assertNull(res); }
@Test(expected = IllegalStateException.class) public void testGetConnectionWithoutInitialization() throws Exception { final Connection res = dataSource.getConnection(); assert res == null; }