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 UnusedParameterCheckTest 7 extends BaseCheckTestCase 8 { 9 public void testDefault() throws Exception 10 { 11 final DefaultConfiguration checkConfig = 12 createCheckConfig(UnusedParameterCheck.class); 13 final String [] expected = { 14 "8:57: Unused parameter 'aUnreadPrimitive'.", 15 "16:16: Unused parameter 'aUnreadObject'.", 16 "29:66: Unused parameter 'aUnreadArray'.", 17 }; 18 verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected); 19 } 20 21 public void testException() throws Exception 22 { 23 final DefaultConfiguration checkConfig = 24 createCheckConfig(UnusedParameterCheck.class); 25 checkConfig.addAttribute("ignoreCatch", Boolean.FALSE.toString()); 26 final String [] expected = { 27 "8:57: Unused parameter 'aUnreadPrimitive'.", 28 "16:16: Unused parameter 'aUnreadObject'.", 29 "25:26: Unused parameter 'unreadException'.", 30 "29:66: Unused parameter 'aUnreadArray'.", 31 }; 32 verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected); 33 } 34 35 public void testIgnoreFormat() throws Exception 36 { 37 final DefaultConfiguration checkConfig = 38 createCheckConfig(UnusedParameterCheck.class); 39 checkConfig.addAttribute("ignoreFormat", "Array$"); 40 final String [] expected = { 41 "8:57: Unused parameter 'aUnreadPrimitive'.", 42 "16:16: Unused parameter 'aUnreadObject'.", 43 }; 44 verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected); 45 } 46 47 public void testIgnoreNonLocal() throws Exception 48 { 49 final DefaultConfiguration checkConfig = 50 createCheckConfig(UnusedParameterCheck.class); 51 checkConfig.addAttribute("ignoreNonLocal", "true"); 52 final String [] expected = { 53 "8:57: Unused parameter 'aUnreadPrimitive'.", 54 "29:66: Unused parameter 'aUnreadArray'.", 55 }; 56 verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected); 57 } 58 } 59 | Popular Tags |