### Question:
DatasourceInMemoryServiceHelper { public static SerializedResultSet getSerializeableResultSet( String connectionName, String query, int rowLimit, IPentahoSession session ) throws DatasourceServiceException { SerializedResultSet serializedResultSet = null; SQLConnection sqlConnection = null; try { sqlConnection = getConnection( connectionName ); sqlConnection.setMaxRows( rowLimit ); sqlConnection.setReadOnly( true ); IPentahoResultSet resultSet = sqlConnection.executeQuery( query ); MarshallableResultSet marshallableResultSet = new MarshallableResultSet(); marshallableResultSet.setResultSet( resultSet ); IPentahoMetaData ipmd = resultSet.getMetaData(); if ( ipmd instanceof SQLMetaData ) { SQLMetaData smd = (SQLMetaData) ipmd; int[] columnTypes = smd.getJDBCColumnTypes(); List<List<String>> data = new ArrayList<List<String>>(); for ( MarshallableRow row : marshallableResultSet.getRows() ) { String[] rowData = row.getCell(); List<String> rowDataList = new ArrayList<String>( rowData.length ); for ( int j = 0; j < rowData.length; j++ ) { rowDataList.add( rowData[ j ] ); } data.add( rowDataList ); } serializedResultSet = new SerializedResultSet( columnTypes, marshallableResultSet.getColumnNames().getColumnName(), data ); } } catch ( Exception e ) { logger.error( Messages.getErrorString( "DatasourceInMemoryServiceHelper.ERROR_0005_QUERY_VALIDATION_FAILED", e.getLocalizedMessage() ), e ); throw new DatasourceServiceException( Messages .getErrorString( "DatasourceInMemoryServiceHelper.ERROR_0005_QUERY_VALIDATION_FAILED", e.getLocalizedMessage() ), e ); } finally { if ( sqlConnection != null ) { sqlConnection.close(); } } return serializedResultSet; }  static java.sql.Connection getDataSourceConnection( String connectionName ); static SQLConnection getConnection( String connectionName ); static SerializedResultSet getSerializeableResultSet( String connectionName, String query, int rowLimit,
                                                               IPentahoSession session ); static List<List<String>> getCsvDataSample( String fileLocation, boolean headerPresent, String delimiter,
                                                     String enclosure, int rowLimit );  }### Answer:
@Test public void testGetSerializeableResultSet() throws DatasourceServiceException, SQLException { SerializedResultSet rs = DatasourceInMemoryServiceHelper.getSerializeableResultSet( GENERIC_CONN_DRIVER_CLASS, SAMPLE_VALID_QUERY, 10, null ); assertNotNull( rs ); verify( sqlConnection ).close(); }
@Test public void testGetSerializeableResultSet_NullResultSet() throws SQLException { try { DatasourceInMemoryServiceHelper.getSerializeableResultSet( GENERIC_CONN_DRIVER_CLASS, SAMPLE_INVALID_QUERY, 10, null ); } catch ( DatasourceServiceException e ) { verify( sqlConnection ).close(); return; } fail( "We should get exception" ); }