| 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 |
|
|
|
|
|
| 99% |
Uncovered Elements: 1 (99) |
Complexity: 8 |
Complexity Density: 0.09 |
|
| 13 |
|
public class CheckerTest extends TestCase |
| 14 |
|
{ |
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
| 15 |
1
|
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 |
|
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
1
PASS
|
|
| 23 |
1
|
public void testOsBasedir() throws Exception... |
| 24 |
|
{ |
| 25 |
1
|
Checker c = new Checker(); |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 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 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
| 42 |
1
|
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(); |
| 51 |
|
|
| 52 |
|
|
| 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 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 1 |
Complexity Density: 0.05 |
1
PASS
|
|
| 68 |
1
|
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 |
|
|
| 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
|
|