Java Code Examples for org.apache.commons.io.FileUtils#contentEqualsIgnoreEOL()

The following examples show how to use org.apache.commons.io.FileUtils#contentEqualsIgnoreEOL() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StagingServicesImpl.java    From mdw with Apache License 2.0 6 votes vote down vote up
/**
 * Staged asset vs main.
 */
private void addDiffInfo(String pkg, AssetInfo assetInfo) throws ServiceException {
    AssetInfo mainAssetInfo = ServiceLocator.getAssetServices().getAsset(pkg + "/" + assetInfo.getName());
    if (mainAssetInfo == null) {
        assetInfo.setVcsDiffType(DiffType.EXTRA);
    }
    else if (assetInfo.getVcsDiffType() != DiffType.MISSING) {
        try {
            if (!FileUtils.contentEqualsIgnoreEOL(assetInfo.getFile(), mainAssetInfo.getFile(), null)) {
                assetInfo.setVcsDiffType(DiffType.DIFFERENT);
            }
        }
        catch (IOException ex) {
            logger.error(ex.getMessage(), ex);
        }
    }
}
 
Example 2
Source File: CsvIntegrationTest.java    From yarg with Apache License 2.0 6 votes vote down vote up
@Test
public void testCsv() throws Exception {
    BandData root = createRootCsvTree();

    FileOutputStream outputStream = new FileOutputStream("./result/integration/result.csv");
    ReportFormatter formatter = new DefaultFormatterFactory().createFormatter(new FormatterFactoryInput("csv", root,
            new ReportTemplateImpl("", "test.csv", "./modules/core/test/integration/test.csv", ReportOutputType.csv), outputStream));
    formatter.renderDocument();

    IOUtils.closeQuietly(outputStream);

    File sample = new File("./modules/core/test/integration/ethalon.csv");
    File result = new File("./result/integration/result.csv");
    boolean isTwoEqual = FileUtils.contentEqualsIgnoreEOL(sample, result, null);

    Assert.assertTrue("Files are not equal", isTwoEqual);
}
 
Example 3
Source File: CsvIntegrationTest.java    From yarg with Apache License 2.0 6 votes vote down vote up
@Test
public void testCsvQuote() throws Exception {
    BandData root = createRootCsvTree();

    FileOutputStream outputStream = new FileOutputStream("./result/integration/result-quote.csv");
    ReportFormatter formatter = new DefaultFormatterFactory().createFormatter(new FormatterFactoryInput("csv", root,
            new ReportTemplateImpl("", "test-quote.csv", "./modules/core/test/integration/test-quote.csv", ReportOutputType.csv), outputStream));
    formatter.renderDocument();

    IOUtils.closeQuietly(outputStream);

    File sample = new File("./modules/core/test/integration/ethalon-quote.csv");
    File result = new File("./result/integration/result-quote.csv");
    boolean isTwoEqual = FileUtils.contentEqualsIgnoreEOL(sample, result, null);

    Assert.assertTrue("Files are not equal", isTwoEqual);
}
 
Example 4
Source File: HtmlGroovyIntegrationTest.java    From yarg with Apache License 2.0 5 votes vote down vote up
@Test
public void testHtmlFormatter() throws Exception {
    BandData root = new BandData("Root", null, BandOrientation.HORIZONTAL);

    BandData userBand = new BandData("User", root, BandOrientation.HORIZONTAL);
    userBand.addData("active", true);
    userBand.addData("login", "admin");
    root.addChild(userBand);
    root.setFirstLevelBandDefinitionNames(new HashSet<String>());
    root.getFirstLevelBandDefinitionNames().add("User");

    FileOutputStream outputStream = new FileOutputStream("./result/integration/html-groovy-test-result.html");

    ReportFormatter formatter = new DefaultFormatterFactory().createFormatter(new FormatterFactoryInput("html", root,
            new ReportTemplateImpl("", "./modules/core/test/integration/html-groovy-test-template.html",
                    "./modules/core/test/integration/html-groovy-test-template.html", ReportOutputType.html, true), outputStream));

    formatter.renderDocument();

    IOUtils.closeQuietly(outputStream);

    File sample = new File("./modules/core/test/integration/html-groovy-test-template-result.html");
    File result = new File("./result/integration/html-groovy-test-result.html");
    boolean isTwoEqual = FileUtils.contentEqualsIgnoreEOL(sample, result, null);

    Assert.assertTrue("Files are not equal", isTwoEqual);
}
 
Example 5
Source File: XlsxIntegrationTest.java    From yarg with Apache License 2.0 4 votes vote down vote up
@Test
public void testXlsxToCsv() throws Exception {
    BandData root = new BandData("Root", null, BandOrientation.HORIZONTAL);

    BandData band1_1 = new BandData("Band1", root, BandOrientation.HORIZONTAL);
    band1_1.addData("col1", 1);
    band1_1.addData("col2", 2);
    band1_1.addData("col3", 3);
    band1_1.addData("col4", 4);
    band1_1.addData("col5", 5);
    band1_1.addData("col6", 6);

    BandData band12_1 = new BandData("Band12", band1_1, BandOrientation.HORIZONTAL);
    band12_1.addData("col1", 10);
    band12_1.addData("col2", 20);
    band12_1.addData("col3", 30);

    BandData band12_2 = new BandData("Band12", band1_1, BandOrientation.HORIZONTAL);
    band12_2.addData("col1", 100);
    band12_2.addData("col2", 200);
    band12_2.addData("col3", 300);

    BandData band13_1 = new BandData("Band13", band1_1, BandOrientation.VERTICAL);
    band13_1.addData("col1", 190);
    band13_1.addData("col2", 290);

    BandData band13_2 = new BandData("Band13", band1_1, BandOrientation.VERTICAL);
    band13_2.addData("col1", 390);
    band13_2.addData("col2", 490);

    BandData band14_1 = new BandData("Band14", band1_1, BandOrientation.VERTICAL);
    band14_1.addData("col1", "v5");
    band14_1.addData("col2", "v6");

    BandData band14_2 = new BandData("Band14", band1_1, BandOrientation.VERTICAL);
    band14_2.addData("col1", "v7");
    band14_2.addData("col2", "v8");

    BandData band1_2 = new BandData("Band1", root, BandOrientation.HORIZONTAL);
    band1_2.addData("col1", 11);
    band1_2.addData("col2", 22);
    band1_2.addData("col3", 33);
    band1_2.addData("col4", 44);
    band1_2.addData("col5", 55);
    band1_2.addData("col6", 66);

    BandData band12_3 = new BandData("Band12", band1_2, BandOrientation.HORIZONTAL);
    band12_3.addData("col1", 40);
    band12_3.addData("col2", 50);
    band12_3.addData("col3", 60);

    BandData band12_4 = new BandData("Band12", band1_2, BandOrientation.HORIZONTAL);
    band12_4.addData("col1", 400);
    band12_4.addData("col2", 500);
    band12_4.addData("col3", 600);

    band1_1.addChild(band12_1);
    band1_1.addChild(band12_2);
    band1_1.addChild(band13_1);
    band1_1.addChild(band13_2);
    band1_1.addChild(band14_1);
    band1_1.addChild(band14_2);

    band1_2.addChild(band12_3);
    band1_2.addChild(band12_4);

    root.addChild(band1_1);
    root.addChild(band1_2);

    root.setFirstLevelBandDefinitionNames(new HashSet<String>());
    root.getFirstLevelBandDefinitionNames().add("Band1");

    FileOutputStream outputStream = new FileOutputStream("./result/integration/result_xlsx.csv");
    ReportFormatter formatter = new DefaultFormatterFactory().createFormatter(new FormatterFactoryInput("xlsx", root,
            new ReportTemplateImpl("", "./modules/core/test/integration/test.xlsx", "./modules/core/test/integration/test.xlsx", ReportOutputType.csv), outputStream));
    formatter.renderDocument();

    IOUtils.closeQuietly(outputStream);

    File sample = new File("./modules/core/test/integration/ethalon_xlsx.csv");
    File result = new File("./result/integration/result_xlsx.csv");
    boolean isTwoEqual = FileUtils.contentEqualsIgnoreEOL(sample, result, null);

    assertTrue("Files are not equal", isTwoEqual);
}