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:43 UTC

[1/2] incubator-datafu git commit: DATAFU-106 Test files should be created in a subfolder of projects

Repository: incubator-datafu
Updated Branches:
  refs/heads/master 0b4b2e178 -> 278e3587b


DATAFU-106 Test files should be created in a subfolder of projects

Modified PigTests.java so that test files are created in the directory datafu-pig/build/test-files. Added a unit test(datafu-pig/src/test/java/datafu/test/TestFilesSubdirTest.java) for this.

Signed-off-by: Matthew Hayes <mh...@apache.org>


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

Branch: refs/heads/master
Commit: fa28ee6915c7076ca9684bb3c721da2d51ba3ba9
Parents: 0b4b2e1
Author: Piyush Sharma <ps...@gmail.com>
Authored: Wed Jan 18 03:10:23 2017 +0530
Committer: Matthew Hayes <mh...@apache.org>
Committed: Mon Feb 13 14:44:21 2017 -0800

----------------------------------------------------------------------
 .../java/datafu/test/TestFilesSubdirTest.java   | 39 ++++++++++++++++++++
 .../src/test/java/datafu/test/pig/PigTests.java | 16 +++++++-
 2 files changed, 53 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-datafu/blob/fa28ee69/datafu-pig/src/test/java/datafu/test/TestFilesSubdirTest.java
----------------------------------------------------------------------
diff --git a/datafu-pig/src/test/java/datafu/test/TestFilesSubdirTest.java b/datafu-pig/src/test/java/datafu/test/TestFilesSubdirTest.java
new file mode 100644
index 0000000..3e29c38
--- /dev/null
+++ b/datafu-pig/src/test/java/datafu/test/TestFilesSubdirTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package datafu.test;
+
+import java.io.File;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import datafu.test.pig.PigTests;
+
+public class TestFilesSubdirTest extends PigTests
+{
+
+	@Test
+	public void isWorkingDirTest()
+	{	
+		//the working directory should be datafu-pig/build/test-files for the PigTests
+		Assert.assertEquals(System.getProperty("user.dir").substring(System.getProperty("user.dir").lastIndexOf(File.separator)+1),"test-files");
+	}	
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-datafu/blob/fa28ee69/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 d1d6fcc..aef1c35 100644
--- a/datafu-pig/src/test/java/datafu/test/pig/PigTests.java
+++ b/datafu-pig/src/test/java/datafu/test/pig/PigTests.java
@@ -50,13 +50,25 @@ 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();		
+    
   }
-  
+	  
   @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");
     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")));
+  }
   
   protected String[] getDefaultArgs()
   {


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

Posted by mh...@apache.org.
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()