UnusedParameterCheckTest.java :  » Code-Analyzer » checkstyle-5.1 » com » puppycrawl » tools » checkstyle » checks » usage » Java Open Source

Java Open Source » Code Analyzer » checkstyle 5.1 
checkstyle 5.1 » com » puppycrawl » tools » checkstyle » checks » usage » UnusedParameterCheckTest.java
package com.puppycrawl.tools.checkstyle.checks.usage;

import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;

public class UnusedParameterCheckTest
    extends BaseCheckTestCase
{
    public void testDefault() throws Exception
    {
        final DefaultConfiguration checkConfig =
            createCheckConfig(UnusedParameterCheck.class);
        final String[] expected = {
            "8:57: Unused parameter 'aUnreadPrimitive'.",
            "16:16: Unused parameter 'aUnreadObject'.",
            "29:66: Unused parameter 'aUnreadArray'.",            
        };
        verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
    }
    
    public void testException() throws Exception
    {
        final DefaultConfiguration checkConfig =
            createCheckConfig(UnusedParameterCheck.class);
        checkConfig.addAttribute("ignoreCatch", Boolean.FALSE.toString());
        final String[] expected = {
            "8:57: Unused parameter 'aUnreadPrimitive'.",
            "16:16: Unused parameter 'aUnreadObject'.",
            "25:26: Unused parameter 'unreadException'.",
            "29:66: Unused parameter 'aUnreadArray'.",            
        };
        verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
    }
    
    public void testIgnoreFormat() throws Exception
    {
        final DefaultConfiguration checkConfig =
            createCheckConfig(UnusedParameterCheck.class);
        checkConfig.addAttribute("ignoreFormat", "Array$");
        final String[] expected = {
            "8:57: Unused parameter 'aUnreadPrimitive'.",
            "16:16: Unused parameter 'aUnreadObject'.",
        };
        verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
    }

    public void testIgnoreNonLocal() throws Exception
    {
        final DefaultConfiguration checkConfig =
            createCheckConfig(UnusedParameterCheck.class);
        checkConfig.addAttribute("ignoreNonLocal", "true");
        final String[] expected = {
            "8:57: Unused parameter 'aUnreadPrimitive'.",
            "29:66: Unused parameter 'aUnreadArray'.",            
        };
        verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.