1 package com.puppycrawl.tools.checkstyle.checks.usage; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 6 public class UnusedPrivateMethodCheckTest 7 extends BaseCheckTestCase 8 { 9 public void testDefault() throws Exception 10 { 11 final DefaultConfiguration checkConfig = 12 createCheckConfig(UnusedPrivateMethodCheck.class); 13 final String [] expected = { 14 "7:18: Unused private method 'methodUnused0'.", 15 "66:18: Unused private method 'writeObject'.", 16 "71:18: Unused private method 'readObject'.", 17 "76:20: Unused private method 'writeReplace'.", 18 "82:20: Unused private method 'readResolve'.", 19 "91:18: Unused private method 'writeObject'.", 20 "95:18: Unused private method 'writeObject'.", 21 "99:18: Unused private method 'writeObject'.", 22 "103:18: Unused private method 'readObject'.", 23 "107:18: Unused private method 'readObject'.", 24 "111:17: Unused private method 'writeReplace'.", 25 "116:20: Unused private method 'writeReplace'.", 26 "121:17: Unused private method 'readResolve'.", 27 "126:20: Unused private method 'readResolve'.", 28 "134:17: Unused private method 'writeObject'.", 29 "139:18: Unused private method 'readObject'.", 30 "143:20: Unused private method 'readResolve'.", 31 "151:17: Unused private method 'readObject'.", 32 }; 33 verify(checkConfig, getPath("usage/InputUnusedMethod.java"), expected); 34 } 35 36 public void testAllowSerializationMethods() throws Exception 37 { 38 final DefaultConfiguration checkConfig = 39 createCheckConfig(UnusedPrivateMethodCheck.class); 40 checkConfig.addAttribute("allowSerializationMethods", "true"); 41 42 final String [] expected = { 43 "7:18: Unused private method 'methodUnused0'.", 44 "91:18: Unused private method 'writeObject'.", 45 "95:18: Unused private method 'writeObject'.", 46 "99:18: Unused private method 'writeObject'.", 47 "103:18: Unused private method 'readObject'.", 48 "107:18: Unused private method 'readObject'.", 49 "111:17: Unused private method 'writeReplace'.", 50 "116:20: Unused private method 'writeReplace'.", 51 "121:17: Unused private method 'readResolve'.", 52 "126:20: Unused private method 'readResolve'.", 53 "134:17: Unused private method 'writeObject'.", 54 "139:18: Unused private method 'readObject'.", 55 "143:20: Unused private method 'readResolve'.", 56 "151:17: Unused private method 'readObject'.", 57 }; 58 verify(checkConfig, getPath("usage/InputUnusedMethod.java"), expected); 59 } 60 61 public void testInner() throws Exception 62 { 63 final DefaultConfiguration checkConfig = 64 createCheckConfig(UnusedPrivateMethodCheck.class); 65 final String [] expected = { 66 }; 67 verify(checkConfig, getPath("usage/InputInnerUsedMethod.java"), expected); 68 } 69 70 public void testEmptyFile() throws Exception 71 { 72 final DefaultConfiguration checkConfig = 73 createCheckConfig(UnusedPrivateMethodCheck.class); 74 final String [] expected = { 75 }; 76 verify(checkConfig, getPath("usage/InputEmptyFile.java"), expected); 77 } 78 } 79 | Popular Tags |