JenaDriver implements Closeable, ConnectionListener { JenaConnection acquireConnection() { ensureOpen(); final StorageConnector connector = connectorFactory.createConnector(); final JenaAdapter adapter = new JenaAdapter(connector, connectorFactory.createInferredConnector(connector)); final JenaConnection connection = new JenaConnection(adapter); connection.registerListener(this); connection.setAutoCommit(autoCommit); openConnections.add(connection); return connection; } JenaDriver(OntologyStorageProperties storageProperties, Map<String, String> properties); @Override void connectionClosed(JenaConnection connection); @Override synchronized void close(); @Override boolean isOpen();  }
@Test public void driverRegistersItselfAsListenerOnCreatedConnection() throws Exception { this.driver = new JenaDriver(storageProps, properties); final JenaConnection connection = driver.acquireConnection(); final Field listenerField = JenaConnection.class.getDeclaredField("listener"); listenerField.setAccessible(true); assertEquals(driver, listenerField.get(connection)); }
@Test public void driverCreatesAutoCommitConnectionsWhenConfiguredTo() { properties.put(OntoDriverProperties.CONNECTION_AUTO_COMMIT, Boolean.TRUE.toString()); this.driver = new JenaDriver(storageProps, properties); final JenaConnection connection = driver.acquireConnection(); assertTrue(connection.isAutoCommit()); }