You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafu.apache.org by mh...@apache.org on 2017/02/13 22:45:44 UTC

[2/2] incubator-datafu git commit: Minor refactoring of user.dir usage for test file output location

Minor refactoring of user.dir usage for test file output location


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

Branch: refs/heads/master
Commit: 278e3587b8ec48408dea27f457426f5f7d6e9e4d
Parents: fa28ee6
Author: Matthew Hayes <mh...@apache.org>
Authored: Mon Feb 13 14:45:12 2017 -0800
Committer: Matthew Hayes <mh...@apache.org>
Committed: Mon Feb 13 14:45:12 2017 -0800

----------------------------------------------------------------------
 .../src/test/java/datafu/test/pig/PigTests.java   | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-datafu/blob/278e3587/datafu-pig/src/test/java/datafu/test/pig/PigTests.java
----------------------------------------------------------------------
diff --git a/datafu-pig/src/test/java/datafu/test/pig/PigTests.java b/datafu-pig/src/test/java/datafu/test/pig/PigTests.java
index aef1c35..6fa500d 100644
--- a/datafu-pig/src/test/java/datafu/test/pig/PigTests.java
+++ b/datafu-pig/src/test/java/datafu/test/pig/PigTests.java
@@ -43,6 +43,9 @@ import org.apache.pig.tools.parameters.ParseException;
 
 public abstract class PigTests
 {    
+  private String testFileDir;
+  private String savedUserDir;
+  
   @org.testng.annotations.BeforeClass
   public void beforeClass()
   {
@@ -50,24 +53,27 @@ public abstract class PigTests
     // however otherwise it is useful to see the errors
     Logger.getRootLogger().removeAllAppenders();
     Logger.getLogger(JvmMetrics.class).setLevel(Level.OFF);
-    //Test files will be created in the following sub-directory
-    new File(System.getProperty("user.dir")+File.separator+"build","test-files").mkdir();		
     
+    // Test files will be created in the following sub-directory
+    new File(System.getProperty("user.dir") + File.separator + "build", "test-files").mkdir();		
   }
 	  
   @org.testng.annotations.BeforeMethod
   public void beforeMethod(Method method)
   {	
-    //working directory needs to be changed to the location of the test files for the PigTests to work properly
-    System.setProperty("user.dir", System.getProperty("user.dir")+File.separator+"build"+File.separator+"test-files");
+    // working directory needs to be changed to the location of the test files for the PigTests to work properly
+    this.savedUserDir = System.getProperty("user.dir");
+    this.testFileDir = System.getProperty("user.dir") + File.separator + "build" + File.separator + "test-files";
+    System.setProperty("user.dir", this.testFileDir);
+    
     System.out.println("\n*** Running " + method.getName() + " ***");
   }
 
   @org.testng.annotations.AfterMethod 	
   public void afterMethod(Method method)
   {
-    //offset the change made in the location of the working directory in beforeMethod 
-    System.setProperty("user.dir", System.getProperty("user.dir").substring(0,System.getProperty("user.dir").lastIndexOf(File.separator+"build"+File.separator+"test-files")));
+    // restore the change made in the location of the working directory in beforeMethod 
+    System.setProperty("user.dir", this.savedUserDir);
   }
   
   protected String[] getDefaultArgs()