class TableMetadata {

    List<String> getColumnNames(String tableName) throws SQLException {
        List<String> result = Lists.newArrayList();
        try (
                Connection connection = connectionProvider.getConnection();
                PreparedStatement stmt = connection.prepareStatement(GET_COLUMN_NAMES_QUERY)) {
            stmt.setString(1, tableName);
            ResultSet rs = stmt.executeQuery();

            while (rs.next()) {
                result.add(rs.getString(1));
            }

            return result;
        } catch (SQLException sqle) {
            throw new DataAccessException(COLUMN_NAMES_ERROR + tableName, sqle);
        }
    }

}

class TableMetadataTest {

    @Mock AbstractConnectionProvider mockedConnectionProvider;
    @Mock Connection mockedConnection;
    @Mock PreparedStatement mockedStmt;
    @Mock ResultSet mockedResultSet;
     TableMetadata tableMetadata;

    @Test(groups = INTEGRATION)
    public void testGetColumnNamesForExistingTable() throws SQLException {

        tableMetadata = new TableMetadata(new MysqlConnectionProvider(URL, USERNAME, PASSWORD));
        List<String> columnNames = tableMetadata.getColumnNames(TEST_TABLE_NAME);

        assertEquals(columnNames.size(), 2);
        assertTrue(columnNames.contains("ID"));
        assertTrue(columnNames.contains("TXT"));
    }

}