@AfterClass void cleanup() throws IOException { // clean up files created under the test directory
Files.walk(testDir).map(Path::toFile).forEach(File::delete);
Files.deleteIfExists(testDir);
}
// create files with size several times > BUFFER_SIZE to be used for tests that verify // the situations where they are read into full buffers a few times
size = BUFFER_SIZE << 3;
Path test65536a = createASCIIFile(testDir, "test65536a", size, -1, ' ');
Path test65536b = createASCIIFile(testDir, "test65536b", size, -1, ' ');
Path test65536m0 = createASCIIFile(testDir, "test65536m0", size, 0, '!');
Path test65536m32768 = createASCIIFile(testDir, "test65536m32768", size, size >> 1, '%');
Path test65536m65535 = createASCIIFile(testDir, "test65536m65535", size, size - 1, '$');
// create files with sizes that will be iterated several times with full buffers, and // then a partial one at the last
size = 70025;
Path test70025a = createASCIIFile(testDir, "test70025a", size, -1, ' ');
Path test70025b = createASCIIFile(testDir, "test70025b", size, -1, ' ');
Path test70025m8400 = createASCIIFile(testDir, "test70025m8400", size, 8400, '@');
Path test70025m35000 = createASCIIFile(testDir, "test70025m35000", size, 35000, '%');
Path test70025m70024 = createASCIIFile(testDir, "test70025m70024", size, 70024, '$');
// create larger files with >= 1048576. The mismatching will be similar. These are just // tests to exercise the process with larger files
size = 1048576;
Path test1048576a = createASCIIFile(testDir, "test1048576a", size, -1, ' ');
returnnew Object[][]{ // Spec Case 1: the two paths locate the same file , even if one does not exist
{foo, foo, MISMATCH_NO, "Same file, no mismatch"},
{test1024a, test1024a, MISMATCH_NO, "Same file, no mismatch"},
// Spec Case 2: The two files are the same size, and every byte in the first file // is identical to the corresponding byte in the second file.
{test0a, test0b, MISMATCH_NO, "Sizes == 0, no mismatch"},
{test147a, test147b, MISMATCH_NO, "size = 147 < buffer = 8192, no mismatch"},
{test1024a, test1024b, MISMATCH_NO, "size = 1024 < buffer = 8192, no mismatch"},
{test8192a, test8192b, MISMATCH_NO, "size = 8192 = buffer = 8192, no mismatch"},
{test65536a, test65536b, MISMATCH_NO, "read 8 * full buffer, no mismatch"},
{test70025a, test70025b, MISMATCH_NO, "read 8 * full buffer plus a partial buffer, no mismatch"},
// edge case, one of the file sizes is zero // also covers Spec Case 4 and 6
{test147a, test147m0, 0, "mismatch = 0 (at the beginning)"},
{test65536m0, test65536a, 0, "mismatch = 0 (at the beginning)"},
/** *Comparesfilesofequalsizes
*/ // small files
{test147a, test147m70, 70, "read one partial buffer, mismatch = 70"},
{test147a, test147m146, 146, "read one partial buffer, mismatch = 146 (end)"},
{test1024a, test1024m512, 512, "read one partial buffer, mismatch = 512"},
{test1024a, test1024m1023, 1023, "read one partial buffer, mismatch = 1023 (end)"},
// file size >= Impl's Buffer Size
{test8192a, test8192m4096, 4096, "read one buffer, mismatch = 4096 "},
{test8192a, test8192m8191, 8191, "read one buffer, mismatch = 8191 (at the end)"},
// file size = n * Impl's Buffer Size
{test65536a, test65536m32768, 32768, "read through half of the file, mismatch = 32768"},
{test65536a, test65536m65535, 65535, "read through the whole file, mismatch = 65535 (at the end)"},
// file size = n * Impl's Buffer Size + x
{test70025a, test70025m8400, 8400, "mismatch in the 2nd buffer, mismatch = 8400"},
{test70025a, test70025m35000, 35000, "read about half of the file, mismatch = 35000"},
{test70025a, test70025m70024, 70024, "read through the whole file, mismatch = 70024 (at the end)"},
/** *Comparesfilesofunequalsizes
*/
{test8192m8191, test70025m35000, 8191, "mismatch at the end of the 1st file/buffer, mismatch = 8191"},
{test65536m32768, test70025m8400, 8400, "mismatch in the 2nd buffer, mismatch = 8400"},
{test70025m70024, test1065000m532500, 70024, "mismatch at the end of the 1st file, mismatch = 70024"},
/** *SpecCase4:returnsthesizeofthesmallerfile(inbytes)whenthefilesare *differentsizesandeverybyteofthesmallerfileisidenticaltothecorresponding *byteofthelargerfile. *Impl:similartocase3,coversarangeoffilesizes
*/
{test147a, test1024a, 147, "mismatch is the length of the smaller file: 147"},
{test1024a, test8192a, 1024, "mismatch is the length of the smaller file: 1024"},
{test1024a, test65536a, 1024, "mismatch is the length of the smaller file: 1024"},
{test8192a, test65536a, 8192, "mismatch is the length of the smaller file: 8192"},
{test70025a, test65536a, 65536, "mismatch is the length of the smaller file: 65536"},
{test1048576a, test1065000m1064999, 1048576, "mismatch is the length of the smaller file: 1048576"},
// Spec Case 5: This method is always reflexive (for Path f , mismatch(f,f) returns -1L) // See tests for Spec Case 1.
// Spec Case 6: If the file system and files remain static, then this method is symmetric // (for two Paths f and g, mismatch(f,g) will return the same value as mismatch(g,f)). // The following tests are selected from tests for Spec Case 3 with the order of // file paths switched, the returned values are the same as those for Case 3:
{test147m70, test147a, 70, "read one partial buffer, mismatch = 70"},
{test147m146, test147a, 146, "read one partial buffer, mismatch = 146 (end)"},
{test1024m512, test1024a, 512, "read one partial buffer, mismatch = 512"},
{test1024m1023, test1024a, 1023, "read one partial buffer, mismatch = 1023 (end)"},
{test70025m35000, test8192m8191, 8191, "mismatch at the end of the 1st file/buffer, mismatch = 8191"},
{test70025m8400, test65536m32768, 8400, "mismatch in the 2nd buffer, mismatch = 8400"},
{test1065000m532500, test70025m70024, 70024, "mismatch at the end of the 1st file, mismatch = 70024"},
};
}
/* *DataProviderformismatchtestsinvolvingZipFSusingafewtestcasesselected *fromthoseoftheoriginalmismatchtests.
*/
@DataProvider(name = "testMismatchZipfs") public Object[][] getDataForMismatchZipfs() throws IOException {
Path test1200 = createASCIIFile(testDir, "test1200", 1200, -1, ' ');
Path test9500 = createASCIIFile(testDir, "test9500", 9500, -1, ' ');
Path test9500m4200 = createASCIIFile(testDir, "test9500m4200", 9500, 4200, '!');
Path test80025 = createASCIIFile(testDir, "test80025", 80025, -1, ' ');
Path test1028500 = createASCIIFile(testDir, "test1028500", 1028500, -1, ' '); returnnew Object[][]{
{test1200, test1200, MISMATCH_NO, "Compares the file and its copy in zip, no mismatch"},
{test9500, test9500m4200, 4200, "Compares a copy of test9500m4200 in zip with test9500, shall return 4200"},
{test80025, test1028500, 80025, "mismatch is the length of the smaller file: 80025"},
};
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.