public void createControlFile( String filename, Object[] row, OraBulkLoaderMeta meta ) throws KettleException {
    FileWriter fw = null;

    try {
      File controlFile = new File( getFileObject( filename, getTransMeta() ).getURL().getFile() );
      // Need to ensure that the parent directory they set exists for the control file.
      controlFile.getParentFile().mkdirs();
      controlFile.createNewFile();
      fw = new FileWriter( controlFile );
      fw.write( getControlFileContents( meta, getInputRowMeta(), row ) );
    } catch ( IOException ex ) {
      throw new KettleException( ex.getMessage(), ex );
    } finally {
      try {
        if ( fw != null ) {
          fw.close();
        }
      } catch ( Exception ex ) {
        // Ignore errors
      }
    }
  }
@Test
  public void testCreateControlFile() throws Exception {
    // Create a tempfile, so we can use the temp file path when we run the createControlFile method
    String tempTrueControlFilepath = tempControlFile.getAbsolutePath() + "A.txt";
    String expectedControlContents = "test";
    OraBulkLoaderMeta oraBulkLoaderMeta = mock( OraBulkLoaderMeta.class );
    RowMetaInterface rowMetaInterface = mock( RowMetaInterface.class );
    Object[] objectRow = {};

    doReturn( rowMetaInterface ).when( oraBulkLoader ).getInputRowMeta();
    doReturn( expectedControlContents ).when( oraBulkLoader ).getControlFileContents( oraBulkLoaderMeta, rowMetaInterface, objectRow );
    oraBulkLoader.createControlFile( tempTrueControlFilepath,  objectRow, oraBulkLoaderMeta );

    assertTrue( Files.exists( Paths.get( tempTrueControlFilepath ) ) );

    File tempTrueControlFile = new File( tempTrueControlFilepath );
    String tempTrueControlFileContents = new String( Files.readAllBytes( tempTrueControlFile.toPath() ) );
    assertEquals( expectedControlContents, tempTrueControlFileContents );
    tempTrueControlFile.delete();
  }