KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > sizes > AnonInnerLengthCheckTest


1 ////////////////////////////////////////////////////////////////////////////////
2
// checkstyle: Checks Java source code for adherence to a set of rules.
3
// Copyright (C) 2001-2002 Oliver Burn
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation; either
8
// version 2.1 of the License, or (at your option) any later version.
9
//
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with this library; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
////////////////////////////////////////////////////////////////////////////////
19
package com.puppycrawl.tools.checkstyle.checks.sizes;
20
21 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
22 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
23 import com.puppycrawl.tools.checkstyle.checks.sizes.AnonInnerLengthCheck;
24
25 /**
26  * @author Rob Worth
27  * @author Lars Kühne
28  */

29 public class AnonInnerLengthCheckTest extends BaseCheckTestCase
30 {
31
32     public void testDefault() throws Exception JavaDoc
33     {
34         final DefaultConfiguration checkConfig =
35             createCheckConfig(AnonInnerLengthCheck.class);
36         final String JavaDoc[] expected = {
37             "50:35: Anonymous inner class length is 21 lines (max allowed is 20).",
38         };
39         verify(checkConfig, getPath("InputAnonInnerLength.java"), expected);
40     }
41
42     public void testNonDefault() throws Exception JavaDoc
43     {
44         final DefaultConfiguration checkConfig =
45             createCheckConfig(AnonInnerLengthCheck.class);
46         checkConfig.addAttribute("max", "6");
47         final String JavaDoc[] expected = {
48             "50:35: Anonymous inner class length is 21 lines (max allowed is 6).",
49             "75:35: Anonymous inner class length is 20 lines (max allowed is 6).",
50         };
51         verify(checkConfig, getPath("InputAnonInnerLength.java"), expected);
52     }
53 }
54
Popular Tags