Repository: wicket Updated Branches: refs/heads/wicket-6.x efa1a6db2 -> 8b4aaa05e
WICKET-6236 honoring the javadoc by putting a wait only after the 10th failed attempt to delete a file Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/8b4aaa05 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/8b4aaa05 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/8b4aaa05 Branch: refs/heads/wicket-6.x Commit: 8b4aaa05e9b3526062f7db663b2881322ae87242 Parents: efa1a6d Author: Pedro Henrique Oliveira dos Santos <[email protected]> Authored: Mon Sep 5 04:31:23 2016 -0300 Committer: Pedro Henrique Oliveira dos Santos <[email protected]> Committed: Mon Sep 5 04:31:23 2016 -0300 ---------------------------------------------------------------------- wicket-util/pom.xml | 5 +++++ .../java/org/apache/wicket/util/file/Files.java | 17 ++++++++--------- .../org/apache/wicket/util/file/FilesTest.java | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/8b4aaa05/wicket-util/pom.xml ---------------------------------------------------------------------- diff --git a/wicket-util/pom.xml b/wicket-util/pom.xml index edd0bb9..0084d86 100755 --- a/wicket-util/pom.xml +++ b/wicket-util/pom.xml @@ -31,6 +31,11 @@ <artifactId>junit</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build> <pluginManagement> http://git-wip-us.apache.org/repos/asf/wicket/blob/8b4aaa05/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java b/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java index 471bf1c..48d21e7 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java @@ -129,15 +129,14 @@ public class Files { return true; } - - try - { - Thread.sleep(100); - } - catch (InterruptedException ix) - { - Thread.currentThread().interrupt(); - } + } + try + { + Thread.sleep(100); + } + catch (InterruptedException ix) + { + Thread.currentThread().interrupt(); } } } http://git-wip-us.apache.org/repos/asf/wicket/blob/8b4aaa05/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java b/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java index 1892105..3204881 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java @@ -16,6 +16,11 @@ */ package org.apache.wicket.util.file; +import static java.lang.System.currentTimeMillis; +import static org.hamcrest.Matchers.lessThan; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.io.IOException; import java.net.URL; @@ -63,6 +68,21 @@ public class FilesTest extends Assert } /** + * WICKET-6236 - honoring the javadoc by putting a wait only after the 10th failed attempt to delete a file + */ + @Test + public void dontWaitTooMuchIfCantDelete(){ + java.io.File f = mock(java.io.File.class); + when(f.isFile()).thenReturn(true); + when(f.delete()).thenReturn(false); + long start = currentTimeMillis(); + Files.remove(f); + long end = currentTimeMillis(); + assertThat(end - start, lessThan(5000l)); + } + + + /** * Tests for {@link Files#removeFolder(java.io.File)} * * @throws Exception
