KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > incava > analysis > TestTerseReport


1 package org.incava.analysis;
2
3 import java.io.*;
4 import java.util.*;
5 import junit.framework.TestCase;
6
7
8 public class TestTerseReport extends TestCase
9 {
10     public TestTerseReport(String JavaDoc name)
11     {
12         super(name);
13     }
14
15     public void testReportOrder()
16     {
17         StringWriter sw;
18         Report r;
19         
20         sw = new StringWriter();
21         r = new TerseReport(sw);
22         r.addViolation(new Violation("msg", 3, 5, 4, 6));
23         r.addViolation(new Violation("msg2", 5, 3, 6, 4));
24         assertEquals(2, r.getViolations().size());
25         r.flush();
26         
27         String JavaDoc str0 = sw.toString();
28         tr.Ace.log("str0: " + str0);
29
30         sw = new StringWriter();
31         r = new TerseReport(sw);
32         r.addViolation(new Violation("msg2", 5, 3, 6, 4));
33         r.addViolation(new Violation("msg", 3, 5, 4, 6));
34         assertEquals(2, r.getViolations().size());
35         r.flush();
36         
37         String JavaDoc str1 = sw.toString();
38         tr.Ace.log("str1: " + str1);
39
40         assertEquals("order of reported violations", str0, str1);
41     }
42
43     public void testOutput()
44     {
45         StringWriter sw = new StringWriter();
46         Report r = new TerseReport(sw);
47         r.addViolation(new Violation("msg", 3, 5, 4, 6));
48         r.addViolation(new Violation("msg2", 5, 3, 6, 4));
49         assertEquals(2, r.getViolations().size());
50         r.flush();
51         String JavaDoc str = sw.toString();
52         tr.Ace.log("str: " + str);
53
54         assertEquals("-:3:5:4:6: msg\n-:5:3:6:4: msg2\n", str);
55     }
56 }
57
58
Popular Tags