public void open( VariableSpace space, Process sqlldrProcess ) throws KettleException {
    String loadMethod = meta.getLoadMethod();
    try {
      OutputStream os;

      if ( OraBulkLoaderMeta.METHOD_AUTO_CONCURRENT.equals( loadMethod ) ) {
        os = sqlldrProcess.getOutputStream();
      } else {
        // Else open the data file filled in.
        String dataFilePath = getFilename( getFileObject( space.environmentSubstitute( meta.getDataFile() ), space ) );
        File dataFile = new File( dataFilePath );
        // Make sure the parent directory exists
        dataFile.getParentFile().mkdirs();
        os = new FileOutputStream( dataFile, false );
      }

      String encoding = meta.getEncoding();
      if ( Utils.isEmpty( encoding ) ) {
        // Use the default encoding.
        output = new BufferedWriter( new OutputStreamWriter( os ) );
      } else {
        // Use the specified encoding
        output = new BufferedWriter( new OutputStreamWriter( os, encoding ) );
      }
    } catch ( IOException e ) {
      throw new KettleException( "IO exception occured: " + e.getMessage(), e );
    }
  }
@Test
  public void testOpen() {
    try {
      String tmpDir = System.getProperty("java.io.tmpdir");
      File tempFile = File.createTempFile("orafiles", "test" );
      String tempFilePath = tempFile.getAbsolutePath();
      String dataFileVfsPath = "file:///" + tempFilePath;
      LocalFile tempFileObject = mock( LocalFile.class );

      tempFile.deleteOnExit();

      doReturn( dataFileVfsPath ).when( oraBulkLoaderMeta ).getDataFile();
      doReturn( tempFilePath ).when( space ).environmentSubstitute( dataFileVfsPath );
      doReturn( tempFileObject ).when( oraBulkDataOutput ).getFileObject( tempFilePath, space );
      doReturn( tempFilePath ).when( oraBulkDataOutput ).getFilename( tempFileObject );

      oraBulkDataOutput.open( space, sqlldrProcess );
      oraBulkDataOutput.close();

    } catch ( Exception ex ) {
      fail( "If any exception occurs, this test fails: " + ex );
    }
  }