void () { IoTestUtil.assumeWindows(); File f = tempDir.newFile("temp_file"); assertTrue(f.exists()); long ts = 0; try (OutputStream os = new FileOutputStream(f)) { // This locks the file on Windows, preventing it from being deleted. // Utils.delete() will retry for about 100 ms. os.write("test".getBytes(StandardCharsets.UTF_8)); ts = System.nanoTime(); Utils.delete(f); fail("Utils.delete did not fail with the expected IOException on Windows"); } catch (IOException e) { ts = (System.nanoTime() - ts) / 1_000_000; assertEquals("Cannot delete: " + f.getAbsolutePath(), e.getMessage()); assertThat(ts).as("Utils.delete took " + ts + " ms, which is less than expected").isGreaterThanOrEqualTo(95); } }