List of usage examples for org.apache.commons.io FileUtils contentEquals
public static boolean contentEquals(File file1, File file2) throws IOException
From source file:com.microsoft.alm.plugin.idea.common.setup.ApplicationStartupTest.java
@Test public void testCacheIdeLocationFirstTime() throws Exception { File expectedFile = File.createTempFile("expectedLocation", ".csv"); writeToFile(expectedFile, IDEA_NAME + "," + TEST_IDE_LOCATION + "\n"); ApplicationStartup appStartup = new ApplicationStartup(); appStartup.cacheIdeLocation(VSTS_DIR, TEST_IDE_LOCATION); Assert.assertTrue(FileUtils.contentEquals(expectedFile, new File(LOCATIONS_CSV_PATH))); }
From source file:com.silverpeas.workflow.engine.model.ProcessModelManagerImplTest.java
/** * Test of saveProcessModel method, of class ProcessModelManagerImpl. *///from ww w . j a v a2 s. c o m @org.junit.Test public void testSaveProcessModel() throws Exception { System.out.println("saveProcessModel"); String processFileName = "DemandeCongesSimple.xml"; boolean absolutePath = false; ProcessModelManagerImpl instance = new ProcessModelManagerImpl(); ProcessModel process = instance.loadProcessModel(processFileName, absolutePath); String resultFileName = "DemandeCongesSimpleSerial.xml"; instance.saveProcessModel(process, resultFileName); FileUtils.contentEquals(new File(instance.getProcessPath(processFileName)), new File(instance.getProcessPath(resultFileName))); }
From source file:de.tudarmstadt.ukp.dkpro.core.io.text.TokenizedTextWriterTest.java
@Test public void testMultipleFiles() throws UIMAException, IOException { String text = "This is the 1st sentence .\nHere is another sentence ."; File targetDir = context.getTestOutputFolder(); File targetFile = new File(targetDir, "id.txt"); File tokenized = new File("src/test/resources/tokenizedTexts/textTokenized.txt"); AnalysisEngineDescription writer = createEngineDescription(TokenizedTextWriter.class, TokenizedTextWriter.PARAM_TARGET_LOCATION, targetDir, TokenizedTextWriter.PARAM_SINGULAR_TARGET, false, TokenizedTextWriter.PARAM_OVERWRITE, true); TestRunner.runTest("id", writer, "en", text); assertTrue(targetDir.isDirectory()); assertTrue(targetFile.exists());// w ww . ja va2 s . com assertTrue(FileUtils.contentEquals(tokenized, targetFile)); }
From source file:com.amazonaws.ant.s3.DownloadFromS3TaskTests.java
@Test public void testDownloadFilesWithPrefix() throws IOException { DownloadFileFromS3Task task = new DownloadFileFromS3Task(); task.setProject(new Project()); task.setBucketName(BUCKET_NAME);//from w w w . j a va2 s . com task.setKeyPrefix(KEY_PREFIX); task.setDir(USER_DIR); resFile1 = new File(DIR + testFile1.getName()); resFile2 = new File(DIR + testFile2.getName()); resFile3 = new File(DIR + testFile3.getName()); task.execute(); assertTrue(FileUtils.contentEquals(testFile1, resFile1)); assertTrue(FileUtils.contentEquals(testFile2, resFile2)); assertTrue(FileUtils.contentEquals(testFile3, resFile3)); }
From source file:com.sonarsource.cobol.ebcdic.FileConverterTest.java
@Test public void shouldConvertEbcdicFile() throws Exception { converter = new FileConverter(FileConverter.CP1047, Charset.forName("UTF-8")); converter.setFixedLength(80);/*from w w w . j a va2 s .co m*/ File ebcdicFile = new File(FileConverterTest.class.getResource("/EBCDIC.txt").toURI()); File expectedOutputFile = new File(FileConverterTest.class.getResource("/ASCII.txt").toURI()); File workingFile = new File("target/converter/cobol.txt"); FileUtils.copyFile(ebcdicFile, workingFile); converter.convert(workingFile, workingFile); assertThat(FileUtils.contentEquals(workingFile, expectedOutputFile)).isTrue(); }
From source file:de.nbi.ontology.test.OntologyIndexTest.java
/** * Test, if concept labels are created properly. The input file contains a * URI in each line./*from ww w . j a v a 2 s.c om*/ * * @param inFile * an ontology * @throws IOException */ // @Test(dataProviderClass=OntologyDataProvider.class, dataProvider="indexTestFiles", // groups = {"functest"}) public void createIndex(File inFile) throws IOException { log.info("Processing " + inFile.getName()); String basename = FilenameUtils.removeExtension(inFile.getAbsolutePath()); File outFile = new File(basename + ".out"); File resFile = new File(basename + ".res"); index.reset(); index.load(new FileInputStream(inFile)); PrintWriter w = new PrintWriter(new FileWriter(outFile)); Map<String, OntClass[]> labelIdx = index.getLabelIndex(); for (String k : labelIdx.keySet()) { w.println(k + " = > " + Arrays.toString(labelIdx.get(k))); } List<String> prefixIdx = new ArrayList<String>(index.getPrefixIndex()); Collections.sort(prefixIdx); for (String p : prefixIdx) { w.println(p); } w.flush(); w.close(); Assert.assertTrue(FileUtils.contentEquals(outFile, resFile)); }
From source file:de.nbi.ontology.test.OntologyMatchTest.java
/** * Test, if terms are properly match to concept labels. The a list of terms * contains a term in each line./*from ww w .j a v a 2 s. c om*/ * * @param inFile * a list of terms * @throws IOException */ @SuppressWarnings("unchecked") @Test(dataProviderClass = TestFileProvider.class, dataProvider = "exactMatchTestFiles", groups = { "functest" }) public void exactMatch(File inFile) throws IOException { log.info("Processing " + inFile.getName()); String basename = FilenameUtils.removeExtension(inFile.getAbsolutePath()); File outFile = new File(basename + ".out"); File resFile = new File(basename + ".res"); List<String> terms = FileUtils.readLines(inFile); PrintWriter w = new PrintWriter(new FileWriter(outFile)); for (String term : terms) { log.trace("** matching " + term); w.println(index.getExactMatches(term)); } w.flush(); w.close(); Assert.assertTrue(FileUtils.contentEquals(outFile, resFile)); }
From source file:edu.cornell.med.icb.goby.modes.TestReformatCompactReadsMode.java
/** * Validates that the reformat compact reads mode is capable of reformatting when * given positions at the extreme minimum and maximum values. * * @throws IOException if there is a problem reading or writing to the files *//*from w w w. ja va2 s . c om*/ @Test public void startAndEndAtExtremes() throws IOException { final ReformatCompactReadsMode reformat = new ReformatCompactReadsMode(); final String inputFilename = "test-data/compact-reads/s_1_sequence_short.compact-reads"; reformat.setInputFilenames(inputFilename); reformat.setStartPosition(0L); reformat.setEndPosition(Long.MAX_VALUE); final String outputFilename = "test-results/reformat-test-extremes.compact-reads"; reformat.setOutputFile(outputFilename); reformat.execute(); assertTrue(FileUtils.contentEquals(new File(inputFilename), new File(outputFilename))); }
From source file:com.fizzed.blaze.ssh.SshIntegrationTest.java
@Test public void sftpPutAndGet() throws Exception { Path exampleFile = FileHelper.resourceAsPath("/example/test1.txt"); try (SshSession ssh = sshConnect(uri).configFile(sshConfigFile).run()) { try (SshSftpSession sftp = SecureShells.sshSftp(ssh).run()) { // make sure file does not exist on remote system sshExec(ssh, "rm", "-f", "test1.txt").run(); sftp.put().source(exampleFile).target(exampleFile.getFileName()).run(); File tempFile = File.createTempFile("blaze.", ".sshtest"); tempFile.deleteOnExit();//from www .j a v a 2 s . co m sftp.get().source(exampleFile.getFileName()).target(tempFile).run(); // files match? assertTrue("The files differ!", FileUtils.contentEquals(tempFile, exampleFile.toFile())); } } }
From source file:com.izforge.izpack.util.file.types.selectors.DifferentSelector.java
/** * this test is our selection test that compared the file with the destfile * * @param srcfile the source file//from ww w . ja v a 2s . c o m * @param destfile the destination file * @return true if the files are different */ protected boolean selectionTest(File srcfile, File destfile) { //if either of them is missing, they are different if (srcfile.exists() != destfile.exists()) { return true; } if (srcfile.length() != destfile.length()) { // different size =>different files return true; } if (!ignoreFileTimes) { //same date if dest timestamp is within granularity of the srcfile boolean sameDate; sameDate = destfile.lastModified() >= srcfile.lastModified() - granularity && destfile.lastModified() <= srcfile.lastModified() + granularity; // different dates => different files if (!sameDate) { return true; } } if (!ignoreContents) { //here do a bulk comparison try { return !FileUtils.contentEquals(srcfile, destfile); } catch (Exception e) { throw new IzPackException("while comparing " + srcfile + " and " + destfile, e); } } else { return false; } }