View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2018 the original author or authors.
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  
20  package com.google.checkstyle.test.chapter2filebasic.rule232specialescape;
21  
22  import org.junit.Test;
23  
24  import com.google.checkstyle.test.base.AbstractModuleTestSupport;
25  import com.puppycrawl.tools.checkstyle.api.Configuration;
26  
27  public class IllegalTokenTextTest extends AbstractModuleTestSupport {
28  
29      @Override
30      protected String getPackageLocation() {
31          return "com/google/checkstyle/test/chapter2filebasic/rule232specialescape";
32      }
33  
34      @Test
35      public void testIllegalTokens() throws Exception {
36          final String message = "Consider using special escape sequence instead of octal value or "
37                  + "Unicode escaped value.";
38  
39          final String[] expected = {
40              "18:27: " + message,
41              "19:27: " + message,
42              "22:25: " + message,
43              "23:25: " + message,
44              "25:16: " + message,
45              "43:21: " + message,
46              "44:21: " + message,
47              "45:21: " + message,
48              "46:21: " + message,
49              "47:21: " + message,
50              "48:21: " + message,
51              "49:21: " + message,
52              "54:21: " + message,
53              "55:21: " + message,
54              "56:21: " + message,
55              "57:21: " + message,
56              "58:21: " + message,
57              "59:21: " + message,
58              "60:21: " + message,
59              "61:21: " + message,
60              "69:31: " + message,
61              "70:31: " + message,
62              "73:29: " + message,
63              "74:29: " + message,
64              "76:20: " + message,
65              "94:25: " + message,
66              "95:25: " + message,
67              "96:25: " + message,
68              "97:25: " + message,
69              "98:25: " + message,
70              "99:25: " + message,
71              "100:25: " + message,
72              "105:25: " + message,
73              "106:25: " + message,
74              "107:25: " + message,
75              "108:25: " + message,
76              "109:25: " + message,
77              "110:25: " + message,
78              "111:25: " + message,
79              "112:25: " + message,
80              "119:35: " + message,
81              "120:35: " + message,
82              "123:33: " + message,
83              "124:33: " + message,
84              "126:24: " + message,
85              "144:29: " + message,
86              "145:29: " + message,
87              "146:29: " + message,
88              "147:29: " + message,
89              "148:29: " + message,
90              "149:29: " + message,
91              "150:29: " + message,
92              "155:29: " + message,
93              "156:29: " + message,
94              "157:29: " + message,
95              "158:29: " + message,
96              "159:29: " + message,
97              "160:29: " + message,
98              "161:29: " + message,
99              "162:29: " + message,
100         };
101 
102         final Configuration checkConfig = getModuleConfig("IllegalTokenText");
103         final String filePath = getPath("InputIllegalTokenText.java");
104 
105         final Integer[] warnList = getLinesWithWarn(filePath);
106         verify(checkConfig, filePath, expected, warnList);
107     }
108 
109 }