Eliminate Unnecessary printStackTrace() Calls
Stacktraces flood test logs for expected exceptions. This change
suppresses stacktraces in these instances.
Change-Id: Ie0239010579a495a42b68c1f3cf19e8b03f72eee
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1578
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
index 9a3de14..5bcad8c 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
@@ -900,7 +900,7 @@
} catch (Exception e) {
// An exception is expected.
failed = true;
- e.printStackTrace();
+ System.err.println("testFile " + testFile.toString() + " raised an exception: " + e);
}
if (!failed) {
throw new Exception("Test \"" + testFile + "\" FAILED!\n An exception" + "is expected.");
@@ -928,7 +928,7 @@
} catch (Exception e) {
// expected error happens
failed = true;
- e.printStackTrace();
+ System.err.println("testFile " + testFile.toString() + " raised an exception: " + e);
}
if (!failed) {
throw new Exception("Test \"" + testFile + "\" FAILED!\n An exception is expected.");
@@ -1219,7 +1219,7 @@
System.err.println("...Unexpected!");
Exception e = new Exception(
"Test \"" + cUnit.getName() + "\" FAILED!\nExpected error was not thrown...");
- e.printStackTrace();
+ System.err.println(e);
throw e;
} else if (numOfFiles == testFileCtxs.size()) {
LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName()
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
index 0789fa0..da8f810 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
@@ -91,9 +91,9 @@
"[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName() + " PASSED ");
queryCount++;
} catch (Exception e) {
- System.err.println("testFile " + testFile.toString() + " raised an exception:");
- e.printStackTrace();
+ System.err.println("testFile " + testFile.toString() + " raised an exception: " + e);
if (cUnit.getExpectedError().isEmpty()) {
+ e.printStackTrace();
System.err.println("...Unexpected!");
if (failedGroup != null) {
failedGroup.getTestCase().add(testCaseCtx.getTestCase());