List of usage examples for org.apache.commons.io FileUtils contentEquals
public static boolean contentEquals(File file1, File file2) throws IOException
From source file:opendap.aggregation.FilterAsciiHeaderStreamTest.java
@Test public void testWrite_1() throws Exception { _in = new FileInputStream("resources/aggregation/unit-tests/source_1.txt"); _out = new FilterAsciiHeaderStream(new FileOutputStream("src/opendap/aggregation/dest.txt")); _out.set(false);/*from w w w. j a va 2s. c o m*/ grind(false); _out.set(true); _in = new FileInputStream("resources/aggregation/unit-tests/source_2.txt"); grind(true); // validate dest_2.txt here Assert.assertTrue(FileUtils.contentEquals(new File("src/opendap/aggregation/dest.txt"), new File("resources/aggregation/unit-tests/baseline_3.txt"))); }
From source file:opendap.aggregation.FilterAsciiHeaderStreamTest.java
@Test public void testWrite_2() throws Exception { _in = new FileInputStream("resources/aggregation/unit-tests/source_1.txt"); _out = new FilterAsciiHeaderStream(new FileOutputStream("src/opendap/aggregation/dest.txt")); _out.set(false);/* ww w .ja v a2 s . com*/ grind(false); _out.set(true); _in = new FileInputStream("resources/aggregation/unit-tests/source_2.txt"); grind(false); _out.set(true); _in = new FileInputStream("resources/aggregation/unit-tests/source_3.txt"); grind(true); // validate dest_2.txt here Assert.assertTrue(FileUtils.contentEquals(new File("src/opendap/aggregation/dest.txt"), new File("resources/aggregation/unit-tests/baseline_4.txt"))); }
From source file:opendap.aggregation.FilterAsciiHeaderStreamTest.java
@Test public void testWriteArray() throws Exception { _out = new FilterAsciiHeaderStream(new FileOutputStream("src/opendap/aggregation/dest.txt")); Path path = Paths.get("resources/aggregation/unit-tests/source_1.txt"); byte[] data = Files.readAllBytes(path); _out.set(false);/*from ww w . ja va 2 s .co m*/ _out.write(data); _out.close(); Assert.assertTrue(FileUtils.contentEquals(new File("src/opendap/aggregation/dest.txt"), new File("resources/aggregation/unit-tests/baseline_1.txt"))); }
From source file:opendap.aggregation.FilterAsciiHeaderStreamTest.java
@Test public void testWriteArray_1() throws Exception { _out = new FilterAsciiHeaderStream(new FileOutputStream("src/opendap/aggregation/dest.txt")); Path path = Paths.get("resources/aggregation/unit-tests/source_1.txt"); byte[] data = Files.readAllBytes(path); _out.set(false);/* w ww . j a v a 2 s.c o m*/ _out.write(data); data = Files.readAllBytes(Paths.get("resources/aggregation/unit-tests/source_2.txt")); _out.set(true); _out.write(data); _out.close(); Assert.assertTrue(FileUtils.contentEquals(new File("src/opendap/aggregation/dest.txt"), new File("resources/aggregation/unit-tests/baseline_3.txt"))); }
From source file:opendap.aggregation.FilterAsciiHeaderStreamTest.java
@Test public void testWriteArray_2() throws Exception { _out = new FilterAsciiHeaderStream(new FileOutputStream("src/opendap/aggregation/dest.txt")); Path path = Paths.get("resources/aggregation/unit-tests/source_1.txt"); byte[] data = Files.readAllBytes(path); _out.set(false);/*w w w . j av a 2 s . c o m*/ _out.write(data); data = Files.readAllBytes(Paths.get("resources/aggregation/unit-tests/source_2.txt")); _out.set(true); _out.write(data); data = Files.readAllBytes(Paths.get("resources/aggregation/unit-tests/source_3.txt")); _out.set(true); _out.write(data); _out.close(); Assert.assertTrue(FileUtils.contentEquals(new File("src/opendap/aggregation/dest.txt"), new File("resources/aggregation/unit-tests/baseline_4.txt"))); }
From source file:opendap.aggregation.FilterAsciiHeaderStreamTest.java
@Test public void testWrite_3() throws Exception { _out = new FilterAsciiHeaderStream(new FileOutputStream("src/opendap/aggregation/dest.txt")); byte[] data1 = Files.readAllBytes(Paths.get("resources/aggregation/unit-tests/source_1.txt")); byte[] data2 = Files.readAllBytes(Paths.get("resources/aggregation/unit-tests/source_2.txt")); byte[] data3 = Files.readAllBytes(Paths.get("resources/aggregation/unit-tests/source_3.txt")); byte[] data = new byte[data1.length + data2.length + data3.length]; System.arraycopy(data1, 0, data, 0, data1.length); System.arraycopy(data2, 0, data, data1.length, data2.length); System.arraycopy(data3, 0, data, data1.length + data2.length, data3.length); _out.set(false);/*from ww w. j av a 2 s . c o m*/ _out.write(data, 0, data1.length); _out.set(true); _out.write(data, data1.length, data2.length); _out.set(true); _out.write(data, data1.length + data2.length, data3.length); _out.close(); Assert.assertTrue(FileUtils.contentEquals(new File("src/opendap/aggregation/dest.txt"), new File("resources/aggregation/unit-tests/baseline_4.txt"))); }
From source file:org.activiti.crystalball.diagram.AuditTrailProcessDiagramGeneratorTest.java
@Test @Ignore("Order ") public void test() throws IOException { AuditTrailProcessDiagramGenerator generator = new AuditTrailProcessDiagramGenerator(); generator.setHistoryService(processEngine.getHistoryService()); generator.setRepositoryService((RepositoryServiceImpl) processEngine.getRepositoryService()); Map<String, Object> params = new HashMap<String, Object>(); params.put(AuditTrailProcessDiagramGenerator.PROCESS_INSTANCE_ID, processInstanceId); ImageIO.write(ImageIO.read(generator.generateLayer("png", params)), "png", new File("target/auditTrail1.png")); int i = 1;// w w w.ja v a2s . c o m while (processEngine.getTaskService().createTaskQuery().count() > 0) { Task task = processEngine.getTaskService().createTaskQuery().singleResult(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } processEngine.getTaskService().complete(task.getId()); File generatedFile = new File("target/auditTrail" + ++i + ".png"); ImageIO.write(ImageIO.read(generator.generateLayer("png", params)), "png", generatedFile); assertTrue(FileUtils.contentEquals(generatedFile, new File("src/test/resources/org/activiti/crystalball/diagram/auditTrail" + i + ".png"))); } }
From source file:org.activiti.crystalball.diagram.AuditTrailProcessDiagramGeneratorTest.java
@Test public void testSVG() throws IOException { AuditTrailProcessDiagramGenerator generator = new AuditTrailProcessDiagramGenerator(new SVGCanvasFactory()); generator.setHistoryService(processEngine.getHistoryService()); generator.setRepositoryService((RepositoryServiceImpl) processEngine.getRepositoryService()); Map<String, Object> params = new HashMap<String, Object>(); params.put(AuditTrailProcessDiagramGenerator.PROCESS_INSTANCE_ID, processInstanceId); FileUtils.copyInputStreamToFile(generator.generateLayer("svg", params), new File("target/auditTrail1.svg")); int i = 1;//ww w . j a v a2 s .c o m while (processEngine.getTaskService().createTaskQuery().count() > 0) { Task task = processEngine.getTaskService().createTaskQuery().singleResult(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } processEngine.getTaskService().complete(task.getId()); File generatedFile = new File("target/auditTrail" + ++i + ".svg"); FileUtils.copyInputStreamToFile(generator.generateLayer("svg", params), generatedFile); assertTrue(FileUtils.contentEquals(generatedFile, new File("src/test/resources/org/activiti/crystalball/diagram/auditTrail" + i + ".svg"))); } }
From source file:org.activiti.crystalball.diagram.ProcessDiagramGeneratorTest.java
@Ignore("Generator provides platform dependent images (fonts) see http://forums.activiti.org/en/viewtopic.php?f=6&t=4647&start=0") public void testGenerateProcessDefinition() throws IOException { String id = FINANCIALREPORT_PROCESS_KEY; DiagramLayerGenerator generator = new BasicProcessDiagramGenerator( (RepositoryServiceImpl) repositoryService); Map<String, Object> params = new HashMap<String, Object>(); params.put(AbstractProcessDiagramLayerGenerator.PROCESS_DEFINITION_ID, id); File expectedFile = new File( "src/test/resources/org/activiti/crystalball/diagram/BasicProcessDiagramGeneratorTest.testSimpleProcessDefinition.png"); File generatedFile = new File("target/BasicProcessDiagramGeneratorTest.testSimpleProcessDefinition.png"); ImageIO.write(ImageIO.read(generator.generateLayer("png", params)), "png", generatedFile); assertTrue(FileUtils.contentEquals(expectedFile, generatedFile)); }
From source file:org.activiti.crystalball.diagram.ProcessDiagramGeneratorTest.java
public void testGenerateProcessDefinitionSVG() throws IOException { String id = FINANCIALREPORT_PROCESS_KEY; DiagramLayerGenerator generator = new BasicProcessDiagramGenerator( (RepositoryServiceImpl) repositoryService, new SVGCanvasFactory()); Map<String, Object> params = new HashMap<String, Object>(); params.put(AbstractProcessDiagramLayerGenerator.PROCESS_DEFINITION_ID, id); File expectedFile = new File( "src/test/resources/org/activiti/crystalball/diagram/BasicProcessDiagramGeneratorTest.testSimpleProcessDefinition.svg"); File generatedFile = new File("target/BasicProcessDiagramGeneratorTest.testSimpleProcessDefinition.svg"); FileUtils.copyInputStreamToFile(generator.generateLayer("svg", params), generatedFile); assertTrue(FileUtils.contentEquals(expectedFile, generatedFile)); }