1 package com.puppycrawl.tools.checkstyle.checks.javadoc; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 import com.puppycrawl.tools.checkstyle.api.Scope; 6 7 import java.io.File ; 8 9 public class JavadocVariableCheckTest 10 extends BaseCheckTestCase 11 { 12 public void testDefault() 13 throws Exception 14 { 15 final DefaultConfiguration checkConfig = 16 createCheckConfig(JavadocVariableCheck.class); 17 final String [] expected = { 18 "11:5: Missing a Javadoc comment.", 19 "304:5: Missing a Javadoc comment.", 20 "311:5: Missing a Javadoc comment.", 21 "330:5: Missing a Javadoc comment.", 22 }; 23 verify(checkConfig, getPath("InputTags.java"), expected); 24 } 25 26 public void testAnother() 27 throws Exception 28 { 29 final DefaultConfiguration checkConfig = 30 createCheckConfig(JavadocVariableCheck.class); 31 final String [] expected = { 32 "17:9: Missing a Javadoc comment.", 33 "24:9: Missing a Javadoc comment.", 34 "30:13: Missing a Javadoc comment.", 35 }; 36 verify(checkConfig, getPath("InputInner.java"), expected); 37 } 38 39 public void testAnother2() 40 throws Exception 41 { 42 final DefaultConfiguration checkConfig = 43 createCheckConfig(JavadocVariableCheck.class); 44 checkConfig.addAttribute("scope", Scope.PUBLIC.getName()); 45 final String [] expected = { 46 }; 47 verify(checkConfig, getPath("InputInner.java"), expected); 48 } 49 50 public void testAnother3() 51 throws Exception 52 { 53 final DefaultConfiguration checkConfig = 54 createCheckConfig(JavadocVariableCheck.class); 55 final String [] expected = { 56 "11:9: Missing a Javadoc comment.", 57 "16:13: Missing a Javadoc comment.", 58 "36:9: Missing a Javadoc comment.", 59 "43:5: Missing a Javadoc comment.", 60 "44:5: Missing a Javadoc comment.", 61 "45:5: Missing a Javadoc comment.", 62 "46:5: Missing a Javadoc comment.", 63 }; 64 verify(checkConfig, getPath("InputPublicOnly.java"), expected); 65 } 66 public void testAnother4() 67 throws Exception 68 { 69 final DefaultConfiguration checkConfig = 70 createCheckConfig(JavadocVariableCheck.class); 71 checkConfig.addAttribute("scope", Scope.PUBLIC.getName()); 72 final String [] expected = { 73 "46:5: Missing a Javadoc comment.", 74 }; 75 verify(checkConfig, getPath("InputPublicOnly.java"), expected); 76 } 77 78 public void testScopes() throws Exception 79 { 80 final DefaultConfiguration checkConfig = 81 createCheckConfig(JavadocVariableCheck.class); 82 final String [] expected = { 83 "3:5: Missing a Javadoc comment.", 84 "4:5: Missing a Javadoc comment.", 85 "5:5: Missing a Javadoc comment.", 86 "6:5: Missing a Javadoc comment.", 87 "14:9: Missing a Javadoc comment.", 88 "15:9: Missing a Javadoc comment.", 89 "16:9: Missing a Javadoc comment.", 90 "17:9: Missing a Javadoc comment.", 91 "26:9: Missing a Javadoc comment.", 92 "27:9: Missing a Javadoc comment.", 93 "28:9: Missing a Javadoc comment.", 94 "29:9: Missing a Javadoc comment.", 95 "38:9: Missing a Javadoc comment.", 96 "39:9: Missing a Javadoc comment.", 97 "40:9: Missing a Javadoc comment.", 98 "41:9: Missing a Javadoc comment.", 99 "51:5: Missing a Javadoc comment.", 100 "52:5: Missing a Javadoc comment.", 101 "53:5: Missing a Javadoc comment.", 102 "54:5: Missing a Javadoc comment.", 103 "62:9: Missing a Javadoc comment.", 104 "63:9: Missing a Javadoc comment.", 105 "64:9: Missing a Javadoc comment.", 106 "65:9: Missing a Javadoc comment.", 107 "74:9: Missing a Javadoc comment.", 108 "75:9: Missing a Javadoc comment.", 109 "76:9: Missing a Javadoc comment.", 110 "77:9: Missing a Javadoc comment.", 111 "86:9: Missing a Javadoc comment.", 112 "87:9: Missing a Javadoc comment.", 113 "88:9: Missing a Javadoc comment.", 114 "89:9: Missing a Javadoc comment.", 115 "98:9: Missing a Javadoc comment.", 116 "99:9: Missing a Javadoc comment.", 117 "100:9: Missing a Javadoc comment.", 118 "101:9: Missing a Javadoc comment.", 119 }; 120 verify(checkConfig, 121 getPath("javadoc" + File.separator +"InputNoJavadoc.java"), 122 expected); 123 } 124 125 public void testScopes2() throws Exception 126 { 127 final DefaultConfiguration checkConfig = 128 createCheckConfig(JavadocVariableCheck.class); 129 checkConfig.addAttribute("scope", Scope.PROTECTED.getName()); 130 final String [] expected = { 131 "3:5: Missing a Javadoc comment.", 132 "4:5: Missing a Javadoc comment.", 133 "14:9: Missing a Javadoc comment.", 134 "15:9: Missing a Javadoc comment.", 135 }; 136 verify(checkConfig, 137 getPath("javadoc" + File.separator +"InputNoJavadoc.java"), 138 expected); 139 } 140 141 public void testExcludeScope() throws Exception 142 { 143 final DefaultConfiguration checkConfig = 144 createCheckConfig(JavadocVariableCheck.class); 145 checkConfig.addAttribute("scope", Scope.PRIVATE.getName()); 146 checkConfig.addAttribute("excludeScope", Scope.PROTECTED.getName()); 147 final String [] expected = { 148 "5:5: Missing a Javadoc comment.", 149 "6:5: Missing a Javadoc comment.", 150 "16:9: Missing a Javadoc comment.", 151 "17:9: Missing a Javadoc comment.", 152 "26:9: Missing a Javadoc comment.", 153 "27:9: Missing a Javadoc comment.", 154 "28:9: Missing a Javadoc comment.", 155 "29:9: Missing a Javadoc comment.", 156 "38:9: Missing a Javadoc comment.", 157 "39:9: Missing a Javadoc comment.", 158 "40:9: Missing a Javadoc comment.", 159 "41:9: Missing a Javadoc comment.", 160 "51:5: Missing a Javadoc comment.", 161 "52:5: Missing a Javadoc comment.", 162 "53:5: Missing a Javadoc comment.", 163 "54:5: Missing a Javadoc comment.", 164 "62:9: Missing a Javadoc comment.", 165 "63:9: Missing a Javadoc comment.", 166 "64:9: Missing a Javadoc comment.", 167 "65:9: Missing a Javadoc comment.", 168 "74:9: Missing a Javadoc comment.", 169 "75:9: Missing a Javadoc comment.", 170 "76:9: Missing a Javadoc comment.", 171 "77:9: Missing a Javadoc comment.", 172 "86:9: Missing a Javadoc comment.", 173 "87:9: Missing a Javadoc comment.", 174 "88:9: Missing a Javadoc comment.", 175 "89:9: Missing a Javadoc comment.", 176 "98:9: Missing a Javadoc comment.", 177 "99:9: Missing a Javadoc comment.", 178 "100:9: Missing a Javadoc comment.", 179 "101:9: Missing a Javadoc comment.", 180 }; 181 verify(checkConfig, 182 getPath("javadoc" + File.separator +"InputNoJavadoc.java"), 183 expected); 184 } 185 } 186 | Popular Tags |