Example usage for org.apache.commons.io.comparator ExtensionFileComparator ExtensionFileComparator

List of usage examples for org.apache.commons.io.comparator ExtensionFileComparator ExtensionFileComparator

Introduction

In this page you can find the example usage for org.apache.commons.io.comparator ExtensionFileComparator ExtensionFileComparator.

Prototype

public ExtensionFileComparator() 

Source Link

Document

Construct a case sensitive file extension comparator instance.

Usage

From source file:org.bonitasoft.platform.configuration.util.FolderComparator.java

private void compareFileContent(File expectedFile, File givenFile) throws Exception {
    final String givenFileAbsolutePath = givenFile.getAbsolutePath();

    final String expectedFileExtension = getExtension(expectedFile.getName());
    final String expectedFileAbsolutePath = expectedFile.getAbsolutePath();
    assertThat(new ExtensionFileComparator().compare(expectedFile, givenFile))
            .as(expectedFileAbsolutePath + " and " + givenFileAbsolutePath + " should have same extension")
            .isEqualTo(ARE_EQUALS);//from w w  w . ja  va 2s .  c o m

    switch (expectedFileExtension) {
    case PROPERTIES:
        assertThat(getProperties(expectedFile)).as(
                expectedFileAbsolutePath + " and " + givenFileAbsolutePath + " should contain same properties")
                .isEqualTo(getProperties(givenFile));
        break;
    case XML:
        final List<Diff> allDifferences = new DetailedDiff(
                XMLUnit.compareXML(new FileReader(givenFile), new FileReader(expectedFile)))
                        .getAllDifferences();
        assertThat(allDifferences).as("should xml file be equals").isEmpty();
        break;
    default:
        fail("unexpected file:" + expectedFile.getAbsolutePath());
        break;
    }

}