Skip to content

Commit

Permalink
make tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Feb 6, 2025
1 parent 4ac08d8 commit 3afe84c
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ public void basic() throws Exception {
anchor.click();
files = FileUtils.listFiles(downloadFolder, null, false);
assertEquals(2, files.size());
final Iterator<File> filesIter = files.iterator();
assertEquals("download", filesIter.next().getName());
assertEquals("download(1)", filesIter.next().getName());

// be order agnostic
assertTrue(files.removeIf(f -> f.getName().equals("download")));
assertTrue(files.removeIf(f -> f.getName().equals("download(1)")));
assertEquals(0, files.size());
}
finally {
FileUtils.deleteDirectory(downloadFolder);
Expand Down Expand Up @@ -140,9 +142,11 @@ public void basicFileNameFromUrl() throws Exception {
anchor.click();
files = FileUtils.listFiles(downloadFolder, null, false);
assertEquals(2, files.size());
final Iterator<File> filesIter = files.iterator();
assertEquals("test(1).txt", filesIter.next().getName());
assertEquals("test.txt", filesIter.next().getName());

// be order agnostic
assertTrue(files.removeIf(f -> f.getName().equals("test.txt")));
assertTrue(files.removeIf(f -> f.getName().equals("test(1).txt")));
assertEquals(0, files.size());
}
finally {
FileUtils.deleteDirectory(downloadFolder);
Expand Down Expand Up @@ -194,9 +198,11 @@ public void basicFileNameFromHeader() throws Exception {
anchor.click();
files = FileUtils.listFiles(downloadFolder, null, false);
assertEquals(2, files.size());
final Iterator<File> filesIter = files.iterator();
assertEquals("sample(1).pdf", filesIter.next().getName());
assertEquals("sample.pdf", filesIter.next().getName());

// be order agnostic
assertTrue(files.removeIf(f -> f.getName().equals("sample.pdf")));
assertTrue(files.removeIf(f -> f.getName().equals("sample(1).pdf")));
assertEquals(0, files.size());
}
finally {
FileUtils.deleteDirectory(downloadFolder);
Expand Down

0 comments on commit 3afe84c

Please sign in to comment.