Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1194

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................

Add JUnit Rule Implementation To Trace Test Methods

Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
---
M 
asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
A 
asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
A 
asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
M 
asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
M 
asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
M 
asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
M 
asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
7 files changed, 124 insertions(+), 42 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/94/1194/1

diff --git 
a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
index adb0d7a..4953ac8 100644
--- 
a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
+++ 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
@@ -27,8 +27,6 @@
 import java.util.ArrayList;
 
 import org.apache.commons.io.FileUtils;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
 
 public class AsterixTestHelper {
 
@@ -100,36 +98,4 @@
         }
     }
 
-    public static class RetainLogsRule extends TestWatcher {
-        private final File baseDir;
-        private final File destDir;
-        private long startTime;
-
-        public RetainLogsRule(File baseDir, File destDir) {
-            this.baseDir = baseDir;
-            this.destDir = destDir;
-        }
-
-        public RetainLogsRule(String baseDir, String destDir) {
-            this(new File(baseDir), new File(destDir));
-        }
-
-        @Override
-        protected void starting(Description description) {
-            startTime = System.currentTimeMillis();
-        }
-
-        @Override
-        protected void failed(Throwable e, Description description) {
-            File reportDir = new File(destDir, 
description.getTestClass().getName() + "." + description.getMethodName());
-            reportDir.mkdirs();
-            try {
-                AsterixTestHelper.deepSelectiveCopy(baseDir, reportDir,
-                        pathname -> pathname.getName().endsWith("log") &&
-                                pathname.lastModified() > startTime);
-            } catch (Exception e1) {
-                e1.printStackTrace();
-            }
-        }
-    }
 }
diff --git 
a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
new file mode 100644
index 0000000..39bd5e7
--- /dev/null
+++ 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
@@ -0,0 +1,57 @@
+/*
+ * 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 org.apache.asterix.test.base;
+
+import java.io.File;
+
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+public class RetainLogsRule extends TestWatcher {
+    private final File baseDir;
+    private final File destDir;
+    private long startTime;
+
+    public RetainLogsRule(File baseDir, File destDir) {
+        this.baseDir = baseDir;
+        this.destDir = destDir;
+    }
+
+    public RetainLogsRule(String baseDir, String destDir) {
+        this(new File(baseDir), new File(destDir));
+    }
+
+    @Override
+    protected void starting(Description description) {
+        startTime = System.currentTimeMillis();
+    }
+
+    @Override
+    protected void failed(Throwable e, Description description) {
+        File reportDir = new File(destDir, 
description.getTestClass().getName() + "." + description.getMethodName());
+        reportDir.mkdirs();
+        try {
+            AsterixTestHelper.deepSelectiveCopy(baseDir, reportDir,
+                    pathname -> pathname.getName().endsWith("log") &&
+                            pathname.lastModified() > startTime);
+        } catch (Exception e1) {
+            e1.printStackTrace();
+        }
+    }
+}
diff --git 
a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
new file mode 100644
index 0000000..99664a8
--- /dev/null
+++ 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
@@ -0,0 +1,59 @@
+/*
+ * 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 org.apache.asterix.test.base;
+
+import java.io.PrintStream;
+
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+/*
+ * Traces method entry/exit to System.out (or supplied PrintStream).  To use, 
add the following to your test class:
+ *
+ *   @Rule
+ *   public TestRule watcher = new TestMethodTracer();
+ */
+
+public class TestMethodTracer extends TestWatcher {
+
+    private final PrintStream out;
+
+    public TestMethodTracer(PrintStream out) {
+        this.out = out;
+    }
+
+    public TestMethodTracer() {
+        this(System.out);
+    }
+
+    @Override
+    protected void starting(Description description) {
+        out.println("+" + description.getMethodName());
+    }
+
+    @Override
+    protected void failed(Throwable e, Description description) {
+        out.println("-" + description.getMethodName() + ": FAILED");
+    }
+
+    @Override
+    protected void succeeded(Description description) {
+        out.println("-" + description.getMethodName() + ": SUCCEEDED");
+    }
+}
diff --git 
a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
 
b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
index 676137c..d9c902e 100644
--- 
a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
+++ 
b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
@@ -24,7 +24,7 @@
 import org.apache.asterix.external.util.ExternalDataConstants;
 import org.apache.asterix.external.util.IdentitiyResolverFactory;
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.test.runtime.HDFSCluster;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.asterix.testframework.context.TestFileContext;
@@ -65,7 +65,7 @@
             new File(StringUtils.join(new String[] { "target", 
"failsafe-reports" }, File.separator)).getAbsolutePath();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(
+    public TestRule retainLogs = new RetainLogsRule(
             AsterixInstallerIntegrationUtil.getManagixHome(), reportPath);
 
     @BeforeClass
diff --git 
a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
 
b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
index 57aaeee..ae98d19 100644
--- 
a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
+++ 
b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
@@ -24,7 +24,7 @@
 
 import org.apache.asterix.event.model.AsterixInstance.State;
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.AfterClass;
@@ -49,7 +49,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(
+    public TestRule retainLogs = new RetainLogsRule(
             AsterixInstallerIntegrationUtil.getManagixHome(), reportPath);
 
     @BeforeClass
diff --git 
a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
 
b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
index 68c009a..b55510a 100644
--- 
a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
+++ 
b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
@@ -26,7 +26,7 @@
 import java.util.logging.Logger;
 
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.io.FileUtils;
 import org.junit.AfterClass;
@@ -60,7 +60,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new 
AsterixTestHelper.RetainLogsRule(managixHomePath, reportPath);
+    public TestRule retainLogs = new RetainLogsRule(managixHomePath, 
reportPath);
 
     @BeforeClass
     public static void setUp() throws Exception {
diff --git 
a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
 
b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
index 9795702..98c0853 100644
--- 
a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
+++ 
b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
@@ -26,7 +26,7 @@
 import java.util.logging.Logger;
 
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.test.runtime.HDFSCluster;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.io.FileUtils;
@@ -58,7 +58,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new 
AsterixTestHelper.RetainLogsRule(managixHomePath, reportPath);
+    public TestRule retainLogs = new RetainLogsRule(managixHomePath, 
reportPath);
 
     @BeforeClass
     public static void setUp() throws Exception {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>

Reply via email to