flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject flink git commit: [FLINK-1542] Test case at BlobUtilsTest should not assume user could not create new item in root directory
Date Mon, 16 Feb 2015 19:54:06 GMT
Repository: flink
Updated Branches:
  refs/heads/master 6ba5fcdf8 -> 5ab1f1f19


[FLINK-1542] Test case at BlobUtilsTest should not assume user could not create new item in
root directory

Sometimes, user that run tests could have write access to root dir such as creating /cannot-create-this
is possible, hence to exception thrown.

Need to construct a Flink test directory under directory specified under "java.io.tmpdir"
and change the permission to not allow create new
directory.

This closes #396


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/5ab1f1f1
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/5ab1f1f1
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/5ab1f1f1

Branch: refs/heads/master
Commit: 5ab1f1f197b4ab86382e7e20b4964e991663b62c
Parents: 6ba5fcd
Author: Henry Saputra <henry.saputra@gmail.com>
Authored: Fri Feb 13 13:44:29 2015 -0800
Committer: Stephan Ewen <sewen@apache.org>
Committed: Mon Feb 16 20:48:37 2015 +0100

----------------------------------------------------------------------
 .../flink/runtime/blob/BlobUtilsTest.java       | 28 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/5ab1f1f1/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobUtilsTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobUtilsTest.java
b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobUtilsTest.java
index a5c83b9..92c723c 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobUtilsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobUtilsTest.java
@@ -20,21 +20,45 @@ package org.apache.flink.runtime.blob;
 
 import static org.mockito.Mockito.mock;
 
+import com.google.common.io.Files;
+
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 import java.io.File;
 
 public class BlobUtilsTest {
 
+	private final static String CANNOT_CREATE_THIS = "cannot-create-this";
+
+	private File blobUtilsTestDirectory;
+
+	@Before
+	public void before() {
+		// Prepare test directory
+		blobUtilsTestDirectory = Files.createTempDir();
+
+		blobUtilsTestDirectory.setExecutable(true, false);
+		blobUtilsTestDirectory.setReadable(true, false);
+		blobUtilsTestDirectory.setWritable(false, false);
+	}
+
+	@After
+	public void after() {
+		// Cleanup test directory
+		blobUtilsTestDirectory.delete();
+	}
+
 	@Test(expected = Exception.class)
 	public void testExceptionOnCreateStorageDirectoryFailure() {
 		// Should throw an Exception
-		BlobUtils.initStorageDirectory("/cannot-create-this");
+		BlobUtils.initStorageDirectory(new File(blobUtilsTestDirectory, CANNOT_CREATE_THIS).getAbsolutePath());
 	}
 
 	@Test(expected = Exception.class)
 	public void testExceptionOnCreateCacheDirectoryFailure() {
 		// Should throw an Exception
-		BlobUtils.getStorageLocation(new File("/cannot-create-this"), mock(BlobKey.class));
+		BlobUtils.getStorageLocation(new File(blobUtilsTestDirectory, CANNOT_CREATE_THIS), mock(BlobKey.class));
 	}
 }


Mime
View raw message