KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > FileSetCheckLifecycleTest


1 package com.puppycrawl.tools.checkstyle.checks;
2
3 import java.io.File JavaDoc;
4
5 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
6 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
7 import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
8 import com.puppycrawl.tools.checkstyle.api.Configuration;
9
10 public class FileSetCheckLifecycleTest
11     extends BaseCheckTestCase
12 {
13     protected DefaultConfiguration createCheckerConfig(
14         Configuration aCheckConfig)
15     {
16         final DefaultConfiguration dc = new DefaultConfiguration("root");
17         dc.addChild(aCheckConfig);
18         return dc;
19     }
20
21     public static class TestFileSetCheck extends AbstractFileSetCheck
22     {
23         private static boolean destroyed = false;
24
25         public void destroy()
26         {
27             destroyed = true;
28         }
29
30         public static boolean isDestroyed()
31         {
32             return destroyed;
33         }
34
35         public void process(File JavaDoc[] aFiles)
36         {
37         }
38     }
39
40     public void testTranslation()
41          throws Exception JavaDoc
42     {
43         final Configuration checkConfig =
44             createCheckConfig(TestFileSetCheck.class);
45         final String JavaDoc[] expected = {
46         };
47         verify(checkConfig, getPath("InputScopeAnonInner.java"), expected);
48
49         assertTrue("destroy() not called by Checker", TestFileSetCheck.isDestroyed());
50     }
51
52 }
53
Popular Tags