diff options
author | Aidan Skinner <aidan@apache.org> | 2009-09-09 13:05:43 +0000 |
---|---|---|
committer | Aidan Skinner <aidan@apache.org> | 2009-09-09 13:05:43 +0000 |
commit | c1ebe66bfab328c5192a35c21ea290b5c45f40f5 (patch) | |
tree | 6e61e50d92442f29287a82c22b54de6beac43b2c /qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java | |
parent | 7b28732091473d93ce7546c70fa1d2dbd685161a (diff) | |
download | qpid-python-c1ebe66bfab328c5192a35c21ea290b5c45f40f5.tar.gz |
Merge from trunk
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-network-refactor@812936 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java')
-rw-r--r-- | qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java b/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java index df8dd0b85b..44ac5b4838 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java @@ -31,6 +31,7 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStreamWriter; +import java.util.ArrayList; import java.util.List; /** @@ -118,7 +119,7 @@ public class LogMonitor * @throws java.io.FileNotFoundException if the Log file can nolonger be found * @throws IOException thrown when reading the log file */ - public boolean waitForMessage(String message, long wait) + public boolean waitForMessage(String message, long wait, boolean printFileOnFailure) throws FileNotFoundException, IOException { // Loop through alerts until we're done or wait ms seconds have passed, @@ -126,20 +127,35 @@ public class LogMonitor BufferedReader reader = new BufferedReader(new FileReader(_logfile)); boolean found = false; long endtime = System.currentTimeMillis() + wait; + ArrayList<String> contents = new ArrayList<String>(); while (!found && System.currentTimeMillis() < endtime) { while (reader.ready()) { String line = reader.readLine(); + contents.add(line); if (line.contains(message)) { found = true; } } } - + if (!found && printFileOnFailure) + { + for (String line : contents) + { + System.out.println(line); + } + } return found; } + + + public boolean waitForMessage(String messageCountAlert, long alertLogWaitPeriod) throws FileNotFoundException, IOException + { + return waitForMessage(messageCountAlert, alertLogWaitPeriod, true); + } + /** * Read the log file in to memory as a String |