01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.runner;
04:
05: import fit.*;
06:
07: public class TestRunnerFixtureListener implements FixtureListener {
08: public Counts counts = new Counts();
09:
10: private boolean atStartOfResult = true;
11:
12: private PageResult currentPageResult;
13:
14: private TestRunner runner;
15:
16: public TestRunnerFixtureListener(TestRunner runner) {
17: this .runner = runner;
18: }
19:
20: public void tableFinished(Parse table) {
21: try {
22: String data = new String(FitServer.readTable(table),
23: "UTF-8");
24: if (atStartOfResult) {
25: int indexOfFirstLineBreak = data.indexOf("\n");
26: String pageTitle = data.substring(0,
27: indexOfFirstLineBreak);
28: data = data.substring(indexOfFirstLineBreak + 1);
29: currentPageResult = new PageResult(pageTitle);
30: atStartOfResult = false;
31: }
32: currentPageResult.append(data);
33: } catch (Exception e) {
34: e.printStackTrace();
35: }
36: }
37:
38: public void tablesFinished(Counts count) {
39: try {
40: currentPageResult.setCounts(count);
41: runner.acceptResults(currentPageResult);
42: atStartOfResult = true;
43: counts.tally(count);
44: } catch (Exception e) {
45: e.printStackTrace();
46: }
47: }
48: }
|