### Question:
OraBulkDataOutput { public void open( IVariables variables, Process sqlldrProcess ) throws HopException { String loadMethod = meta.getLoadMethod(); try { OutputStream os; if ( OraBulkLoaderMeta.METHOD_AUTO_CONCURRENT.equals( loadMethod ) ) { os = sqlldrProcess.getOutputStream(); } else { String dataFilePath = getFilename( getFileObject( variables.environmentSubstitute( meta.getDataFile() ), variables ) ); File dataFile = new File( dataFilePath ); dataFile.getParentFile().mkdirs(); os = new FileOutputStream( dataFile, false ); } String encoding = meta.getEncoding(); if ( Utils.isEmpty( encoding ) ) { output = new BufferedWriter( new OutputStreamWriter( os ) ); } else { output = new BufferedWriter( new OutputStreamWriter( os, encoding ) ); } } catch ( IOException e ) { throw new HopException( "IO exception occured: " + e.getMessage(), e ); } } OraBulkDataOutput( OraBulkLoaderMeta meta, String recTerm ); void open( IVariables variables, Process sqlldrProcess ); void close(); @SuppressWarnings( "ArrayToString" ) void writeLine( IRowMeta mi, Object[] row );  }### Answer:
@Test public void testOpen() { try { File tempFile = TempFile.createTempFile( "temp", "test" ); String tempFilePath = tempFile.getAbsolutePath(); String dataFileVfsPath = "file: LocalFile tempFileObject = mock( LocalFile.class ); tempFile.deleteOnExit(); doReturn( dataFileVfsPath ).when( oraBulkLoaderMeta ).getDataFile(); doReturn( tempFilePath ).when( variables ).environmentSubstitute( dataFileVfsPath ); doReturn( tempFileObject ).when( oraBulkDataOutput ).getFileObject( tempFilePath, variables ); doReturn( tempFilePath ).when( oraBulkDataOutput ).getFilename( tempFileObject ); oraBulkDataOutput.open( variables, sqlldrProcess ); oraBulkDataOutput.close(); } catch ( Exception ex ) { fail( "If any exception occurs, this test fails: " + ex ); } }
@Test public void testOpenFileException() { doThrow( IOException.class ).when( oraBulkLoaderMeta ).getDataFile(); try { oraBulkDataOutput.open( variables, sqlldrProcess ); fail( "An IOException was supposed to be thrown, failing test" ); } catch ( HopException kex ) { assertTrue( kex.getMessage().contains( "IO exception occured:" ) ); } }