### Question:
FileExtractor { static List<String> extractArchive(String archiveFile) { LOGGER.entering(archiveFile); LOGGER.fine("Extracting " + archiveFile); String archiveStreamType; boolean isCompressedArchive = false; String compressName = null; String outputArchiveName = null; List<String> files = new ArrayList<>(); if (BZip2Utils.isCompressedFilename(archiveFile)) { isCompressedArchive = true; compressName = CompressorStreamFactory.BZIP2; outputArchiveName = BZip2Utils.getUncompressedFilename(archiveFile); LOGGER.fine("Output archive name: " + outputArchiveName); } else if (GzipUtils.isCompressedFilename(archiveFile)) { isCompressedArchive = true; compressName = CompressorStreamFactory.GZIP; outputArchiveName = GzipUtils.getUncompressedFilename(archiveFile); LOGGER.fine("Output archive name: " + outputArchiveName); } String workingArchiveFile = archiveFile; if (isCompressedArchive) { LOGGER.fine("Found a compressed archive"); CompressorInputStream is; try { is = new CompressorStreamFactory().createCompressorInputStream(compressName, new FileInputStream( archiveFile)); FileOutputStream decompressStream = new FileOutputStream(outputArchiveName); IOUtils.copy(is, decompressStream); is.close(); decompressStream.close(); workingArchiveFile = outputArchiveName; files.add(outputArchiveName); } catch (CompressorException | IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } archiveStreamType = ArchiveStreamFactory.ZIP; if (workingArchiveFile.endsWith(".tar")) { archiveStreamType = ArchiveStreamFactory.TAR; } OutputStream outputFileStream = null; LOGGER.fine("Getting file list for archive " + workingArchiveFile); List<String> executableNameList = FileExtractor.getExecutableNames(); LOGGER.fine("Executable list: " + executableNameList.toString()); ArchiveInputStream archiveStream = null; try { archiveStream = new ArchiveStreamFactory().createArchiveInputStream(archiveStreamType, new FileInputStream( workingArchiveFile)); ArchiveEntry entry; while ((entry = archiveStream.getNextEntry()) != null) { String fileNameInEntry = getFileNameFromPath(entry.getName()); if (!entry.isDirectory() && executableNameList.contains(fileNameInEntry.toLowerCase())) { String filename = SeLionConstants.SELION_HOME_DIR + getFileNameFromPath(entry.getName()); File outputFile = new File(filename); if (outputFile.exists()) { outputFile.delete(); } outputFile.createNewFile(); LOGGER.fine(String.format("Creating output file %s.", outputFile.getAbsolutePath())); outputFileStream = new FileOutputStream(outputFile); IOUtils.copy(archiveStream, outputFileStream); LOGGER.fine("Is binary executable by application: " + outputFile.canExecute()); if (!outputFile.canExecute()) { LOGGER.fine("Setting the file to be executable"); outputFile.setExecutable(true); } files.add(filename); break; } } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Unable to extract archive", e); } finally { try { if (archiveStream != null) { archiveStream.close(); } if (outputFileStream != null) { outputFileStream.close(); } } catch (IOException e) { LOGGER.log(Level.SEVERE, "Error closing streams while extracting archive", e); } } LOGGER.exiting(files.toString()); return files; } FileExtractor();   }### Answer:
@Test public void testExtractingZip() { List<String> files = FileExtractor.extractArchive(DUMMY_ZIP_ARCHIVE_FILE_PATH); assertTrue(extractedFile.exists()); assertEquals(files.size(), 1); }
@Test public void testExtractingBzip2() { List<String> files = FileExtractor.extractArchive(DUMMY_BZ2_ARCHIVE_FILE_PATH); assertTrue(extractedFile.exists()); tarFile = new File( new File(FileExtractorTest.class.getResource("/artifacts/DummyBz2Archive.tar").getPath()) .getAbsolutePath()); assertTrue(tarFile.exists()); assertEquals(files.size(), 2); }