Skip to content

Commit 853445a

Browse files
committed
improve move tests
1 parent c0d82d3 commit 853445a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/test/java/org/cryptomator/cryptofs/inuse/RealUseTokenTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void afterEach() {
7171

7272
try {
7373
tokenPersistor.shutdown();
74-
if(!tokenPersistor.awaitTermination(3000, TimeUnit.MILLISECONDS)) {
74+
if (!tokenPersistor.awaitTermination(3000, TimeUnit.MILLISECONDS)) {
7575
tokenPersistor.shutdownNow();
7676
}
7777
} catch (InterruptedException e) {
@@ -213,6 +213,7 @@ public void testMoveToNeverPersistedClosed() throws IOException {
213213

214214
token.moveToInternal(targetPath);
215215

216+
Awaitility.await().pollDelay(FILE_OPERATION_DELAY).until(() -> true); //give some time to ensure no event was triggered
216217
MatcherAssert.assertThat(watchKey.pollEvents(), Matchers.empty());
217218
Assertions.assertNull(useTokens.get(targetPath));
218219
}
@@ -231,10 +232,12 @@ public void testMoveToClosed() throws IOException {
231232
watchKey.pollEvents(); //clear watchEvents
232233
token.close();
233234
Awaitility.await().atMost(FILE_OPERATION_MAX) //
234-
.until(() -> !watchKey.pollEvents().isEmpty());
235+
.untilAsserted(() -> Assertions.assertTrue(Files.notExists(filePath)));
236+
watchKey.pollEvents(); //drain events
235237

236238
token.moveToInternal(targetPath);
237239

240+
Awaitility.await().pollDelay(FILE_OPERATION_DELAY).until(() -> true); //give some time to ensure no event was triggered
238241
MatcherAssert.assertThat(watchKey.pollEvents(), Matchers.empty());
239242
Assertions.assertNull(useTokens.get(targetPath));
240243
}

0 commit comments

Comments
 (0)