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.Counts;
06: import fitnesse.util.StreamReader;
07: import fitnesse.testutil.AbstractRegex;
08:
09: public class CachingResultFormatterTest extends AbstractRegex {
10: public void testAddResult() throws Exception {
11: CachingResultFormatter formatter = new CachingResultFormatter();
12: PageResult result = new PageResult("PageTitle", new Counts(1,
13: 2, 3, 4), "content");
14: formatter.acceptResult(result);
15: formatter.acceptFinalCount(new Counts(1, 2, 3, 4));
16:
17: String content = new StreamReader(formatter.getResultStream())
18: .read(formatter.getByteCount());
19: assertSubString("0000000060", content);
20: assertSubString(result.toString(), content);
21: assertSubString("0000000001", content);
22: assertSubString("0000000002", content);
23: assertSubString("0000000003", content);
24: assertSubString("0000000004", content);
25: }
26:
27: public void testIsComposit() throws Exception {
28: CachingResultFormatter formatter = new CachingResultFormatter();
29: MockResultFormatter mockFormatter = new MockResultFormatter();
30: formatter.addHandler(mockFormatter);
31:
32: PageResult result = new PageResult("PageTitle", new Counts(1,
33: 2, 3, 4), "content");
34: formatter.acceptResult(result);
35: Counts counts = new Counts(1, 2, 3, 4);
36: formatter.acceptFinalCount(counts);
37:
38: assertEquals(1, mockFormatter.results.size());
39: assertEquals(result.toString(), mockFormatter.results.get(0)
40: .toString());
41: assertEquals(counts, mockFormatter.finalCounts);
42: }
43: }
|