1 package com.puppycrawl.tools.checkstyle.checks.coding; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 6 import java.io.File ; 7 8 public class IllegalTypeCheckTest extends BaseCheckTestCase { 9 private DefaultConfiguration mCheckConfig; 10 11 public void setUp() { 12 mCheckConfig = createCheckConfig(IllegalTypeCheck.class); 13 } 14 15 public void testDefaults() throws Exception { 16 String [] expected = { 17 "6:13: Declaring variables, return values or parameters of type 'AbstractClass' is not allowed.", 18 "9:13: Declaring variables, return values or parameters of type " 19 + "'com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass'" 20 + " is not allowed.", 21 "16:13: Declaring variables, return values or parameters of type 'java.util.Hashtable' is not allowed.", 22 "17:13: Declaring variables, return values or parameters of type 'Hashtable' is not allowed.", 23 }; 24 25 verify(mCheckConfig, getPath("coding" + File.separator + "InputIllegalType.java"), expected); 26 } 27 28 public void testIgnoreMethodNames() throws Exception { 29 mCheckConfig.addAttribute("ignoredMethodNames", "table2"); 30 31 String [] expected = { 32 "6:13: Declaring variables, return values or parameters of type 'AbstractClass' is not allowed.", 33 "9:13: Declaring variables, return values or parameters of type " 34 + "'com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass'" 35 + " is not allowed.", 36 "16:13: Declaring variables, return values or parameters of type 'java.util.Hashtable' is not allowed.", 37 }; 38 39 verify(mCheckConfig, getPath("coding" + File.separator + "InputIllegalType.java"), expected); 40 } 41 42 public void testFormat() throws Exception { 43 mCheckConfig.addAttribute("format", "^$"); 44 45 String [] expected = { 46 "16:13: Declaring variables, return values or parameters of type 'java.util.Hashtable' is not allowed.", 47 "17:13: Declaring variables, return values or parameters of type 'Hashtable' is not allowed.", 48 }; 49 50 verify(mCheckConfig, getPath("coding" + File.separator + "InputIllegalType.java"), expected); 51 } 52 53 public void testLegalAbstractClassNames() throws Exception { 54 mCheckConfig.addAttribute("legalAbstractClassNames", "AbstractClass"); 55 56 String [] expected = { 57 "9:13: Declaring variables, return values or parameters of type " 58 + "'com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass'" 59 + " is not allowed.", 60 "16:13: Declaring variables, return values or parameters of type 'java.util.Hashtable' is not allowed.", 61 "17:13: Declaring variables, return values or parameters of type 'Hashtable' is not allowed.", 62 }; 63 64 verify(mCheckConfig, getPath("coding" + File.separator + "InputIllegalType.java"), expected); 65 } 66 } 67 | Popular Tags |