protected void testFilesExists( HashMap<String, IFileStore> destMap, IFileStore sourceRoot, IFileStore sourceFile, int timeTolerance) throws CoreException { String relPath = EFSUtils.getRelativePath(sourceRoot, sourceFile, null); IFileStore destFile = destMap.get(relPath); // System.out.println("Comparing " + relPath); assertNotNull(MessageFormat.format("File {0} not found on destination", relPath), destFile); IFileInfo f1 = sourceFile.fetchInfo(IExtendedFileStore.DETAILED, null); IFileInfo f2 = destFile.fetchInfo(IExtendedFileStore.DETAILED, null); if (!f1.isDirectory()) { long sourceFileTime = f1.getLastModified(); long destFileTime = f2.getLastModified(); long timeDiff = destFileTime - sourceFileTime; assertTrue( MessageFormat.format( "File {0} is {1} seconds newer on destination", relPath, (int) timeDiff / 1000), -timeTolerance <= timeDiff && timeDiff <= timeTolerance); assertEquals( MessageFormat.format("File {0} different sizes", relPath), f1.getLength(), f2.getLength()); } }
protected void testFilesEqual( IFileStore root1, IFileStore root2, IFileStore file1, IFileStore file2) throws CoreException { String file1RelPath = EFSUtils.getRelativePath(root1, file1, null); String file2RelPath = EFSUtils.getRelativePath(root2, file2, null); assertEquals( MessageFormat.format("File {0} and {1} not equal", file1RelPath, file2RelPath), file1RelPath, file2RelPath); IFileInfo f1 = file1.fetchInfo(IExtendedFileStore.DETAILED, null); IFileInfo f2 = file2.fetchInfo(IExtendedFileStore.DETAILED, null); if (!f1.isDirectory()) { assertEquals( MessageFormat.format( "File {0} and {1} modification times differ", file1RelPath, file2RelPath), f1.getLastModified(), f2.getLastModified()); assertEquals( MessageFormat.format("File {0} and {1} different sizes", file1RelPath, file2RelPath), f1.getLength(), f2.getLength()); } }
protected void testDirectoriesEqual( IFileStore root1, IFileStore root2, boolean includeCloakedFiles, int timeTolerance) throws CoreException { IFileStore[] ctd = EFSUtils.getFiles(root1, true, includeCloakedFiles); IFileStore[] ccd = EFSUtils.getFiles(root2, true, includeCloakedFiles); // create map of files on destination HashMap<String, IFileStore> map = new HashMap<String, IFileStore>(); for (int i = 0; i < ccd.length; i++) { IFileStore fsTest = ccd[i]; String fileRelPath = EFSUtils.getRelativePath(root2, fsTest, null); map.put(fileRelPath, fsTest); } assertEquals(ctd.length, ccd.length); // iterate through source and ensure all files made it to dest for (int i = 0; i < ctd.length; i++) { IFileStore fsControl = ctd[i]; testFilesExists(map, root1, fsControl, timeTolerance); } }