BackendConnection implements JDBCExecutionConnection { public void add(final Statement statement) { cachedStatements.add(statement); } BackendConnection(final TransactionType initialTransactionType); void setCurrentSchema(final String schemaName); @Override List<Connection> getConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode); @Override Statement createStorageResource(final Connection connection, final ConnectionMode connectionMode, final StatementOption option); @Override PreparedStatement createStorageResource(final String sql, final List<Object> parameters, 
                                                   final Connection connection, final ConnectionMode connectionMode, final StatementOption option); boolean isSerialExecute(); int getConnectionSize(); void add(final Statement statement); void add(final ResultSet resultSet); synchronized Collection<SQLException> closeResultSets(); synchronized Collection<SQLException> closeStatements(); synchronized Collection<SQLException> closeConnections(final boolean forceRollback);  }
@Test public void assertAddStatementCorrectly() throws NoSuchFieldException, IllegalAccessException { Statement statement = mock(Statement.class); backendConnection.add(statement); Field field = backendConnection.getClass().getDeclaredField("cachedStatements"); field.setAccessible(true); assertTrue(((Collection<Statement>) field.get(backendConnection)).contains(statement)); }
@Test public void assertAddResultSetCorrectly() throws NoSuchFieldException, IllegalAccessException { ResultSet resultSet = mock(ResultSet.class); backendConnection.add(resultSet); Field field = backendConnection.getClass().getDeclaredField("cachedResultSets"); field.setAccessible(true); assertTrue(((Collection<ResultSet>) field.get(backendConnection)).contains(resultSet)); }