Example usage for org.apache.commons.io FileUtils contentEquals

List of usage examples for org.apache.commons.io FileUtils contentEquals

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils contentEquals.

Prototype

public static boolean contentEquals(File file1, File file2) throws IOException 

Source Link

Document

Compares the contents of two files to determine if they are equal or not.

Usage

From source file:es.uvigo.ei.sing.laimages.core.entities.datasets.VerticalElementDataTest.java

@Test
public void testVerticalElementDataToCSVVWithLibreOfficeFormatES() throws IOException {
    Locale.setDefault(new Locale("es", "ES"));

    File exportFile = exportElementToTmpCSVFile(TEST_ELEMENT_DATA_VERTICAL, FileFormat.LIBRE_OFFICE);

    assertTrue(FileUtils.contentEquals(TEST_ELEMENT_DATA_VERTICAL_LIBRE_OFFICE_ES, exportFile));
}

From source file:es.uvigo.ei.sing.laimages.core.entities.datasets.VerticalElementDataTest.java

@Test
public void testVerticalElementDataToCSVVWithLibreOfficeFormatUS() throws IOException {
    Locale.setDefault(new Locale("en", "US"));

    File exportFile = exportElementToTmpCSVFile(TEST_ELEMENT_DATA_VERTICAL, FileFormat.LIBRE_OFFICE);

    assertTrue(FileUtils.contentEquals(TEST_ELEMENT_DATA_VERTICAL_LIBRE_OFFICE_US, exportFile));
}

From source file:mitm.common.postfix.PostfixMainConfigBuilderTest.java

@Test
public void testBuildConfigNoChange() throws IOException {
    File inputFile = new File(baseDir, "main.cf");

    FileReader reader = new FileReader(inputFile);

    File outputFile = new File(tempDir, "main.cf.out");

    FileWriter writer = new FileWriter(outputFile);

    PostfixMainConfigBuilder builder = new PostfixMainConfigBuilder(reader);

    assertEquals("hostname.example.com", builder.getMyHostname().trim());
    assertEquals(2, builder.getMyDestinations().size());
    assertEquals("s1.example.com", new ArrayList<String>(builder.getMyDestinations()).get(0).trim());
    assertEquals("s2.example.com", new ArrayList<String>(builder.getMyDestinations()).get(1).trim());
    assertEquals(2, builder.getMyNetworks().size());
    assertEquals("127.0.0.0/24", new ArrayList<String>(builder.getMyNetworks()).get(0).trim());
    assertEquals("192.168.1.1/32", new ArrayList<String>(builder.getMyNetworks()).get(1).trim());
    assertEquals("relay.example.com", builder.getRelayHost());
    assertTrue(builder.isRelayHostMxLookup());
    /* we need to cast to long to prevent ambigous error */
    assertEquals(2525, (long) builder.getRelayHostPort());
    assertEquals(2, builder.getRelayDomains().size());
    assertEquals("backup.example.com", new ArrayList<String>(builder.getRelayDomains()).get(0).trim());
    assertEquals("backup2.example.com", new ArrayList<String>(builder.getRelayDomains()).get(1).trim());
    /* we need to cast to long to prevent ambigous error */
    assertEquals(123, (long) builder.getBeforeFilterMessageSizeLimit());
    assertEquals(456, (long) builder.getAfterFilterMessageSizeLimit());
    assertEquals(789, (long) builder.getMailboxSizeLimit());
    assertEquals("some helo name", builder.getSMTPHeloName());
    assertEquals("somehost.com", builder.getRelayTransportHost());
    assertTrue(builder.isRelayTransportHostMxLookup());
    assertEquals(2526, (long) builder.getRelayTransportHostPort());
    assertTrue(builder.isRejectUnverifiedRecipient());
    assertEquals("123", builder.getUnverifiedRecipientRejectCode());

    builder.writeConfig(writer);/*from   w w w .j a v a2 s.c o m*/

    writer.close();

    assertTrue(FileUtils.contentEquals(inputFile, outputFile));
}

From source file:CompareFiles.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:

    System.out.println(jLabel1.getText());
    File file1 = new File(jLabel1.getText());
    File file2 = new File(jLabel2.getText());

    try {//from   ww  w  .j  a v  a 2 s  .  c om
        boolean compare1 = FileUtils.contentEquals(file1, file2);

        JOptionPane.showMessageDialog(null, " the result is : " + compare1);
    } catch (IOException ex) {
        Logger.getLogger(CompareFiles.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:de.clusteval.utils.TestRepositoryObject.java

/**
 * Test method for//from   w  w w. j  a v  a  2s. co m
 * {@link framework.repository.RepositoryObject#copyTo(java.io.File, boolean)}
 * .
 * 
 * @throws IOException
 * @throws RegisterException
 * 
 */
@Test
public void testCopyToFileBoolean() throws IOException, RegisterException {
    File f = new File("testCaseRepository/data/goldstandards/DS1/Zachary_karate_club_gold_standard.txt")
            .getAbsoluteFile();
    this.repositoryObject = new StubRepositoryObject(this.getRepository(), false, f.lastModified(), f);
    File destFolder = new File("testCaseRepository/data/goldstandards/DS1/copy");
    if (destFolder.exists())
        FileUtils.deleteDirectory(destFolder);
    destFolder.mkdirs();
    this.repositoryObject.copyToFolder(destFolder);
    File destF = new File(
            "testCaseRepository/data/goldstandards/DS1/copy/Zachary_karate_club_gold_standard.txt");
    Assert.assertTrue(destF.exists());
    FileUtils.contentEquals(f, destF);
    file.FileUtils.delete(destF);
}

From source file:es.uvigo.ei.sing.laimages.core.entities.datasets.HorizontalElementDatasetTest.java

@Test
public void testElementDataToCSVVWithLibreOfficeFormatES() throws IOException {
    Locale.setDefault(new Locale("es", "ES"));

    File exportFile = exportElementToTmpCSVFile(TEST_ELEMENT_DATA, FileFormat.LIBRE_OFFICE);

    assertTrue(FileUtils.contentEquals(TEST_ELEMENT_DATA_LIBRE_OFFICE_ES, exportFile));
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.text.TokenizedTextWriterTest.java

@Test
public void testNumbers() throws UIMAException, IOException {
    File targetFile = new File(context.getTestOutputFolder(), "TokenizedTextWriterNoStopwords.out");
    targetFile.deleteOnExit();//  ww w .j  a v  a  2 s. co  m
    File tokenized = new File("src/test/resources/tokenizedTexts/textTokenizedNoNumbers.txt");
    String text = "This is 1 sentence .\nHere is 2 sentences , or even 2.5 .";
    String numbersRegex = "^[0-9]+(\\.[0-9]*)?$";

    AnalysisEngineDescription writer = createEngineDescription(TokenizedTextWriter.class,
            TokenizedTextWriter.PARAM_TARGET_LOCATION, targetFile, TokenizedTextWriter.PARAM_NUMBER_REGEX,
            numbersRegex, TokenizedTextWriter.PARAM_SINGULAR_TARGET, true, TokenizedTextWriter.PARAM_OVERWRITE,
            true);
    TestRunner.runTest("id", writer, "en", text);
    assertTrue(FileUtils.contentEquals(tokenized, targetFile));
}

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  w  w  w. ja v  a  2 s .co  m
 * 
 * @param inFile
 *            a list of terms
 * @throws IOException
 */
@SuppressWarnings("unchecked")
@Test(dataProviderClass = TestFileProvider.class, dataProvider = "similarTestFiles", groups = { "functest" })
public void similar(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.getSimilarMatches(term));
    }
    w.flush();
    w.close();

    Assert.assertTrue(FileUtils.contentEquals(outFile, resFile));
}

From source file:es.uvigo.ei.sing.laimages.core.entities.datasets.HorizontalElementDatasetTest.java

@Test
public void testElementDataToCSVVWithLibreOfficeFormatUS() throws IOException {
    Locale.setDefault(new Locale("en", "US"));

    File exportFile = exportElementToTmpCSVFile(TEST_ELEMENT_DATA, FileFormat.LIBRE_OFFICE);

    assertTrue(FileUtils.contentEquals(TEST_ELEMENT_DATA_LIBRE_OFFICE_US, exportFile));
}

From source file:edu.cornell.med.icb.goby.modes.TestReformatCompactReadsMode.java

/**
 * Validates that a subset of a compact reads file can be written.
 *
 * @throws IOException if there is a problem reading or writing to the files
 *///from  www . java 2s .c  o m
@Test
public void reformatStartOfCompactFile() throws IOException {
    final ReformatCompactReadsMode reformat = new ReformatCompactReadsMode();

    final String inputFilename = "test-data/compact-reads/s_1_sequence_short_1_per_chunk.compact-reads";
    reformat.setInputFilenames(inputFilename);
    reformat.setStartPosition(0);
    reformat.setEndPosition(10);
    final String outputFilename = "test-results/reformat-test-start.compact-reads";
    reformat.setOutputFile(outputFilename);
    reformat.execute();

    final File inputFile = new File(inputFilename);
    final File outputFile = new File(outputFilename);
    assertFalse("The reformatted file should not be the same as the original",
            FileUtils.contentEquals(inputFile, outputFile));

    final ReadsReader reader = new ReadsReader(FileUtils.openInputStream(outputFile));
    assertTrue("There should be reads in this file", reader.hasNext());
    final Reads.ReadEntry entry = reader.next();
    assertNotNull("Entry should not be null", entry);
    assertEquals("Reader returned the wrong sequence string", "CTCATGTTCATACACCTNTCCCCCATTCTCCTCCT",
            entry.getSequence().toString(Charset.defaultCharset().name()));
    assertFalse("There should be no other reads in this file", reader.hasNext());
}