List of usage examples for org.apache.commons.io FileUtils contentEquals
public static boolean contentEquals(File file1, File file2) throws IOException
From source file:org.orbisgis.mapcomposer.model.utils.IOControllerTest.java
@Test public final void loadTest() { SaveAndLoadHandler sh = new SaveAndLoadHandler(new GEManager(), new CAManager()); List<GraphicalElement> listGE = null; try {/*from ww w . j a v a2s . co m*/ listGE = sh.load(IOControllerTest.class.getResource("loadTest.xml").getPath()); } catch (IOException | ParserConfigurationException | SAXException e) { Assert.fail("\nFail to load loadTest.xml. Exception get : \n" + e.toString()); } try { sh.save(listGE, "target/loadTest1.xml"); } catch (IOException e) { Assert.fail("\nFail to save listGE. Exception get : \n" + e.getMessage()); } try { FileUtils.contentEquals(new File("target/loadTest.xml"), new File("target/loadTest1.xml")); } catch (IOException e) { Assert.assertNotSame("\nSaved and loaded file are different.", new File("target/loadTest.xml"), new File("target/loadTest1.xml")); } }
From source file:org.pentaho.di.job.entries.http.JobEntryHTTP_PDI208_Test.java
@Test public void testHTTPResultDefaultRows() throws IOException { File localFileForUpload = getInputFile("existingFile1", ".tmp"); File tempFileForDownload = File.createTempFile("downloadedFile1", ".tmp"); localFileForUpload.deleteOnExit();// w ww . j a va 2 s . c om tempFileForDownload.deleteOnExit(); Object[] r = new Object[] { HTTP_SERVER_BASEURL + "/uploadFile", localFileForUpload.getCanonicalPath(), tempFileForDownload.getCanonicalPath() }; RowMeta rowMetaDefault = new RowMeta(); rowMetaDefault.addValueMeta(new ValueMetaString("URL")); rowMetaDefault.addValueMeta(new ValueMetaString("UPLOAD")); rowMetaDefault.addValueMeta(new ValueMetaString("DESTINATION")); List<RowMetaAndData> rows = new ArrayList<RowMetaAndData>(); rows.add(new RowMetaAndData(rowMetaDefault, r)); Result previousResult = new Result(); previousResult.setRows(rows); JobEntryHTTP http = new JobEntryHTTP(); http.setParentJob(new Job()); http.setRunForEveryRow(true); http.setAddFilenameToResult(false); http.execute(previousResult, 0); assertTrue(FileUtils.contentEquals(localFileForUpload, tempFileForDownload)); }
From source file:org.pentaho.di.job.entries.http.JobEntryHTTP_PDI208_Test.java
@Test public void testHTTPResultCustomRows() throws IOException { File localFileForUpload = getInputFile("existingFile2", ".tmp"); File tempFileForDownload = File.createTempFile("downloadedFile2", ".tmp"); localFileForUpload.deleteOnExit();/*www. j a va 2 s . co m*/ tempFileForDownload.deleteOnExit(); Object[] r = new Object[] { HTTP_SERVER_BASEURL + "/uploadFile", localFileForUpload.getCanonicalPath(), tempFileForDownload.getCanonicalPath() }; RowMeta rowMetaDefault = new RowMeta(); rowMetaDefault.addValueMeta(new ValueMetaString("MyURL")); rowMetaDefault.addValueMeta(new ValueMetaString("MyUpload")); rowMetaDefault.addValueMeta(new ValueMetaString("MyDestination")); List<RowMetaAndData> rows = new ArrayList<RowMetaAndData>(); rows.add(new RowMetaAndData(rowMetaDefault, r)); Result previousResult = new Result(); previousResult.setRows(rows); JobEntryHTTP http = new JobEntryHTTP(); http.setParentJob(new Job()); http.setRunForEveryRow(true); http.setAddFilenameToResult(false); http.setUrlFieldname("MyURL"); http.setUploadFieldname("MyUpload"); http.setDestinationFieldname("MyDestination"); http.execute(previousResult, 0); assertTrue(FileUtils.contentEquals(localFileForUpload, tempFileForDownload)); }
From source file:org.pentaho.di.trans.steps.excelinput.PoiWorkBookIT.java
License:asdf
@Test public void testFileDoesNotChange() throws KettleException, IOException { File fileBeforeRead = new File(sampleFile); readData(sampleFile, null);/*from w w w. j av a 2s . com*/ File fileAfterRead = new File(sampleFile); assertTrue(FileUtils.contentEquals(fileBeforeRead, fileAfterRead)); }
From source file:org.pentaho.di.trans.steps.excelinput.PoiWorkBookTest.java
@Test public void testFileDoesNotChange() throws KettleException, IOException { File fileBeforeRead = new File("testfiles/sample-file.xlsx"); readData();//from w w w . j a va2s .c o m File fileAfterRead = new File("testfiles/sample-file.xlsx"); assertTrue(FileUtils.contentEquals(fileBeforeRead, fileAfterRead)); }
From source file:org.pentaho.di.trans.steps.excelinput.StaxWorkBookIT.java
@Test public void testFileDoesNotChange() throws KettleException, IOException { File fileBeforeRead = new File(sample); readData(sample);/*ww w. j av a 2 s. c om*/ File fileAfterRead = new File(sample); assertTrue(FileUtils.contentEquals(fileBeforeRead, fileAfterRead)); }
From source file:org.pentaho.di.trans.steps.normaliser.NormaliserMetaInjectionIT.java
@Test public void injectValuesToNormaliserTransformation() throws Exception { trans = createTransformationFromFile( "src/it/resources/org/pentaho/di/trans/steps/normaliser/injecting-trans-pdi-13761.ktr"); runTransformation(trans);/*from ww w . j ava 2s . c o m*/ String outputFileName = trans.getVariable(OUTPUT_FILENAME); File expectedOutputFile = new File(EXPECTED_OUTPUT_FILE_NAME); assertTrue(FileUtils.contentEquals(expectedOutputFile, new File(outputFileName))); }
From source file:org.pentaho.di.trans.steps.normaliser.NormaliserMetaInjectionIT.java
@Test public void injectValuesToNormaliserTransformation_does_not_inject_fields() throws Exception { trans = createTransformationFromFile( "src/it/resources/org/pentaho/di/trans/steps/normaliser/injecting-trans-pdi-13761-does-not-inject-field.ktr"); runTransformation(trans);//from w ww . j ava 2 s.co m String outputFileName = trans.getVariable(OUTPUT_FILENAME); File expectedOutputFile = new File(EXPECTED_OUTPUT_FILE_NAME); assertTrue(FileUtils.contentEquals(expectedOutputFile, new File(outputFileName))); }
From source file:org.pentaho.di.trans.steps.textfileoutput.TextFileOutputTest.java
@Test public void testsIterate() { File resultFile = null;//from w w w . j a v a 2 s.co m File contentFile; String content = null; Boolean[] bool = new Boolean[] { false, true }; int i = 0; for (Boolean fileExists : bool) { for (Boolean dataReceived : bool) { for (Boolean isDoNotOpenNewFileInit : bool) { for (Boolean endLineExists : bool) { for (Boolean append : bool) { try { resultFile = helpTestInit(fileExists, dataReceived, isDoNotOpenNewFileInit, endLineExists, append); content = (String) contents.toArray()[i++]; contentFile = createTemplateFile(content); assertTrue(FileUtils.contentEquals(resultFile, contentFile)); } catch (Exception e) { Assert.fail(e.getMessage() + "\n FileExists = " + fileExists + "\n DataReceived = " + dataReceived + "\n isDoNotOpenNewFileInit = " + isDoNotOpenNewFileInit + "\n EndLineExists = " + endLineExists + "\n Append = " + append + "\n Content = " + content + "\n resultFile = " + resultFile); } } } } } } }
From source file:org.prorefactor.core.unittest.TP01FramesTest.java
public void test01() throws Exception { Schema schema = Schema.getInstance(); schema.clear();// w w w .java2 s . com schema.loadSchema(schemaName); ParseUnit pu = new ParseUnit(new File(inFileName)); pu.treeParser01(); JPNodeLister nodeLister = new TP01FramesTreeLister(pu.getTopNode(), outFileName, tokenTypes); nodeLister.print(); assertTrue("Differences in: " + expectFileName + " " + outFileName, FileUtils.contentEquals(new File(expectFileName), new File(outFileName))); }