Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
105   309   22   5
2   201   0.21   5.25
21     1.05  
4    
 
  CheckerTest       Line # 13 99% 0.989899
8 90 8 8 0.09
  DebugChecker       Line # 221 100% 1.0
3 3 3 3 1
  DebugAuditAdapter       Line # 238 87.5% 0.875
8.12 8 8 8 1
  DebugFilter       Line # 290 100% 1.0
3 4 3 3 0.75
 
  (7)
 
1    package com.puppycrawl.tools.checkstyle;
2   
3    import java.io.File;
4   
5    import junit.framework.TestCase;
6   
7    import com.puppycrawl.tools.checkstyle.api.AuditEvent;
8    import com.puppycrawl.tools.checkstyle.api.AuditListener;
9    import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
10    import com.puppycrawl.tools.checkstyle.api.Filter;
11    import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
12   
 
13    public class CheckerTest extends TestCase
14    {
 
15  1 toggle public void testDosBasedir() throws Exception
16    {
17  1 Checker c = new Checker();
18   
19  1 c.setBasedir("c:/a\\b/./c\\..\\d");
20  1 assertEquals("C:\\a\\b\\d", c.getBasedir());
21    }
22   
 
23  1 toggle public void testOsBasedir() throws Exception
24    {
25  1 Checker c = new Checker();
26   
27    // we need something to create absolute path
28    // let's take testinputs.dir
29  1 String testinputs_dir = System.getProperty("testinputs.dir");
30   
31  1 if (!testinputs_dir.endsWith(File.separator)) {
32  1 testinputs_dir += File.separator;
33    }
34   
35  1 c.setBasedir(testinputs_dir + "indentation/./..\\coding\\");
36   
37   
38  1 assertEquals(testinputs_dir + "coding", c.getBasedir());
39    }
40   
41   
 
42  1 toggle public void testDestroy() throws Exception
43    {
44  1 DebugChecker c= new DebugChecker();
45  1 DebugAuditAdapter aa = new DebugAuditAdapter();
46  1 c.addListener(aa);
47  1 DebugFilter f = new DebugFilter();
48  1 c.addFilter(f);
49   
50  1 c.destroy(); // should remove al listeners and filters
51   
52    // Let's try fire some events
53  1 c.fireAuditStarted();
54  1 c.fireAuditFinished();
55  1 c.fireFileStarted("Some File Name");
56  1 c.fireFileFinished("Some File Name");
57   
58  1 LocalizedMessage[] msgs = new LocalizedMessage[1];
59  1 msgs[0] = new LocalizedMessage(0, 0, "a Bundle", "message.key",
60    new Object[] {"arg"}, null,
61    getClass());
62  1 c.fireErrors("Some File Name", msgs);
63   
64  1 assertFalse("Checker.destroy() doesn't remove listeners.", aa.wasCalled());
65  1 assertFalse("Checker.destroy() doesn't remove filters.", f.wasCalled());
66    }
67   
 
68  1 toggle public void testAddListener() throws Exception
69    {
70  1 DebugChecker c= new DebugChecker();
71  1 DebugAuditAdapter aa = new DebugAuditAdapter();
72  1 c.addListener(aa);
73   
74    // Let's try fire some events
75  1 c.fireAuditStarted();
76  1 assertTrue("Checker.fireAuditStarted() doesn't call listener", aa.wasCalled());
77   
78  1 aa.resetListener();
79  1 c.fireAuditFinished();
80  1 assertTrue("Checker.fireAuditFinished() doesn't call listener", aa.wasCalled());
81   
82  1 aa.resetListener();
83  1 c.fireFileStarted("Some File Name");
84  1 assertTrue("Checker.fireFileStarted() doesn't call listener", aa.wasCalled());
85   
86  1