You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2015/01/12 18:01:09 UTC

incubator-slider git commit: SLIDER-749 jenkins on windows failing: add test of rename working, double file size

Repository: incubator-slider
Updated Branches:
  refs/heads/develop 2ad763cfb -> e4f5db951


SLIDER-749 jenkins on windows failing: add test of rename working, double file size


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/e4f5db95
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/e4f5db95
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/e4f5db95

Branch: refs/heads/develop
Commit: e4f5db95166ed5351f0056d1f1b9fa6202049484
Parents: 2ad763c
Author: Steve Loughran <st...@apache.org>
Authored: Mon Jan 12 17:00:59 2015 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Jan 12 17:00:59 2015 +0000

----------------------------------------------------------------------
 .../slider/other/TestLocalDirStatus.groovy      | 77 +++++++++++++++++---
 1 file changed, 67 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e4f5db95/slider-core/src/test/groovy/org/apache/slider/other/TestLocalDirStatus.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/other/TestLocalDirStatus.groovy b/slider-core/src/test/groovy/org/apache/slider/other/TestLocalDirStatus.groovy
index 6d4f15d..940e6f4 100644
--- a/slider-core/src/test/groovy/org/apache/slider/other/TestLocalDirStatus.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/other/TestLocalDirStatus.groovy
@@ -30,24 +30,71 @@ import org.junit.Test
 class TestLocalDirStatus extends SliderTestUtils {
 
 
-  public static final int SIZE = 0x100000
-
+  public static final int SIZE = 0x200000
+  
   @Test
   public void testTempDir() throws Throwable {
-    File tmpf = File.createTempFile("testl",".bin")
-    createAndReadFile(tmpf, SIZE)
-    tmpf.delete()
-    assert !tmpf.exists()
+    File tmpf = null
+    try {
+      tmpf = File.createTempFile("testl", ".bin")
+      createAndReadFile(tmpf, SIZE)
+      tmpf.delete()
+      assert !tmpf.exists()
+    } finally {
+      tmpf?.delete()
+    }
   }
   
   @Test
   public void testTargetDir() throws Throwable {
+    File target = target()
+    File tmpf = null
+    try {
+      tmpf = File.createTempFile("testl", ".bin", target)
+      createAndReadFile(tmpf, SIZE)
+      tmpf.delete()
+      assert !tmpf.exists()
+    } finally {
+      tmpf?.delete()
+    }
+  }
+
+  public File target() {
     File target = new File("target").absoluteFile
     assert target.exists()
-    File tmpf = File.createTempFile("testl", ".bin", target)
-    createAndReadFile(tmpf, SIZE)
-    tmpf.delete()
-    assert !tmpf.exists()
+    return target
+  }
+
+  @Test
+  public void testRenameInTargetDir() throws Throwable {
+    def target = target()
+    File tmpf = null, dst= null
+    try {
+      tmpf = File.createTempFile("testl", ".bin", target)
+      dst = File.createTempFile("test-dest", ".bin", target)
+      createRenameAndReadFile(tmpf, dst, SIZE)
+      assert !tmpf.exists()
+      dst.delete()
+    } finally {
+      tmpf?.delete()
+      dst?.delete()
+    } 
+  }
+  
+  @Test
+  public void testRenameInTmpDir() throws Throwable {
+    def target = target()
+    File tmpf = null, dst= null
+    try {
+      tmpf = File.createTempFile("testl", ".bin")
+      dst = File.createTempFile("test-dest", ".bin")
+      createRenameAndReadFile(tmpf, dst, SIZE)
+      assert !tmpf.exists()
+      dst.delete()
+    } finally {
+      tmpf?.delete()
+      dst?.delete()
+    } 
   }
   
   protected void createAndReadFile(File path, int len) {
@@ -57,6 +104,16 @@ class TestLocalDirStatus extends SliderTestUtils {
     assert path.length() == len
     def persisted = readFile(path)
     TestUtility.compareByteArrays(dataset, persisted, len)
+  }  
+  
+  protected void createRenameAndReadFile(File src, File dst , int len) {
+    byte[] dataset = TestUtility.dataset(len, 32, 128)
+    writeFile(src, dataset)
+    assert src.exists()
+    assert src.length() == len
+    assert src.renameTo(dst)
+    def persisted = readFile(dst)
+    TestUtility.compareByteArrays(dataset, persisted, len)
   }
   
   protected void writeFile(File path, byte[] dataset) {