diff options
author | Julien Desprez <jdesprez@google.com> | 2020-02-24 09:21:26 -0800 |
---|---|---|
committer | Julien Desprez <jdesprez@google.com> | 2020-02-24 09:21:26 -0800 |
commit | ece24bb4c1623edca7e9b1c3cdb0cca93a332ac7 (patch) | |
tree | 720912663685a98934b78aa24dc8452114500792 | |
parent | 748515ea07c66110ba709e458c479d8c01f26d8e (diff) | |
download | loganalysis-ece24bb4c1623edca7e9b1c3cdb0cca93a332ac7.tar.gz |
Fix [CatchFail] situation
Test: unit tests
Bug: 148418189
Change-Id: I600e95f0d7ec9c59dc92055716d4eb36d79f83a6
3 files changed, 7 insertions, 30 deletions
diff --git a/tests/src/com/android/loganalysis/parser/BugreportParserFuncTest.java b/tests/src/com/android/loganalysis/parser/BugreportParserFuncTest.java index b759e98..802c5c0 100644 --- a/tests/src/com/android/loganalysis/parser/BugreportParserFuncTest.java +++ b/tests/src/com/android/loganalysis/parser/BugreportParserFuncTest.java @@ -20,7 +20,6 @@ import com.android.loganalysis.item.BugreportItem; import junit.framework.TestCase; import java.io.BufferedReader; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; @@ -36,21 +35,14 @@ public class BugreportParserFuncTest extends TestCase { * assist a developer in checking why a given bugreport file might not be parsed correctly by * Brillopad. */ - public void testParse() { - BufferedReader bugreportReader = null; - try { - bugreportReader = new BufferedReader(new FileReader(BUGREPORT_PATH)); - } catch (FileNotFoundException e) { - fail(String.format("File not found at %s", BUGREPORT_PATH)); - } + public void testParse() throws Exception { + BufferedReader bugreportReader = new BufferedReader(new FileReader(BUGREPORT_PATH)); BugreportItem bugreport = null; try { long start = System.currentTimeMillis(); bugreport = new BugreportParser().parse(bugreportReader); long stop = System.currentTimeMillis(); System.out.println(String.format("Bugreport took %d ms to parse.", stop - start)); - } catch (IOException e) { - fail(String.format("IOException: %s", e.toString())); } finally { if (bugreportReader != null) { try { diff --git a/tests/src/com/android/loganalysis/parser/LogcatParserFuncTest.java b/tests/src/com/android/loganalysis/parser/LogcatParserFuncTest.java index 7d63b19..5c43b75 100644 --- a/tests/src/com/android/loganalysis/parser/LogcatParserFuncTest.java +++ b/tests/src/com/android/loganalysis/parser/LogcatParserFuncTest.java @@ -20,7 +20,6 @@ import com.android.loganalysis.item.LogcatItem; import junit.framework.TestCase; import java.io.BufferedReader; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; @@ -36,21 +35,15 @@ public class LogcatParserFuncTest extends TestCase { * assist a developer in checking why a given logcat file might not be parsed correctly by * Brillopad. */ - public void testParse() { - BufferedReader logcatReader = null; - try { - logcatReader = new BufferedReader(new FileReader(LOGCAT_PATH)); - } catch (FileNotFoundException e) { - fail(String.format("File not found at %s", LOGCAT_PATH)); - } + public void testParse() throws Exception { + BufferedReader logcatReader = new BufferedReader(new FileReader(LOGCAT_PATH)); + LogcatItem logcat = null; try { long start = System.currentTimeMillis(); logcat = new LogcatParser().parse(logcatReader); long stop = System.currentTimeMillis(); System.out.println(String.format("Logcat took %d ms to parse.", stop - start)); - } catch (IOException e) { - fail(String.format("IOException: %s", e.toString())); } finally { if (logcatReader != null) { try { diff --git a/tests/src/com/android/loganalysis/parser/MonkeyLogParserFuncTest.java b/tests/src/com/android/loganalysis/parser/MonkeyLogParserFuncTest.java index 58fcebe..d4dec36 100644 --- a/tests/src/com/android/loganalysis/parser/MonkeyLogParserFuncTest.java +++ b/tests/src/com/android/loganalysis/parser/MonkeyLogParserFuncTest.java @@ -23,7 +23,6 @@ import com.android.loganalysis.item.MonkeyLogItem.DroppedCategory; import junit.framework.TestCase; import java.io.BufferedReader; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; @@ -39,21 +38,14 @@ public class MonkeyLogParserFuncTest extends TestCase { * assist a developer in checking why a given monkey log file might not be parsed correctly by * Brillopad. */ - public void testParse() { - BufferedReader monkeyLogReader = null; - try { - monkeyLogReader = new BufferedReader(new FileReader(MONKEY_LOG_PATH)); - } catch (FileNotFoundException e) { - fail(String.format("File not found at %s", MONKEY_LOG_PATH)); - } + public void testParse() throws Exception { + BufferedReader monkeyLogReader = new BufferedReader(new FileReader(MONKEY_LOG_PATH)); MonkeyLogItem monkeyLog = null; try { long start = System.currentTimeMillis(); monkeyLog = new MonkeyLogParser().parse(monkeyLogReader); long stop = System.currentTimeMillis(); System.out.println(String.format("Monkey log took %d ms to parse.", stop - start)); - } catch (IOException e) { - fail(String.format("IOException: %s", e.toString())); } finally { if (monkeyLogReader != null) { try { |