View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code and other text files for adherence to a set of rules.
3   // Copyright (C) 2001-2026 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.puppycrawl.tools.checkstyle.checks.indentation;
21  
22  import static com.google.common.truth.Truth.assertWithMessage;
23  import static com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.MSG_CHILD_ERROR;
24  import static com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.MSG_CHILD_ERROR_MULTI;
25  import static com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.MSG_ERROR;
26  import static com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.MSG_ERROR_MULTI;
27  
28  import java.io.BufferedReader;
29  import java.io.IOException;
30  import java.nio.file.Files;
31  import java.nio.file.Path;
32  import java.util.ArrayList;
33  import java.util.Arrays;
34  import java.util.Deque;
35  import java.util.List;
36  import java.util.Locale;
37  import java.util.regex.Matcher;
38  import java.util.regex.Pattern;
39  
40  import org.junit.jupiter.api.Test;
41  
42  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
43  import com.puppycrawl.tools.checkstyle.Checker;
44  import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
45  import com.puppycrawl.tools.checkstyle.api.AuditEvent;
46  import com.puppycrawl.tools.checkstyle.api.AuditListener;
47  import com.puppycrawl.tools.checkstyle.api.Configuration;
48  import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
49  import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
50  
51  /**
52   * Unit test for IndentationCheck.
53   */
54  public class IndentationCheckTest extends AbstractModuleTestSupport {
55  
56      private static final Pattern LINE_WITH_COMMENT_REGEX = Pattern.compile(
57          ".*?//(?:below )?indent:(\\d+)(?:"
58                  + " ioffset:(\\d+))? exp:(>=)?(\\d+(?:,\\d+)*?)( warn)?$");
59  
60      private static final IndentComment[] EMPTY_INDENT_COMMENT_ARRAY = new IndentComment[0];
61  
62      private static IndentComment[] getLinesWithWarnAndCheckComments(String fileName,
63              final int tabWidth)
64                      throws IOException {
65          final List<IndentComment> result = new ArrayList<>();
66          try (BufferedReader br = Files.newBufferedReader(Path.of(fileName))) {
67              int lineNumber = 1;
68              String line = br.readLine();
69              IndentComment pendingBelowComment = null;
70  
71              while (line != null) {
72                  final Matcher match = LINE_WITH_COMMENT_REGEX.matcher(line);
73                  if (pendingBelowComment != null) {
74                      final int actualIndent = getLineStart(line, tabWidth);
75  
76                      processPendingBelowComment(pendingBelowComment, actualIndent,
77                              lineNumber, result);
78  
79                      pendingBelowComment = null;
80                  }
81                  else if (match.matches()) {
82                      final boolean isBelow = line.contains("//below indent:");
83                      final IndentComment warn = new IndentComment(match, lineNumber);
84  
85                      if (isBelow) {
86                          pendingBelowComment = warn;
87                      }
88                      else {
89                          final int actualIndent = getLineStart(line, tabWidth);
90                          processInlineComment(warn, actualIndent, lineNumber, fileName, result);
91                      }
92                  }
93                  else if (!line.isEmpty()) {
94                      throw new IllegalStateException(String.format(Locale.ROOT,
95                              "File \"%1$s\" has no indentation comment or its format "
96                                      + "malformed. Error on line: %2$d",
97                              fileName,
98                              lineNumber));
99                  }
100 
101                 line = br.readLine();
102                 lineNumber++;
103             }
104         }
105 
106         return result.toArray(EMPTY_INDENT_COMMENT_ARRAY);
107     }
108 
109     private static void processPendingBelowComment(IndentComment pendingBelowComment,
110             int actualIndent, int lineNumber, List<IndentComment> result) {
111         if (actualIndent != pendingBelowComment.getIndent()) {
112             throw new IllegalStateException(String.format(Locale.ROOT,
113                     "Incorrect indentation in 'below' comment. "
114                             + "Line %1$d (from line %2$d): comment:%3$d, actual:%4$d.",
115                     lineNumber,
116                     pendingBelowComment.getLineNumber(),
117                     pendingBelowComment.getIndent(),
118                     actualIndent));
119         }
120 
121         if (!isCommentConsistent(pendingBelowComment)) {
122             throw new IllegalStateException(String.format(Locale.ROOT,
123                     "Inconsistent 'below' comment on line %1$d",
124                     pendingBelowComment.getLineNumber()));
125         }
126 
127         if (pendingBelowComment.isWarning()) {
128             result.add(new IndentComment(pendingBelowComment, lineNumber));
129         }
130     }
131 
132     private static void processInlineComment(IndentComment warn, int actualIndent,
133         int lineNumber, String fileName, List<IndentComment> result) {
134 
135         if (actualIndent != warn.getIndent()) {
136             throw new IllegalStateException(String.format(Locale.ROOT,
137                     "File \"%1$s\" has incorrect indentation in comment. "
138                             + "Line %2$d: comment:%3$d, actual:%4$d.",
139                     fileName,
140                     lineNumber,
141                     warn.getIndent(),
142                     actualIndent));
143         }
144 
145         if (!isCommentConsistent(warn)) {
146             throw new IllegalStateException(String.format(Locale.ROOT,
147                     "File \"%1$s\" has inconsistent comment on line %2$d",
148                     fileName,
149                     lineNumber));
150         }
151 
152         if (warn.isWarning()) {
153             result.add(warn);
154         }
155     }
156 
157     private static boolean isCommentConsistent(IndentComment comment) {
158         final String[] levels = comment.getExpectedWarning().split(", ");
159         final int indent = comment.getIndent() + comment.getIndentOffset();
160         final boolean result;
161         if (levels.length > 1) {
162             // multi
163             final boolean containsActualLevel =
164                             Arrays.asList(levels).contains(String.valueOf(indent));
165 
166             result = containsActualLevel != comment.isWarning();
167         }
168         else {
169             final int expectedWarning = Integer.parseInt(comment.getExpectedWarning());
170 
171             final boolean test;
172             if (comment.isExpectedNonStrict()) {
173                 // non-strict
174                 test = indent >= expectedWarning;
175             }
176             else {
177                 // single
178                 test = expectedWarning == indent;
179             }
180             result = test != comment.isWarning();
181 
182         }
183         return result;
184     }
185 
186     private static int getLineStart(String line, final int tabWidth) {
187         int lineStart = 0;
188         for (int index = 0; index < line.length(); index++) {
189             if (!Character.isWhitespace(line.charAt(index))) {
190                 lineStart = CommonUtil.lengthExpandedTabs(line, index, tabWidth);
191                 break;
192             }
193         }
194         return lineStart;
195     }
196 
197     private void verifyWarns(Configuration config, String filePath,
198                     String... expected)
199                             throws Exception {
200         final int tabWidth = Integer.parseInt(config.getProperty("tabWidth"));
201         final IndentComment[] linesWithWarn =
202                         getLinesWithWarnAndCheckComments(filePath, tabWidth);
203         verify(config, filePath, expected, linesWithWarn);
204         assertWithMessage("Expected warning count in UT does not match warn comment count "
205                 + "in input file")
206             .that(linesWithWarn.length)
207             .isEqualTo(expected.length);
208     }
209 
210     private void verify(Configuration config, String filePath, String[] expected,
211             final IndentComment... linesWithWarn)
212                     throws Exception {
213         final Checker checker = createChecker(config);
214         checker.addListener(new IndentAudit(linesWithWarn));
215         verify(checker, filePath, expected);
216     }
217 
218     @Override
219     public String getPackageLocation() {
220         return "com/puppycrawl/tools/checkstyle/checks/indentation/indentation";
221     }
222 
223     @Test
224     public void testGetRequiredTokens() {
225         final IndentationCheck checkObj = new IndentationCheck();
226         final int[] requiredTokens = checkObj.getRequiredTokens();
227         final HandlerFactory handlerFactory = new HandlerFactory();
228         final int[] expected = handlerFactory.getHandledTypes();
229         Arrays.sort(expected);
230         Arrays.sort(requiredTokens);
231         assertWithMessage("Default required tokens are invalid")
232             .that(requiredTokens)
233             .isEqualTo(expected);
234     }
235 
236     @Test
237     public void testGetAcceptableTokens() {
238         final IndentationCheck checkObj = new IndentationCheck();
239         final int[] acceptableTokens = checkObj.getAcceptableTokens();
240         final HandlerFactory handlerFactory = new HandlerFactory();
241         final int[] expected = handlerFactory.getHandledTypes();
242         Arrays.sort(expected);
243         Arrays.sort(acceptableTokens);
244         assertWithMessage("Default acceptable tokens are invalid")
245             .that(acceptableTokens)
246             .isEqualTo(expected);
247     }
248 
249     @Test
250     public void testThrowsIndentProperty() {
251         final IndentationCheck indentationCheck = new IndentationCheck();
252 
253         indentationCheck.setThrowsIndent(1);
254         indentationCheck.beginTree(null);
255         final IndentationContext context =
256             TestUtil.getInternalState(indentationCheck, "context", IndentationContext.class);
257 
258         assertWithMessage("Invalid throws indent")
259             .that(context.getThrowsIndent())
260             .isEqualTo(1);
261     }
262 
263     @Test
264     public void testStrictCondition() throws Exception {
265         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
266         checkConfig.addProperty("arrayInitIndent", "4");
267         checkConfig.addProperty("basicOffset", "4");
268         checkConfig.addProperty("braceAdjustment", "4");
269         checkConfig.addProperty("caseIndent", "4");
270         checkConfig.addProperty("forceStrictCondition", "true");
271         checkConfig.addProperty("lineWrappingIndentation", "8");
272         checkConfig.addProperty("tabWidth", "4");
273         checkConfig.addProperty("throwsIndent", "8");
274         final String[] expected = {
275             "10:29: " + getCheckMessage(MSG_ERROR_MULTI, "method def rcurly", 28, "16, 20, 24"),
276             "13:9: " + getCheckMessage(MSG_ERROR, "method def rcurly", 8, 4),
277             "14:5: " + getCheckMessage(MSG_ERROR, "class def rcurly", 4, 0),
278         };
279         verifyWarns(checkConfig, getPath("InputIndentationStrictCondition.java"), expected);
280     }
281 
282     @Test
283     public void forbidOldStyle() throws Exception {
284         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
285         checkConfig.addProperty("arrayInitIndent", "4");
286         checkConfig.addProperty("basicOffset", "4");
287         checkConfig.addProperty("braceAdjustment", "0");
288         checkConfig.addProperty("caseIndent", "4");
289         checkConfig.addProperty("forceStrictCondition", "true");
290         checkConfig.addProperty("lineWrappingIndentation", "8");
291         checkConfig.addProperty("tabWidth", "4");
292         checkConfig.addProperty("throwsIndent", "8");
293         final String[] expected = {
294             "20:30: " + getCheckMessage(MSG_ERROR, "int", 29, 12),
295             "21:30: " + getCheckMessage(MSG_ERROR, "int", 29, 12),
296         };
297         verifyWarns(checkConfig, getPath("InputIndentationMethodCStyle.java"), expected);
298     }
299 
300     @Test
301     public void testZeroCaseLevel() throws Exception {
302         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
303         checkConfig.addProperty("arrayInitIndent", "4");
304         checkConfig.addProperty("basicOffset", "4");
305         checkConfig.addProperty("braceAdjustment", "0");
306         checkConfig.addProperty("caseIndent", "0");
307         checkConfig.addProperty("forceStrictCondition", "false");
308         checkConfig.addProperty("lineWrappingIndentation", "4");
309         checkConfig.addProperty("tabWidth", "4");
310         checkConfig.addProperty("throwsIndent", "4");
311         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
312         verifyWarns(checkConfig, getPath("InputIndentationZeroCaseLevel.java"), expected);
313     }
314 
315     @Test
316     public void testAndroidStyle() throws Exception {
317         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
318         checkConfig.addProperty("arrayInitIndent", "4");
319         checkConfig.addProperty("basicOffset", "4");
320         checkConfig.addProperty("braceAdjustment", "0");
321         checkConfig.addProperty("caseIndent", "4");
322         checkConfig.addProperty("forceStrictCondition", "false");
323         checkConfig.addProperty("lineWrappingIndentation", "8");
324         checkConfig.addProperty("tabWidth", "4");
325         checkConfig.addProperty("throwsIndent", "8");
326         final String[] expected = {
327             "42:4: " + getCheckMessage(MSG_ERROR, "extends", 3, 8),
328             "44:4: " + getCheckMessage(MSG_ERROR, "member def type", 3, 4),
329             "47:9: " + getCheckMessage(MSG_ERROR, "foo", 8, 12),
330             "50:9: " + getCheckMessage(MSG_ERROR, "int", 8, 12),
331             "53:14: " + getCheckMessage(MSG_ERROR, "true", 13, 16),
332             "56:17: " + getCheckMessage(MSG_ERROR, "+", 16, 20),
333             "57:9: " + getCheckMessage(MSG_ERROR, "if", 8, 12),
334             "60:12: " + getCheckMessage(MSG_ERROR, "if rcurly", 11, 12),
335             "62:8: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 7, 8),
336         };
337         verifyWarns(checkConfig, getPath("InputIndentationAndroidStyle.java"), expected);
338     }
339 
340     @Test
341     public void testMethodCallLineWrap() throws Exception {
342         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
343 
344         checkConfig.addProperty("arrayInitIndent", "4");
345         checkConfig.addProperty("basicOffset", "4");
346         checkConfig.addProperty("braceAdjustment", "0");
347         checkConfig.addProperty("caseIndent", "4");
348         checkConfig.addProperty("forceStrictCondition", "false");
349         checkConfig.addProperty("lineWrappingIndentation", "4");
350         checkConfig.addProperty("tabWidth", "4");
351         checkConfig.addProperty("throwsIndent", "4");
352         final String[] expected = {
353             "53:19: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 18, 20),
354             "54:15: " + getCheckMessage(MSG_ERROR, "method call rparen", 14, 16),
355             "75:13: " + getCheckMessage(MSG_ERROR, "lambda arguments", 12, 16),
356             "81:16: " + getCheckMessage(MSG_ERROR, "method call rparen", 15, 8),
357         };
358         verifyWarns(checkConfig, getPath("InputIndentationMethodCallLineWrap.java"), expected);
359     }
360 
361     @Test
362     public void testMethodCallLineWrap1() throws Exception {
363         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
364 
365         checkConfig.addProperty("arrayInitIndent", "4");
366         checkConfig.addProperty("basicOffset", "4");
367         checkConfig.addProperty("braceAdjustment", "0");
368         checkConfig.addProperty("caseIndent", "4");
369         checkConfig.addProperty("forceStrictCondition", "false");
370         checkConfig.addProperty("lineWrappingIndentation", "4");
371         checkConfig.addProperty("tabWidth", "4");
372         checkConfig.addProperty("throwsIndent", "4");
373         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
374         verifyWarns(checkConfig, getPath("InputIndentationMethodCallLineWrap1.java"),
375                 expected);
376     }
377 
378     @Test
379     public void testChainedMethodCallRparenIndent() throws Exception {
380         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
381 
382         checkConfig.addProperty("arrayInitIndent", "4");
383         checkConfig.addProperty("basicOffset", "4");
384         checkConfig.addProperty("braceAdjustment", "0");
385         checkConfig.addProperty("caseIndent", "4");
386         checkConfig.addProperty("forceStrictCondition", "false");
387         checkConfig.addProperty("lineWrappingIndentation", "4");
388         checkConfig.addProperty("tabWidth", "4");
389         checkConfig.addProperty("throwsIndent", "4");
390         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
391         verifyWarns(checkConfig, getPath("InputIndentationChainedMethodCallRparen.java"),
392                 expected);
393     }
394 
395     @Test
396     public void testDifficultAnnotations() throws Exception {
397         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
398 
399         checkConfig.addProperty("arrayInitIndent", "4");
400         checkConfig.addProperty("basicOffset", "4");
401         checkConfig.addProperty("braceAdjustment", "0");
402         checkConfig.addProperty("caseIndent", "4");
403         checkConfig.addProperty("forceStrictCondition", "false");
404         checkConfig.addProperty("lineWrappingIndentation", "4");
405         checkConfig.addProperty("tabWidth", "4");
406         checkConfig.addProperty("throwsIndent", "4");
407         final String[] expected = {
408             "41:1: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
409                     "annotation array initialization", 0, "4, 25, 72"),
410             "42:1: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
411                     "annotation array initialization", 0, "4, 25, 72"),
412             "51:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
413                     "annotation array initialization", 6, "8, 29, 72"),
414         };
415         verifyWarns(checkConfig, getPath("InputIndentationDifficultAnnotations.java"), expected);
416     }
417 
418     @Test
419     public void testAnnotationClosingParenthesisEndsInSameIndentationAsOpening() throws Exception {
420         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
421 
422         checkConfig.addProperty("basicOffset", "4");
423         checkConfig.addProperty("forceStrictCondition", "true");
424         checkConfig.addProperty("tabWidth", "4");
425 
426         final String[] expected = {
427             "34:17: " + getCheckMessage(MSG_ERROR, ")", 16, 0),
428             "36:17: " + getCheckMessage(MSG_ERROR, ")", 16, 0),
429             "40:9: " + getCheckMessage(MSG_ERROR, ")", 8, 4),
430             "42:9: " + getCheckMessage(MSG_ERROR, ")", 8, 4),
431             "46:9: " + getCheckMessage(MSG_ERROR, ")", 8, 4),
432         };
433 
434         verifyWarns(checkConfig,
435             getPath("InputIndentation"
436                 + "AnnotationClosingParenthesisEndsInSameIndentationAsOpen.java"),
437                 expected);
438     }
439 
440     @Test
441     public void testAnnotationsFromGuava() throws Exception {
442         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
443 
444         checkConfig.addProperty("arrayInitIndent", "4");
445         checkConfig.addProperty("basicOffset", "2");
446         checkConfig.addProperty("braceAdjustment", "0");
447         checkConfig.addProperty("caseIndent", "4");
448         checkConfig.addProperty("forceStrictCondition", "false");
449         checkConfig.addProperty("lineWrappingIndentation", "4");
450         checkConfig.addProperty("tabWidth", "4");
451         checkConfig.addProperty("throwsIndent", "4");
452         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
453         verifyWarns(checkConfig, getPath("InputIndentationFromGuava.java"), expected);
454     }
455 
456     @Test
457     public void testAnnotationsFromGuava1() throws Exception {
458         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
459 
460         checkConfig.addProperty("arrayInitIndent", "4");
461         checkConfig.addProperty("basicOffset", "2");
462         checkConfig.addProperty("braceAdjustment", "0");
463         checkConfig.addProperty("caseIndent", "4");
464         checkConfig.addProperty("forceStrictCondition", "false");
465         checkConfig.addProperty("lineWrappingIndentation", "4");
466         checkConfig.addProperty("tabWidth", "4");
467         checkConfig.addProperty("throwsIndent", "4");
468         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
469         verifyWarns(checkConfig, getPath("InputIndentationFromGuava1.java"), expected);
470     }
471 
472     @Test
473     public void testAnnotationsFromGuava2() throws Exception {
474         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
475 
476         checkConfig.addProperty("arrayInitIndent", "4");
477         checkConfig.addProperty("basicOffset", "2");
478         checkConfig.addProperty("braceAdjustment", "0");
479         checkConfig.addProperty("caseIndent", "4");
480         checkConfig.addProperty("forceStrictCondition", "false");
481         checkConfig.addProperty("lineWrappingIndentation", "4");
482         checkConfig.addProperty("tabWidth", "4");
483         checkConfig.addProperty("throwsIndent", "4");
484         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
485         verifyWarns(checkConfig, getPath("InputIndentationFromGuava2.java"), expected);
486     }
487 
488     @Test
489     public void testAnnotationsFromGuava3() throws Exception {
490         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
491 
492         checkConfig.addProperty("arrayInitIndent", "4");
493         checkConfig.addProperty("basicOffset", "2");
494         checkConfig.addProperty("braceAdjustment", "0");
495         checkConfig.addProperty("caseIndent", "4");
496         checkConfig.addProperty("forceStrictCondition", "false");
497         checkConfig.addProperty("lineWrappingIndentation", "4");
498         checkConfig.addProperty("tabWidth", "4");
499         checkConfig.addProperty("throwsIndent", "4");
500         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
501         verifyWarns(checkConfig, getPath("InputIndentationFromGuava3.java"), expected);
502     }
503 
504     @Test
505     public void testAnnotationsFromGuava4() throws Exception {
506         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
507 
508         checkConfig.addProperty("arrayInitIndent", "4");
509         checkConfig.addProperty("basicOffset", "2");
510         checkConfig.addProperty("braceAdjustment", "0");
511         checkConfig.addProperty("caseIndent", "4");
512         checkConfig.addProperty("forceStrictCondition", "false");
513         checkConfig.addProperty("lineWrappingIndentation", "4");
514         checkConfig.addProperty("tabWidth", "4");
515         checkConfig.addProperty("throwsIndent", "4");
516         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
517         verifyWarns(checkConfig, getPath("InputIndentationFromGuava4.java"), expected);
518     }
519 
520     @Test
521     public void testCorrectIfAndParameters() throws Exception {
522         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
523 
524         checkConfig.addProperty("arrayInitIndent", "4");
525         checkConfig.addProperty("basicOffset", "2");
526         checkConfig.addProperty("braceAdjustment", "0");
527         checkConfig.addProperty("caseIndent", "4");
528         checkConfig.addProperty("forceStrictCondition", "false");
529         checkConfig.addProperty("lineWrappingIndentation", "4");
530         checkConfig.addProperty("tabWidth", "4");
531         checkConfig.addProperty("throwsIndent", "4");
532         final String[] expected = {
533             "66:15: " + getCheckMessage(MSG_ERROR_MULTI, "new", 14, "16, 18"),
534             "75:19: " + getCheckMessage(MSG_ERROR_MULTI, "new", 18, "40, 42"),
535             "96:17: " + getCheckMessage(MSG_ERROR_MULTI, "new", 16, "18, 20"),
536             "100:11: " + getCheckMessage(MSG_ERROR, "+", 10, 12),
537             "104:31: " + getCheckMessage(MSG_ERROR_MULTI, "new", 30, "38, 40"),
538             "106:17: " + getCheckMessage(MSG_CHILD_ERROR, "new", 16, 44),
539         };
540         verifyWarns(checkConfig, getPath("InputIndentationIfAndParameter.java"), expected);
541     }
542 
543     @Test
544     public void testCorrectIfAndParameters1() throws Exception {
545         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
546 
547         checkConfig.addProperty("arrayInitIndent", "4");
548         checkConfig.addProperty("basicOffset", "2");
549         checkConfig.addProperty("braceAdjustment", "0");
550         checkConfig.addProperty("caseIndent", "4");
551         checkConfig.addProperty("forceStrictCondition", "false");
552         checkConfig.addProperty("lineWrappingIndentation", "4");
553         checkConfig.addProperty("tabWidth", "4");
554         checkConfig.addProperty("throwsIndent", "4");
555         final String[] expected = {
556             "38:13: " + getCheckMessage(MSG_ERROR_MULTI, "new", 12, "14, 16"),
557             "42:17: " + getCheckMessage(MSG_CHILD_ERROR, "new", 16, 28),
558             "45:25: " + getCheckMessage(MSG_ERROR_MULTI, "new", 24, "42, 44"),
559         };
560         verifyWarns(checkConfig, getPath("InputIndentationCorrectIfAndParameter1.java"), expected);
561     }
562 
563     @Test
564     public void testAnonymousClasses() throws Exception {
565         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
566 
567         checkConfig.addProperty("arrayInitIndent", "4");
568         checkConfig.addProperty("basicOffset", "2");
569         checkConfig.addProperty("braceAdjustment", "0");
570         checkConfig.addProperty("caseIndent", "4");
571         checkConfig.addProperty("forceStrictCondition", "false");
572         checkConfig.addProperty("lineWrappingIndentation", "4");
573         checkConfig.addProperty("tabWidth", "4");
574         checkConfig.addProperty("throwsIndent", "4");
575         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
576         verifyWarns(checkConfig, getPath("InputIndentationAnonymousClasses.java"), expected);
577     }
578 
579     @Test
580     public void testArrays() throws Exception {
581         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
582 
583         checkConfig.addProperty("arrayInitIndent", "2");
584         checkConfig.addProperty("basicOffset", "2");
585         checkConfig.addProperty("braceAdjustment", "0");
586         checkConfig.addProperty("caseIndent", "4");
587         checkConfig.addProperty("forceStrictCondition", "false");
588         checkConfig.addProperty("lineWrappingIndentation", "4");
589         checkConfig.addProperty("tabWidth", "4");
590         checkConfig.addProperty("throwsIndent", "4");
591         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
592         verifyWarns(checkConfig, getPath("InputIndentationArrays.java"), expected);
593     }
594 
595     @Test
596     public void testLabels() throws Exception {
597         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
598 
599         checkConfig.addProperty("arrayInitIndent", "4");
600         checkConfig.addProperty("basicOffset", "2");
601         checkConfig.addProperty("braceAdjustment", "0");
602         checkConfig.addProperty("caseIndent", "4");
603         checkConfig.addProperty("forceStrictCondition", "false");
604         checkConfig.addProperty("lineWrappingIndentation", "4");
605         checkConfig.addProperty("tabWidth", "4");
606         checkConfig.addProperty("throwsIndent", "4");
607         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
608         verifyWarns(checkConfig, getPath("InputIndentationLabels.java"), expected);
609     }
610 
611     @Test
612     public void testLabels1() throws Exception {
613         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
614 
615         checkConfig.addProperty("arrayInitIndent", "4");
616         checkConfig.addProperty("basicOffset", "2");
617         checkConfig.addProperty("braceAdjustment", "0");
618         checkConfig.addProperty("caseIndent", "4");
619         checkConfig.addProperty("forceStrictCondition", "false");
620         checkConfig.addProperty("lineWrappingIndentation", "4");
621         checkConfig.addProperty("tabWidth", "4");
622         checkConfig.addProperty("throwsIndent", "4");
623         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
624         verifyWarns(checkConfig, getPath("InputIndentationLabels1.java"), expected);
625     }
626 
627     @Test
628     public void testClassesAndMethods() throws Exception {
629         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
630 
631         checkConfig.addProperty("arrayInitIndent", "4");
632         checkConfig.addProperty("basicOffset", "2");
633         checkConfig.addProperty("braceAdjustment", "0");
634         checkConfig.addProperty("caseIndent", "4");
635         checkConfig.addProperty("forceStrictCondition", "false");
636         checkConfig.addProperty("lineWrappingIndentation", "4");
637         checkConfig.addProperty("tabWidth", "4");
638         checkConfig.addProperty("throwsIndent", "4");
639         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
640         verifyWarns(checkConfig, getPath("InputIndentationClassesMethods.java"), expected);
641     }
642 
643     @Test
644     public void testCtorCall() throws Exception {
645         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
646 
647         checkConfig.addProperty("basicOffset", "2");
648         checkConfig.addProperty("braceAdjustment", "0");
649         checkConfig.addProperty("lineWrappingIndentation", "4");
650         checkConfig.addProperty("tabWidth", "4");
651         final String[] expected = {
652             "29:5: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 4, 6),
653             "30:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 6),
654             "31:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 6),
655             "35:5: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 4, 6),
656             "36:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 6),
657             "40:5: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 4, 6),
658             "41:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 8),
659             "42:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 8),
660             "46:5: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 4, 6),
661             "47:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 8),
662             "51:5: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 4, 6),
663             "52:5: " + getCheckMessage(MSG_ERROR, "(", 4, 8),
664             "53:5: " + getCheckMessage(MSG_ERROR, "x", 4, 8),
665             "57:5: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 4, 6),
666             "58:5: " + getCheckMessage(MSG_ERROR, "method call lparen", 4, 6),
667             "63:5: " + getCheckMessage(MSG_ERROR, ".", 4, 10),
668             "64:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 8),
669             "69:5: " + getCheckMessage(MSG_ERROR, "super", 4, 10),
670             "70:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 8),
671             "76:11: " + getCheckMessage(MSG_ERROR_MULTI, "lambda arguments", 10, "12, 14"),
672         };
673         verifyWarns(checkConfig, getPath("InputIndentationCtorCall.java"), expected);
674     }
675 
676     @Test
677     public void testCtorCall1() throws Exception {
678         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
679 
680         checkConfig.addProperty("basicOffset", "2");
681         checkConfig.addProperty("braceAdjustment", "0");
682         checkConfig.addProperty("lineWrappingIndentation", "4");
683         checkConfig.addProperty("tabWidth", "4");
684         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
685         verifyWarns(checkConfig, getPath("InputIndentationCtorCall1.java"), expected);
686     }
687 
688     @Test
689     public void testMembers() throws Exception {
690         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
691 
692         checkConfig.addProperty("arrayInitIndent", "4");
693         checkConfig.addProperty("basicOffset", "2");
694         checkConfig.addProperty("braceAdjustment", "0");
695         checkConfig.addProperty("caseIndent", "4");
696         checkConfig.addProperty("forceStrictCondition", "false");
697         checkConfig.addProperty("lineWrappingIndentation", "4");
698         checkConfig.addProperty("tabWidth", "4");
699         checkConfig.addProperty("throwsIndent", "4");
700         final String[] expected = {
701             "22:6: " + getCheckMessage(MSG_ERROR, "=", 5, 6),
702             "57:4: " + getCheckMessage(MSG_ERROR, "class def rcurly", 3, 2),
703         };
704 
705         verifyWarns(checkConfig, getPath("InputIndentationMembers.java"), expected);
706     }
707 
708     @Test
709     public void testAnnotationArrayInit() throws Exception {
710         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
711 
712         checkConfig.addProperty("arrayInitIndent", "6");
713         checkConfig.addProperty("basicOffset", "2");
714         checkConfig.addProperty("braceAdjustment", "0");
715         checkConfig.addProperty("caseIndent", "4");
716         checkConfig.addProperty("forceStrictCondition", "false");
717         checkConfig.addProperty("lineWrappingIndentation", "4");
718         checkConfig.addProperty("tabWidth", "8");
719         checkConfig.addProperty("throwsIndent", "4");
720         final String[] expected = {
721             "15:1: " + getCheckMessage(MSG_ERROR, "com", 0, "4"),
722             "19:1: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization", 0,
723                 "4, 6, 34, 36"),
724             "24:14: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
725                     13, "4, 6, 36, 70"),
726             "25:3: " + getCheckMessage(MSG_ERROR_MULTI,
727                     "annotation array initialization rcurly", 2, "0, 4"),
728             "36:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization", 6,
729                 "8, 10, 33, 70"),
730             "37:3: " + getCheckMessage(MSG_ERROR_MULTI,
731                     "annotation array initialization rcurly", 2, "4, 8"),
732 
733             "53:6: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
734                     "annotation array initialization", 5, "6, 8, 10, 70"),
735             "55:6: " + getCheckMessage(MSG_ERROR_MULTI,
736                     "annotation array initialization rcurly", 5, "2, 6"),
737         };
738         final String fileName = getPath("InputIndentationAnnArrInit.java");
739         verifyWarns(checkConfig, fileName, expected);
740     }
741 
742     @Test
743     public void testAnnotationArrayInitTwo() throws Exception {
744         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
745 
746         checkConfig.addProperty("arrayInitIndent", "0");
747         checkConfig.addProperty("basicOffset", "2");
748         checkConfig.addProperty("braceAdjustment", "0");
749         checkConfig.addProperty("caseIndent", "4");
750         checkConfig.addProperty("forceStrictCondition", "false");
751         checkConfig.addProperty("lineWrappingIndentation", "0");
752         checkConfig.addProperty("tabWidth", "8");
753         checkConfig.addProperty("throwsIndent", "4");
754         final String[] expected = {
755 
756             "19:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
757                 "annotation array initialization", 4, "0, 33, 63"),
758             "32:9: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
759                 "annotation array initialization", 8, "4, 29, 63"),
760             "34:3: " + getCheckMessage(MSG_ERROR,
761                 "annotation array initialization rcurly", 2, 4),
762             "49:7: " + getCheckMessage(MSG_ERROR,
763                 "annotation array initialization lcurly", 6, 2),
764             "51:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
765                 "annotation array initialization", 4, "2, 6, 63"),
766         };
767         final String fileName = getPath("InputIndentationAnnArrInit2.java");
768         verifyWarns(checkConfig, fileName, expected);
769     }
770 
771     @Test
772     public void testAnnotationArrayInitWithEmoji() throws Exception {
773         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
774 
775         checkConfig.addProperty("arrayInitIndent", "0");
776         checkConfig.addProperty("basicOffset", "2");
777         checkConfig.addProperty("braceAdjustment", "0");
778         checkConfig.addProperty("caseIndent", "4");
779         checkConfig.addProperty("forceStrictCondition", "false");
780         checkConfig.addProperty("lineWrappingIndentation", "0");
781         checkConfig.addProperty("tabWidth", "8");
782         checkConfig.addProperty("throwsIndent", "4");
783         final String[] expected = {
784             "18:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
785                     "annotation array initialization", 4, "0, 41, 70"),
786             "31:9: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
787                     "annotation array initialization", 8, "4, 29, 70"),
788             "33:3: " + getCheckMessage(MSG_ERROR,
789                     "annotation array initialization rcurly", 2, 4),
790             "43:7: " + getCheckMessage(MSG_ERROR,
791                     "member def type", 6, "4"),
792             "48:7: " + getCheckMessage(MSG_ERROR,
793                     "annotation array initialization lcurly", 6, "2"),
794             "49:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
795                     "annotation array initialization", 10, "2, 6, 70"),
796             "50:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
797                     "annotation array initialization", 12, "2, 6, 70"),
798             "51:21: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
799                     "annotation array initialization", 20, "2, 6, 70"),
800             "53:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
801                     "annotation array initialization", 4, "2, 6, 70"),
802         };
803         final String fileName = getPath("InputIndentationAnnArrInitWithEmoji.java");
804         verifyWarns(checkConfig, fileName, expected);
805 
806     }
807 
808     @Test
809     public void testOddAnnotations()
810             throws Exception {
811         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
812 
813         checkConfig.addProperty("arrayInitIndent", "3");
814         checkConfig.addProperty("basicOffset", "4");
815         checkConfig.addProperty("braceAdjustment", "0");
816         checkConfig.addProperty("caseIndent", "4");
817 
818         checkConfig.addProperty("forceStrictCondition", "false");
819         checkConfig.addProperty("lineWrappingIndentation", "9");
820         checkConfig.addProperty("tabWidth", "4");
821         checkConfig.addProperty("throwsIndent", "4");
822         final String fileName = getPath("InputIndentationOddLineWrappingAndArrayInit.java");
823         final String[] expected = {
824             "26:17: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
825                     16, "11, 17, 54, 64"),
826         };
827         verifyWarns(checkConfig, fileName, expected);
828     }
829 
830     @Test
831     public void testAnnotationOddStyles() throws Exception {
832         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
833 
834         checkConfig.addProperty("tabWidth", "8");
835 
836         final String fileName = getPath("InputIndentationAnnotationArrayInitOldStyle.java");
837 
838         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
839 
840         verifyWarns(checkConfig, fileName, expected);
841     }
842 
843     @Test
844     public void testZeroAnnotationArrayInit()
845             throws Exception {
846         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
847 
848         checkConfig.addProperty("arrayInitIndent", "0");
849         checkConfig.addProperty("basicOffset", "4");
850         checkConfig.addProperty("braceAdjustment", "0");
851         checkConfig.addProperty("caseIndent", "4");
852         checkConfig.addProperty("forceStrictCondition", "false");
853         checkConfig.addProperty("lineWrappingIndentation", "4");
854         checkConfig.addProperty("tabWidth", "4");
855         checkConfig.addProperty("throwsIndent", "4");
856         final String fileName = getPath("InputIndentationZeroArrayInit.java");
857 
858         final String[] expected = {
859             "23:12: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
860                     11, "8, 12, 37, 66"),
861         };
862         verifyWarns(checkConfig, fileName, expected);
863     }
864 
865     @Test
866     public void testAnnotationArrayInitGoodCase()
867             throws Exception {
868         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
869 
870         checkConfig.addProperty("arrayInitIndent", "4");
871         checkConfig.addProperty("basicOffset", "4");
872         checkConfig.addProperty("braceAdjustment", "0");
873         checkConfig.addProperty("caseIndent", "4");
874         checkConfig.addProperty("forceStrictCondition", "false");
875         checkConfig.addProperty("lineWrappingIndentation", "4");
876         checkConfig.addProperty("tabWidth", "4");
877         checkConfig.addProperty("throwsIndent", "4");
878         final String fileName = getPath("InputIndentationAnnotationArrayInitGood.java");
879         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
880         verifyWarns(checkConfig, fileName, expected);
881     }
882 
883     @Test
884     public void testAnnotationArrayInitGoodCaseTwo()
885             throws Exception {
886         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
887 
888         checkConfig.addProperty("arrayInitIndent", "4");
889         checkConfig.addProperty("basicOffset", "4");
890         checkConfig.addProperty("braceAdjustment", "2");
891         checkConfig.addProperty("caseIndent", "4");
892         checkConfig.addProperty("forceStrictCondition", "false");
893         checkConfig.addProperty("lineWrappingIndentation", "4");
894         checkConfig.addProperty("tabWidth", "4");
895         checkConfig.addProperty("throwsIndent", "4");
896         final String fileName = getPath("InputIndentationAnnotationArrayInitGood.java");
897         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
898         verifyWarns(checkConfig, fileName, expected);
899     }
900 
901     @Test
902     public void testAnnotationArrayInitWithTextBlockAfterLeftCurly() throws Exception {
903         final DefaultConfiguration checkConfig =
904             createModuleConfig(IndentationCheck.class);
905         checkConfig.addProperty("arrayInitIndent", "4");
906         checkConfig.addProperty("basicOffset", "4");
907         checkConfig.addProperty("braceAdjustment", "0");
908         checkConfig.addProperty("caseIndent", "4");
909         checkConfig.addProperty("throwsIndent", "4");
910         checkConfig.addProperty("lineWrappingIndentation", "4");
911         checkConfig.addProperty("tabWidth", "4");
912 
913         final String[] expected = {
914             "38:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
915                 "annotation array initialization", 4, "8, 26, 68"),
916             "47:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
917                 "annotation array initialization", 4, "8, 26, 68"),
918             "49:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
919                 "annotation array initialization", 4, "12, 30, 72"),
920             "79:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
921                 "annotation array initialization", 4, "8, 12, 68"),
922             "81:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
923                 "annotation array initialization", 4, "12, 16, 72"),
924             "89:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
925                 "annotation array initialization", 4, "8, 12, 68"),
926         };
927         verifyWarns(checkConfig, getPath("InputIndentationAnnArrInitTextBlock.java"), expected);
928     }
929 
930     @Test
931     public void testAnnotationArrayInitWithTextBlockAfterLeftCurly2() throws Exception {
932         final DefaultConfiguration checkConfig =
933             createModuleConfig(IndentationCheck.class);
934         checkConfig.addProperty("arrayInitIndent", "4");
935         checkConfig.addProperty("basicOffset", "4");
936         checkConfig.addProperty("braceAdjustment", "0");
937         checkConfig.addProperty("caseIndent", "4");
938         checkConfig.addProperty("throwsIndent", "4");
939         checkConfig.addProperty("lineWrappingIndentation", "4");
940         checkConfig.addProperty("tabWidth", "4");
941 
942         final String[] expected = {
943             "13:13: " + getCheckMessage(MSG_CHILD_ERROR,
944                 "annotation array initialization", 12, 8),
945             "17:13: " + getCheckMessage(MSG_CHILD_ERROR,
946                 "annotation array initialization", 12, 8),
947             "21:13: " + getCheckMessage(MSG_CHILD_ERROR,
948                 "annotation array initialization", 12, 8),
949             "37:13: " + getCheckMessage(MSG_CHILD_ERROR,
950                 "annotation array initialization", 12, 8),
951             "39:5: " + getCheckMessage(MSG_CHILD_ERROR,
952                 "annotation array initialization", 4, 12),
953         };
954         verifyWarns(checkConfig, getPath("InputIndentationAnnArrInitTextBlock2.java"), expected);
955     }
956 
957     @Test
958     public void testInvalidLabel() throws Exception {
959         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
960 
961         checkConfig.addProperty("arrayInitIndent", "4");
962         checkConfig.addProperty("basicOffset", "4");
963         checkConfig.addProperty("braceAdjustment", "0");
964         checkConfig.addProperty("caseIndent", "4");
965         checkConfig.addProperty("forceStrictCondition", "false");
966         checkConfig.addProperty("lineWrappingIndentation", "4");
967         checkConfig.addProperty("tabWidth", "4");
968         checkConfig.addProperty("throwsIndent", "4");
969         final String[] expected = {
970             "24:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "label", 10, "8, 12"),
971             "33:3: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "label", 2, "4, 8"),
972             "36:19: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "label", 18, "8, 12"),
973             "37:19: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 18, 8),
974             "39:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "label", 6, "8, 12"),
975             "41:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "label", 6, "8, 12"),
976         };
977         verifyWarns(checkConfig, getPath("InputIndentationInvalidLabelIndent.java"), expected);
978     }
979 
980     @Test
981     public void testInvalidLabelWithWhileLoop() throws Exception {
982         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
983 
984         checkConfig.addProperty("arrayInitIndent", "4");
985         checkConfig.addProperty("basicOffset", "4");
986         checkConfig.addProperty("braceAdjustment", "0");
987         checkConfig.addProperty("caseIndent", "4");
988         checkConfig.addProperty("forceStrictCondition", "false");
989         checkConfig.addProperty("lineWrappingIndentation", "4");
990         checkConfig.addProperty("tabWidth", "4");
991         checkConfig.addProperty("throwsIndent", "4");
992         final String[] expected = {
993             "18:10: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "label", 9, "4, 8"),
994             "19:10: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "label", 9, "8, 12"),
995         };
996         verifyWarns(checkConfig, getPath("InputIndentationInvalidLabelWithWhileLoopIndent.java"),
997             expected);
998     }
999 
1000     @Test
1001     public void testValidLabel() throws Exception {
1002         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1003 
1004         checkConfig.addProperty("arrayInitIndent", "4");
1005         checkConfig.addProperty("basicOffset", "4");
1006         checkConfig.addProperty("braceAdjustment", "0");
1007         checkConfig.addProperty("caseIndent", "4");
1008         checkConfig.addProperty("forceStrictCondition", "false");
1009         checkConfig.addProperty("lineWrappingIndentation", "4");
1010         checkConfig.addProperty("tabWidth", "4");
1011         checkConfig.addProperty("throwsIndent", "4");
1012         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1013         verifyWarns(checkConfig, getPath("InputIndentationValidLabelIndent.java"), expected);
1014     }
1015 
1016     @Test
1017     public void testValidIfWithChecker() throws Exception {
1018         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1019 
1020         checkConfig.addProperty("arrayInitIndent", "4");
1021         checkConfig.addProperty("basicOffset", "4");
1022         checkConfig.addProperty("braceAdjustment", "0");
1023         checkConfig.addProperty("caseIndent", "4");
1024         checkConfig.addProperty("forceStrictCondition", "false");
1025         checkConfig.addProperty("lineWrappingIndentation", "4");
1026         checkConfig.addProperty("tabWidth", "4");
1027         checkConfig.addProperty("throwsIndent", "4");
1028         final String fileName = getPath("InputIndentationValidIfIndent.java");
1029         final String[] expected = {
1030             "95:9: " + getCheckMessage(MSG_ERROR, "(", 8, 12),
1031         };
1032         verifyWarns(checkConfig, fileName, expected);
1033     }
1034 
1035     @Test
1036     public void testValidIfWithChecker1() throws Exception {
1037         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1038 
1039         checkConfig.addProperty("arrayInitIndent", "4");
1040         checkConfig.addProperty("basicOffset", "4");
1041         checkConfig.addProperty("braceAdjustment", "0");
1042         checkConfig.addProperty("caseIndent", "4");
1043         checkConfig.addProperty("forceStrictCondition", "false");
1044         checkConfig.addProperty("lineWrappingIndentation", "4");
1045         checkConfig.addProperty("tabWidth", "4");
1046         checkConfig.addProperty("throwsIndent", "4");
1047         final String fileName = getPath("InputIndentationValidIfIndent1.java");
1048         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1049         verifyWarns(checkConfig, fileName, expected);
1050     }
1051 
1052     @Test
1053     public void testValidIfWithChecker2() throws Exception {
1054         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1055 
1056         checkConfig.addProperty("arrayInitIndent", "4");
1057         checkConfig.addProperty("basicOffset", "4");
1058         checkConfig.addProperty("braceAdjustment", "0");
1059         checkConfig.addProperty("caseIndent", "4");
1060         checkConfig.addProperty("forceStrictCondition", "false");
1061         checkConfig.addProperty("lineWrappingIndentation", "4");
1062         checkConfig.addProperty("tabWidth", "4");
1063         checkConfig.addProperty("throwsIndent", "4");
1064         final String fileName = getPath("InputIndentationValidIfIndent2.java");
1065         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1066         verifyWarns(checkConfig, fileName, expected);
1067     }
1068 
1069     @Test
1070     public void testValidDotWithChecker()
1071             throws Exception {
1072         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1073 
1074         checkConfig.addProperty("arrayInitIndent", "4");
1075         checkConfig.addProperty("basicOffset", "4");
1076         checkConfig.addProperty("braceAdjustment", "0");
1077         checkConfig.addProperty("caseIndent", "4");
1078         checkConfig.addProperty("forceStrictCondition", "false");
1079         checkConfig.addProperty("lineWrappingIndentation", "4");
1080         checkConfig.addProperty("tabWidth", "4");
1081         checkConfig.addProperty("throwsIndent", "4");
1082         final String fileName = getPath("InputIndentationValidDotIndent.java");
1083         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1084         verifyWarns(checkConfig, fileName, expected);
1085     }
1086 
1087     @Test
1088     public void testValidMethodWithChecker()
1089             throws Exception {
1090         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1091 
1092         checkConfig.addProperty("arrayInitIndent", "4");
1093         checkConfig.addProperty("basicOffset", "4");
1094         checkConfig.addProperty("braceAdjustment", "0");
1095         checkConfig.addProperty("caseIndent", "4");
1096         checkConfig.addProperty("forceStrictCondition", "false");
1097         checkConfig.addProperty("lineWrappingIndentation", "4");
1098         checkConfig.addProperty("tabWidth", "4");
1099         checkConfig.addProperty("throwsIndent", "4");
1100         final String fileName = getPath("InputIndentationValidMethodIndent.java");
1101         final String[] expected = {
1102             "76:5: " + getCheckMessage(MSG_ERROR, "void", 4, 8),
1103             "77:5: " + getCheckMessage(MSG_ERROR, "method5", 4, 8),
1104         };
1105         verifyWarns(checkConfig, fileName, expected);
1106     }
1107 
1108     @Test
1109     public void testValidMethodWithChecker1()
1110             throws Exception {
1111         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1112 
1113         checkConfig.addProperty("arrayInitIndent", "4");
1114         checkConfig.addProperty("basicOffset", "4");
1115         checkConfig.addProperty("braceAdjustment", "0");
1116         checkConfig.addProperty("caseIndent", "4");
1117         checkConfig.addProperty("forceStrictCondition", "false");
1118         checkConfig.addProperty("lineWrappingIndentation", "4");
1119         checkConfig.addProperty("tabWidth", "4");
1120         checkConfig.addProperty("throwsIndent", "4");
1121         final String fileName = getPath("InputIndentationValidMethodIndent1.java");
1122         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1123         verifyWarns(checkConfig, fileName, expected);
1124     }
1125 
1126     @Test
1127     public void testInvalidMethodWithChecker1()
1128             throws Exception {
1129         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1130 
1131         checkConfig.addProperty("arrayInitIndent", "4");
1132         checkConfig.addProperty("basicOffset", "4");
1133         checkConfig.addProperty("braceAdjustment", "0");
1134         checkConfig.addProperty("caseIndent", "4");
1135         checkConfig.addProperty("forceStrictCondition", "false");
1136         checkConfig.addProperty("lineWrappingIndentation", "4");
1137         checkConfig.addProperty("tabWidth", "4");
1138         checkConfig.addProperty("throwsIndent", "4");
1139         final String fileName = getPath("InputIndentationInvalidMethodIndent1.java");
1140         final String[] expected = {
1141             "23:7: " + getCheckMessage(MSG_ERROR, "ctor def rcurly", 6, 4),
1142             "26:7: " + getCheckMessage(MSG_ERROR, "ctor def modifier", 6, 4),
1143             "27:3: " + getCheckMessage(MSG_ERROR, "ctor def lcurly", 2, 4),
1144             "28:7: " + getCheckMessage(MSG_ERROR, "ctor def rcurly", 6, 4),
1145             "31:3: " + getCheckMessage(MSG_ERROR, "method def modifier", 2, 4),
1146             "32:7: " + getCheckMessage(MSG_ERROR, "method def rcurly", 6, 4),
1147             "69:6: " + getCheckMessage(MSG_ERROR, "method def modifier", 5, 4),
1148             "70:6: " + getCheckMessage(MSG_ERROR, "final", 5, 9),
1149             "71:6: " + getCheckMessage(MSG_ERROR, "void", 5, 9),
1150             "72:5: " + getCheckMessage(MSG_ERROR, "method5", 4, 9),
1151             "86:11: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 10, 12),
1152             "89:11: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 10, 12),
1153             "99:7: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 6, 12),
1154         };
1155         verifyWarns(checkConfig, fileName, expected);
1156     }
1157 
1158     @Test
1159     public void testInvalidMethodWithChecker2()
1160             throws Exception {
1161         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1162 
1163         checkConfig.addProperty("arrayInitIndent", "4");
1164         checkConfig.addProperty("basicOffset", "4");
1165         checkConfig.addProperty("braceAdjustment", "0");
1166         checkConfig.addProperty("caseIndent", "4");
1167         checkConfig.addProperty("forceStrictCondition", "false");
1168         checkConfig.addProperty("lineWrappingIndentation", "4");
1169         checkConfig.addProperty("tabWidth", "4");
1170         checkConfig.addProperty("throwsIndent", "4");
1171         final String fileName = getPath("InputIndentationInvalidMethodIndent2.java");
1172         final String[] expected = {
1173             "23:5: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 4, 8),
1174             "26:4: " + getCheckMessage(MSG_ERROR, "method def modifier", 3, 4),
1175             "27:4: " + getCheckMessage(MSG_ERROR, "final", 3, 7),
1176             "28:4: " + getCheckMessage(MSG_ERROR, "void", 3, 7),
1177             "29:6: " + getCheckMessage(MSG_ERROR, "method6", 5, 7),
1178             "39:7: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 6, 8),
1179             "40:7: " + getCheckMessage(MSG_ERROR, "if", 6, 8),
1180             "41:11: " + getCheckMessage(MSG_CHILD_ERROR, "if", 10, 12),
1181             "42:7: " + getCheckMessage(MSG_ERROR, "if rcurly", 6, 8),
1182             "45:11: " + getCheckMessage(MSG_ERROR, "Arrays", 10, 12),
1183             "51:15: " + getCheckMessage(MSG_ERROR, "new", 14, 16),
1184             "54:11: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 10, 12),
1185             "59:15: " + getCheckMessage(MSG_ERROR, "new", 14, 16),
1186             "63:11: " + getCheckMessage(MSG_ERROR, "new", 10, 12),
1187             "67:11: " + getCheckMessage(MSG_ERROR, "new", 10, 12),
1188             "68:7: " + getCheckMessage(MSG_ERROR, ")", 6, 8),
1189             "72:7: " + getCheckMessage(MSG_ERROR, "method call rparen", 6, 8),
1190             "86:5: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 4, 8),
1191             "91:5: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 4, 8),
1192             "95:1: " + getCheckMessage(MSG_ERROR, "int", 0, 8),
1193             "96:5: " + getCheckMessage(MSG_ERROR, "method9", 4, 8),
1194             "106:13: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 12, 8),
1195         };
1196         verifyWarns(checkConfig, fileName, expected);
1197     }
1198 
1199     @Test
1200     public void testAlternativeGoogleStyleSwitchCaseAndEnums()
1201             throws Exception {
1202         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1203 
1204         checkConfig.addProperty("arrayInitIndent", "4");
1205         checkConfig.addProperty("basicOffset", "2");
1206         checkConfig.addProperty("braceAdjustment", "2");
1207         checkConfig.addProperty("caseIndent", "2");
1208         checkConfig.addProperty("forceStrictCondition", "false");
1209         checkConfig.addProperty("lineWrappingIndentation", "4");
1210         checkConfig.addProperty("tabWidth", "4");
1211         checkConfig.addProperty("throwsIndent", "4");
1212         final String fileName = getPath("InputIndentationSwitchCasesAndEnums.java");
1213         final String[] expected = {
1214             "18:7: " + getCheckMessage(MSG_CHILD_ERROR, "block", 6, 4),
1215             "35:7: " + getCheckMessage(MSG_ERROR, "block lcurly", 6, 8),
1216             "38:11: " + getCheckMessage(MSG_ERROR, "block rcurly", 10, 8),
1217             "54:5: " + getCheckMessage(MSG_ERROR, "block lcurly", 4, 2),
1218             "55:3: " + getCheckMessage(MSG_CHILD_ERROR, "block", 2, 4),
1219         };
1220         verifyWarns(checkConfig, fileName, expected);
1221     }
1222 
1223     @Test
1224     public void testInvalidSwitchWithChecker()
1225             throws Exception {
1226         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1227 
1228         checkConfig.addProperty("arrayInitIndent", "4");
1229         checkConfig.addProperty("basicOffset", "4");
1230         checkConfig.addProperty("braceAdjustment", "0");
1231         checkConfig.addProperty("caseIndent", "4");
1232         checkConfig.addProperty("forceStrictCondition", "false");
1233         checkConfig.addProperty("lineWrappingIndentation", "4");
1234         checkConfig.addProperty("tabWidth", "4");
1235         checkConfig.addProperty("throwsIndent", "4");
1236         final String fileName = getPath("InputIndentationInvalidSwitchIndent.java");
1237         final String[] expected = {
1238             "30:7: " + getCheckMessage(MSG_ERROR, "switch", 6, 8),
1239             "32:11: " + getCheckMessage(MSG_CHILD_ERROR, "case", 10, 12),
1240             "33:15: " + getCheckMessage(MSG_CHILD_ERROR, "block", 14, 16),
1241             "37:15: " + getCheckMessage(MSG_CHILD_ERROR, "block", 14, 16),
1242             "39:15: " + getCheckMessage(MSG_CHILD_ERROR, "case", 14, 12),
1243             "40:11: " + getCheckMessage(MSG_CHILD_ERROR, "case", 10, 12),
1244             "43:11: " + getCheckMessage(MSG_CHILD_ERROR, "case", 10, 12),
1245             "44:15: " + getCheckMessage(MSG_CHILD_ERROR, "block", 14, 16),
1246             "45:15: " + getCheckMessage(MSG_CHILD_ERROR, "block", 14, 16),
1247             "53:15: " + getCheckMessage(MSG_CHILD_ERROR, "block", 14, 16),
1248             "54:19: " + getCheckMessage(MSG_CHILD_ERROR, "block", 18, 16),
1249             "55:11: " + getCheckMessage(MSG_ERROR, "block rcurly", 10, 12),
1250             "59:11: " + getCheckMessage(MSG_ERROR, "block lcurly", 10, 12),
1251             "62:15: " + getCheckMessage(MSG_ERROR, "block rcurly", 14, 12),
1252             "66:15: " + getCheckMessage(MSG_ERROR, "block lcurly", 14, 12),
1253             "69:11: " + getCheckMessage(MSG_ERROR, "block rcurly", 10, 12),
1254             "76:15: " + getCheckMessage(MSG_CHILD_ERROR, "case", 14, 16),
1255             "81:15: " + getCheckMessage(MSG_CHILD_ERROR, "case", 14, 16),
1256             "89:7: " + getCheckMessage(MSG_ERROR, "switch rcurly", 6, 8),
1257             "92:7: " + getCheckMessage(MSG_ERROR, "switch lcurly", 6, 8),
1258             "93:11: " + getCheckMessage(MSG_ERROR, "switch rcurly", 10, 8),
1259             "95:11: " + getCheckMessage(MSG_ERROR, "switch lcurly", 10, 8),
1260             "96:7: " + getCheckMessage(MSG_ERROR, "switch rcurly", 6, 8),
1261             "99:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 12),
1262             "100:13: " + getCheckMessage(MSG_ERROR, "if", 12, 16),
1263             "101:17: " + getCheckMessage(MSG_CHILD_ERROR, "if", 16, 20),
1264             "102:13: " + getCheckMessage(MSG_ERROR, "else", 12, 16),
1265             "103:17: " + getCheckMessage(MSG_CHILD_ERROR, "else", 16, 20),
1266             "106:17: " + getCheckMessage(MSG_CHILD_ERROR, "case", 4, 12),
1267         };
1268         verifyWarns(checkConfig, fileName, expected);
1269     }
1270 
1271     @Test
1272     public void testIfElseWithNoCurly()
1273             throws Exception {
1274         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1275 
1276         checkConfig.addProperty("arrayInitIndent", "4");
1277         checkConfig.addProperty("basicOffset", "4");
1278         checkConfig.addProperty("braceAdjustment", "0");
1279         checkConfig.addProperty("caseIndent", "4");
1280         checkConfig.addProperty("forceStrictCondition", "false");
1281         checkConfig.addProperty("lineWrappingIndentation", "4");
1282         checkConfig.addProperty("tabWidth", "4");
1283         checkConfig.addProperty("throwsIndent", "4");
1284         final String fileName = getPath("InputIndentationIfElseWithNoCurly.java");
1285         final String[] expected = {
1286             "20:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
1287             "25:5: " + getCheckMessage(MSG_ERROR, "if", 4, 8),
1288             "26:9: " + getCheckMessage(MSG_CHILD_ERROR, "if", 8, 12),
1289             "37:13: " + getCheckMessage(MSG_ERROR, "else", 12, 8),
1290             "39:9: " + getCheckMessage(MSG_ERROR, "if", 8, 12),
1291             "43:9: " + getCheckMessage(MSG_CHILD_ERROR, "if", 8, 16),
1292         };
1293         verifyWarns(checkConfig, fileName, expected);
1294     }
1295 
1296     @Test
1297     public void testWhileWithNoCurly()
1298             throws Exception {
1299         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1300 
1301         checkConfig.addProperty("arrayInitIndent", "4");
1302         checkConfig.addProperty("basicOffset", "4");
1303         checkConfig.addProperty("braceAdjustment", "0");
1304         checkConfig.addProperty("caseIndent", "4");
1305         checkConfig.addProperty("forceStrictCondition", "false");
1306         checkConfig.addProperty("lineWrappingIndentation", "4");
1307         checkConfig.addProperty("tabWidth", "4");
1308         checkConfig.addProperty("throwsIndent", "4");
1309         final String fileName = getPath("InputIndentationWhileNoCurly.java");
1310         final String[] expected = {
1311             "21:1: " + getCheckMessage(MSG_CHILD_ERROR, "while", 0, 12),
1312             "26:5: " + getCheckMessage(MSG_ERROR, "while", 4, 8),
1313             "27:9: " + getCheckMessage(MSG_CHILD_ERROR, "while", 8, 12),
1314             "32:9: " + getCheckMessage(MSG_ERROR, "while", 8, 12),
1315             "36:9: " + getCheckMessage(MSG_CHILD_ERROR, "while", 8, 16),
1316         };
1317         verifyWarns(checkConfig, fileName, expected);
1318     }
1319 
1320     @Test
1321     public void testForWithNoCurly()
1322             throws Exception {
1323         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1324 
1325         checkConfig.addProperty("arrayInitIndent", "4");
1326         checkConfig.addProperty("basicOffset", "4");
1327         checkConfig.addProperty("braceAdjustment", "0");
1328         checkConfig.addProperty("caseIndent", "4");
1329         checkConfig.addProperty("forceStrictCondition", "false");
1330         checkConfig.addProperty("lineWrappingIndentation", "4");
1331         checkConfig.addProperty("tabWidth", "4");
1332         checkConfig.addProperty("throwsIndent", "4");
1333         final String fileName = getPath("InputIndentationForWithoutCurly.java");
1334         final String[] expected = {
1335             "21:1: " + getCheckMessage(MSG_CHILD_ERROR, "for", 0, 12),
1336             "26:5: " + getCheckMessage(MSG_ERROR, "for", 4, 8),
1337             "27:9: " + getCheckMessage(MSG_CHILD_ERROR, "for", 8, 12),
1338             "32:9: " + getCheckMessage(MSG_ERROR, "for", 8, 12),
1339             "33:9: " + getCheckMessage(MSG_CHILD_ERROR, "for", 8, 16),
1340             "37:9: " + getCheckMessage(MSG_CHILD_ERROR, "for", 8, 16),
1341 
1342         };
1343         verifyWarns(checkConfig, fileName, expected);
1344     }
1345 
1346     @Test
1347     public void testDoWhileWithoutCurly()
1348             throws Exception {
1349         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1350 
1351         checkConfig.addProperty("arrayInitIndent", "4");
1352         checkConfig.addProperty("basicOffset", "4");
1353         checkConfig.addProperty("braceAdjustment", "0");
1354         checkConfig.addProperty("caseIndent", "4");
1355         checkConfig.addProperty("forceStrictCondition", "false");
1356         checkConfig.addProperty("lineWrappingIndentation", "4");
1357         checkConfig.addProperty("tabWidth", "4");
1358         checkConfig.addProperty("throwsIndent", "4");
1359         final String fileName = getPath("InputIndentationDoWhile.java");
1360         final String[] expected = {
1361             "23:9: " + getCheckMessage(MSG_CHILD_ERROR, "do..while", 8, 12),
1362             "30:5: " + getCheckMessage(MSG_ERROR, "do..while while", 4, 8),
1363             "33:13: " + getCheckMessage(MSG_ERROR, "do..while while", 12, 8),
1364         };
1365         verifyWarns(checkConfig, fileName, expected);
1366     }
1367 
1368     @Test
1369     public void testValidSwitchWithChecker()
1370             throws Exception {
1371         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1372 
1373         checkConfig.addProperty("arrayInitIndent", "4");
1374         checkConfig.addProperty("basicOffset", "4");
1375         checkConfig.addProperty("braceAdjustment", "0");
1376         checkConfig.addProperty("caseIndent", "4");
1377         checkConfig.addProperty("forceStrictCondition", "false");
1378         checkConfig.addProperty("lineWrappingIndentation", "4");
1379         checkConfig.addProperty("tabWidth", "4");
1380         checkConfig.addProperty("throwsIndent", "4");
1381         final String fileName = getPath("InputIndentationValidSwitchIndent.java");
1382         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1383         verifyWarns(checkConfig, fileName, expected);
1384     }
1385 
1386     @Test
1387     public void testNewKeyword() throws Exception {
1388         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1389 
1390         checkConfig.addProperty("basicOffset", "4");
1391         checkConfig.addProperty("forceStrictCondition", "false");
1392         checkConfig.addProperty("lineWrappingIndentation", "8");
1393         checkConfig.addProperty("tabWidth", "4");
1394         checkConfig.addProperty("throwsIndent", "8");
1395         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1396         verifyWarns(checkConfig, getPath("InputIndentationNew.java"), expected);
1397     }
1398 
1399     @Test
1400     public void testNewKeywordWithTab() throws Exception {
1401         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1402 
1403         checkConfig.addProperty("basicOffset", "4");
1404         checkConfig.addProperty("forceStrictCondition", "false");
1405         checkConfig.addProperty("lineWrappingIndentation", "4");
1406         checkConfig.addProperty("tabWidth", "4");
1407         checkConfig.addProperty("throwsIndent", "4");
1408         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1409         verifyWarns(checkConfig, getPath("InputIndentationNewWithTab.java"), expected);
1410     }
1411 
1412     @Test
1413     public void testNewBlockWithoutAssignment() throws Exception {
1414         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1415 
1416         checkConfig.addProperty("basicOffset", "4");
1417         checkConfig.addProperty("forceStrictCondition", "false");
1418         checkConfig.addProperty("lineWrappingIndentation", "4");
1419         checkConfig.addProperty("tabWidth", "4");
1420         final String[] expected = {
1421             "15:9: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
1422                     "object def", 8, "12, 16"),
1423             "17:9: " + getCheckMessage(MSG_ERROR_MULTI,
1424                     "method def modifier", 8, "12, 16"),
1425             "19:13: " + getCheckMessage(MSG_ERROR_MULTI, "if", 12, "16, 20"),
1426             "20:17: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "if", 16, "20, 24"),
1427             "21:13: " + getCheckMessage(MSG_ERROR_MULTI, "if rcurly", 12, "16, 20"),
1428             "22:9: " + getCheckMessage(MSG_ERROR_MULTI,
1429                     "method def rcurly", 8, "12, 16"),
1430         };
1431         verifyWarns(checkConfig,
1432                 getPath("InputIndentationNewBlockWithoutAssignment.java"), expected);
1433     }
1434 
1435     @Test
1436     public void testNewKeywordWithTabRegression() throws Exception {
1437         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1438 
1439         checkConfig.addProperty("basicOffset", "8");
1440         checkConfig.addProperty("forceStrictCondition", "false");
1441         checkConfig.addProperty("lineWrappingIndentation", "4");
1442         checkConfig.addProperty("tabWidth", "8");
1443         final String[] expected = {
1444             "16:33: " + getCheckMessage(MSG_ERROR, "new", 32, 36),
1445             "27:33: " + getCheckMessage(MSG_ERROR_MULTI,
1446                     "method def modifier", 32, "20, 24, 28"),
1447             "29:41: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
1448                     "method def", 40, "28, 32, 36"),
1449             "30:33: " + getCheckMessage(MSG_ERROR_MULTI,
1450                     "method def rcurly", 32, "20, 24, 28"),
1451             "31:25: " + getCheckMessage(MSG_ERROR_MULTI,
1452                     "object def rcurly", 24, "12, 16, 20"),
1453         };
1454         verifyWarns(checkConfig, getPath("InputIndentationNewWithTabRegression.java"), expected);
1455     }
1456 
1457     @Test
1458     public void testNewKeywordWithTabSpringRegression() throws Exception {
1459         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1460 
1461         checkConfig.addProperty("basicOffset", "8");
1462         checkConfig.addProperty("forceStrictCondition", "false");
1463         checkConfig.addProperty("lineWrappingIndentation", "4");
1464         checkConfig.addProperty("tabWidth", "8");
1465         final String[] expected = {
1466             "16:33: " + getCheckMessage(MSG_ERROR_MULTI,
1467                     "method def modifier", 32, "20, 24, 28"),
1468             "19:33: " + getCheckMessage(MSG_ERROR_MULTI,
1469                     "method def rcurly", 32, "20, 24, 28"),
1470             "20:33: " + getCheckMessage(MSG_ERROR_MULTI,
1471                     "method def modifier", 32, "20, 24, 28"),
1472             "23:33: " + getCheckMessage(MSG_ERROR_MULTI,
1473                     "method def rcurly", 32, "20, 24, 28"),
1474             "24:33: " + getCheckMessage(MSG_ERROR_MULTI,
1475                     "method def modifier", 32, "20, 24, 28"),
1476             "27:33: " + getCheckMessage(MSG_ERROR_MULTI,
1477                     "method def rcurly", 32, "20, 24, 28"),
1478             "28:33: " + getCheckMessage(MSG_ERROR_MULTI,
1479                     "method def modifier", 32, "20, 24, 28"),
1480             "30:41: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
1481                     "method def", 40, "28, 32, 36"),
1482             "31:33: " + getCheckMessage(MSG_ERROR_MULTI,
1483                     "method def rcurly", 32, "20, 24, 28"),
1484             "32:25: " + getCheckMessage(MSG_ERROR_MULTI,
1485                     "object def rcurly", 24, "12, 16, 20"),
1486         };
1487         verifyWarns(checkConfig,
1488                 getPath("InputIndentationNewWithTabSpring.java"), expected);
1489     }
1490 
1491     @Test
1492     public void testNewKeywordWithTabStrict() throws Exception {
1493         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1494 
1495         checkConfig.addProperty("basicOffset", "4");
1496         checkConfig.addProperty("forceStrictCondition", "true");
1497         checkConfig.addProperty("lineWrappingIndentation", "4");
1498         checkConfig.addProperty("tabWidth", "4");
1499         checkConfig.addProperty("throwsIndent", "4");
1500         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1501         verifyWarns(checkConfig, getPath("InputIndentationNewWithTabStrict.java"), expected);
1502     }
1503 
1504     @Test
1505     public void testNewKeywordChildren() throws Exception {
1506         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1507 
1508         checkConfig.addProperty("arrayInitIndent", "2");
1509         checkConfig.addProperty("basicOffset", "2");
1510         checkConfig.addProperty("braceAdjustment", "2");
1511         checkConfig.addProperty("caseIndent", "2");
1512         checkConfig.addProperty("forceStrictCondition", "false");
1513         checkConfig.addProperty("lineWrappingIndentation", "4");
1514         checkConfig.addProperty("tabWidth", "4");
1515         checkConfig.addProperty("throwsIndent", "4");
1516         final String[] expected = {
1517             "27:1: " + getCheckMessage(MSG_ERROR_MULTI, "new", 0, "14, 16"),
1518             "28:1: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "new", 0, "18, 20"),
1519             "36:1: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "new", 0, "18, 20"),
1520             "42:9: " + getCheckMessage(MSG_ERROR, "new", 8, 12),
1521             "43:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "object def", 10, "14, 16, 18"),
1522             "51:1: " + getCheckMessage(MSG_CHILD_ERROR, "new", 0, 16),
1523             "56:5: " + getCheckMessage(MSG_CHILD_ERROR, "new", 4, 8),
1524             "57:5: " + getCheckMessage(MSG_CHILD_ERROR, "new", 4, 8),
1525             "63:5: " + getCheckMessage(MSG_ERROR_MULTI, "lambda arguments", 4, "10, 12"),
1526             "64:1: " + getCheckMessage(MSG_CHILD_ERROR, "new", 0, 8),
1527         };
1528         verifyWarns(checkConfig, getPath("InputIndentationNewChildren.java"), expected);
1529     }
1530 
1531     @Test
1532     public void testNewKeywordChildrenSevntuConfig() throws Exception {
1533         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1534 
1535         checkConfig.addProperty("arrayInitIndent", "4");
1536         checkConfig.addProperty("basicOffset", "4");
1537         checkConfig.addProperty("braceAdjustment", "0");
1538         checkConfig.addProperty("caseIndent", "4");
1539         checkConfig.addProperty("forceStrictCondition", "false");
1540         checkConfig.addProperty("lineWrappingIndentation", "8");
1541         checkConfig.addProperty("tabWidth", "4");
1542         checkConfig.addProperty("throwsIndent", "8");
1543         final String[] expected = {
1544             "43:29: " + getCheckMessage(MSG_CHILD_ERROR, "new", 28, 36),
1545         };
1546         verifyWarns(checkConfig,
1547                 getPath("InputIndentationNewChildrenSevntuConfig.java"), expected);
1548     }
1549 
1550     @Test
1551     public void testNewKeyword2() throws Exception {
1552         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1553 
1554         checkConfig.addProperty("basicOffset", "4");
1555         checkConfig.addProperty("forceStrictCondition", "true");
1556         checkConfig.addProperty("lineWrappingIndentation", "8");
1557         checkConfig.addProperty("tabWidth", "4");
1558         checkConfig.addProperty("throwsIndent", "8");
1559         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1560         verifyWarns(checkConfig, getPath("InputIndentationNew.java"), expected);
1561     }
1562 
1563     // we can not use verifyWarns() due to usage of multi line string syntax in input
1564     @Test
1565     public void testTextBlockLiteral() throws Exception {
1566         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1567 
1568         checkConfig.addProperty("lineWrappingIndentation", "4");
1569         checkConfig.addProperty("forceStrictCondition", "true");
1570         checkConfig.addProperty("tabWidth", "4");
1571         final String[] expected = {
1572             "18:1: " + getCheckMessage(MSG_ERROR, "\"\"\"", 0, 8),
1573             "29:17: " + getCheckMessage(MSG_ERROR, "\"\"\"", 16, 12),
1574             "46:1: " + getCheckMessage(MSG_ERROR, "\"\"\"", 0, 12),
1575             "52:1: " + getCheckMessage(MSG_ERROR, "\"\"\"", 0, 12),
1576             "59:9: " + getCheckMessage(MSG_ERROR, "\"\"\"", 8, 12),
1577             "78:15: " + getCheckMessage(MSG_ERROR, "\"\"\"", 14, 12),
1578         };
1579         verifyWarns(checkConfig, getPath("InputIndentationTextBlock.java"),
1580             expected);
1581     }
1582 
1583     @Test
1584     public void testValidNewKeywordWithForceStrictCondition() throws Exception {
1585         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1586 
1587         checkConfig.addProperty("basicOffset", "4");
1588         checkConfig.addProperty("forceStrictCondition", "true");
1589         checkConfig.addProperty("lineWrappingIndentation", "8");
1590         checkConfig.addProperty("tabWidth", "4");
1591         checkConfig.addProperty("throwsIndent", "8");
1592         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1593         verifyWarns(checkConfig, getPath("InputIndentationNew.java"), expected);
1594     }
1595 
1596     @Test
1597     public void testInvalidNewKeywordWithForceStrictCondition() throws Exception {
1598         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1599 
1600         checkConfig.addProperty("basicOffset", "4");
1601         checkConfig.addProperty("forceStrictCondition", "true");
1602         checkConfig.addProperty("lineWrappingIndentation", "8");
1603         checkConfig.addProperty("tabWidth", "4");
1604         checkConfig.addProperty("throwsIndent", "8");
1605         final String[] expected = {
1606             "21:12: " + getCheckMessage(MSG_ERROR, "]", 11, 12),
1607             "25:5: " + getCheckMessage(MSG_ERROR, "[", 4, 12),
1608             "32:17: " + getCheckMessage(MSG_ERROR, "new", 16, 24),
1609             "33:21: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "object def", 20, "28, 32, 36"),
1610             "34:17: " + getCheckMessage(MSG_ERROR_MULTI, "object def rcurly", 16, "24, 28, 32"),
1611             "37:36: " + getCheckMessage(MSG_ERROR, "+", 35, 16),
1612             "41:35: " + getCheckMessage(MSG_ERROR, "]", 34, 16),
1613             "45:36: " + getCheckMessage(MSG_ERROR, "42", 35, 16),
1614             "49:36: " + getCheckMessage(MSG_ERROR, "+", 35, 16),
1615             "50:36: " + getCheckMessage(MSG_ERROR, "+", 35, 16),
1616             "55:21: " + getCheckMessage(MSG_ERROR, "1", 20, 16),
1617             "59:13: " + getCheckMessage(MSG_ERROR, "fun2", 12, 16),
1618             "78:11: " + getCheckMessage(MSG_ERROR, "Object", 10, 12),
1619             "82:16: " + getCheckMessage(MSG_ERROR, "]", 15, 12),
1620         };
1621         verifyWarns(checkConfig,
1622             getPath("InputIndentationNewWithForceStrictCondition.java"), expected);
1623     }
1624 
1625     @Test
1626     public void testValidArrayInitDefaultIndentWithChecker()
1627             throws Exception {
1628         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1629 
1630         checkConfig.addProperty("arrayInitIndent", "4");
1631         checkConfig.addProperty("basicOffset", "4");
1632         checkConfig.addProperty("braceAdjustment", "0");
1633         checkConfig.addProperty("caseIndent", "4");
1634         checkConfig.addProperty("forceStrictCondition", "false");
1635         checkConfig.addProperty("lineWrappingIndentation", "4");
1636         checkConfig.addProperty("tabWidth", "4");
1637         checkConfig.addProperty("throwsIndent", "4");
1638         final String fileName = getPath("InputIndentationValidArrayInitDefaultIndent.java");
1639         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1640         verifyWarns(checkConfig, fileName, expected);
1641     }
1642 
1643     @Test
1644     public void testValidArrayInitWithChecker()
1645             throws Exception {
1646         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1647 
1648         checkConfig.addProperty("arrayInitIndent", "8");
1649         checkConfig.addProperty("basicOffset", "4");
1650         checkConfig.addProperty("braceAdjustment", "0");
1651         checkConfig.addProperty("caseIndent", "4");
1652         checkConfig.addProperty("forceStrictCondition", "false");
1653         checkConfig.addProperty("lineWrappingIndentation", "4");
1654         checkConfig.addProperty("tabWidth", "4");
1655         checkConfig.addProperty("throwsIndent", "4");
1656         final String fileName = getPath("InputIndentationValidArrayInitIndent.java");
1657         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1658         verifyWarns(checkConfig, fileName, expected);
1659     }
1660 
1661     @Test
1662     public void testValidArrayInitTwoDimensional() throws Exception {
1663         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1664 
1665         checkConfig.addProperty("arrayInitIndent", "2");
1666         checkConfig.addProperty("basicOffset", "4");
1667         checkConfig.addProperty("braceAdjustment", "4");
1668         checkConfig.addProperty("caseIndent", "4");
1669         checkConfig.addProperty("forceStrictCondition", "false");
1670         checkConfig.addProperty("lineWrappingIndentation", "4");
1671         checkConfig.addProperty("tabWidth", "4");
1672         checkConfig.addProperty("throwsIndent", "4");
1673         final String fileName = getPath("InputIndentationValidArrayInitIndentTwoDimensional.java");
1674         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1675         verifyWarns(checkConfig, fileName, expected);
1676     }
1677 
1678     @Test
1679     public void testInvalidArrayInitTwoDimensional() throws Exception {
1680         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1681 
1682         checkConfig.addProperty("arrayInitIndent", "2");
1683         checkConfig.addProperty("basicOffset", "4");
1684         checkConfig.addProperty("braceAdjustment", "4");
1685         checkConfig.addProperty("caseIndent", "4");
1686         checkConfig.addProperty("forceStrictCondition", "false");
1687         checkConfig.addProperty("lineWrappingIndentation", "4");
1688         checkConfig.addProperty("tabWidth", "4");
1689         checkConfig.addProperty("throwsIndent", "4");
1690         final String fileName =
1691             getPath("InputIndentationInvalidArrayInitIndent2D.java");
1692         final String[] expected = {
1693             "19:5: " + getCheckMessage(MSG_ERROR_MULTI,
1694                 "array initialization lcurly", 4, "6, 8, 20, 56, 60"),
1695             "24:10: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
1696                 "array initialization", 9, "8, 10, 12, 22, 24, 56, 58, 60"),
1697             "27:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
1698                 "array initialization", 6, "8, 10, 12, 22, 24, 56, 58, 60"),
1699             "29:5: " + getCheckMessage(MSG_ERROR_MULTI,
1700                 "array initialization lcurly", 4, "6, 8, 20, 56, 60"),
1701             "30:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI,
1702                 "array initialization", 6, "8, 10, 12, 22, 24, 56, 58, 60"),
1703             "31:5: " + getCheckMessage(MSG_ERROR_MULTI,
1704                 "array initialization rcurly", 4, "6, 8, 20, 56, 60"),
1705 
1706         };
1707         verifyWarns(checkConfig, fileName, expected);
1708     }
1709 
1710     @Test
1711     public void testValidArrayInit()
1712             throws Exception {
1713         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1714 
1715         checkConfig.addProperty("arrayInitIndent", "2");
1716         checkConfig.addProperty("basicOffset", "2");
1717         checkConfig.addProperty("braceAdjustment", "2");
1718         checkConfig.addProperty("caseIndent", "2");
1719         checkConfig.addProperty("forceStrictCondition", "false");
1720         checkConfig.addProperty("lineWrappingIndentation", "4");
1721         checkConfig.addProperty("tabWidth", "4");
1722         checkConfig.addProperty("throwsIndent", "4");
1723         final String fileName = getPath("InputIndentationValidArrayInitIndentTwo.java");
1724         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
1725         verifyWarns(checkConfig, fileName, expected);
1726     }
1727 
1728     @Test
1729     public void testArrayInitWithSupplementaryCharactersBeforeLeftCurly() throws Exception {
1730         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1731         checkConfig.addProperty("tabWidth", "4");
1732         final String[] expected = {
1733             "32:16: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1734                     15, "8, 16, 18"),
1735         };
1736         verifyWarns(checkConfig,
1737                 getPath("InputIndentationArrayInitCodePoints.java"), expected);
1738     }
1739 
1740     @Test
1741     public void testArrayInitWithEmoji() throws Exception {
1742         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1743 
1744         checkConfig.addProperty("arrayInitIndent", "2");
1745         checkConfig.addProperty("basicOffset", "2");
1746         checkConfig.addProperty("braceAdjustment", "2");
1747         checkConfig.addProperty("caseIndent", "2");
1748         checkConfig.addProperty("forceStrictCondition", "false");
1749         checkConfig.addProperty("lineWrappingIndentation", "4");
1750         checkConfig.addProperty("tabWidth", "4");
1751         checkConfig.addProperty("throwsIndent", "4");
1752         final String fileName = getPath("InputIndentationArrayInitIndentWithEmoji.java");
1753         final String[] expected = {
1754             "20:6: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1755                5, "4, 6, 54, 56"),
1756             "25:9: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1757                8, "4, 6, 37, 56"),
1758             "26:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1759                10, "4, 6, 37, 56"),
1760             "31:11: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization lcurly",
1761                10, "4, 6, 21, 56, 60"),
1762         };
1763         verifyWarns(checkConfig, fileName, expected);
1764     }
1765 
1766     @Test
1767     public void testYieldKeywordWithForceStrictCondition() throws Exception {
1768         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1769         checkConfig.addProperty("forceStrictCondition", "true");
1770         checkConfig.addProperty("tabWidth", "4");
1771         final String[] expected = {
1772             "15:13: " + getCheckMessage(MSG_CHILD_ERROR, "block", 12, 16),
1773             "16:13: " + getCheckMessage(MSG_ERROR, "yield", 12, 16),
1774             "44:13: " + getCheckMessage(MSG_CHILD_ERROR, "block", 12, 16),
1775             "45:13: " + getCheckMessage(MSG_ERROR, "yield", 12, 16),
1776             "50:5: " + getCheckMessage(MSG_ERROR, "yield", 4, 16),
1777             "71:15: " + getCheckMessage(MSG_ERROR, "yield", 14, 16),
1778             "74:20: " + getCheckMessage(MSG_ERROR, "yield", 19, 16),
1779             "77:9: " + getCheckMessage(MSG_ERROR, "yield", 8, 16),
1780         };
1781         verifyWarns(checkConfig,
1782                 getPath("InputIndentationYieldForceStrict.java"), expected);
1783     }
1784 
1785     @Test
1786     public void testChainedMethodCalling() throws Exception {
1787         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1788 
1789         checkConfig.addProperty("arrayInitIndent", "2");
1790         checkConfig.addProperty("basicOffset", "2");
1791         checkConfig.addProperty("braceAdjustment", "2");
1792         checkConfig.addProperty("caseIndent", "2");
1793         checkConfig.addProperty("forceStrictCondition", "false");
1794         checkConfig.addProperty("lineWrappingIndentation", "4");
1795         checkConfig.addProperty("tabWidth", "4");
1796         checkConfig.addProperty("throwsIndent", "4");
1797         final String fileName = getPath("InputIndentationChainedMethodCalls.java");
1798         final String[] expected = {
1799             "36:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 8),
1800             "41:5: " + getCheckMessage(MSG_ERROR, ".", 4, 8),
1801             "42:5: " + getCheckMessage(MSG_ERROR, ".", 4, 8),
1802             "45:5: " + getCheckMessage(MSG_ERROR, "new", 4, 8),
1803         };
1804         verifyWarns(checkConfig, fileName, expected);
1805     }
1806 
1807     @Test
1808     public void testInvalidArrayInitWithTrueStrictCondition()
1809             throws Exception {
1810         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1811 
1812         checkConfig.addProperty("arrayInitIndent", "4");
1813         checkConfig.addProperty("basicOffset", "4");
1814         checkConfig.addProperty("braceAdjustment", "0");
1815         checkConfig.addProperty("caseIndent", "4");
1816         checkConfig.addProperty("forceStrictCondition", "true");
1817         checkConfig.addProperty("lineWrappingIndentation", "4");
1818         checkConfig.addProperty("tabWidth", "4");
1819         checkConfig.addProperty("throwsIndent", "4");
1820         final String fileName = getPath("InputIndentationInvalidArrayInitIndent.java");
1821         final String[] expected = {
1822             "22:3: " + getCheckMessage(MSG_ERROR, "member def type", 2, 4),
1823             "23:7: " + getCheckMessage(MSG_ERROR, "member def type", 6, 4),
1824             "25:3: " + getCheckMessage(MSG_ERROR, "member def type", 2, 4),
1825             "29:7: " + getCheckMessage(MSG_ERROR, "member def type", 6, 4),
1826             "30:9: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 8,
1827                 "10, 36, 71"),
1828             "31:5: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 4, "6, 10"),
1829             "34:10: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 9,
1830                 "8, 33, 71"),
1831             "35:8: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 7,
1832                 "8, 33, 71"),
1833             "36:10: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 9,
1834                 "8, 33, 71"),
1835             "41:3: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization lcurly", 2, "4, 8"),
1836             "45:7: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 6, "4, 8"),
1837             "49:3: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization lcurly", 2, "4, 8"),
1838             "53:21: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 20,
1839                 "8, 31, 33"),
1840             "54:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1841                 4, "8, 31, 33"),
1842             "59:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1843                 6, "8, 33, 71"),
1844             "64:3: " + getCheckMessage(MSG_ERROR, "member def type", 2, 4),
1845             "66:7: " + getCheckMessage(MSG_ERROR, "member def type", 6, 4),
1846             "67:3: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 2, "6, 10"),
1847             "70:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1848                 6, "8, 38, 71"),
1849             "77:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1850                 10, "12, 26, 71"),
1851         };
1852 
1853         verifyWarns(checkConfig, fileName, expected);
1854     }
1855 
1856     @Test
1857     public void testInvalidArrayInitWithTrueStrictCondition1()
1858             throws Exception {
1859         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1860 
1861         checkConfig.addProperty("arrayInitIndent", "4");
1862         checkConfig.addProperty("basicOffset", "4");
1863         checkConfig.addProperty("braceAdjustment", "0");
1864         checkConfig.addProperty("caseIndent", "4");
1865         checkConfig.addProperty("forceStrictCondition", "true");
1866         checkConfig.addProperty("lineWrappingIndentation", "4");
1867         checkConfig.addProperty("tabWidth", "4");
1868         checkConfig.addProperty("throwsIndent", "4");
1869         final String fileName = getPath("InputIndentationInvalidArrayInitIndent1.java");
1870         final String[] expected = {
1871             "30:9: " + getCheckMessage(MSG_ERROR, "1", 8, 12),
1872             "41:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 10,
1873                 "12, 32, 71"),
1874             "42:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 14,
1875                 "12, 32, 71"),
1876             "45:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 10,
1877                 "12, 32, 71"),
1878             "46:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 14,
1879                 "12, 32, 71"),
1880             "47:7: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 6, "8, 12"),
1881             "50:7: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization lcurly", 6, "8, 12"),
1882             "51:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 14,
1883                 "10, 12, 71"),
1884             "53:7: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 6, "8, 12"),
1885             // following are tests for annotation array initialization
1886             "61:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
1887                 12, "16, 46, 48"),
1888             "65:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
1889                 14, "12, 16, 71"),
1890             "69:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
1891                 14, "16, 28, 30"),
1892             "70:9: " + getCheckMessage(MSG_ERROR_MULTI, "annotation array initialization rcurly",
1893                 8, "12, 16"),
1894             "72:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
1895                 12, "16, 31, 71"),
1896         };
1897 
1898         verifyWarns(checkConfig, fileName, expected);
1899     }
1900 
1901     @Test
1902     public void testInvalidArrayInitWithFalseStrictCondition()
1903             throws Exception {
1904         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1905 
1906         checkConfig.addProperty("arrayInitIndent", "4");
1907         checkConfig.addProperty("basicOffset", "4");
1908         checkConfig.addProperty("braceAdjustment", "0");
1909         checkConfig.addProperty("caseIndent", "4");
1910         checkConfig.addProperty("forceStrictCondition", "false");
1911         checkConfig.addProperty("lineWrappingIndentation", "4");
1912         checkConfig.addProperty("tabWidth", "4");
1913         checkConfig.addProperty("throwsIndent", "4");
1914         final String fileName = getPath("InputIndentationInvalidArrayInitIndent.java");
1915         final String[] expected = {
1916             "22:3: " + getCheckMessage(MSG_ERROR, "member def type", 2, 4),
1917             "23:7: " + getCheckMessage(MSG_ERROR, "member def type", 6, 4),
1918             "25:3: " + getCheckMessage(MSG_ERROR, "member def type", 2, 4),
1919             "29:7: " + getCheckMessage(MSG_ERROR, "member def type", 6, 4),
1920             "30:9: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 8,
1921                 "10, 36, 71"),
1922             "31:5: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 4, "6, 10"),
1923             "34:10: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 9,
1924                 "8, 33, 71"),
1925             "35:8: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 7,
1926                 "8, 33, 71"),
1927             "36:10: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 9,
1928                 "8, 33, 71"),
1929             "41:3: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization lcurly", 2, "4, 8"),
1930             "45:7: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 6, "4, 8"),
1931             "49:3: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization lcurly", 2, "4, 8"),
1932             "53:21: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 20,
1933                 "8, 31, 33"),
1934             "54:5: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1935                 4, "8, 31, 33"),
1936             "59:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1937                 6, "8, 33, 71"),
1938             "64:3: " + getCheckMessage(MSG_ERROR, "member def type", 2, 4),
1939             "66:7: " + getCheckMessage(MSG_ERROR, "member def type", 6, 4),
1940             "67:3: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 2, "6, 10"),
1941             "70:7: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1942                 6, "8, 38, 71"),
1943             "77:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization",
1944                 10, "12, 26, 71"),
1945         };
1946 
1947         verifyWarns(checkConfig, fileName, expected);
1948     }
1949 
1950     @Test
1951     public void testInvalidArrayInitWithFalseStrictCondition1()
1952             throws Exception {
1953         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
1954 
1955         checkConfig.addProperty("arrayInitIndent", "4");
1956         checkConfig.addProperty("basicOffset", "4");
1957         checkConfig.addProperty("braceAdjustment", "0");
1958         checkConfig.addProperty("caseIndent", "4");
1959         checkConfig.addProperty("forceStrictCondition", "false");
1960         checkConfig.addProperty("lineWrappingIndentation", "4");
1961         checkConfig.addProperty("tabWidth", "4");
1962         checkConfig.addProperty("throwsIndent", "4");
1963         final String fileName = getPath("InputIndentationInvalidArrayInitIndent1.java");
1964         final String[] expected = {
1965             "30:9: " + getCheckMessage(MSG_ERROR, "1", 8, 12),
1966             "41:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 10,
1967                 "12, 32, 71"),
1968             "42:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 14,
1969                 "12, 32, 71"),
1970             "45:11: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 10,
1971                 "12, 32, 71"),
1972             "46:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 14,
1973                 "12, 32, 71"),
1974             "47:7: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 6, "8, 12"),
1975             "50:7: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization lcurly", 6, "8, 12"),
1976             "51:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 14,
1977                 "10, 12, 71"),
1978             "53:7: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 6, "8, 12"),
1979             // following are tests for annotation array initialization
1980             "61:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
1981                 12, "16, 46, 48"),
1982             "65:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
1983                 14, "12, 16, 71"),
1984             "69:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
1985                 14, "16, 28, 30"),
1986             "70:9: " + getCheckMessage(MSG_ERROR_MULTI, "annotation array initialization rcurly",
1987                 8, "12, 16"),
1988             "72:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
1989                 12, "16, 31, 71"),
1990         };
1991 
1992         verifyWarns(checkConfig, fileName, expected);
1993     }
1994 
1995     // Test Input without trailing comment and usage of 'verify' method is due to #16906
1996     @Test
1997     public void testInvalidArrayInitIndentNoCommentsTrueStrictCondition()
1998             throws Exception {
1999         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2000 
2001         checkConfig.addProperty("arrayInitIndent", "4");
2002         checkConfig.addProperty("basicOffset", "4");
2003         checkConfig.addProperty("braceAdjustment", "0");
2004         checkConfig.addProperty("caseIndent", "4");
2005         checkConfig.addProperty("forceStrictCondition", "true");
2006         checkConfig.addProperty("lineWrappingIndentation", "4");
2007         checkConfig.addProperty("tabWidth", "4");
2008         checkConfig.addProperty("throwsIndent", "4");
2009         final String fileName = getPath(
2010             "InputIndentationInvalidArrInitIndentNoTrailingComments.java");
2011         final String[] expected = {
2012             "31:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
2013                 12, "16, 46, 48"),
2014             "37:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
2015                 14, "12, 16"),
2016             "41:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
2017                 14, "16, 28, 30"),
2018             "42:9: " + getCheckMessage(MSG_ERROR_MULTI, "annotation array initialization rcurly",
2019                 8, "12, 16"),
2020             "45:13: " + getCheckMessage(MSG_CHILD_ERROR, "annotation array initialization",
2021                 12, 16),
2022         };
2023         verifyWarns(checkConfig, fileName, expected);
2024     }
2025 
2026     // Test Input without trailing comment and usage of 'verify' method is due to #16906
2027     @Test
2028     public void testInvalidArrayInitIndentNoCommentsFalseStrictCondition()
2029             throws Exception {
2030         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2031 
2032         checkConfig.addProperty("arrayInitIndent", "4");
2033         checkConfig.addProperty("basicOffset", "4");
2034         checkConfig.addProperty("braceAdjustment", "0");
2035         checkConfig.addProperty("caseIndent", "4");
2036         checkConfig.addProperty("forceStrictCondition", "false");
2037         checkConfig.addProperty("lineWrappingIndentation", "4");
2038         checkConfig.addProperty("tabWidth", "4");
2039         checkConfig.addProperty("throwsIndent", "4");
2040         final String fileName = getPath(
2041             "InputIndentationInvalidArrInitIndentNoTrailingComments.java");
2042         final String[] expected = {
2043             "31:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
2044                 12, "16, 46, 48"),
2045             "37:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
2046                 14, "12, 16"),
2047             "41:15: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "annotation array initialization",
2048                 14, "16, 28, 30"),
2049             "42:9: " + getCheckMessage(MSG_ERROR_MULTI, "annotation array initialization rcurly",
2050                 8, "12, 16"),
2051             "45:13: " + getCheckMessage(MSG_CHILD_ERROR, "annotation array initialization",
2052                 12, 16),
2053         };
2054         verifyWarns(checkConfig, fileName, expected);
2055     }
2056 
2057     @Test
2058     public void testValidTryWithChecker()
2059             throws Exception {
2060         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2061 
2062         checkConfig.addProperty("arrayInitIndent", "4");
2063         checkConfig.addProperty("basicOffset", "4");
2064         checkConfig.addProperty("braceAdjustment", "0");
2065         checkConfig.addProperty("caseIndent", "4");
2066         checkConfig.addProperty("forceStrictCondition", "false");
2067         checkConfig.addProperty("lineWrappingIndentation", "4");
2068         checkConfig.addProperty("tabWidth", "4");
2069         checkConfig.addProperty("throwsIndent", "4");
2070         final String fileName = getPath("InputIndentationValidTryIndent.java");
2071         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2072         verifyWarns(checkConfig, fileName, expected);
2073     }
2074 
2075     @Test
2076     public void testInvalidTryWithChecker()
2077             throws Exception {
2078         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2079 
2080         checkConfig.addProperty("arrayInitIndent", "4");
2081         checkConfig.addProperty("basicOffset", "4");
2082         checkConfig.addProperty("braceAdjustment", "0");
2083         checkConfig.addProperty("caseIndent", "4");
2084         checkConfig.addProperty("forceStrictCondition", "false");
2085         checkConfig.addProperty("lineWrappingIndentation", "4");
2086         checkConfig.addProperty("tabWidth", "4");
2087         checkConfig.addProperty("throwsIndent", "4");
2088         final String fileName = getPath("InputIndentationInvalidTryIndent.java");
2089         final String[] expected = {
2090             "25:10: " + getCheckMessage(MSG_ERROR, "try", 9, 8),
2091             "26:8: " + getCheckMessage(MSG_ERROR, "try rcurly", 7, 8),
2092             "28:8: " + getCheckMessage(MSG_ERROR, "catch rcurly", 7, 8),
2093             "30:5: " + getCheckMessage(MSG_ERROR, "try", 4, 8),
2094             "31:9: " + getCheckMessage(MSG_CHILD_ERROR, "try", 8, 12),
2095             "32:5: " + getCheckMessage(MSG_ERROR, "try rcurly", 4, 8),
2096             "33:9: " + getCheckMessage(MSG_CHILD_ERROR, "finally", 8, 12),
2097             "38:9: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 8, 12),
2098             "43:11: " + getCheckMessage(MSG_ERROR, "try rcurly", 10, 8),
2099             "45:7: " + getCheckMessage(MSG_ERROR, "catch rcurly", 6, 8),
2100             "52:6: " + getCheckMessage(MSG_ERROR, "catch rcurly", 5, 8),
2101             "59:11: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 10, 12),
2102             "60:15: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 14, 12),
2103             "61:11: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 10, 12),
2104             "63:7: " + getCheckMessage(MSG_ERROR, "catch", 6, 8),
2105             "70:11: " + getCheckMessage(MSG_ERROR, "try lcurly", 10, 8),
2106             "72:11: " + getCheckMessage(MSG_ERROR, "try rcurly", 10, 8),
2107             "74:7: " + getCheckMessage(MSG_ERROR, "catch lcurly", 6, 8),
2108             "77:11: " + getCheckMessage(MSG_ERROR, "catch rcurly", 10, 8),
2109             "80:11: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 10, 12),
2110             "86:1: " + getCheckMessage(MSG_ERROR, "try", 0, 8),
2111             "87:1: " + getCheckMessage(MSG_ERROR, "try rcurly", 0, 8),
2112             "88:1: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 0, 12),
2113             "89:1: " + getCheckMessage(MSG_ERROR, "catch rcurly", 0, 8),
2114             "91:1: " + getCheckMessage(MSG_ERROR, "try", 0, 8),
2115             "92:1: " + getCheckMessage(MSG_ERROR, "try rcurly", 0, 8),
2116             "93:1: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 0, 12),
2117             "94:1: " + getCheckMessage(MSG_ERROR, "catch rcurly", 0, 8),
2118         };
2119         verifyWarns(checkConfig, fileName, expected);
2120     }
2121 
2122     @Test
2123     public void testCatchParametersOnNewLine()
2124             throws Exception {
2125         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2126 
2127         checkConfig.addProperty("arrayInitIndent", "2");
2128         checkConfig.addProperty("basicOffset", "2");
2129         checkConfig.addProperty("braceAdjustment", "2");
2130         checkConfig.addProperty("caseIndent", "2");
2131         checkConfig.addProperty("forceStrictCondition", "false");
2132         checkConfig.addProperty("lineWrappingIndentation", "4");
2133         checkConfig.addProperty("tabWidth", "4");
2134         checkConfig.addProperty("throwsIndent", "4");
2135         final String fileName =
2136             getPath("InputIndentationCatchParametersOnNewLine.java");
2137 
2138         final String[] expected = {
2139             "22:1: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 0, 8),
2140             "31:5: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 4, 8),
2141             "38:5: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 4, 8),
2142             "48:13: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 12, 8),
2143             "64:9: " + getCheckMessage(MSG_CHILD_ERROR, "catch", 8, 12),
2144         };
2145         verifyWarns(checkConfig, fileName, expected);
2146     }
2147 
2148     @Test
2149     public void testMultiLineStatements()
2150             throws Exception {
2151         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2152 
2153         checkConfig.addProperty("arrayInitIndent", "2");
2154         checkConfig.addProperty("basicOffset", "2");
2155         checkConfig.addProperty("braceAdjustment", "2");
2156         checkConfig.addProperty("caseIndent", "2");
2157         checkConfig.addProperty("forceStrictCondition", "false");
2158         checkConfig.addProperty("lineWrappingIndentation", "4");
2159         checkConfig.addProperty("tabWidth", "4");
2160         checkConfig.addProperty("throwsIndent", "4");
2161         final String fileName =
2162             getPath("InputIndentationMultilineStatements.java");
2163 
2164         final String[] expected = {
2165             "23:7: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 6, 8),
2166             "39:7: " + getCheckMessage(MSG_ERROR, 0, 6, 8),
2167             "40:7: " + getCheckMessage(MSG_ERROR, 1, 6, 8),
2168             "65:7: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 6, 8),
2169         };
2170         verifyWarns(checkConfig, fileName, expected);
2171     }
2172 
2173     @Test
2174     public void testInvalidClassDefWithChecker()
2175             throws Exception {
2176         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2177 
2178         checkConfig.addProperty("arrayInitIndent", "4");
2179         checkConfig.addProperty("basicOffset", "4");
2180         checkConfig.addProperty("braceAdjustment", "0");
2181         checkConfig.addProperty("caseIndent", "4");
2182         checkConfig.addProperty("forceStrictCondition", "false");
2183         checkConfig.addProperty("lineWrappingIndentation", "4");
2184         checkConfig.addProperty("tabWidth", "4");
2185         checkConfig.addProperty("throwsIndent", "4");
2186         final String fileName = getPath("InputIndentationInvalidClassDefIndent.java");
2187         final String[] expected = {
2188             "18:3: " + getCheckMessage(MSG_ERROR, "class def modifier", 2, 0),
2189             "24:3: " + getCheckMessage(MSG_ERROR, "class def lcurly", 2, 0),
2190             "27:3: " + getCheckMessage(MSG_ERROR, "class def rcurly", 2, 0),
2191             "30:9: " + getCheckMessage(MSG_ERROR, "class def ident", 2, 0),
2192             "34:3: " + getCheckMessage(MSG_ERROR, "class def rcurly", 2, 0),
2193             "39:3: " + getCheckMessage(MSG_ERROR, "extends", 2, 4),
2194             "40:3: " + getCheckMessage(MSG_ERROR, "implements", 2, 4),
2195             "46:3: " + getCheckMessage(MSG_ERROR, "extends", 2, 4),
2196             "54:3: " + getCheckMessage(MSG_ERROR, "implements", 2, 4),
2197             "55:3: " + getCheckMessage(MSG_ERROR, "java", 2, 4),
2198             "60:3: " + getCheckMessage(MSG_ERROR, "class def modifier", 2, 0),
2199             "61:3: " + getCheckMessage(MSG_ERROR, "class def lcurly", 2, 0),
2200             "69:3: " + getCheckMessage(MSG_ERROR, "class def rcurly", 2, 0),
2201             "73:3: " + getCheckMessage(MSG_ERROR, "extends", 2, 4),
2202             "81:1: " + getCheckMessage(MSG_ERROR, "class", 0, 4),
2203         };
2204         verifyWarns(checkConfig, fileName, expected);
2205     }
2206 
2207     @Test
2208     public void testInvalidClassDefWithChecker1()
2209             throws Exception {
2210         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2211 
2212         checkConfig.addProperty("arrayInitIndent", "4");
2213         checkConfig.addProperty("basicOffset", "4");
2214         checkConfig.addProperty("braceAdjustment", "0");
2215         checkConfig.addProperty("caseIndent", "4");
2216         checkConfig.addProperty("forceStrictCondition", "false");
2217         checkConfig.addProperty("lineWrappingIndentation", "4");
2218         checkConfig.addProperty("tabWidth", "4");
2219         checkConfig.addProperty("throwsIndent", "4");
2220         final String fileName = getPath("InputIndentationInvalidClassDefIndent1.java");
2221         final String[] expected = {
2222             "23:3: " + getCheckMessage(MSG_ERROR, "class def modifier", 2, 0),
2223             "28:9: " + getCheckMessage(MSG_ERROR, "class def ident", 2, 4),
2224             "30:13: " + getCheckMessage(MSG_ERROR, "class def ident", 6, 4),
2225             "32:9: " + getCheckMessage(MSG_ERROR, "class def ident", 2, 4),
2226             "35:7: " + getCheckMessage(MSG_ERROR, "member def modifier", 6, 8),
2227             "41:11: " + getCheckMessage(MSG_ERROR, "int", 10, 12),
2228             "45:7: " + getCheckMessage(MSG_ERROR, "member def modifier", 6, 8),
2229             "50:7: " + getCheckMessage(MSG_ERROR, "class def rcurly", 6, 4),
2230             "52:13: " + getCheckMessage(MSG_ERROR, "class def ident", 6, 4),
2231             "57:13: " + getCheckMessage(MSG_ERROR, "class def ident", 6, 8),
2232             "60:17: " + getCheckMessage(MSG_ERROR, "class def ident", 10, 8),
2233             "62:11: " + getCheckMessage(MSG_ERROR, "class def rcurly", 10, 8),
2234             "65:11: " + getCheckMessage(MSG_ERROR, "member def type", 10, 12),
2235             "70:11: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 10, 8),
2236             "71:9: " + getCheckMessage(MSG_ERROR_MULTI, "object def lcurly", 8, "10, 14"),
2237             "75:9: " + getCheckMessage(MSG_ERROR_MULTI, "object def rcurly", 8, "10, 14"),
2238             "78:7: " + getCheckMessage(MSG_ERROR_MULTI, "object def lcurly", 6, "8, 12"),
2239             "82:7: " + getCheckMessage(MSG_ERROR_MULTI, "object def rcurly", 6, "8, 12"),
2240             "86:11: " + getCheckMessage(MSG_ERROR, "method def modifier", 10, 12),
2241             "88:11: " + getCheckMessage(MSG_ERROR, "method def rcurly", 10, 12),
2242         };
2243         verifyWarns(checkConfig, fileName, expected);
2244     }
2245 
2246     @Test
2247     public void testInvalidBlockWithChecker()
2248             throws Exception {
2249         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2250 
2251         checkConfig.addProperty("arrayInitIndent", "4");
2252         checkConfig.addProperty("basicOffset", "4");
2253         checkConfig.addProperty("braceAdjustment", "0");
2254         checkConfig.addProperty("caseIndent", "4");
2255         checkConfig.addProperty("forceStrictCondition", "false");
2256         checkConfig.addProperty("lineWrappingIndentation", "4");
2257         checkConfig.addProperty("tabWidth", "4");
2258         checkConfig.addProperty("throwsIndent", "4");
2259         final String fileName = getPath("InputIndentationInvalidBlockIndent.java");
2260         final String[] expected = {
2261             "26:8: " + getCheckMessage(MSG_ERROR, "block lcurly", 7, 8),
2262             "27:10: " + getCheckMessage(MSG_ERROR, "block lcurly", 9, 8),
2263             "29:10: " + getCheckMessage(MSG_ERROR, "block lcurly", 9, 8),
2264             "30:8: " + getCheckMessage(MSG_ERROR, "block rcurly", 7, 8),
2265             "32:7: " + getCheckMessage(MSG_ERROR, "block lcurly", 6, 8),
2266             "34:7: " + getCheckMessage(MSG_ERROR, "block rcurly", 6, 8),
2267             "35:7: " + getCheckMessage(MSG_ERROR, "block lcurly", 6, 8),
2268             "38:10: " + getCheckMessage(MSG_ERROR, "block lcurly", 9, 8),
2269             "39:14: " + getCheckMessage(MSG_CHILD_ERROR, "block", 13, 12),
2270             "41:14: " + getCheckMessage(MSG_CHILD_ERROR, "block", 13, 12),
2271             "42:10: " + getCheckMessage(MSG_ERROR, "block rcurly", 9, 8),
2272             "45:7: " + getCheckMessage(MSG_ERROR, "block lcurly", 6, 8),
2273             "46:11: " + getCheckMessage(MSG_CHILD_ERROR, "block", 10, 12),
2274             "48:11: " + getCheckMessage(MSG_CHILD_ERROR, "block", 10, 12),
2275             "49:7: " + getCheckMessage(MSG_ERROR, "block rcurly", 6, 8),
2276             "52:7: " + getCheckMessage(MSG_ERROR, "block lcurly", 6, 8),
2277             "55:11: " + getCheckMessage(MSG_CHILD_ERROR, "block", 10, 12),
2278             "59:11: " + getCheckMessage(MSG_ERROR, "block lcurly", 10, 12),
2279             "63:11: " + getCheckMessage(MSG_ERROR, "block rcurly", 10, 12),
2280             "68:11: " + getCheckMessage(MSG_CHILD_ERROR, "block", 10, 12),
2281             "70:11: " + getCheckMessage(MSG_ERROR, "block lcurly", 10, 12),
2282             "71:15: " + getCheckMessage(MSG_CHILD_ERROR, "block", 14, 16),
2283             "86:11: " + getCheckMessage(MSG_ERROR, "block rcurly", 10, 12),
2284         };
2285         verifyWarns(checkConfig, fileName, expected);
2286     }
2287 
2288     @Test
2289     public void testInvalidBlockWithChecker1()
2290             throws Exception {
2291         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2292 
2293         checkConfig.addProperty("arrayInitIndent", "4");
2294         checkConfig.addProperty("basicOffset", "4");
2295         checkConfig.addProperty("braceAdjustment", "0");
2296         checkConfig.addProperty("caseIndent", "4");
2297         checkConfig.addProperty("forceStrictCondition", "false");
2298         checkConfig.addProperty("lineWrappingIndentation", "4");
2299         checkConfig.addProperty("tabWidth", "4");
2300         checkConfig.addProperty("throwsIndent", "4");
2301         final String fileName = getPath("InputIndentationInvalidBlockIndent1.java");
2302         final String[] expected = {
2303             "27:3: " + getCheckMessage(MSG_ERROR, "static initialization", 2, 4),
2304             "28:7: " + getCheckMessage(MSG_ERROR, "static initialization", 6, 4),
2305             "32:8: " + getCheckMessage(MSG_CHILD_ERROR, "static initialization", 7, 8),
2306             "35:7: " + getCheckMessage(MSG_ERROR, "static initialization", 6, 4),
2307             "37:3: " + getCheckMessage(MSG_ERROR, "static initialization rcurly", 2, 4),
2308             "39:3: " + getCheckMessage(MSG_ERROR, "static initialization", 2, 4),
2309             "41:7: " + getCheckMessage(MSG_ERROR, "static initialization rcurly", 6, 4),
2310             "43:3: " + getCheckMessage(MSG_ERROR, "static initialization", 2, 4),
2311             "45:7: " + getCheckMessage(MSG_CHILD_ERROR, "static initialization", 6, 8),
2312             "48:3: " + getCheckMessage(MSG_ERROR, "static initialization lcurly", 2, 4),
2313             "49:7: " + getCheckMessage(MSG_CHILD_ERROR, "static initialization", 6, 8),
2314             "50:7: " + getCheckMessage(MSG_ERROR, "static initialization rcurly", 6, 4),
2315             "55:7: " + getCheckMessage(MSG_CHILD_ERROR, "static initialization", 6, 8),
2316             "60:5: " + getCheckMessage(MSG_CHILD_ERROR, "static initialization", 4, 8),
2317             "61:3: " + getCheckMessage(MSG_ERROR, "static initialization rcurly", 2, 4),
2318             "66:7: " + getCheckMessage(MSG_ERROR, "static initialization rcurly", 6, 4),
2319             "69:3: " + getCheckMessage(MSG_ERROR, "block lcurly", 2, 4),
2320             "70:7: " + getCheckMessage(MSG_ERROR, "block lcurly", 6, 4),
2321             "73:3: " + getCheckMessage(MSG_ERROR, "block lcurly", 2, 4),
2322             "75:7: " + getCheckMessage(MSG_ERROR, "block rcurly", 6, 4),
2323             "77:7: " + getCheckMessage(MSG_ERROR, "block lcurly", 6, 4),
2324             "79:3: " + getCheckMessage(MSG_ERROR, "block rcurly", 2, 4),
2325             "82:7: " + getCheckMessage(MSG_CHILD_ERROR, "block", 6, 8),
2326         };
2327         verifyWarns(checkConfig, fileName, expected);
2328     }
2329 
2330     @Test
2331     public void testInvalidIfWithChecker()
2332             throws Exception {
2333         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2334 
2335         checkConfig.addProperty("arrayInitIndent", "4");
2336         checkConfig.addProperty("basicOffset", "4");
2337         checkConfig.addProperty("braceAdjustment", "0");
2338         checkConfig.addProperty("caseIndent", "4");
2339         checkConfig.addProperty("forceStrictCondition", "false");
2340         checkConfig.addProperty("lineWrappingIndentation", "4");
2341         checkConfig.addProperty("tabWidth", "4");
2342         checkConfig.addProperty("throwsIndent", "4");
2343         final String fileName = getPath("InputIndentationInvalidIfIndent.java");
2344         final String[] expected = {
2345             "54:2: " + getCheckMessage(MSG_ERROR, "if", 1, 8),
2346             "60:10: " + getCheckMessage(MSG_ERROR, "if", 9, 8),
2347             "61:10: " + getCheckMessage(MSG_ERROR, "if lcurly", 9, 8),
2348             "62:8: " + getCheckMessage(MSG_ERROR, "if rcurly", 7, 8),
2349             "64:7: " + getCheckMessage(MSG_ERROR, "if", 6, 8),
2350             "65:6: " + getCheckMessage(MSG_ERROR, "if lcurly", 5, 8),
2351             "66:6: " + getCheckMessage(MSG_ERROR, "if rcurly", 5, 8),
2352             "71:11: " + getCheckMessage(MSG_ERROR, "if rcurly", 10, 8),
2353             "72:8: " + getCheckMessage(MSG_ERROR, "else rcurly", 7, 8),
2354             "75:10: " + getCheckMessage(MSG_ERROR, "if", 9, 8),
2355 
2356             "76:8: " + getCheckMessage(MSG_ERROR, "if lcurly", 7, 8),
2357             "78:10: " + getCheckMessage(MSG_ERROR, "else", 9, 8),
2358             "80:10: " + getCheckMessage(MSG_ERROR, "else rcurly", 9, 8),
2359             "83:11: " + getCheckMessage(MSG_ERROR, "if", 10, 8),
2360             "84:8: " + getCheckMessage(MSG_ERROR, "if rcurly", 7, 8),
2361             "85:10: " + getCheckMessage(MSG_ERROR, "else", 9, 8),
2362             "86:8: " + getCheckMessage(MSG_ERROR, "else lcurly", 7, 8),
2363             "87:10: " + getCheckMessage(MSG_ERROR, "else rcurly", 9, 8),
2364 
2365             "91:10: " + getCheckMessage(MSG_ERROR, "if", 9, 8),
2366             "92:10: " + getCheckMessage(MSG_ERROR, "if lcurly", 9, 8),
2367             "93:10: " + getCheckMessage(MSG_ERROR, "if rcurly", 9, 8),
2368             "94:8: " + getCheckMessage(MSG_ERROR, "else lcurly", 7, 8),
2369             "95:11: " + getCheckMessage(MSG_ERROR, "else rcurly", 10, 8),
2370             "98:7: " + getCheckMessage(MSG_ERROR, "if", 6, 8),
2371             "99:11: " + getCheckMessage(MSG_ERROR, "if lcurly", 10, 8),
2372             "100:11: " + getCheckMessage(MSG_ERROR, "if rcurly", 10, 8),
2373             "101:8: " + getCheckMessage(MSG_ERROR, "else rcurly", 7, 8),
2374             "104:6: " + getCheckMessage(MSG_ERROR, "if", 5, 8),
2375             "105:12: " + getCheckMessage(MSG_ERROR, "if rcurly", 11, 8),
2376             "106:6: " + getCheckMessage(MSG_ERROR, "else", 5, 8),
2377             "107:12: " + getCheckMessage(MSG_ERROR, "else rcurly", 11, 8),
2378         };
2379         verifyWarns(checkConfig, fileName, expected);
2380     }
2381 
2382     @Test
2383     public void testInvalidIfWithChecker1()
2384             throws Exception {
2385         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2386 
2387         checkConfig.addProperty("arrayInitIndent", "4");
2388         checkConfig.addProperty("basicOffset", "4");
2389         checkConfig.addProperty("braceAdjustment", "0");
2390         checkConfig.addProperty("caseIndent", "4");
2391         checkConfig.addProperty("forceStrictCondition", "false");
2392         checkConfig.addProperty("lineWrappingIndentation", "4");
2393         checkConfig.addProperty("tabWidth", "4");
2394         checkConfig.addProperty("throwsIndent", "4");
2395         final String fileName = getPath("InputIndentationInvalidIfIndent1.java");
2396         final String[] expected = {
2397             "37:15: " + getCheckMessage(MSG_CHILD_ERROR, "if", 14, 12),
2398             "42:11: " + getCheckMessage(MSG_ERROR, "if lcurly", 10, 8),
2399             "43:11: " + getCheckMessage(MSG_CHILD_ERROR, "if", 10, 12),
2400             "48:15: " + getCheckMessage(MSG_CHILD_ERROR, "if", 14, 12),
2401             "49:11: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 10, 12),
2402             "51:11: " + getCheckMessage(MSG_CHILD_ERROR, "else", 10, 12),
2403             "52:9: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 8, 12),
2404 
2405             "59:17: " + getCheckMessage(MSG_CHILD_ERROR, "if", 16, 12),
2406             "60:10: " + getCheckMessage(MSG_ERROR, "if rcurly", 9, 8),
2407             "63:17: " + getCheckMessage(MSG_CHILD_ERROR, "else", 16, 12),
2408             "69:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
2409             "73:41: " + getCheckMessage(MSG_CHILD_ERROR, "else", 40, 12),
2410             "80:15: " + getCheckMessage(MSG_CHILD_ERROR, "if", 14, 12),
2411 
2412             "83:15: " + getCheckMessage(MSG_CHILD_ERROR, "else", 14, 12),
2413             "89:11: " + getCheckMessage(MSG_CHILD_ERROR, "if", 10, 12),
2414             "91:11: " + getCheckMessage(MSG_CHILD_ERROR, "else", 10, 12),
2415             "95:11: " + getCheckMessage(MSG_ERROR, "if", 10, 8),
2416             "96:15: " + getCheckMessage(MSG_CHILD_ERROR, "if", 14, 12),
2417             "97:11: " + getCheckMessage(MSG_ERROR, "if rcurly", 10, 8),
2418             "98:11: " + getCheckMessage(MSG_ERROR, "else", 10, 8),
2419             "99:15: " + getCheckMessage(MSG_CHILD_ERROR, "else", 14, 12),
2420             "100:11: " + getCheckMessage(MSG_ERROR, "else rcurly", 10, 8),
2421         };
2422         verifyWarns(checkConfig, fileName, expected);
2423     }
2424 
2425     @Test
2426     public void testInvalidIfWithChecker2()
2427             throws Exception {
2428         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2429 
2430         checkConfig.addProperty("arrayInitIndent", "4");
2431         checkConfig.addProperty("basicOffset", "4");
2432         checkConfig.addProperty("braceAdjustment", "0");
2433         checkConfig.addProperty("caseIndent", "4");
2434         checkConfig.addProperty("forceStrictCondition", "false");
2435         checkConfig.addProperty("lineWrappingIndentation", "4");
2436         checkConfig.addProperty("tabWidth", "4");
2437         checkConfig.addProperty("throwsIndent", "4");
2438         final String fileName = getPath("InputIndentationInvalidIfIndent2.java");
2439         final String[] expected = {
2440             "26:10: " + getCheckMessage(MSG_CHILD_ERROR, "if", 9, 12),
2441             "27:12: " + getCheckMessage(MSG_CHILD_ERROR, "if", 11, 12),
2442             "31:11: " + getCheckMessage(MSG_CHILD_ERROR, "if", 10, 12),
2443             "34:8: " + getCheckMessage(MSG_ERROR, "if rcurly", 7, 8),
2444             "41:11: " + getCheckMessage(MSG_CHILD_ERROR, "if", 10, 12),
2445             "43:11: " + getCheckMessage(MSG_CHILD_ERROR, "if", 10, 12),
2446 
2447             "50:11: " + getCheckMessage(MSG_CHILD_ERROR, "if", 10, 12),
2448             "59:11: " + getCheckMessage(MSG_ERROR, "if", 10, 12),
2449             "63:19: " + getCheckMessage(MSG_CHILD_ERROR, "if", 18, 20),
2450             "74:11: " + getCheckMessage(MSG_ERROR, "if rparen", 10, 8),
2451             "79:7: " + getCheckMessage(MSG_ERROR, "if rparen", 6, 8),
2452             "85:7: " + getCheckMessage(MSG_ERROR, "if lparen", 6, 8),
2453             "87:7: " + getCheckMessage(MSG_ERROR, "if rparen", 6, 8),
2454             "90:1: " + getCheckMessage(MSG_ERROR, "if", 0, 8),
2455             "91:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
2456             "92:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
2457             "93:1: " + getCheckMessage(MSG_ERROR, "if rcurly", 0, 8),
2458             "94:1: " + getCheckMessage(MSG_ERROR, "if", 0, 8),
2459             "95:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
2460             "96:1: " + getCheckMessage(MSG_ERROR, "else", 0, 8),
2461             "97:1: " + getCheckMessage(MSG_CHILD_ERROR, "else", 0, 12),
2462         };
2463         verifyWarns(checkConfig, fileName, expected);
2464     }
2465 
2466     @Test
2467     public void testInvalidWhileWithChecker()
2468             throws Exception {
2469         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2470 
2471         checkConfig.addProperty("arrayInitIndent", "4");
2472         checkConfig.addProperty("basicOffset", "4");
2473         checkConfig.addProperty("braceAdjustment", "0");
2474         checkConfig.addProperty("caseIndent", "4");
2475         checkConfig.addProperty("forceStrictCondition", "false");
2476         checkConfig.addProperty("lineWrappingIndentation", "4");
2477         checkConfig.addProperty("tabWidth", "4");
2478         checkConfig.addProperty("throwsIndent", "4");
2479         final String fileName = getPath("InputIndentationInvalidWhileIndent.java");
2480         final String[] expected = {
2481             "25:10: " + getCheckMessage(MSG_ERROR, "while", 9, 8),
2482             "26:8: " + getCheckMessage(MSG_ERROR, "while rcurly", 7, 8),
2483             "28:8: " + getCheckMessage(MSG_ERROR, "while", 7, 8),
2484             "29:10: " + getCheckMessage(MSG_ERROR, "while lcurly", 9, 8),
2485             "30:10: " + getCheckMessage(MSG_ERROR, "while rcurly", 9, 8),
2486 
2487             "32:10: " + getCheckMessage(MSG_ERROR, "while", 9, 8),
2488             "33:7: " + getCheckMessage(MSG_ERROR, "while lcurly", 6, 8),
2489             "34:15: " + getCheckMessage(MSG_CHILD_ERROR, "while", 14, 12),
2490             "35:7: " + getCheckMessage(MSG_ERROR, "while rcurly", 6, 8),
2491 
2492             "37:11: " + getCheckMessage(MSG_ERROR, "while", 10, 8),
2493             "39:11: " + getCheckMessage(MSG_ERROR, "while rcurly", 10, 8),
2494             "41:11: " + getCheckMessage(MSG_ERROR, "while", 10, 8),
2495             "44:11: " + getCheckMessage(MSG_ERROR, "while rcurly", 10, 8),
2496 
2497             "46:7: " + getCheckMessage(MSG_ERROR, "while", 6, 8),
2498             "47:11: " + getCheckMessage(MSG_ERROR, "while lcurly", 10, 8),
2499             "50:7: " + getCheckMessage(MSG_ERROR, "while rcurly", 6, 8),
2500             "53:15: " + getCheckMessage(MSG_ERROR, "if", 14, 12),
2501             "54:19: " + getCheckMessage(MSG_CHILD_ERROR, "if", 18, 16),
2502             "55:15: " + getCheckMessage(MSG_ERROR, "if rcurly", 14, 12),
2503             "56:15: " + getCheckMessage(MSG_CHILD_ERROR, "while", 14, 12),
2504             "57:11: " + getCheckMessage(MSG_ERROR, "while rcurly", 10, 8),
2505 
2506             "60:11: " + getCheckMessage(MSG_CHILD_ERROR, "while", 10, 12),
2507             "66:11: " + getCheckMessage(MSG_CHILD_ERROR, "while", 10, 12),
2508             "71:11: " + getCheckMessage(MSG_CHILD_ERROR, "while", 10, 12),
2509             "78:6: " + getCheckMessage(MSG_ERROR, "while rparen", 5, 8),
2510             "85:11: " + getCheckMessage(MSG_ERROR, "while rparen", 10, 8),
2511             "92:11: " + getCheckMessage(MSG_ERROR, "while rparen", 10, 8),
2512             "99:9: " + getCheckMessage(MSG_CHILD_ERROR, "while", 8, 12),
2513         };
2514         verifyWarns(checkConfig, fileName, expected);
2515     }
2516 
2517     @Test
2518     public void testInvalidInvalidAnonymousClass() throws Exception {
2519         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2520 
2521         checkConfig.addProperty("arrayInitIndent", "4");
2522         checkConfig.addProperty("basicOffset", "4");
2523         checkConfig.addProperty("braceAdjustment", "0");
2524         checkConfig.addProperty("caseIndent", "4");
2525         checkConfig.addProperty("forceStrictCondition", "false");
2526         checkConfig.addProperty("lineWrappingIndentation", "4");
2527         checkConfig.addProperty("tabWidth", "4");
2528         checkConfig.addProperty("throwsIndent", "4");
2529         final String fileName = getPath("InputIndentationInvalidAnonymousClassIndent.java");
2530         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2531         verifyWarns(checkConfig, fileName, expected);
2532     }
2533 
2534     @Test
2535     public void testInvalidForWithChecker()
2536             throws Exception {
2537         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2538 
2539         checkConfig.addProperty("arrayInitIndent", "4");
2540         checkConfig.addProperty("basicOffset", "4");
2541         checkConfig.addProperty("braceAdjustment", "0");
2542         checkConfig.addProperty("caseIndent", "4");
2543         checkConfig.addProperty("forceStrictCondition", "false");
2544         checkConfig.addProperty("lineWrappingIndentation", "4");
2545         checkConfig.addProperty("tabWidth", "4");
2546         checkConfig.addProperty("throwsIndent", "4");
2547         final String fileName = getPath("InputIndentationInvalidForIndent.java");
2548         final String[] expected = {
2549             "27:7: " + getCheckMessage(MSG_ERROR, "for", 6, 8),
2550             "28:11: " + getCheckMessage(MSG_ERROR, "for rcurly", 10, 8),
2551             "30:10: " + getCheckMessage(MSG_ERROR, "for", 9, 8),
2552             "31:7: " + getCheckMessage(MSG_ERROR, "for lcurly", 6, 8),
2553             "32:7: " + getCheckMessage(MSG_ERROR, "for rcurly", 6, 8),
2554             "36:11: " + getCheckMessage(MSG_CHILD_ERROR, "for", 10, 12),
2555 
2556             "37:11: " + getCheckMessage(MSG_ERROR, "for rcurly", 10, 8),
2557             "40:11: " + getCheckMessage(MSG_ERROR, "for lcurly", 10, 8),
2558             "41:11: " + getCheckMessage(MSG_CHILD_ERROR, "for", 10, 12),
2559             "49:11: " + getCheckMessage(MSG_CHILD_ERROR, "for", 10, 12),
2560             "55:8: " + getCheckMessage(MSG_ERROR, "for", 7, 8),
2561 
2562             "56:11: " + getCheckMessage(MSG_CHILD_ERROR, "for", 10, 12),
2563             "65:8: " + getCheckMessage(MSG_CHILD_ERROR, "for", 7, 12),
2564 
2565             "70:7: " + getCheckMessage(MSG_ERROR, "for", 6, 8),
2566             "71:11: " + getCheckMessage(MSG_CHILD_ERROR, "for", 10, 12),
2567             "72:15: " + getCheckMessage(MSG_CHILD_ERROR, "for", 14, 16),
2568             "73:11: " + getCheckMessage(MSG_CHILD_ERROR, "for", 10, 12),
2569             "82:13: " + getCheckMessage(MSG_ERROR, "for rparen", 12, 8),
2570             "87:3: " + getCheckMessage(MSG_ERROR, "method def modifier", 2, 4),
2571             "88:5: " + getCheckMessage(MSG_ERROR, "for", 4, 8),
2572             "89:9: " + getCheckMessage(MSG_CHILD_ERROR, "for", 8, 12),
2573             "90:7: " + getCheckMessage(MSG_CHILD_ERROR, "for", 6, 12),
2574             "91:9: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 8, 16),
2575             "93:1: " + getCheckMessage(MSG_ERROR, "for", 0, 8),
2576             "94:1: " + getCheckMessage(MSG_ERROR, "for lparen", 0, 8),
2577             "95:1: " + getCheckMessage(MSG_CHILD_ERROR, "for", 0, 12),
2578             "96:1: " + getCheckMessage(MSG_ERROR, ";", 0, 4),
2579             "97:1: " + getCheckMessage(MSG_CHILD_ERROR, "for", 0, 12),
2580             "98:1: " + getCheckMessage(MSG_ERROR, ";", 0, 4),
2581             "99:1: " + getCheckMessage(MSG_CHILD_ERROR, "for", 0, 12),
2582         };
2583         verifyWarns(checkConfig, fileName, expected);
2584     }
2585 
2586     @Test
2587     public void testValidForWithChecker()
2588             throws Exception {
2589         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2590 
2591         checkConfig.addProperty("arrayInitIndent", "4");
2592         checkConfig.addProperty("basicOffset", "4");
2593         checkConfig.addProperty("braceAdjustment", "0");
2594         checkConfig.addProperty("caseIndent", "4");
2595         checkConfig.addProperty("forceStrictCondition", "false");
2596         checkConfig.addProperty("lineWrappingIndentation", "4");
2597         checkConfig.addProperty("tabWidth", "4");
2598         checkConfig.addProperty("throwsIndent", "4");
2599         final String fileName = getPath("InputIndentationValidForIndent.java");
2600         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2601         verifyWarns(checkConfig, fileName, expected);
2602     }
2603 
2604     @Test
2605     public void testValidDoWhileWithChecker()
2606             throws Exception {
2607         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2608 
2609         checkConfig.addProperty("arrayInitIndent", "4");
2610         checkConfig.addProperty("basicOffset", "4");
2611         checkConfig.addProperty("braceAdjustment", "0");
2612         checkConfig.addProperty("caseIndent", "4");
2613         checkConfig.addProperty("forceStrictCondition", "false");
2614         checkConfig.addProperty("lineWrappingIndentation", "4");
2615         checkConfig.addProperty("tabWidth", "4");
2616         checkConfig.addProperty("throwsIndent", "4");
2617         final String fileName = getPath("InputIndentationValidDoWhileIndent.java");
2618         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2619         verifyWarns(checkConfig, fileName, expected);
2620     }
2621 
2622     @Test
2623     public void testInvalidDoWhileWithChecker()
2624             throws Exception {
2625         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2626 
2627         checkConfig.addProperty("arrayInitIndent", "4");
2628         checkConfig.addProperty("basicOffset", "4");
2629         checkConfig.addProperty("braceAdjustment", "0");
2630         checkConfig.addProperty("caseIndent", "4");
2631         checkConfig.addProperty("forceStrictCondition", "false");
2632         checkConfig.addProperty("lineWrappingIndentation", "4");
2633         checkConfig.addProperty("tabWidth", "4");
2634         checkConfig.addProperty("throwsIndent", "4");
2635         final String fileName = getPath("InputIndentationInvalidDoWhileIndent.java");
2636         final String[] expected = {
2637             "7:1: " + getCheckMessage(MSG_ERROR, "do..while", 0, 8),
2638             "8:1: " + getCheckMessage(MSG_ERROR, "do..while", 0, 8),
2639             "9:1: " + getCheckMessage(MSG_ERROR, "do..while", 0, 8),
2640             "10:1: " + getCheckMessage(MSG_ERROR, "do..while rcurly", 0, 8),
2641             "11:1: " + getCheckMessage(MSG_ERROR, "do..while", 0, 8),
2642             "12:1: " + getCheckMessage(MSG_ERROR, "do..while while", 0, 8),
2643             "13:1: " + getCheckMessage(MSG_ERROR, "do..while", 0, 8),
2644             "14:1: " + getCheckMessage(MSG_ERROR, "do..while lcurly", 0, 8),
2645             "15:1: " + getCheckMessage(MSG_ERROR, "do..while", 0, 8),
2646             "16:1: " + getCheckMessage(MSG_ERROR, "do..while while", 0, 8),
2647             "17:1: " + getCheckMessage(MSG_ERROR, "do..while lparen", 0, 8),
2648             "18:1: " + getCheckMessage(MSG_ERROR, "do..while", 0, 8),
2649             "19:1: " + getCheckMessage(MSG_ERROR, "do..while lparen", 0, 8),
2650             "20:1: " + getCheckMessage(MSG_ERROR, "do..while", 0, 8),
2651             "21:1: " + getCheckMessage(MSG_ERROR, "do..while lparen", 0, 8),
2652             "22:1: " + getCheckMessage(MSG_CHILD_ERROR, "do..while", 0, 8),
2653             "23:1: " + getCheckMessage(MSG_ERROR, "do..while rparen", 0, 8),
2654         };
2655         verifyWarns(checkConfig, fileName, expected);
2656     }
2657 
2658     @Test
2659     public void testValidBlockWithChecker()
2660             throws Exception {
2661         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2662 
2663         checkConfig.addProperty("arrayInitIndent", "4");
2664         checkConfig.addProperty("basicOffset", "4");
2665         checkConfig.addProperty("braceAdjustment", "0");
2666         checkConfig.addProperty("caseIndent", "4");
2667         checkConfig.addProperty("forceStrictCondition", "false");
2668         checkConfig.addProperty("lineWrappingIndentation", "4");
2669         checkConfig.addProperty("tabWidth", "4");
2670         checkConfig.addProperty("throwsIndent", "4");
2671         final String fileName = getPath("InputIndentationValidBlockIndent.java");
2672         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2673         verifyWarns(checkConfig, fileName, expected);
2674     }
2675 
2676     @Test
2677     public void testValidBlockWithChecker1()
2678             throws Exception {
2679         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2680 
2681         checkConfig.addProperty("arrayInitIndent", "4");
2682         checkConfig.addProperty("basicOffset", "4");
2683         checkConfig.addProperty("braceAdjustment", "0");
2684         checkConfig.addProperty("caseIndent", "4");
2685         checkConfig.addProperty("forceStrictCondition", "false");
2686         checkConfig.addProperty("lineWrappingIndentation", "4");
2687         checkConfig.addProperty("tabWidth", "4");
2688         checkConfig.addProperty("throwsIndent", "4");
2689         final String fileName = getPath("InputIndentationValidBlockIndent1.java");
2690         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2691         verifyWarns(checkConfig, fileName, expected);
2692     }
2693 
2694     @Test
2695     public void testValidWhileWithChecker()
2696             throws Exception {
2697         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2698 
2699         checkConfig.addProperty("arrayInitIndent", "4");
2700         checkConfig.addProperty("basicOffset", "4");
2701         checkConfig.addProperty("braceAdjustment", "0");
2702         checkConfig.addProperty("caseIndent", "4");
2703         checkConfig.addProperty("forceStrictCondition", "false");
2704         checkConfig.addProperty("lineWrappingIndentation", "4");
2705         checkConfig.addProperty("tabWidth", "4");
2706         checkConfig.addProperty("throwsIndent", "4");
2707         final String fileName = getPath("InputIndentationValidWhileIndent.java");
2708         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2709         verifyWarns(checkConfig, fileName, expected);
2710     }
2711 
2712     @Test
2713     public void testValidClassDefWithChecker()
2714             throws Exception {
2715         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2716 
2717         checkConfig.addProperty("arrayInitIndent", "4");
2718         checkConfig.addProperty("basicOffset", "4");
2719         checkConfig.addProperty("braceAdjustment", "0");
2720         checkConfig.addProperty("caseIndent", "4");
2721         checkConfig.addProperty("forceStrictCondition", "false");
2722         checkConfig.addProperty("lineWrappingIndentation", "4");
2723         checkConfig.addProperty("tabWidth", "4");
2724         checkConfig.addProperty("throwsIndent", "4");
2725         final String fileName = getPath("InputIndentationValidClassDefIndent.java");
2726         final String[] expected = {
2727             "38:9: " + getCheckMessage(MSG_ERROR, "int", 8, 12),
2728         };
2729         verifyWarns(checkConfig, fileName, expected);
2730     }
2731 
2732     @Test
2733     public void testValidClassDefWithChecker1()
2734             throws Exception {
2735         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2736 
2737         checkConfig.addProperty("arrayInitIndent", "4");
2738         checkConfig.addProperty("basicOffset", "4");
2739         checkConfig.addProperty("braceAdjustment", "0");
2740         checkConfig.addProperty("caseIndent", "4");
2741         checkConfig.addProperty("forceStrictCondition", "false");
2742         checkConfig.addProperty("lineWrappingIndentation", "4");
2743         checkConfig.addProperty("tabWidth", "4");
2744         checkConfig.addProperty("throwsIndent", "4");
2745         final String fileName = getPath("InputIndentationValidClassDefIndent1.java");
2746         final String[] expected = {
2747             "43:1: " + getCheckMessage(MSG_ERROR, "class", 0, 4),
2748         };
2749         verifyWarns(checkConfig, fileName, expected);
2750     }
2751 
2752     @Test
2753     public void testValidInterfaceDefWithChecker()
2754             throws Exception {
2755         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2756 
2757         checkConfig.addProperty("arrayInitIndent", "4");
2758         checkConfig.addProperty("basicOffset", "4");
2759         checkConfig.addProperty("braceAdjustment", "0");
2760         checkConfig.addProperty("caseIndent", "4");
2761         checkConfig.addProperty("forceStrictCondition", "false");
2762         checkConfig.addProperty("lineWrappingIndentation", "4");
2763         checkConfig.addProperty("tabWidth", "4");
2764         checkConfig.addProperty("throwsIndent", "4");
2765         final String fileName = getPath("InputIndentationValidInterfaceDefIndent.java");
2766         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2767         verifyWarns(checkConfig, fileName, expected);
2768     }
2769 
2770     @Test
2771     public void testValidCommaWithChecker()
2772             throws Exception {
2773         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2774 
2775         checkConfig.addProperty("arrayInitIndent", "4");
2776         checkConfig.addProperty("basicOffset", "4");
2777         checkConfig.addProperty("braceAdjustment", "0");
2778         checkConfig.addProperty("caseIndent", "4");
2779         checkConfig.addProperty("forceStrictCondition", "false");
2780         checkConfig.addProperty("lineWrappingIndentation", "4");
2781         checkConfig.addProperty("tabWidth", "4");
2782         checkConfig.addProperty("throwsIndent", "4");
2783         final String fileName = getPath("InputIndentationValidCommaIndent.java");
2784         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2785         verifyWarns(checkConfig, fileName, expected);
2786     }
2787 
2788     @Test
2789     public void testTabs() throws Exception {
2790         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2791 
2792         checkConfig.addProperty("arrayInitIndent", "4");
2793         checkConfig.addProperty("basicOffset", "4");
2794         checkConfig.addProperty("braceAdjustment", "0");
2795         checkConfig.addProperty("caseIndent", "4");
2796         checkConfig.addProperty("forceStrictCondition", "false");
2797         checkConfig.addProperty("lineWrappingIndentation", "4");
2798         checkConfig.addProperty("tabWidth", "4");
2799         checkConfig.addProperty("throwsIndent", "4");
2800         final String[] expected = {
2801             "29:10: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 9, 8),
2802         };
2803         verifyWarns(checkConfig, getPath("InputIndentationUseTabs.java"), expected);
2804     }
2805 
2806     @Test
2807     public void testIndentationLevel() throws Exception {
2808         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2809 
2810         checkConfig.addProperty("arrayInitIndent", "4");
2811         checkConfig.addProperty("basicOffset", "2");
2812         checkConfig.addProperty("braceAdjustment", "0");
2813         checkConfig.addProperty("caseIndent", "4");
2814         checkConfig.addProperty("forceStrictCondition", "false");
2815         checkConfig.addProperty("lineWrappingIndentation", "2");
2816         checkConfig.addProperty("tabWidth", "4");
2817         checkConfig.addProperty("throwsIndent", "4");
2818         final String[] expected = {
2819             "29:6: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 5, 4),
2820         };
2821         verifyWarns(checkConfig, getPath("InputIndentationUseTwoSpaces.java"), expected);
2822     }
2823 
2824     @Test
2825     public void testThrowsIndentationLevel() throws Exception {
2826         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2827 
2828         checkConfig.addProperty("arrayInitIndent", "4");
2829         checkConfig.addProperty("basicOffset", "4");
2830         checkConfig.addProperty("braceAdjustment", "0");
2831         checkConfig.addProperty("caseIndent", "4");
2832         checkConfig.addProperty("forceStrictCondition", "false");
2833         checkConfig.addProperty("lineWrappingIndentation", "4");
2834         checkConfig.addProperty("tabWidth", "4");
2835         checkConfig.addProperty("throwsIndent", "8");
2836         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2837         verifyWarns(checkConfig, getPath("InputIndentationInvalidThrowsIndent.java"), expected);
2838     }
2839 
2840     @Test
2841     public void testThrowsIndentationLevel2() throws Exception {
2842         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2843 
2844         checkConfig.addProperty("basicOffset", "1");
2845         checkConfig.addProperty("forceStrictCondition", "true");
2846         checkConfig.addProperty("lineWrappingIndentation", "3");
2847         checkConfig.addProperty("tabWidth", "4");
2848         checkConfig.addProperty("throwsIndent", "5");
2849         final String[] expected = {
2850             "7:1: " + getCheckMessage(MSG_ERROR, "Exception", 0, 6),
2851             "10:1: " + getCheckMessage(MSG_ERROR, "NullPointerException", 0, 6),
2852             "13:1: " + getCheckMessage(MSG_ERROR, "throws", 0, 6),
2853             "16:1: " + getCheckMessage(MSG_ERROR, "throws", 0, 6),
2854             "18:1: " + getCheckMessage(MSG_ERROR, "throws", 0, 6),
2855             "19:1: " + getCheckMessage(MSG_ERROR, "Exception", 0, 6),
2856             "22:1: " + getCheckMessage(MSG_ERROR, "throws", 0, 6),
2857             "23:1: " + getCheckMessage(MSG_ERROR, "Exception", 0, 6),
2858             "24:1: " + getCheckMessage(MSG_ERROR, "NullPointerException", 0, 6),
2859             "27:1: " + getCheckMessage(MSG_ERROR, "throws", 0, 6),
2860             "28:1: " + getCheckMessage(MSG_ERROR, "Exception", 0, 6),
2861             "31:1: " + getCheckMessage(MSG_ERROR, "throws", 0, 6),
2862             "37:1: " + getCheckMessage(MSG_ERROR, "throws", 0, 6),
2863         };
2864         verifyWarns(checkConfig, getPath("InputIndentationInvalidThrowsIndent2.java"), expected);
2865     }
2866 
2867     @Test
2868     public void testCaseLevel() throws Exception {
2869         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2870 
2871         checkConfig.addProperty("arrayInitIndent", "4");
2872         checkConfig.addProperty("basicOffset", "4");
2873         checkConfig.addProperty("braceAdjustment", "0");
2874         checkConfig.addProperty("caseIndent", "0");
2875         checkConfig.addProperty("forceStrictCondition", "false");
2876         checkConfig.addProperty("lineWrappingIndentation", "4");
2877         checkConfig.addProperty("tabWidth", "4");
2878         checkConfig.addProperty("throwsIndent", "4");
2879         final String[] expected = {
2880             "27:11: " + getCheckMessage(MSG_CHILD_ERROR, "case", 10, 8),
2881         };
2882         verifyWarns(checkConfig, getPath("InputIndentationCaseLevel.java"), expected);
2883     }
2884 
2885     @Test
2886     public void testBraceAdjustment() throws Exception {
2887         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2888 
2889         checkConfig.addProperty("arrayInitIndent", "4");
2890         checkConfig.addProperty("basicOffset", "4");
2891         checkConfig.addProperty("braceAdjustment", "2");
2892         checkConfig.addProperty("caseIndent", "4");
2893         checkConfig.addProperty("forceStrictCondition", "false");
2894         checkConfig.addProperty("lineWrappingIndentation", "4");
2895         checkConfig.addProperty("tabWidth", "4");
2896         checkConfig.addProperty("throwsIndent", "4");
2897         final String[] expected = {
2898             "25:9: " + getCheckMessage(MSG_CHILD_ERROR, "ctor def", 8, 10),
2899             "26:9: " + getCheckMessage(MSG_ERROR, "if", 8, 10),
2900             "27:11: " + getCheckMessage(MSG_ERROR, "if lcurly", 10, 12),
2901             "28:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "if", 12, "14, 16"),
2902             "29:9: " + getCheckMessage(MSG_ERROR, "if rcurly", 8, 12),
2903         };
2904         verifyWarns(checkConfig, getPath("InputIndentationBraceAdjustment.java"), expected);
2905     }
2906 
2907     @Test
2908     public void testInvalidAssignWithChecker() throws Exception {
2909         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2910 
2911         checkConfig.addProperty("arrayInitIndent", "4");
2912         checkConfig.addProperty("basicOffset", "4");
2913         checkConfig.addProperty("braceAdjustment", "0");
2914         checkConfig.addProperty("caseIndent", "4");
2915         checkConfig.addProperty("forceStrictCondition", "false");
2916         checkConfig.addProperty("lineWrappingIndentation", "4");
2917         checkConfig.addProperty("tabWidth", "4");
2918         checkConfig.addProperty("throwsIndent", "4");
2919         final String[] expected = {
2920             "22:11: " + getCheckMessage(MSG_ERROR, "getLineNo", 10, 12),
2921             "24:11: " + getCheckMessage(MSG_ERROR, "getLine", 10, 12),
2922             "28:10: " + getCheckMessage(MSG_ERROR, "=", 9, 12),
2923             "29:11: " + getCheckMessage(MSG_ERROR, "1", 10, 12),
2924         };
2925         verifyWarns(checkConfig, getPath("InputIndentationInvalidAssignIndent.java"), expected);
2926     }
2927 
2928     @Test
2929     public void testInvalidImportIndent() throws Exception {
2930         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2931         checkConfig.addProperty("basicOffset", "8");
2932         checkConfig.addProperty("tabWidth", "4");
2933         final String[] expected = {
2934             "4:3: " + getCheckMessage(MSG_ERROR, ".", 2, 4),
2935             "5:2: " + getCheckMessage(MSG_ERROR, "import", 1, 0),
2936         };
2937         verifyWarns(checkConfig, getPath("InputIndentationInvalidImportIndent.java"), expected);
2938     }
2939 
2940     @Test
2941     public void testModuleImportIndent() throws Exception {
2942         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2943         checkConfig.addProperty("tabWidth", "4");
2944         final String[] expected = {
2945             "5:4: " + getCheckMessage(MSG_ERROR, "import", 3, 0),
2946             "6:7: " + getCheckMessage(MSG_ERROR, "import", 6, 0),
2947             "7:7: " + getCheckMessage(MSG_ERROR, "import", 6, 0),
2948             "8:2: " + getCheckMessage(MSG_ERROR, "import", 1, 0),
2949         };
2950         verifyWarns(checkConfig, getNonCompilablePath("InputIndentationModuleImport.java"),
2951                 expected);
2952     }
2953 
2954     @Test
2955     public void testValidAssignWithChecker() throws Exception {
2956         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2957 
2958         checkConfig.addProperty("arrayInitIndent", "4");
2959         checkConfig.addProperty("basicOffset", "4");
2960         checkConfig.addProperty("braceAdjustment", "0");
2961         checkConfig.addProperty("caseIndent", "4");
2962         checkConfig.addProperty("forceStrictCondition", "false");
2963         checkConfig.addProperty("lineWrappingIndentation", "4");
2964         checkConfig.addProperty("tabWidth", "4");
2965         checkConfig.addProperty("throwsIndent", "4");
2966         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2967         verifyWarns(checkConfig, getPath("InputIndentationValidAssignIndent.java"), expected);
2968     }
2969 
2970     @Test
2971     public void test15Extensions() throws Exception {
2972         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2973 
2974         checkConfig.addProperty("arrayInitIndent", "4");
2975         checkConfig.addProperty("basicOffset", "4");
2976         checkConfig.addProperty("braceAdjustment", "0");
2977         checkConfig.addProperty("caseIndent", "4");
2978         checkConfig.addProperty("forceStrictCondition", "false");
2979         checkConfig.addProperty("lineWrappingIndentation", "4");
2980         checkConfig.addProperty("tabWidth", "4");
2981         checkConfig.addProperty("throwsIndent", "4");
2982         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2983         verifyWarns(checkConfig, getPath("InputIndentation15Extensions.java"), expected);
2984     }
2985 
2986     @Test
2987     public void testTryResources() throws Exception {
2988         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
2989 
2990         checkConfig.addProperty("arrayInitIndent", "4");
2991         checkConfig.addProperty("basicOffset", "4");
2992         checkConfig.addProperty("braceAdjustment", "0");
2993         checkConfig.addProperty("caseIndent", "4");
2994         checkConfig.addProperty("forceStrictCondition", "false");
2995         checkConfig.addProperty("lineWrappingIndentation", "4");
2996         checkConfig.addProperty("tabWidth", "4");
2997         checkConfig.addProperty("throwsIndent", "4");
2998         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
2999         verifyWarns(checkConfig, getPath("InputIndentationValidTryResourcesIndent.java"),
3000                expected);
3001     }
3002 
3003     @Test
3004     public void testSwitchCustom() throws Exception {
3005         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3006 
3007         checkConfig.addProperty("arrayInitIndent", "4");
3008         checkConfig.addProperty("basicOffset", "4");
3009         checkConfig.addProperty("braceAdjustment", "0");
3010         checkConfig.addProperty("caseIndent", "4");
3011         checkConfig.addProperty("forceStrictCondition", "false");
3012         checkConfig.addProperty("lineWrappingIndentation", "8");
3013         checkConfig.addProperty("tabWidth", "4");
3014         checkConfig.addProperty("throwsIndent", "8");
3015         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3016         verifyWarns(checkConfig, getPath("InputIndentationSwitchCustom.java"),
3017                expected);
3018     }
3019 
3020     @Test
3021     public void testSynchronizedStatement() throws Exception {
3022         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3023         checkConfig.addProperty("arrayInitIndent", "4");
3024         checkConfig.addProperty("basicOffset", "4");
3025         checkConfig.addProperty("braceAdjustment", "0");
3026         checkConfig.addProperty("caseIndent", "4");
3027         checkConfig.addProperty("forceStrictCondition", "false");
3028         checkConfig.addProperty("lineWrappingIndentation", "8");
3029         checkConfig.addProperty("tabWidth", "4");
3030         checkConfig.addProperty("throwsIndent", "8");
3031         final String[] expected = {
3032             "27:1: " + getCheckMessage(MSG_CHILD_ERROR, "synchronized", 0, 12),
3033             "30:13: " + getCheckMessage(MSG_ERROR, "synchronized lparen", 12, 8),
3034         };
3035         verifyWarns(checkConfig, getPath("InputIndentationSynchronizedStatement.java"), expected);
3036     }
3037 
3038     @Test
3039     public void testSynchronizedMethod() throws Exception {
3040         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3041         checkConfig.addProperty("arrayInitIndent", "4");
3042         checkConfig.addProperty("basicOffset", "4");
3043         checkConfig.addProperty("braceAdjustment", "0");
3044         checkConfig.addProperty("caseIndent", "4");
3045         checkConfig.addProperty("forceStrictCondition", "false");
3046         checkConfig.addProperty("lineWrappingIndentation", "8");
3047         checkConfig.addProperty("tabWidth", "4");
3048         checkConfig.addProperty("throwsIndent", "8");
3049         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3050         verifyWarns(checkConfig, getPath("InputIndentationSynchronizedMethod.java"), expected);
3051     }
3052 
3053     @Test
3054     public void testAnonymousClassInMethod() throws Exception {
3055         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3056         checkConfig.addProperty("tabWidth", "8");
3057         checkConfig.addProperty("basicOffset", "2");
3058         checkConfig.addProperty("braceAdjustment", "0");
3059         checkConfig.addProperty("caseIndent", "2");
3060         checkConfig.addProperty("lineWrappingIndentation", "4");
3061         checkConfig.addProperty("throwsIndent", "4");
3062         checkConfig.addProperty("arrayInitIndent", "2");
3063         final String[] expected = {
3064             "19:9: " + getCheckMessage(MSG_ERROR, "method def modifier", 8, 2),
3065             "20:17: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 16, 4),
3066             "21:25: " + getCheckMessage(MSG_ERROR_MULTI, "method def modifier", 24, "18, 20, 22"),
3067             "23:33: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "method def", 32, "20, 22, 24"),
3068             "24:25: " + getCheckMessage(MSG_ERROR_MULTI, "method def rcurly", 24, "18, 20, 22"),
3069             "26:9: " + getCheckMessage(MSG_ERROR, "method def rcurly", 8, 2),
3070         };
3071         verifyWarns(checkConfig, getPath("InputIndentationAnonymousClassInMethod.java"), expected);
3072     }
3073 
3074     @Test
3075     public void testAnonymousClassInMethodWithCurlyOnNewLine() throws Exception {
3076         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3077         checkConfig.addProperty("tabWidth", "4");
3078         checkConfig.addProperty("basicOffset", "4");
3079         checkConfig.addProperty("braceAdjustment", "0");
3080         checkConfig.addProperty("caseIndent", "4");
3081         checkConfig.addProperty("lineWrappingIndentation", "8");
3082         checkConfig.addProperty("throwsIndent", "4");
3083         checkConfig.addProperty("arrayInitIndent", "4");
3084         final String[] expected = {
3085             "40:19: " + getCheckMessage(MSG_ERROR_MULTI, "object def rcurly", 18, "16, 20, 24"),
3086             "42:15: " + getCheckMessage(MSG_ERROR, "new", 14, 16),
3087             "48:15: " + getCheckMessage(MSG_ERROR_MULTI, "object def rcurly", 14, "16, 20, 24"),
3088             "60:19: " + getCheckMessage(MSG_ERROR_MULTI, "object def lcurly", 18, "16, 20, 24"),
3089             "66:19: " + getCheckMessage(MSG_ERROR_MULTI, "object def rcurly", 18, "16, 20, 24"),
3090             "69:15: " + getCheckMessage(MSG_ERROR_MULTI, "object def lcurly", 14, "16, 20, 24"),
3091             "75:15: " + getCheckMessage(MSG_ERROR_MULTI, "object def rcurly", 14, "16, 20, 24"),
3092         };
3093         verifyWarns(checkConfig,
3094             getPath("InputIndentationAnonymousClassInMethodCurlyOnNewLine.java"), expected);
3095     }
3096 
3097     // until #19415
3098     @Test
3099     public void testDoubleBraceInit() throws Exception {
3100         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3101         checkConfig.addProperty("tabWidth", "4");
3102         checkConfig.addProperty("basicOffset", "4");
3103         checkConfig.addProperty("braceAdjustment", "0");
3104         checkConfig.addProperty("caseIndent", "4");
3105         checkConfig.addProperty("lineWrappingIndentation", "4");
3106         checkConfig.addProperty("throwsIndent", "4");
3107         checkConfig.addProperty("arrayInitIndent", "4");
3108         final String[] expected = {
3109             "27:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 12, "16, 20"),
3110             "28:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 12, "16, 20"),
3111             "29:9: " + getCheckMessage(MSG_ERROR_MULTI, "block rcurly", 8, "12, 16"),
3112             "35:17: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 16, "20, 24"),
3113             "36:13: " + getCheckMessage(MSG_ERROR_MULTI, "block rcurly", 12, "16, 20"),
3114             "42:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 12, "16, 20"),
3115             "43:9: " + getCheckMessage(MSG_ERROR_MULTI, "block rcurly", 8, "12, 16"),
3116             "56:13: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 12, "16, 20"),
3117             "57:9: " + getCheckMessage(MSG_ERROR_MULTI, "block rcurly", 8, "12, 16"),
3118             "63:17: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 16, "20, 24"),
3119             "64:17: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 16, "20, 24"),
3120             "65:13: " + getCheckMessage(MSG_ERROR_MULTI, "block rcurly", 12, "16, 20"),
3121         };
3122         verifyWarns(checkConfig, getPath("InputIndentationDoubleBraceInit.java"), expected);
3123     }
3124 
3125     @Test
3126     public void testAnnotationDefinition() throws Exception {
3127         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3128         checkConfig.addProperty("tabWidth", "4");
3129         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3130         verifyWarns(checkConfig, getPath("InputIndentationAnnotationDefinition.java"), expected);
3131     }
3132 
3133     @Test
3134     public void testPackageDeclaration() throws Exception {
3135         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3136         checkConfig.addProperty("tabWidth", "4");
3137         final String[] expected = {
3138             "1:2: " + getCheckMessage(MSG_ERROR, "package def", 1, 0),
3139         };
3140         verifyWarns(checkConfig, getPath("InputIndentationPackageDeclaration.java"), expected);
3141     }
3142 
3143     @Test
3144     public void testPackageDeclaration2() throws Exception {
3145         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3146         checkConfig.addProperty("tabWidth", "4");
3147         final String[] expected = {
3148             "2:2: " + getCheckMessage(MSG_ERROR, "package def", 1, 0),
3149         };
3150         verifyWarns(checkConfig,
3151             getPath("package-info.java"), expected);
3152     }
3153 
3154     @Test
3155     public void testPackageDeclaration3() throws Exception {
3156         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3157         checkConfig.addProperty("tabWidth", "4");
3158         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3159         verifyWarns(checkConfig, getPath("InputIndentationPackageDeclaration3.java"), expected);
3160     }
3161 
3162     @Test
3163     public void testPackageDeclaration4() throws Exception {
3164         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3165         checkConfig.addProperty("tabWidth", "4");
3166         final String[] expected = {
3167             "2:1: " + getCheckMessage(MSG_ERROR, "com", 0, 4),
3168             "3:1: " + getCheckMessage(MSG_ERROR, "checks", 0, 4),
3169         };
3170         verifyWarns(checkConfig, getPath("InputIndentationPackageDeclaration4.java"), expected);
3171     }
3172 
3173     @Test
3174     public void testLambda() throws Exception {
3175         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3176         checkConfig.addProperty("tabWidth", "2");
3177         checkConfig.addProperty("basicOffset", "2");
3178         checkConfig.addProperty("lineWrappingIndentation", "4");
3179         final String[] expected = {
3180             "37:6: " + getCheckMessage(MSG_ERROR_MULTI, "block lcurly", 5, "4, 8"),
3181             "38:6: " + getCheckMessage(MSG_ERROR_MULTI, "block rcurly", 5, "4, 8"),
3182             "42:12: " + getCheckMessage(MSG_ERROR, "lambda", 11, 12),
3183             "43:10: " + getCheckMessage(MSG_ERROR, "block lcurly", 9, 8),
3184             "55:8: " + getCheckMessage(MSG_CHILD_ERROR, "block", 7, 6),
3185             "56:6: " + getCheckMessage(MSG_ERROR, "block rcurly", 5, 4),
3186         };
3187         verifyWarns(checkConfig, getPath("InputIndentationLambda.java"), expected);
3188     }
3189 
3190     @Test
3191     public void testLambda1() throws Exception {
3192         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3193         checkConfig.addProperty("tabWidth", "2");
3194         checkConfig.addProperty("basicOffset", "2");
3195         checkConfig.addProperty("lineWrappingIndentation", "4");
3196         final String[] expected = {
3197             "69:10: " + getCheckMessage(MSG_CHILD_ERROR, "block", 9, 10),
3198             "70:12: " + getCheckMessage(MSG_CHILD_ERROR, "block", 11, 10),
3199             "75:8: " + getCheckMessage(MSG_ERROR, "block rcurly", 7, 8),
3200         };
3201         verifyWarns(checkConfig, getPath("InputIndentationLambda1.java"), expected);
3202     }
3203 
3204     @Test
3205     public void testLambda2() throws Exception {
3206         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3207         checkConfig.addProperty("tabWidth", "4");
3208         checkConfig.addProperty("basicOffset", "4");
3209         checkConfig.addProperty("lineWrappingIndentation", "8");
3210         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3211         verifyWarns(checkConfig, getPath("InputIndentationLambda2.java"), expected);
3212     }
3213 
3214     @Test
3215     public void testLambda3() throws Exception {
3216         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3217         checkConfig.addProperty("tabWidth", "4");
3218         checkConfig.addProperty("basicOffset", "4");
3219         checkConfig.addProperty("lineWrappingIndentation", "8");
3220         final String[] expected = {
3221             "15:13: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 12, 8),
3222             "29:13: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 12, 8),
3223             "30:13: " + getCheckMessage(MSG_CHILD_ERROR, "block", 12, 16),
3224             "31:9: " + getCheckMessage(MSG_ERROR, "block rcurly", 8, 12),
3225             "65:13: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 12, 8),
3226             "87:13: " + getCheckMessage(MSG_ERROR, "method def rcurly", 12, 8),
3227         };
3228         verifyWarns(checkConfig, getPath("InputIndentationLambda3.java"), expected);
3229     }
3230 
3231     @Test
3232     public void testLambda4() throws Exception {
3233         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3234         checkConfig.addProperty("tabWidth", "4");
3235         checkConfig.addProperty("basicOffset", "4");
3236         checkConfig.addProperty("lineWrappingIndentation", "8");
3237         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3238         verifyWarns(checkConfig, getPath("InputIndentationLambda4.java"), expected);
3239     }
3240 
3241     @Test
3242     public void testLambda5() throws Exception {
3243         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3244         checkConfig.addProperty("tabWidth", "3");
3245         checkConfig.addProperty("basicOffset", "3");
3246         checkConfig.addProperty("caseIndent", "0");
3247         checkConfig.addProperty("lineWrappingIndentation", "6");
3248         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3249         verifyWarns(checkConfig, getPath("InputIndentationLambda5.java"), expected);
3250     }
3251 
3252     @Test
3253     public void testLambdaFalseForceStrictCondition() throws Exception {
3254         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3255         checkConfig.addProperty("tabWidth", "4");
3256         checkConfig.addProperty("basicOffset", "4");
3257         checkConfig.addProperty("braceAdjustment", "0");
3258         checkConfig.addProperty("forceStrictCondition", "false");
3259         checkConfig.addProperty("lineWrappingIndentation", "0");
3260         final String[] expected = {
3261             "34:5: " + getCheckMessage(MSG_ERROR, "(", 4, 8),
3262             "35:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 12),
3263             "36:5: " + getCheckMessage(MSG_ERROR, "(", 4, 8),
3264             "47:5: " + getCheckMessage(MSG_ERROR_MULTI, "block rcurly", 4, "8, 16"),
3265             "73:5: " + getCheckMessage(MSG_ERROR, "->", 4, 8),
3266         };
3267 
3268         verifyWarns(checkConfig, getPath("InputIndentationLambda6.java"), expected);
3269     }
3270 
3271     @Test
3272     public void testLambdaTrueForceStrictCondition() throws Exception {
3273         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3274         checkConfig.addProperty("tabWidth", "4");
3275         checkConfig.addProperty("basicOffset", "4");
3276         checkConfig.addProperty("braceAdjustment", "0");
3277         checkConfig.addProperty("forceStrictCondition", "true");
3278         checkConfig.addProperty("lineWrappingIndentation", "4");
3279         final String[] expected = {
3280             "23:17: " + getCheckMessage(MSG_ERROR, "(", 16, 12),
3281             "24:17: " + getCheckMessage(MSG_ERROR, "->", 16, 12),
3282             "26:27: " + getCheckMessage(MSG_ERROR, "\"SECOND_ARG\"", 26, 12),
3283             "27:26: " + getCheckMessage(MSG_ERROR, "(", 25, 12),
3284             "30:17: " + getCheckMessage(MSG_ERROR, "(", 16, 12),
3285             "31:21: " + getCheckMessage(MSG_ERROR, "if", 20, 16),
3286             "32:25: " + getCheckMessage(MSG_CHILD_ERROR, "if", 24, 20),
3287             "33:21: " + getCheckMessage(MSG_ERROR, "if rcurly", 20, 16),
3288             "34:25: " + getCheckMessage(MSG_CHILD_ERROR, "else", 24, 20),
3289             "35:21: " + getCheckMessage(MSG_ERROR, "else rcurly", 20, 16),
3290             "36:17: " + getCheckMessage(MSG_ERROR, "block rcurly", 16, 12),
3291             "39:17: " + getCheckMessage(MSG_ERROR, "(", 16, 12),
3292             "40:17: " + getCheckMessage(MSG_ERROR, "->", 16, 12),
3293             "41:21: " + getCheckMessage(MSG_ERROR, "if", 20, 16),
3294             "44:1: " + getCheckMessage(MSG_ERROR, "block rcurly", 0, 12),
3295         };
3296 
3297         verifyWarns(checkConfig, getPath("InputIndentationLambda7.java"), expected);
3298     }
3299 
3300     @Test
3301     public void testLambdaOddConditions() throws Exception {
3302         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3303         checkConfig.addProperty("tabWidth", "4");
3304         checkConfig.addProperty("basicOffset", "3");
3305         checkConfig.addProperty("braceAdjustment", "0");
3306         checkConfig.addProperty("forceStrictCondition", "false");
3307         checkConfig.addProperty("lineWrappingIndentation", "7");
3308         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3309 
3310         verifyWarns(checkConfig, getPath("InputIndentationLambda8.java"), expected);
3311     }
3312 
3313     @Test
3314     public void testSeparatedStatements() throws Exception {
3315         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3316         checkConfig.addProperty("tabWidth", "4");
3317         final String fileName = getPath("InputIndentationSeparatedStatements.java");
3318         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3319         verifyWarns(checkConfig, fileName, expected);
3320     }
3321 
3322     @Test
3323     public void testSeparatedLineWithJustSpaces() throws Exception {
3324         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3325         checkConfig.addProperty("tabWidth", "4");
3326         final String fileName = getPath("InputIndentationSeparatedStatementWithSpaces.java");
3327         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3328         verifyWarns(checkConfig, fileName, expected);
3329     }
3330 
3331     @Test
3332     public void testTwoStatementsPerLine() throws Exception {
3333         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3334         checkConfig.addProperty("tabWidth", "4");
3335         checkConfig.addProperty("basicOffset", "4");
3336         final String fileName = getPath("InputIndentationTwoStatementsPerLine.java");
3337         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3338         verifyWarns(checkConfig, fileName, expected);
3339     }
3340 
3341     @Test
3342     public void testMethodChaining() throws Exception {
3343         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3344         checkConfig.addProperty("tabWidth", "4");
3345         checkConfig.addProperty("basicOffset", "4");
3346         final String fileName = getPath("InputIndentationChainedMethods.java");
3347         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3348         verifyWarns(checkConfig, fileName, expected);
3349     }
3350 
3351     @Test
3352     public void testMultipleAnnotationsWithWrappedLines() throws Exception {
3353         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3354         checkConfig.addProperty("tabWidth", "4");
3355         checkConfig.addProperty("basicOffset", "4");
3356         checkConfig.addProperty("forceStrictCondition", "true");
3357         final String fileName =
3358             getPath("InputIndentationCorrectMultipleAnnotationsWithWrappedLines.java");
3359         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3360         verifyWarns(checkConfig, fileName, expected);
3361     }
3362 
3363     @Test
3364     public void testMultipleAnnotationsWithWrappedLines1() throws Exception {
3365         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3366         checkConfig.addProperty("tabWidth", "4");
3367         checkConfig.addProperty("basicOffset", "4");
3368         checkConfig.addProperty("forceStrictCondition", "true");
3369         final String fileName =
3370             getPath("InputIndentationCorrectMultipleAnnotationsWithWrappedLines1.java");
3371         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3372         verifyWarns(checkConfig, fileName, expected);
3373     }
3374 
3375     @Test
3376     public void testMethodPrecedeByAnnotationsWithParameterOnSeparateLine() throws Exception {
3377         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3378         checkConfig.addProperty("tabWidth", "4");
3379         checkConfig.addProperty("basicOffset", "2");
3380         checkConfig.addProperty("braceAdjustment", "0");
3381         checkConfig.addProperty("caseIndent", "2");
3382         checkConfig.addProperty("throwsIndent", "4");
3383         checkConfig.addProperty("lineWrappingIndentation", "4");
3384         checkConfig.addProperty("arrayInitIndent", "2");
3385         final String fileName =
3386             getPath("InputIndentationMethodPrecededByAnnotationWithParameterOnSeparateLine.java");
3387         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3388         verifyWarns(checkConfig, fileName, expected);
3389     }
3390 
3391     @Test
3392     public void testAnnotationIncorrect() throws Exception {
3393         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3394         checkConfig.addProperty("tabWidth", "4");
3395         checkConfig.addProperty("basicOffset", "4");
3396         checkConfig.addProperty("braceAdjustment", "0");
3397         checkConfig.addProperty("lineWrappingIndentation", "4");
3398         final String fileName =
3399             getPath("InputIndentationAnnotationIncorrect.java");
3400         final String[] expected = {
3401             "11:5: " + getCheckMessage(MSG_ERROR, "(", 4, 8),
3402             "14:9: " + getCheckMessage(MSG_ERROR, "(", 8, 12),
3403             "19:5: " + getCheckMessage(MSG_ERROR, "(", 4, 8),
3404         };
3405         verifyWarns(checkConfig, fileName, expected);
3406     }
3407 
3408     @Test
3409     public void testInputAnnotationScopeIndentationCheck() throws Exception {
3410         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3411         checkConfig.addProperty("tabWidth", "4");
3412         checkConfig.addProperty("basicOffset", "4");
3413         checkConfig.addProperty("forceStrictCondition", "true");
3414         final String fileName = getPath("InputIndentationAnnotationScopeIndentationCheck.java");
3415         final String[] expected = {
3416             "9:9: " + getCheckMessage(MSG_ERROR_MULTI,
3417                     "annotation array initialization rcurly", 8, "0, 4"),
3418         };
3419         verifyWarns(checkConfig, fileName, expected);
3420     }
3421 
3422     @Test
3423     public void testInputAnnotationDefIndentationCheck() throws Exception {
3424         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3425         checkConfig.addProperty("tabWidth", "4");
3426         checkConfig.addProperty("arrayInitIndent", "4");
3427         checkConfig.addProperty("basicOffset", "4");
3428         checkConfig.addProperty("braceAdjustment", "0");
3429         checkConfig.addProperty("lineWrappingIndentation", "4");
3430         checkConfig.addProperty("forceStrictCondition", "true");
3431         final String fileName = getPath("InputIndentationCustomAnnotation.java");
3432         final String[] expected = {
3433             "14:6: " + getCheckMessage(MSG_ERROR, "annotation def modifier", 5, 0),
3434             "16:6: " + getCheckMessage(MSG_ERROR, "annotation def rcurly", 5, 0),
3435             "17:6: " + getCheckMessage(MSG_ERROR, "@", 5, 0),
3436             "18:1: " + getCheckMessage(MSG_ERROR, "annotation field def modifier", 0, 4),
3437             "19:6: " + getCheckMessage(MSG_ERROR, "annotation def rcurly", 5, 0),
3438             "21:4: " + getCheckMessage(MSG_ERROR, "annotation def modifier", 3, 0),
3439             "23:1: " + getCheckMessage(MSG_ERROR, "annotation field def modifier", 0, 4),
3440             "24:6: " + getCheckMessage(MSG_ERROR, "annotation def rcurly", 5, 0),
3441             "26:6: " + getCheckMessage(MSG_ERROR, "@", 5, 0),
3442             "27:6: " + getCheckMessage(MSG_ERROR, "AnnotationWithLineWrap", 5, 0),
3443             "31:6: " + getCheckMessage(MSG_ERROR, "annotation def modifier", 5, 0),
3444             "32:4: " + getCheckMessage(MSG_ERROR, "annotation def modifier", 3, 0),
3445             "35:6: " + getCheckMessage(MSG_ERROR, "annotation field def modifier", 5, 4),
3446             "36:4: " + getCheckMessage(MSG_ERROR, "annotation def modifier", 3, 4),
3447             "37:1: " + getCheckMessage(MSG_ERROR, "annotation def modifier", 0, 4),
3448             "38:1: " + getCheckMessage(MSG_ERROR, "@", 0, 4),
3449             "39:9: " + getCheckMessage(MSG_ERROR, "AnnotationInnerLineWrap", 8, 4),
3450             "42:8: " + getCheckMessage(MSG_ERROR, "annotation field def modifier", 7, 8),
3451             "60:5: " + getCheckMessage(MSG_ERROR, "AnnotationInnerLineWrap2", 4, 0),
3452             "61:4: " + getCheckMessage(MSG_ERROR, "annotation field def modifier", 3, 4),
3453             "62:8: " + getCheckMessage(MSG_ERROR, "annotation field def modifier", 7, 4),
3454             "64:5: " + getCheckMessage(MSG_ERROR, "annotation def rcurly", 4, 0),
3455             "75:4: " + getCheckMessage(MSG_ERROR, "annotation def modifier", 3, 4),
3456             "91:29: " + getCheckMessage(MSG_ERROR_MULTI, "new", 28, "20, 24"),
3457         };
3458         verifyWarns(checkConfig, fileName, expected);
3459     }
3460 
3461     @Test
3462     public void testInputAnnotationDefIndentationCheck1() throws Exception {
3463         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3464         checkConfig.addProperty("tabWidth", "4");
3465         checkConfig.addProperty("arrayInitIndent", "4");
3466         checkConfig.addProperty("basicOffset", "4");
3467         checkConfig.addProperty("braceAdjustment", "0");
3468         checkConfig.addProperty("lineWrappingIndentation", "4");
3469         checkConfig.addProperty("forceStrictCondition", "true");
3470         final String fileName = getPath("InputIndentationCustomAnnotation1.java");
3471         final String[] expected = {
3472             "36:6: " + getCheckMessage(MSG_ERROR, "annotation def modifier", 5, 4),
3473             "47:2: " + getCheckMessage(MSG_ERROR, "interface", 1, 0),
3474             "53:12: " + getCheckMessage(MSG_ERROR, "@", 11, 0),
3475             "56:17: " + getCheckMessage(MSG_ERROR, "@", 16, 0),
3476             "63:13: " + getCheckMessage(MSG_ERROR, "@", 12, 4),
3477             "67:23: " + getCheckMessage(MSG_ERROR, "class def ident", 16, 0),
3478         };
3479         verifyWarns(checkConfig, fileName, expected);
3480     }
3481 
3482     @Test
3483     public void testTryResourcesStrict() throws Exception {
3484         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3485         checkConfig.addProperty("tabWidth", "4");
3486         checkConfig.addProperty("forceStrictCondition", "true");
3487         checkConfig.addProperty("braceAdjustment", "0");
3488         checkConfig.addProperty("lineWrappingIndentation", "4");
3489         final String fileName = getPath("InputIndentationTryWithResourcesStrict.java");
3490         final String[] expected = {
3491             "26:1: " + getCheckMessage(MSG_ERROR, "try resource", 0, 12),
3492             "28:14: " + getCheckMessage(MSG_ERROR_MULTI, "try rparen", 13, "8, 12"),
3493             "33:1: " + getCheckMessage(MSG_ERROR, "newBufferedWriter", 0, 16),
3494             "39:1: " + getCheckMessage(MSG_ERROR, "newBufferedWriter", 0, 12),
3495             "59:21: " + getCheckMessage(MSG_ERROR, "try resource", 20, 16),
3496             "79:14: " + getCheckMessage(MSG_ERROR, ".", 13, 12),
3497             "85:12: " + getCheckMessage(MSG_ERROR, ".", 11, 12),
3498         };
3499         verifyWarns(checkConfig, fileName, expected);
3500     }
3501 
3502     @Test
3503     public void testTryResourcesStrict1() throws Exception {
3504         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3505         checkConfig.addProperty("tabWidth", "4");
3506         checkConfig.addProperty("forceStrictCondition", "true");
3507         checkConfig.addProperty("braceAdjustment", "0");
3508         checkConfig.addProperty("lineWrappingIndentation", "4");
3509         final String fileName = getPath("InputIndentationTryWithResourcesStrict1.java");
3510         final String[] expected = {
3511             "31:20: " + getCheckMessage(MSG_ERROR, "writ", 19, 12),
3512             "38:20: " + getCheckMessage(MSG_ERROR, "writ", 19, 16),
3513             "45:22: " + getCheckMessage(MSG_ERROR, "writ", 21, 16),
3514             "60:18: " + getCheckMessage(MSG_ERROR, "zipFileName", 17, 16),
3515             "67:16: " + getCheckMessage(MSG_ERROR, "zipFileName", 15, 16),
3516             "77:8: " + getCheckMessage(MSG_ERROR, "try", 7, 8),
3517             "82:16: " + getCheckMessage(MSG_CHILD_ERROR, "try", 15, 12),
3518             "88:12: " + getCheckMessage(MSG_ERROR, "try resource", 11, 12),
3519             "89:10: " + getCheckMessage(MSG_CHILD_ERROR, "try", 9, 12),
3520             "93:12: " + getCheckMessage(MSG_ERROR, "try resource", 11, 12),
3521             "94:12: " + getCheckMessage(MSG_ERROR, "newBufferedWriter", 11, 16),
3522             "95:14: " + getCheckMessage(MSG_CHILD_ERROR, "try", 13, 12),
3523             "97:8: " + getCheckMessage(MSG_ERROR, "try", 7, 8),
3524             "98:8: " + getCheckMessage(MSG_ERROR_MULTI, "try rparen", 7, "8, 12"),
3525             "102:10: " + getCheckMessage(MSG_ERROR, "try", 9, 8),
3526         };
3527         verifyWarns(checkConfig, fileName, expected);
3528     }
3529 
3530     @Test
3531     public void testTryResourcesNotStrict() throws Exception {
3532         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3533         checkConfig.addProperty("tabWidth", "4");
3534         checkConfig.addProperty("braceAdjustment", "0");
3535         checkConfig.addProperty("lineWrappingIndentation", "4");
3536         final String fileName = getPath("InputIndentationTryResourcesNotStrict.java");
3537         final String[] expected = {
3538             "26:1: " + getCheckMessage(MSG_ERROR, "try resource", 0, 12),
3539             "32:1: " + getCheckMessage(MSG_ERROR, "newBufferedWriter", 0, 16),
3540             "38:1: " + getCheckMessage(MSG_ERROR, "newBufferedWriter", 0, 12),
3541         };
3542         verifyWarns(checkConfig, fileName, expected);
3543     }
3544 
3545     @Test
3546     public void testTryResourcesNotStrict1() throws Exception {
3547         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3548         checkConfig.addProperty("tabWidth", "4");
3549         checkConfig.addProperty("braceAdjustment", "0");
3550         checkConfig.addProperty("lineWrappingIndentation", "4");
3551         final String fileName = getPath("InputIndentationTryResourcesNotStrict1.java");
3552         final String[] expected = {
3553             "44:16: " + getCheckMessage(MSG_ERROR, "zipFileName", 15, 16),
3554             "54:8: " + getCheckMessage(MSG_ERROR, "try", 7, 8),
3555             "59:16: " + getCheckMessage(MSG_CHILD_ERROR, "try", 15, 12),
3556             "65:12: " + getCheckMessage(MSG_ERROR, "try resource", 11, 12),
3557             "66:10: " + getCheckMessage(MSG_CHILD_ERROR, "try", 9, 12),
3558             "70:12: " + getCheckMessage(MSG_ERROR, "try resource", 11, 12),
3559             "71:12: " + getCheckMessage(MSG_ERROR, "newBufferedWriter", 11, 16),
3560             "72:14: " + getCheckMessage(MSG_CHILD_ERROR, "try", 13, 12),
3561             "74:8: " + getCheckMessage(MSG_ERROR, "try", 7, 8),
3562             "75:8: " + getCheckMessage(MSG_ERROR_MULTI, "try rparen", 7, "8, 12"),
3563             "88:9: " + getCheckMessage(MSG_ERROR, ".", 8, 12),
3564             "96:12: " + getCheckMessage(MSG_ERROR, "new", 11, 12),
3565         };
3566         verifyWarns(checkConfig, fileName, expected);
3567     }
3568 
3569     /**
3570      * Verifies that the arguments of {@link IndentationCheck#MSG_ERROR},
3571      * {@link IndentationCheck#MSG_CHILD_ERROR}, {@link IndentationCheck#MSG_CHILD_ERROR_MULTI},
3572      * {@code IndentationCheck#MSG_CHILD_ERROR_MULTI} are in appropriate order.
3573      *
3574      * <p>In other tests, the argument 0 and text before it are chopped off and only the rest of
3575      * messages are verified. Therefore, the argument 0 is required to be the first argument in
3576      * the messages above. If we update the messages in the future, it is required to keep the
3577      * arguments in appropriate order to ensure other tests will work.</p>
3578      *
3579      * @see IndentComment#getExpectedMessagePostfix(String)
3580      */
3581     @Test
3582     public void testArgumentOrderOfErrorMessages() {
3583         final Object[] arguments = {"##0##", "##1##", "##2##"};
3584         final String[] messages = {
3585             getCheckMessage(MSG_ERROR, arguments),
3586             getCheckMessage(MSG_CHILD_ERROR, arguments),
3587             getCheckMessage(MSG_ERROR_MULTI, arguments),
3588             getCheckMessage(MSG_CHILD_ERROR_MULTI, arguments),
3589         };
3590         final boolean isInOrder = Arrays.stream(messages).allMatch(msg -> {
3591             final int indexOfArgumentZero = msg.indexOf((String) arguments[0]);
3592             return Arrays.stream(arguments)
3593                     .map(String.class::cast)
3594                     .mapToInt(msg::indexOf)
3595                     .allMatch(index -> index >= indexOfArgumentZero);
3596         });
3597         assertWithMessage(
3598                     "the argument 0 of error messages (indentation.error, indentation.child.error,"
3599                         + " indentation.error.multi, indentation.child.error.multi)"
3600                         + " is required to be the first argument of them")
3601                 .that(isInOrder)
3602                 .isTrue();
3603     }
3604 
3605     @Test
3606     public void testEmptyArray() throws Exception {
3607         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3608         checkConfig.addProperty("tabWidth", "4");
3609         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3610         verifyWarns(checkConfig, getPath("InputIndentationEmptyArray.java"), expected);
3611     }
3612 
3613     @Test
3614     public void testNewHandler() throws Exception {
3615         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3616         checkConfig.addProperty("tabWidth", "4");
3617         final String[] expected = {
3618             "10:1: " + getCheckMessage(MSG_ERROR, "Object", 0, 12),
3619             "12:1: " + getCheckMessage(MSG_ERROR, "(", 0, 12),
3620             "15:1: " + getCheckMessage(MSG_CHILD_ERROR, "new", 0, 8),
3621             "17:1: " + getCheckMessage(MSG_ERROR, "new lparen", 0, 8),
3622             "25:1: " + getCheckMessage(MSG_ERROR, "=", 0, 8),
3623         };
3624         verifyWarns(checkConfig, getPath("InputIndentationNewHandler.java"), expected);
3625     }
3626 
3627     @Test
3628     public void testTryHandler() throws Exception {
3629         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3630         checkConfig.addProperty("tabWidth", "4");
3631         checkConfig.addProperty("braceAdjustment", "0");
3632         checkConfig.addProperty("lineWrappingIndentation", "8");
3633         checkConfig.addProperty("forceStrictCondition", "true");
3634         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3635         verifyWarns(checkConfig, getPath("InputIndentationTryBlockWithResources.java"), expected);
3636     }
3637 
3638     @Test
3639     public void testTryHandler2() throws Exception {
3640         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3641         checkConfig.addProperty("tabWidth", "4");
3642         checkConfig.addProperty("braceAdjustment", "0");
3643         checkConfig.addProperty("lineWrappingIndentation", "8");
3644         checkConfig.addProperty("forceStrictCondition", "true");
3645         final String[] expected = {
3646             "25:17: " + getCheckMessage(MSG_ERROR, "new", 16, 20),
3647             "27:13: " + getCheckMessage(MSG_ERROR, "new", 12, 20),
3648         };
3649         verifyWarns(checkConfig, getPath("InputIndentationTryBlock.java"), expected);
3650     }
3651 
3652     @Test
3653     public void testChainedMethodWithBracketOnNewLine() throws Exception {
3654         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3655 
3656         checkConfig.addProperty("arrayInitIndent", "2");
3657         checkConfig.addProperty("basicOffset", "2");
3658         checkConfig.addProperty("braceAdjustment", "0");
3659         checkConfig.addProperty("caseIndent", "2");
3660         checkConfig.addProperty("forceStrictCondition", "false");
3661         checkConfig.addProperty("lineWrappingIndentation", "4");
3662         checkConfig.addProperty("tabWidth", "2");
3663         checkConfig.addProperty("throwsIndent", "2");
3664         final String[] expected = {
3665             "44:7: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 6, 8),
3666             "45:9: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 8, 10),
3667             "47:7: " + getCheckMessage(MSG_ERROR, "method call rparen", 6, 8),
3668             "61:6: " + getCheckMessage(MSG_ERROR, "foo", 5, 8),
3669             "82:5: " + getCheckMessage(MSG_ERROR, "if rcurly", 4, 6),
3670             "84:3: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 2, 4),
3671         };
3672         final String fileName = "InputIndentationChainedMethodWithBracketOnNewLine.java";
3673         verifyWarns(checkConfig, getPath(fileName), expected);
3674     }
3675 
3676     @Test
3677     public void testIndentationSwitchExpression() throws Exception {
3678         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3679         checkConfig.addProperty("tabWidth", "4");
3680         final String[] expected = {
3681             "17:1: " + getCheckMessage(MSG_CHILD_ERROR, "case", 0, 12),
3682             "18:9: " + getCheckMessage(MSG_CHILD_ERROR, "block", 8, 16),
3683             "21:25: " + getCheckMessage(MSG_CHILD_ERROR, "case", 24, 12),
3684             "22:9: " + getCheckMessage(MSG_CHILD_ERROR, "block", 8, 16),
3685             "27:9: " + getCheckMessage(MSG_CHILD_ERROR, "block", 8, 20),
3686             "29:1: " + getCheckMessage(MSG_CHILD_ERROR, "block", 0, 16),
3687             "30:1: " + getCheckMessage(MSG_ERROR, "yield", 0, 16),
3688             "34:5: " + getCheckMessage(MSG_CHILD_ERROR, "block", 4, 20),
3689             "44:1: " + getCheckMessage(MSG_CHILD_ERROR, "block", 0, 16),
3690             "46:21: " + getCheckMessage(MSG_CHILD_ERROR, "case", 20, 12),
3691             "47:1: " + getCheckMessage(MSG_CHILD_ERROR, "block", 0, 16),
3692             "51:9: " + getCheckMessage(MSG_CHILD_ERROR, "block", 8, 20),
3693             "56:33: " + getCheckMessage(MSG_CHILD_ERROR, "block", 32, 20),
3694         };
3695 
3696         verifyWarns(checkConfig,
3697                 getPath("InputIndentationCheckSwitchExpression.java"),
3698                 expected);
3699     }
3700 
3701     @Test
3702     public void testIndentationYieldStatement() throws Exception {
3703         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3704         checkConfig.addProperty("tabWidth", "4");
3705         final String[] expected = {
3706             "23:13: " + getCheckMessage(MSG_ERROR, "yield", 12, 16),
3707             "28:9: " + getCheckMessage(MSG_CHILD_ERROR, "yield", 8, 16),
3708             "40:5: " + getCheckMessage(MSG_ERROR, "yield", 4, 16),
3709             "41:9: " + getCheckMessage(MSG_CHILD_ERROR, "yield", 8, 16),
3710             "71:1: " + getCheckMessage(MSG_ERROR, "yield", 0, 16),
3711             "74:37: " + getCheckMessage(MSG_ERROR, "yield", 36, 16),
3712         };
3713 
3714         verifyWarns(checkConfig,
3715             getPath("InputIndentationYieldStatement.java"),
3716             expected);
3717     }
3718 
3719     @Test
3720     public void testIndentationSwitchExpressionCorrect() throws Exception {
3721         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3722         checkConfig.addProperty("tabWidth", "4");
3723         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3724         verifyWarns(checkConfig,
3725             getPath("InputIndentationCheckSwitchExpressionCorrect.java"),
3726             expected);
3727     }
3728 
3729     @Test
3730     public void testIndentationSwitchExpressionDeclaration() throws Exception {
3731         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3732         checkConfig.addProperty("tabWidth", "4");
3733         checkConfig.addProperty("caseIndent", "4");
3734         checkConfig.addProperty("lineWrappingIndentation", "8");
3735         final String[] expected = {
3736             "33:17: " + getCheckMessage(MSG_CHILD_ERROR, "case", 16, 12),
3737             "34:17: " + getCheckMessage(MSG_CHILD_ERROR, "case", 16, 12),
3738             "41:17: " + getCheckMessage(MSG_CHILD_ERROR, "case", 16, 12),
3739             "42:17: " + getCheckMessage(MSG_CHILD_ERROR, "case", 16, 12),
3740             "49:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 12),
3741             "50:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 12),
3742             "57:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 12),
3743             "58:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 12),
3744         };
3745         verifyWarns(checkConfig,
3746             getPath("InputIndentationCheckSwitchExpressionDeclaration.java"),
3747             expected);
3748     }
3749 
3750     @Test
3751     public void testIndentationSwitchExpressionDeclarationLeftCurlyNewLine() throws Exception {
3752         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3753         checkConfig.addProperty("tabWidth", "4");
3754         final String[] expected = {
3755             "34:5: " + getCheckMessage(MSG_ERROR, "switch lcurly", 4, 8),
3756             "42:5: " + getCheckMessage(MSG_ERROR, "switch lcurly", 4, 8),
3757             "50:13: " + getCheckMessage(MSG_ERROR, "switch lcurly", 12, 8),
3758             "58:13: " + getCheckMessage(MSG_ERROR, "switch lcurly", 12, 8),
3759         };
3760         verifyWarns(checkConfig,
3761             getPath(
3762                     "InputIndentationCheckSwitchExpressionDeclarationLCurlyNewLine.java"),
3763             expected);
3764     }
3765 
3766     @Test
3767     public void testIndentationRecords() throws Exception {
3768         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3769         checkConfig.addProperty("tabWidth", "4");
3770         checkConfig.addProperty("basicOffset", "4");
3771         checkConfig.addProperty("braceAdjustment", "0");
3772         checkConfig.addProperty("caseIndent", "4");
3773         checkConfig.addProperty("throwsIndent", "4");
3774         checkConfig.addProperty("arrayInitIndent", "4");
3775         checkConfig.addProperty("lineWrappingIndentation", "4");
3776         checkConfig.addProperty("forceStrictCondition", "false");
3777 
3778         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3779 
3780         verifyWarns(checkConfig,
3781             getPath("InputIndentationRecords.java"),
3782             expected);
3783     }
3784 
3785     @Test
3786     public void testIndentationRecordsAndCompactCtors() throws Exception {
3787         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3788         checkConfig.addProperty("tabWidth", "4");
3789         final String[] expected = {
3790             "13:1: " + getCheckMessage(MSG_ERROR, "(", 0, 8),
3791             "25:1: " + getCheckMessage(MSG_ERROR, "String", 0, 12),
3792             "38:1: " + getCheckMessage(MSG_CHILD_ERROR, "compact ctor def", 0, 12),
3793             "48:8: " + getCheckMessage(MSG_ERROR, "record def ident", 0, 4),
3794             "53:1: " + getCheckMessage(MSG_ERROR, "compact ctor def rcurly", 0, 8),
3795             "61:1: " + getCheckMessage(MSG_ERROR, "ctor def rcurly", 0, 8),
3796         };
3797 
3798         verifyWarns(checkConfig,
3799             getPath("InputIndentationRecordsAndCompactCtors.java"),
3800             expected);
3801     }
3802 
3803     @Test
3804     public void testIndentationSwitchExpressionNewLine() throws Exception {
3805         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3806         checkConfig.addProperty("tabWidth", "4");
3807         final String[] expected = {
3808             "30:13: " + getCheckMessage(MSG_ERROR, "lambda", 12, 16),
3809             "32:13: " + getCheckMessage(MSG_ERROR, "lambda", 12, 16),
3810         };
3811 
3812         verifyWarns(checkConfig,
3813             getPath("InputIndentationCheckSwitchExpressionNewLine.java"),
3814             expected);
3815     }
3816 
3817     @Test
3818     public void testIndentationMethodParenthesisOnNewLine() throws Exception {
3819         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3820         checkConfig.addProperty("tabWidth", "4");
3821         final String[] expected = {
3822             "22:9: " + getCheckMessage(MSG_ERROR, "method def rparen", 8, 4),
3823             "27:9: " + getCheckMessage(MSG_ERROR, "method def rparen", 8, 4),
3824         };
3825 
3826         verifyWarns(checkConfig,
3827                 getPath("InputIndentationCheckMethodParenOnNewLine.java"),
3828                 expected);
3829     }
3830 
3831     @Test
3832     public void testIndentationMethodParenthesisOnNewLine1() throws Exception {
3833         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3834         checkConfig.addProperty("tabWidth", "4");
3835         final String[] expected = {
3836             "20:10: " + getCheckMessage(MSG_ERROR, "2", 9, 12),
3837             "26:8: " + getCheckMessage(MSG_ERROR, "int", 7, 8),
3838             "27:9: " + getCheckMessage(MSG_ERROR, "method def rparen", 8, 4),
3839         };
3840 
3841         verifyWarns(checkConfig,
3842                 getPath("InputIndentationCheckMethodParenOnNewLine1.java"),
3843                 expected);
3844     }
3845 
3846     @Test
3847     public void testIndentationMethodParenthesisOnNewLine2() throws Exception {
3848         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3849         checkConfig.addProperty("tabWidth", "4");
3850         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3851 
3852         verifyWarns(checkConfig,
3853                 getPath("InputIndentationCheckMethodParenOnNewLine2.java"),
3854                 expected);
3855     }
3856 
3857     @Test
3858     public void testIndentationMethodParenthesisOnNewLine3() throws Exception {
3859         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3860         checkConfig.addProperty("tabWidth", "4");
3861         final String[] expected = {
3862             "17:13: " + getCheckMessage(MSG_ERROR, "method def lparen", 12, 4),
3863         };
3864 
3865         verifyWarns(checkConfig,
3866                 getPath("InputIndentationCheckMethodParenOnNewLine3.java"),
3867                 expected);
3868     }
3869 
3870     @Test
3871     public void testIndentationMethodParenthesisOnNewLine4() throws Exception {
3872         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3873         checkConfig.addProperty("tabWidth", "4");
3874         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3875 
3876         verifyWarns(checkConfig,
3877                 getPath("InputIndentationCheckMethodParenOnNewLine4.java"),
3878                 expected);
3879     }
3880 
3881     @Test
3882     public void testIndentationLineWrappedRecordDeclaration() throws Exception {
3883         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3884         checkConfig.addProperty("tabWidth", "4");
3885         checkConfig.addProperty("basicOffset", "4");
3886         checkConfig.addProperty("braceAdjustment", "0");
3887         checkConfig.addProperty("caseIndent", "4");
3888         checkConfig.addProperty("throwsIndent", "4");
3889         checkConfig.addProperty("arrayInitIndent", "4");
3890         checkConfig.addProperty("lineWrappingIndentation", "4");
3891 
3892         final String[] expected = {
3893             "33:1: " + getCheckMessage(MSG_ERROR, ")", 0, 4),
3894             "55:11: " + getCheckMessage(MSG_ERROR, "interface def ident", 0, 4),
3895             "56:1: " + getCheckMessage(MSG_ERROR, "method def modifier", 0, 8),
3896             "57:1: " + getCheckMessage(MSG_ERROR, "void", 0, 4),
3897             "58:1: " + getCheckMessage(MSG_ERROR, "method", 0, 4),
3898             "59:1: " + getCheckMessage(MSG_ERROR, "throws", 0, 4),
3899             "60:1: " + getCheckMessage(MSG_ERROR, "IOException", 0, 4),
3900             "61:1: " + getCheckMessage(MSG_ERROR, "method def rcurly", 0, 8),
3901             "62:1: " + getCheckMessage(MSG_ERROR, "interface def rcurly", 0, 4),
3902             "75:8: " + getCheckMessage(MSG_ERROR, "record def ident", 0, 4),
3903             "76:1: " + getCheckMessage(MSG_ERROR, "record def rparen", 0, 4),
3904             "77:1: " + getCheckMessage(MSG_ERROR, "implements", 0, 4),
3905             "78:1: " + getCheckMessage(MSG_ERROR, "SimpleInterface2", 0, 4),
3906             "79:8: " + getCheckMessage(MSG_ERROR, "record def ident", 0, 8),
3907             "80:1: " + getCheckMessage(MSG_ERROR, "(", 0, 4),
3908             "81:1: " + getCheckMessage(MSG_ERROR, "record def rparen", 0, 8),
3909             "82:1: " + getCheckMessage(MSG_ERROR, "record def lcurly", 0, 8),
3910             "83:1: " + getCheckMessage(MSG_ERROR, "record def rcurly", 0, 8),
3911             "84:1: " + getCheckMessage(MSG_ERROR, "record def rcurly", 0, 4),
3912         };
3913 
3914         verifyWarns(checkConfig,
3915             getPath("InputIndentationLineWrappedRecordDeclaration.java"),
3916             expected);
3917     }
3918 
3919     @Test
3920     public void testIndentationAnnotationFieldDefinition() throws Exception {
3921         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3922         checkConfig.addProperty("tabWidth", "4");
3923         checkConfig.addProperty("basicOffset", "4");
3924         checkConfig.addProperty("braceAdjustment", "0");
3925         checkConfig.addProperty("caseIndent", "4");
3926         checkConfig.addProperty("throwsIndent", "8");
3927         checkConfig.addProperty("forceStrictCondition", "true");
3928 
3929         final String[] expected = {
3930             "17:5: " + getCheckMessage(MSG_ERROR, "annotation field def modifier", 4, 8),
3931             "18:13: " + getCheckMessage(MSG_ERROR, "annotation field def modifier", 12, 8),
3932             "25:5: " + getCheckMessage(MSG_ERROR, "member def type", 4, 8),
3933             "26:5: " + getCheckMessage(MSG_ERROR, "member def type", 4, 8),
3934         };
3935 
3936         verifyWarns(checkConfig, getPath("InputIndentationAnnotationFieldDef.java"),
3937                 expected);
3938     }
3939 
3940     @Test
3941     public void testIndentationLongConcatenatedString() throws Exception {
3942         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3943         checkConfig.addProperty("tabWidth", "4");
3944 
3945         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3946 
3947         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString.java"),
3948                 expected);
3949     }
3950 
3951     @Test
3952     public void testIndentationLongConcatenatedString1() throws Exception {
3953         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3954         checkConfig.addProperty("tabWidth", "4");
3955 
3956         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3957 
3958         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString1.java"),
3959                 expected);
3960     }
3961 
3962     @Test
3963     public void testIndentationLongConcatenatedString2() throws Exception {
3964         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3965         checkConfig.addProperty("tabWidth", "4");
3966 
3967         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3968 
3969         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString2.java"),
3970                 expected);
3971     }
3972 
3973     @Test
3974     public void testIndentationLongConcatenatedString3() throws Exception {
3975         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3976         checkConfig.addProperty("tabWidth", "4");
3977 
3978         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3979 
3980         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString3.java"),
3981                 expected);
3982     }
3983 
3984     @Test
3985     public void testIndentationLongConcatenatedString4() throws Exception {
3986         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3987         checkConfig.addProperty("tabWidth", "4");
3988 
3989         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
3990 
3991         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString4.java"),
3992                 expected);
3993     }
3994 
3995     @Test
3996     public void testIndentationLongConcatenatedString5() throws Exception {
3997         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
3998         checkConfig.addProperty("tabWidth", "4");
3999 
4000         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4001 
4002         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString5.java"),
4003                 expected);
4004     }
4005 
4006     @Test
4007     public void testIndentationLongConcatenatedString6() throws Exception {
4008         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4009         checkConfig.addProperty("tabWidth", "4");
4010 
4011         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4012 
4013         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString6.java"),
4014                 expected);
4015     }
4016 
4017     @Test
4018     public void testIndentationLongConcatenatedString7() throws Exception {
4019         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4020         checkConfig.addProperty("tabWidth", "4");
4021 
4022         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4023 
4024         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString7.java"),
4025                 expected);
4026     }
4027 
4028     @Test
4029     public void testIndentationLongConcatenatedString8() throws Exception {
4030         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4031         checkConfig.addProperty("tabWidth", "4");
4032 
4033         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4034 
4035         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString8.java"),
4036                 expected);
4037     }
4038 
4039     @Test
4040     public void testIndentationLongConcatenatedString9() throws Exception {
4041         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4042         checkConfig.addProperty("tabWidth", "4");
4043 
4044         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4045 
4046         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString9.java"),
4047                 expected);
4048     }
4049 
4050     @Test
4051     public void testIndentationLongConcatenatedString10() throws Exception {
4052         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4053         checkConfig.addProperty("tabWidth", "4");
4054 
4055         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4056 
4057         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString10.java"),
4058                 expected);
4059     }
4060 
4061     @Test
4062     public void testIndentationLongConcatenatedString11() throws Exception {
4063         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4064         checkConfig.addProperty("tabWidth", "4");
4065 
4066         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4067 
4068         verifyWarns(checkConfig, getPath("InputIndentationLongConcatenatedString11.java"),
4069                 expected);
4070     }
4071 
4072     @Test
4073     public void testIndentationLineBreakVariableDeclaration()
4074             throws Exception {
4075         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4076         checkConfig.addProperty("tabWidth", "4");
4077 
4078         final String fileName = getPath("InputIndentationLineBreakVariableDeclaration.java");
4079         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4080         verifyWarns(checkConfig, fileName, expected);
4081     }
4082 
4083     @Test
4084     public void testIndentationSwitchExpressionOnStartOfTheLine() throws Exception {
4085         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4086         checkConfig.addProperty("tabWidth", "4");
4087         checkConfig.addProperty("basicOffset", "2");
4088         checkConfig.addProperty("braceAdjustment", "2");
4089         checkConfig.addProperty("caseIndent", "2");
4090         checkConfig.addProperty("throwsIndent", "4");
4091         checkConfig.addProperty("lineWrappingIndentation", "4");
4092 
4093         final String[] expected = {
4094             "40:7: " + getCheckMessage(MSG_ERROR, "switch", 6, 8),
4095             "41:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 10),
4096             "42:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 10),
4097             "43:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 10),
4098             "44:7: " + getCheckMessage(MSG_ERROR, "switch rcurly", 6, 8),
4099             "49:11: " + getCheckMessage(MSG_ERROR, "switch", 10, 8),
4100             "50:13: " + getCheckMessage(MSG_CHILD_ERROR, "case", 12, 10),
4101             "51:13: " + getCheckMessage(MSG_CHILD_ERROR, "case", 12, 10),
4102             "52:13: " + getCheckMessage(MSG_CHILD_ERROR, "case", 12, 10),
4103         };
4104 
4105         verifyWarns(checkConfig,
4106                 getPath("InputIndentationSwitchOnStartOfLine.java"), expected);
4107     }
4108 
4109     @Test
4110     public void testIndentationSwitchExpressionWrappingIndentation() throws Exception {
4111         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4112         checkConfig.addProperty("tabWidth", "4");
4113         checkConfig.addProperty("basicOffset", "2");
4114         checkConfig.addProperty("braceAdjustment", "2");
4115         checkConfig.addProperty("caseIndent", "2");
4116         checkConfig.addProperty("lineWrappingIndentation", "4");
4117 
4118         final String fileName = getPath(
4119                 "InputIndentationSwitchExpressionWrappingIndentation.java");
4120         final String[] expected = {
4121             "41:7: " + getCheckMessage(MSG_ERROR, "switch", 6, 8),
4122             "42:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 10),
4123             "43:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 10),
4124             "44:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 10),
4125             "45:7: " + getCheckMessage(MSG_ERROR, "switch rcurly", 6, 8),
4126             "51:9: " + getCheckMessage(MSG_CHILD_ERROR, "lambda", 8, 10),
4127             "52:11: " + getCheckMessage(MSG_CHILD_ERROR, "case", 10, 12),
4128         };
4129         verifyWarns(checkConfig, fileName, expected);
4130     }
4131 
4132     @Test
4133     public void testIndentationYieldWithNestedSwitchExpression() throws Exception {
4134         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4135         checkConfig.addProperty("tabWidth", "4");
4136         checkConfig.addProperty("basicOffset", "4");
4137         checkConfig.addProperty("braceAdjustment", "0");
4138         checkConfig.addProperty("caseIndent", "4");
4139         checkConfig.addProperty("lineWrappingIndentation", "4");
4140 
4141         final String fileName = getPath("InputIndentationYieldSwitchExpression.java");
4142         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4143         verifyWarns(checkConfig, fileName, expected);
4144     }
4145 
4146     @Test
4147     public void testIndentationYieldWithWrappedSwitchExpression() throws Exception {
4148         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4149         checkConfig.addProperty("tabWidth", "4");
4150         checkConfig.addProperty("basicOffset", "4");
4151         checkConfig.addProperty("braceAdjustment", "0");
4152         checkConfig.addProperty("caseIndent", "4");
4153         checkConfig.addProperty("lineWrappingIndentation", "4");
4154 
4155         final String fileName = getPath("InputIndentationYieldSwitchExpressionWrapped.java");
4156         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4157         verifyWarns(checkConfig, fileName, expected);
4158     }
4159 
4160     @Test
4161     public void testSwitchExpressionAsInvocationTarget() throws Exception {
4162         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4163         checkConfig.addProperty("tabWidth", "4");
4164         checkConfig.addProperty("basicOffset", "4");
4165         checkConfig.addProperty("braceAdjustment", "0");
4166         checkConfig.addProperty("caseIndent", "4");
4167         checkConfig.addProperty("lineWrappingIndentation", "4");
4168         checkConfig.addProperty("forceStrictCondition", "false");
4169 
4170         final String[] expected = {
4171             "50:25: " + getCheckMessage(MSG_CHILD_ERROR, "lambda", 24, 16),
4172             "52:25: " + getCheckMessage(MSG_CHILD_ERROR, "lambda", 24, 16),
4173         };
4174         verify(checkConfig,
4175             getPath("InputIndentationSwitchExpressionAsInvocationTarget.java"),
4176             expected);
4177     }
4178 
4179     @Test
4180     public void testLambdaCastAsInvocationTarget() throws Exception {
4181         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4182         checkConfig.addProperty("tabWidth", "4");
4183         checkConfig.addProperty("basicOffset", "4");
4184         checkConfig.addProperty("braceAdjustment", "0");
4185         checkConfig.addProperty("caseIndent", "4");
4186         checkConfig.addProperty("lineWrappingIndentation", "4");
4187         checkConfig.addProperty("forceStrictCondition", "false");
4188 
4189         final String[] expected = {
4190             "16:25: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 24, "12, 20"),
4191             "29:25: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "block", 24, "12, 20"),
4192         };
4193         verify(checkConfig,
4194             getPath("InputIndentationLambdaCastAsInvocationTarget.java"),
4195             expected);
4196     }
4197 
4198     @Test
4199     public void testIndentationChainedMethodCallWithLambda() throws Exception {
4200         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4201         checkConfig.addProperty("tabWidth", "4");
4202         checkConfig.addProperty("basicOffset", "4");
4203         checkConfig.addProperty("braceAdjustment", "0");
4204         checkConfig.addProperty("caseIndent", "4");
4205         checkConfig.addProperty("lineWrappingIndentation", "4");
4206         checkConfig.addProperty("forceStrictCondition", "false");
4207 
4208         final String[] expected = {
4209             "23:29: " + getCheckMessage(MSG_ERROR, "if", 28, "20"),
4210             "24:33: " + getCheckMessage(MSG_CHILD_ERROR, "if", 32, "24"),
4211             "25:29: " + getCheckMessage(MSG_ERROR, "if rcurly", 28, "20"),
4212             "26:25: " + getCheckMessage(MSG_ERROR, "block rcurly", 24, "16"),
4213         };
4214         verify(checkConfig,
4215             getPath("InputIndentationChainedMethodCallWithLambda.java"),
4216             expected);
4217     }
4218 
4219     @Test
4220     public void testYieldNestedSwitchExpressionWithCaseIndentZero() throws Exception {
4221         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4222         checkConfig.addProperty("tabWidth", "4");
4223         checkConfig.addProperty("caseIndent", "0");
4224 
4225         final String[] expected = {
4226             "21:21: " + getCheckMessage(MSG_CHILD_ERROR, "case", 20, 16),
4227             "22:21: " + getCheckMessage(MSG_CHILD_ERROR, "case", 20, 16),
4228         };
4229 
4230         verify(checkConfig,
4231             getPath("InputIndentationYieldNestedSwitchExpressionCaseIndentZero.java"),
4232             expected);
4233     }
4234 
4235     @Test
4236     public void testInputIndentationLambdaChild() throws Exception {
4237         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4238         checkConfig.addProperty("tabWidth", "4");
4239         checkConfig.addProperty("basicOffset", "2");
4240         checkConfig.addProperty("braceAdjustment", "2");
4241         checkConfig.addProperty("caseIndent", "2");
4242         checkConfig.addProperty("lineWrappingIndentation", "4");
4243 
4244         final String fileName = getPath(
4245                 "InputIndentationLambdaChild.java");
4246         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4247         verifyWarns(checkConfig, fileName, expected);
4248     }
4249 
4250     @Test
4251     public void testInputLambdaAndChildOnTheSameLine() throws Exception {
4252         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4253         checkConfig.addProperty("tabWidth", "4");
4254         checkConfig.addProperty("basicOffset", "2");
4255         checkConfig.addProperty("braceAdjustment", "2");
4256         checkConfig.addProperty("caseIndent", "2");
4257         checkConfig.addProperty("lineWrappingIndentation", "4");
4258 
4259         final String fileName = getPath(
4260                 "InputIndentationLambdaAndChildOnTheSameLine.java");
4261         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4262         verifyWarns(checkConfig, fileName, expected);
4263     }
4264 
4265     @Test
4266     public void testIndentationPatternMatchingForSwitch()
4267             throws Exception {
4268         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4269         checkConfig.addProperty("forceStrictCondition", "true");
4270         checkConfig.addProperty("tabWidth", "4");
4271         checkConfig.addProperty("basicOffset", "4");
4272         checkConfig.addProperty("braceAdjustment", "0");
4273         checkConfig.addProperty("caseIndent", "4");
4274         checkConfig.addProperty("throwsIndent", "8");
4275 
4276         final String fileName = getPath(
4277                 "InputIndentationPatternMatchingForSwitch.java");
4278         final String[] expected = {
4279             "21:13: " + getCheckMessage(MSG_CHILD_ERROR, "case", 12, 16),
4280             "54:13: " + getCheckMessage(MSG_CHILD_ERROR, "case", 12, 16),
4281             "69:13: " + getCheckMessage(MSG_CHILD_ERROR, "case", 12, 16),
4282             "70:13: " + getCheckMessage(MSG_CHILD_ERROR, "case", 12, 16),
4283             "75:5: " + getCheckMessage(MSG_CHILD_ERROR, "case", 4, 16),
4284             "76:5: " + getCheckMessage(MSG_CHILD_ERROR, "case", 4, 16),
4285             "87:1: " + getCheckMessage(MSG_CHILD_ERROR, "case", 0, 16),
4286             "88:1: " + getCheckMessage(MSG_CHILD_ERROR, "case", 0, 16),
4287             "89:1: " + getCheckMessage(MSG_CHILD_ERROR, "case", 0, 16),
4288             "90:1: " + getCheckMessage(MSG_ERROR, "lambda", 0, 16),
4289             "91:1: " + getCheckMessage(MSG_CHILD_ERROR, "lambda", 0, 20),
4290         };
4291         verifyWarns(checkConfig, fileName, expected);
4292     }
4293 
4294     @Test
4295     public void testIndentationSingleSwitchStatementsWithoutCurly()
4296             throws Exception {
4297         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4298         checkConfig.addProperty("forceStrictCondition", "true");
4299         checkConfig.addProperty("tabWidth", "4");
4300         checkConfig.addProperty("basicOffset", "4");
4301         checkConfig.addProperty("braceAdjustment", "0");
4302         checkConfig.addProperty("caseIndent", "4");
4303         checkConfig.addProperty("throwsIndent", "4");
4304 
4305         final String fileName = getPath(
4306                 "InputIndentationCheckSingleSwitchStatementsWithoutCurly.java");
4307         final String[] expected = {
4308             "31:13: " + getCheckMessage(MSG_ERROR, "lambda", 12, 16),
4309             "32:13: " + getCheckMessage(MSG_CHILD_ERROR, "lambda", 12, 20),
4310             "33:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 12),
4311             "34:1: " + getCheckMessage(MSG_CHILD_ERROR, "lambda", 0, 16),
4312             "44:25: " + getCheckMessage(MSG_CHILD_ERROR, "lambda", 24, 16),
4313             "47:13: " + getCheckMessage(MSG_CHILD_ERROR, "block", 12, 16),
4314         };
4315         verifyWarns(checkConfig, fileName, expected);
4316     }
4317 
4318     @Test
4319     public void testIndentationRecordPattern()
4320             throws Exception {
4321         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4322         checkConfig.addProperty("forceStrictCondition", "true");
4323         checkConfig.addProperty("tabWidth", "4");
4324         checkConfig.addProperty("basicOffset", "4");
4325         checkConfig.addProperty("braceAdjustment", "0");
4326         checkConfig.addProperty("caseIndent", "4");
4327         checkConfig.addProperty("throwsIndent", "8");
4328 
4329         final String fileName = getNonCompilablePath(
4330                 "InputIndentationRecordPattern.java");
4331         final String[] expected = {
4332             "19:17: " + getCheckMessage(MSG_ERROR, "ColoredPoint", 16, 12),
4333             "24:9: " + getCheckMessage(MSG_ERROR, "ColoredPoint", 8, 12),
4334             "29:17: " + getCheckMessage(MSG_ERROR, "ColoredPoint", 16, 12),
4335             "34:9: " + getCheckMessage(MSG_CHILD_ERROR, "if", 8, 12),
4336             "37:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4337             "39:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4338             "40:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4339             "41:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4340             "42:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4341             "56:17: " + getCheckMessage(MSG_ERROR, "Rectangle", 16, 12),
4342             "57:17: " + getCheckMessage(MSG_ERROR, "ColoredPoint", 16, 12),
4343             "58:25: " + getCheckMessage(MSG_ERROR, "boolean", 24, 12),
4344             "59:17: " + getCheckMessage(MSG_ERROR, "int", 16, 12),
4345             "60:25: " + getCheckMessage(MSG_ERROR, "_", 24, 12),
4346             "61:17: " + getCheckMessage(MSG_ERROR, "ColoredPoint", 16, 12),
4347             "62:17: " + getCheckMessage(MSG_ERROR, ")", 16, 8),
4348             "67:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4349             "66:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4350             "68:9: " + getCheckMessage(MSG_CHILD_ERROR, "if", 8, 12),
4351             "69:9: " + getCheckMessage(MSG_CHILD_ERROR, "if", 8, 12),
4352             "70:9: " + getCheckMessage(MSG_CHILD_ERROR, "if", 8, 12),
4353             "71:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4354             "72:9: " + getCheckMessage(MSG_CHILD_ERROR, "if", 8, 12),
4355             "81:13: " + getCheckMessage(MSG_ERROR, ")", 12, 8),
4356             "89:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 16),
4357             "90:9: " + getCheckMessage(MSG_CHILD_ERROR, "case", 8, 16),
4358         };
4359         verifyWarns(checkConfig, fileName, expected);
4360     }
4361 
4362     @Test
4363     public void testIndentationUnnamedPattern() throws Exception {
4364         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4365         checkConfig.addProperty("forceStrictCondition", "false");
4366         checkConfig.addProperty("tabWidth", "4");
4367         checkConfig.addProperty("basicOffset", "4");
4368         checkConfig.addProperty("braceAdjustment", "0");
4369         checkConfig.addProperty("caseIndent", "4");
4370         checkConfig.addProperty("throwsIndent", "8");
4371         checkConfig.addProperty("lineWrappingIndentation", "4");
4372 
4373         final String fileName = getNonCompilablePath(
4374                 "InputIndentationUnnamedPattern.java");
4375         final String[] expected = {
4376             "26:9: " + getCheckMessage(MSG_CHILD_ERROR, "if", 8, 12),
4377             "29:1: " + getCheckMessage(MSG_CHILD_ERROR, "if", 0, 12),
4378         };
4379         verifyWarns(checkConfig, fileName, expected);
4380     }
4381 
4382     @Test
4383     public void testIndentationCodeBlocks1() throws Exception {
4384         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4385         checkConfig.addProperty("tabWidth", "4");
4386         checkConfig.addProperty("basicOffset", "2");
4387         checkConfig.addProperty("braceAdjustment", "2");
4388         checkConfig.addProperty("caseIndent", "2");
4389         checkConfig.addProperty("throwsIndent", "4");
4390         checkConfig.addProperty("lineWrappingIndentation", "4");
4391         final String[] expected = {
4392             "17:5: " + getCheckMessage(MSG_ERROR, "block lcurly", 4, 2),
4393             "18:7: " + getCheckMessage(MSG_CHILD_ERROR, "block", 6, 4),
4394             "19:5: " + getCheckMessage(MSG_ERROR, "block rcurly", 4, 2),
4395             "30:5: " + getCheckMessage(MSG_ERROR, "block lcurly", 4, 2),
4396             "31:7: " + getCheckMessage(MSG_CHILD_ERROR, "block", 6, 4),
4397             "32:5: " + getCheckMessage(MSG_ERROR, "block rcurly", 4, 2),
4398         };
4399         verifyWarns(checkConfig, getPath("InputIndentationCodeBlocks1.java"), expected);
4400     }
4401 
4402     @Test
4403     public void testIndentationCodeBlocks2() throws Exception {
4404         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4405         checkConfig.addProperty("tabWidth", "4");
4406         checkConfig.addProperty("basicOffset", "2");
4407         checkConfig.addProperty("braceAdjustment", "2");
4408         checkConfig.addProperty("throwsIndent", "4");
4409         checkConfig.addProperty("caseIndent", "2");
4410         checkConfig.addProperty("lineWrappingIndentation", "4");
4411         final String[] expected = {
4412             "45:13: " + getCheckMessage(MSG_ERROR, "for lcurly", 12, 14),
4413             "47:13: " + getCheckMessage(MSG_ERROR, "for rcurly", 12, 14),
4414         };
4415         verifyWarns(checkConfig,
4416                 getPath("InputIndentationCodeBlocks2.java"), expected);
4417     }
4418 
4419     @Test
4420     public void testSynchronizedExprViolation() throws Exception {
4421         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4422         checkConfig.addProperty("basicOffset", "4");
4423         checkConfig.addProperty("braceAdjustment", "0");
4424         checkConfig.addProperty("caseIndent", "4");
4425         checkConfig.addProperty("lineWrappingIndentation", "4");
4426         checkConfig.addProperty("throwsIndent", "4");
4427         checkConfig.addProperty("forceStrictCondition", "false");
4428         checkConfig.addProperty("tabWidth", "4");
4429         final String fileName = getPath("InputIndentationSynchronizedExprViolation.java");
4430         final String[] expected = {
4431             "18:1: " + getCheckMessage(MSG_CHILD_ERROR, "synchronized", 0, 12),
4432         };
4433         verifyWarns(checkConfig, fileName, expected);
4434     }
4435 
4436     @Test
4437     public void testIndentationAnnotationArray() throws Exception {
4438         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4439         checkConfig.addProperty("tabWidth", "4");
4440         checkConfig.addProperty("basicOffset", "2");
4441         checkConfig.addProperty("braceAdjustment", "2");
4442         checkConfig.addProperty("caseIndent", "2");
4443         checkConfig.addProperty("throwsIndent", "4");
4444         checkConfig.addProperty("lineWrappingIndentation", "4");
4445         checkConfig.addProperty("arrayInitIndent", "2");
4446 
4447         final String fileName = getPath(
4448                 "InputIndentationAnnotationArray.java");
4449         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4450         verifyWarns(checkConfig, fileName, expected);
4451     }
4452 
4453     @Test
4454     public void testSwitchExprViolation() throws Exception {
4455         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4456         checkConfig.addProperty("basicOffset", "4");
4457         checkConfig.addProperty("braceAdjustment", "0");
4458         checkConfig.addProperty("caseIndent", "4");
4459         checkConfig.addProperty("lineWrappingIndentation", "4");
4460         checkConfig.addProperty("throwsIndent", "4");
4461         checkConfig.addProperty("forceStrictCondition", "false");
4462         checkConfig.addProperty("tabWidth", "4");
4463         final String fileName = getPath("InputIndentationSwitchExprViolation.java");
4464         final String[] expected = {
4465             "18:1: " + getCheckMessage(MSG_CHILD_ERROR, "switch", 0, 8),
4466         };
4467         verifyWarns(checkConfig, fileName, expected);
4468     }
4469 
4470     @Test
4471     public void testIndentationSealedClasses()
4472             throws Exception {
4473         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4474         checkConfig.addProperty("forceStrictCondition", "true");
4475         checkConfig.addProperty("tabWidth", "4");
4476         checkConfig.addProperty("basicOffset", "4");
4477         checkConfig.addProperty("braceAdjustment", "0");
4478         checkConfig.addProperty("caseIndent", "4");
4479         checkConfig.addProperty("throwsIndent", "8");
4480 
4481         final String fileName = getPath(
4482                 "InputIndentationSealedClasses.java");
4483         final String[] expected = {
4484             "14:1: " + getCheckMessage(MSG_ERROR, "class def modifier", 0, 4),
4485             "15:2: " + getCheckMessage(MSG_ERROR, "class", 1, 4),
4486             "16:6: " + getCheckMessage(MSG_ERROR, "permits", 5, 4),
4487             "19:5: " + getCheckMessage(MSG_ERROR, "class", 4, 8),
4488             "20:5: " + getCheckMessage(MSG_ERROR, "permits", 4, 8),
4489             "28:1: " + getCheckMessage(MSG_ERROR, "class def modifier", 0, 4),
4490             "29:9: " + getCheckMessage(MSG_ERROR, "extends", 8, 4),
4491             "32:5: " + getCheckMessage(MSG_ERROR, "extends", 4, 8),
4492             "38:5: " + getCheckMessage(MSG_ERROR, "class", 4, 8),
4493             "39:1: " + getCheckMessage(MSG_ERROR, "permits", 0, 8),
4494             "40:13: " + getCheckMessage(MSG_ERROR, "C", 12, 8),
4495             "48:5: " + getCheckMessage(MSG_ERROR, "class", 4, 8),
4496             "49:5: " + getCheckMessage(MSG_ERROR, "C", 4, 8),
4497             "55:1: " + getCheckMessage(MSG_ERROR, "class def modifier", 0, 4),
4498             "56:9: " + getCheckMessage(MSG_ERROR, "class", 8, 4),
4499         };
4500         verifyWarns(checkConfig, fileName, expected);
4501     }
4502 
4503     @Test
4504     public void testClassDefWrappedModifiers() throws Exception {
4505         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4506         checkConfig.addProperty("basicOffset", "2");
4507         checkConfig.addProperty("braceAdjustment", "2");
4508         checkConfig.addProperty("caseIndent", "2");
4509         checkConfig.addProperty("lineWrappingIndentation", "4");
4510         checkConfig.addProperty("throwsIndent", "4");
4511         checkConfig.addProperty("forceStrictCondition", "false");
4512         checkConfig.addProperty("tabWidth", "4");
4513         checkConfig.addProperty("arrayInitIndent", "2");
4514         final String fileName =
4515                 getPath("InputIndentationClassDefWrappedModifiers.java");
4516         final String[] expected = {
4517             "25:3: " + getCheckMessage(MSG_ERROR, "class", 2, 6),
4518             "27:3: " + getCheckMessage(MSG_ERROR, "static", 2, 6),
4519             "31:3: " + getCheckMessage(MSG_ERROR, "static", 2, 6),
4520             "40:3: " + getCheckMessage(MSG_ERROR, "strictfp", 2, 6),
4521             "44:3: " + getCheckMessage(MSG_ERROR, "@", 2, 6),
4522             "50:3: " + getCheckMessage(MSG_ERROR, "static", 2, 6),
4523             "51:3: " + getCheckMessage(MSG_ERROR, "strictfp", 2, 6),
4524             "84:2: " + getCheckMessage(MSG_ERROR, "class def modifier", 1, 2),
4525         };
4526         verifyWarns(checkConfig, fileName, expected);
4527     }
4528 
4529     @Test
4530     public void testAnnotationBeforeClass() throws Exception {
4531         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4532         checkConfig.addProperty("basicOffset", "2");
4533         checkConfig.addProperty("braceAdjustment", "2");
4534         checkConfig.addProperty("caseIndent", "2");
4535         checkConfig.addProperty("lineWrappingIndentation", "4");
4536         checkConfig.addProperty("throwsIndent", "4");
4537         checkConfig.addProperty("forceStrictCondition", "false");
4538         checkConfig.addProperty("tabWidth", "4");
4539         checkConfig.addProperty("arrayInitIndent", "2");
4540         final String fileName = getPath("InputIndentationAnnotationBeforeClass.java");
4541         final String[] expected = {
4542             "41:2: " + getCheckMessage(MSG_ERROR, "class def modifier", 1, 2),
4543             "46:2: " + getCheckMessage(MSG_ERROR, "class def modifier", 1, 2),
4544             "47:2: " + getCheckMessage(MSG_ERROR, "class def modifier", 1, 2),
4545             "48:5: " + getCheckMessage(MSG_ERROR, "class def modifier", 4, 2),
4546             "49:5: " + getCheckMessage(MSG_ERROR, "class def modifier", 4, 2),
4547         };
4548         verify(checkConfig, fileName, expected);
4549     }
4550 
4551     @Test
4552     public void testAnnotationBeforeClassOpenJdkCase() throws Exception {
4553         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4554         checkConfig.addProperty("basicOffset", "4");
4555         checkConfig.addProperty("braceAdjustment", "0");
4556         checkConfig.addProperty("caseIndent", "4");
4557         checkConfig.addProperty("lineWrappingIndentation", "4");
4558         checkConfig.addProperty("throwsIndent", "4");
4559         checkConfig.addProperty("forceStrictCondition", "false");
4560         checkConfig.addProperty("tabWidth", "4");
4561         checkConfig.addProperty("arrayInitIndent", "2");
4562         final String fileName = getPath("InputIndentationAnnotBeforeClassOpenJdkCase.java");
4563         final String[] expected = {
4564             "12:4: " + getCheckMessage(MSG_ERROR, "class def modifier", 3, 4),
4565             "13:4: " + getCheckMessage(MSG_ERROR, "class def modifier", 3, 4),
4566             "15:9: " + getCheckMessage(MSG_ERROR, "class def modifier", 8, 4),
4567             "16:9: " + getCheckMessage(MSG_ERROR, "class def modifier", 8, 4),
4568             "18:3: " + getCheckMessage(MSG_ERROR, "class def modifier", 2, 4),
4569             "19:3: " + getCheckMessage(MSG_ERROR, "class def modifier", 2, 4),
4570             "21:7: " + getCheckMessage(MSG_ERROR, "class def modifier", 6, 4),
4571             "22:7: " + getCheckMessage(MSG_ERROR, "class def modifier", 6, 4),
4572             "24:4: " + getCheckMessage(MSG_ERROR, "class def modifier", 3, 4),
4573             "26:4: " + getCheckMessage(MSG_ERROR, "class def modifier", 3, 4),
4574             "28:7: " + getCheckMessage(MSG_ERROR, "class def modifier", 6, 4),
4575             "30:7: " + getCheckMessage(MSG_ERROR, "class def modifier", 6, 4),
4576             "32:3: " + getCheckMessage(MSG_ERROR, "class def modifier", 2, 4),
4577             "33:3: " + getCheckMessage(MSG_ERROR, "class def modifier", 2, 4),
4578             "35:4: " + getCheckMessage(MSG_ERROR, "enum def modifier", 3, 4),
4579             "36:4: " + getCheckMessage(MSG_ERROR, "enum def modifier", 3, 4),
4580             "38:4: " + getCheckMessage(MSG_ERROR, "interface def modifier", 3, 4),
4581             "39:4: " + getCheckMessage(MSG_ERROR, "interface def modifier", 3, 4),
4582         };
4583         verify(checkConfig, fileName, expected);
4584     }
4585 
4586     @Test
4587     public void testTryResourcesLparenViolation() throws Exception {
4588         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4589         checkConfig.addProperty("basicOffset", "4");
4590         checkConfig.addProperty("braceAdjustment", "0");
4591         checkConfig.addProperty("caseIndent", "4");
4592         checkConfig.addProperty("lineWrappingIndentation", "4");
4593         checkConfig.addProperty("throwsIndent", "4");
4594         checkConfig.addProperty("forceStrictCondition", "false");
4595         checkConfig.addProperty("tabWidth", "4");
4596         final String fileName = getPath("InputIndentationTryResourcesLparenViolation.java");
4597         final String[] expected = {
4598             "22:1: " + getCheckMessage(MSG_ERROR_MULTI, "try lparen", 0, "8, 12"),
4599         };
4600         verifyWarns(checkConfig, fileName, expected);
4601     }
4602 
4603     @Test
4604     public void testTryChildOnSameLine() throws Exception {
4605         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4606         checkConfig.addProperty("arrayInitIndent", "4");
4607         checkConfig.addProperty("basicOffset", "4");
4608         checkConfig.addProperty("braceAdjustment", "0");
4609         checkConfig.addProperty("caseIndent", "4");
4610         checkConfig.addProperty("forceStrictCondition", "false");
4611         checkConfig.addProperty("lineWrappingIndentation", "4");
4612         checkConfig.addProperty("tabWidth", "4");
4613         checkConfig.addProperty("throwsIndent", "4");
4614         final String fileName = getPath("InputIndentationTryChildOnSameLine.java");
4615         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4616         verifyWarns(checkConfig, fileName, expected);
4617     }
4618 
4619     @Test
4620     public void testTryChildOnSameLineStrict() throws Exception {
4621         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4622         checkConfig.addProperty("arrayInitIndent", "4");
4623         checkConfig.addProperty("basicOffset", "4");
4624         checkConfig.addProperty("braceAdjustment", "0");
4625         checkConfig.addProperty("caseIndent", "4");
4626         checkConfig.addProperty("forceStrictCondition", "true");
4627         checkConfig.addProperty("lineWrappingIndentation", "4");
4628         checkConfig.addProperty("tabWidth", "4");
4629         checkConfig.addProperty("throwsIndent", "4");
4630         final String fileName = getPath("InputIndentationTryChildOnSameLineStrict.java");
4631         final String[] expected = {
4632             "11:44: " + getCheckMessage(MSG_ERROR, "@", 43, 12),
4633         };
4634         verify(checkConfig, fileName, expected);
4635     }
4636 
4637     @Test
4638     public void testSynchronizedWrapping() throws Exception {
4639         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4640         checkConfig.addProperty("arrayInitIndent", "4");
4641         checkConfig.addProperty("basicOffset", "4");
4642         checkConfig.addProperty("braceAdjustment", "0");
4643         checkConfig.addProperty("caseIndent", "4");
4644         checkConfig.addProperty("forceStrictCondition", "false");
4645         checkConfig.addProperty("lineWrappingIndentation", "8");
4646         checkConfig.addProperty("tabWidth", "4");
4647         checkConfig.addProperty("throwsIndent", "4");
4648         final String fileName = getPath("InputIndentationSynchronizedWrapping.java");
4649         final String[] expected = {
4650             "22:13: " + getCheckMessage(MSG_ERROR, ".", 12, 16),
4651         };
4652         verifyWarns(checkConfig, fileName, expected);
4653     }
4654 
4655     /**
4656      * Pure unit test to satisfy line coverage for {@link PrimordialHandler#checkIndentation()}.
4657      * The method has an empty implementation required by the abstract contract of
4658      * {@link AbstractExpressionHandler}. A unit test is required as this method is not
4659      * reachable through any integration test.
4660      */
4661     @Test
4662     public void testPrimordialHandlerCheckIndentation() {
4663         final IndentationCheck check = new IndentationCheck();
4664         check.beginTree(null);
4665         final IndentationContext context =
4666             TestUtil.getInternalState(check, "context", IndentationContext.class);
4667         final PrimordialHandler handler = new PrimordialHandler(context);
4668         handler.checkIndentation();
4669         assertWithMessage("Method should complete without exception")
4670             .that(handler)
4671             .isNotNull();
4672     }
4673 
4674     @Test
4675     public void testIndexOpWithInvalidChildIndentation() throws Exception {
4676         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4677         checkConfig.addProperty("arrayInitIndent", "4");
4678         checkConfig.addProperty("basicOffset", "4");
4679         checkConfig.addProperty("braceAdjustment", "0");
4680         checkConfig.addProperty("caseIndent", "4");
4681         checkConfig.addProperty("forceStrictCondition", "false");
4682         checkConfig.addProperty("lineWrappingIndentation", "4");
4683         checkConfig.addProperty("tabWidth", "4");
4684         checkConfig.addProperty("throwsIndent", "4");
4685         final String fileName = getPath("InputIndentationInvalidArrayIndexIndent.java");
4686         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4687         verifyWarns(checkConfig, fileName, expected);
4688     }
4689 
4690     @Test
4691     public void testFirstTokenSelection() throws Exception {
4692         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4693         checkConfig.addProperty("basicOffset", "4");
4694         checkConfig.addProperty("tabWidth", "4");
4695 
4696         final String[] expected = {
4697             "15:1: " + getCheckMessage(MSG_ERROR, "member def type", 0, 8),
4698             "16:1: " + getCheckMessage(MSG_ERROR, "Integer", 0, 12),
4699             "17:1: " + getCheckMessage(MSG_ERROR, ">", 0, 12),
4700         };
4701         verifyWarns(checkConfig,
4702             getPath("InputIndentationFirstTokenSelection.java"), expected);
4703     }
4704 
4705     @Test
4706     public void testNewKeywordWithTernaryOperator() throws Exception {
4707         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4708 
4709         checkConfig.addProperty("basicOffset", "4");
4710         checkConfig.addProperty("braceAdjustment", "0");
4711         checkConfig.addProperty("caseIndent", "4");
4712         checkConfig.addProperty("forceStrictCondition", "true");
4713         checkConfig.addProperty("lineWrappingIndentation", "4");
4714         checkConfig.addProperty("tabWidth", "4");
4715         checkConfig.addProperty("throwsIndent", "4");
4716         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4717         verifyWarns(checkConfig,
4718             getPath("InputIndentationNewWithTernaryOp.java"), expected);
4719     }
4720 
4721     @Test
4722     public void testClassDefIndentation() throws Exception {
4723         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4724 
4725         checkConfig.addProperty("tabWidth", "4");
4726         checkConfig.addProperty("basicOffset", "4");
4727         checkConfig.addProperty("braceAdjustment", "0");
4728         checkConfig.addProperty("caseIndent", "4");
4729         checkConfig.addProperty("throwsIndent", "8");
4730         checkConfig.addProperty("forceStrictCondition", "false");
4731         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4732         verifyWarns(checkConfig,
4733                 getPath("InputIndentationClassDef.java"),
4734                 expected);
4735     }
4736 
4737     /**
4738      * Test to kill Pitest mutation by verifying internal state is cleared.
4739      *
4740      * <p>This reflection-based test was chosen because:
4741      * 1. clearState() exists purely for memory management, prevents OutOfMemoryError when
4742      *    processing thousands of files
4743      * 2. Removing clear() has no observable effect in normal tests since each file creates
4744      *    new DetailAST objects (no collision possible)
4745      * 3. Pitest's excludedMethods only protects method bodies, not call-sites
4746      * 4. Creating a utility class with avoidCallsTo was overkill for one mutation
4747      *
4748      * @see <a href="https://github.com/hcoles/pitest/issues/404">Pitest Issue #404</a>
4749      */
4750     @Test
4751     public void testClearStateForMemoryManagement() {
4752         final IndentationCheck check = new IndentationCheck();
4753         check.beginTree(null);
4754         final IndentationContext context =
4755             TestUtil.getInternalState(check, "context", IndentationContext.class);
4756         @SuppressWarnings("unchecked")
4757         final Deque<PrimordialHandler> handlers = TestUtil.getInternalState(check,
4758                 "handlers", Deque.class);
4759 
4760         handlers.push(new PrimordialHandler(context));
4761         handlers.push(new PrimordialHandler(context));
4762 
4763         assertWithMessage("handlers should have 3 elements before beginTree")
4764                 .that(handlers)
4765                 .hasSize(3);
4766 
4767         check.beginTree(null);
4768 
4769         assertWithMessage("handlers should be reset to 1 element after beginTree")
4770                 .that(handlers)
4771                 .hasSize(1);
4772     }
4773 
4774     @Test
4775     public void testLambdaInEnumConstant() throws Exception {
4776         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4777         checkConfig.addProperty("basicOffset", "4");
4778         checkConfig.addProperty("braceAdjustment", "0");
4779         checkConfig.addProperty("caseIndent", "4");
4780         checkConfig.addProperty("throwsIndent", "4");
4781         checkConfig.addProperty("arrayInitIndent", "4");
4782         checkConfig.addProperty("lineWrappingIndentation", "4");
4783         checkConfig.addProperty("forceStrictCondition", "false");
4784         checkConfig.addProperty("tabWidth", "8");
4785 
4786         final String fileName = getPath("InputIndentationLambdaInEnum.java");
4787         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4788         verifyWarns(checkConfig, fileName, expected);
4789     }
4790 
4791     @Test
4792     public void testLambdaInEnumConstantWithMultipleArgs() throws Exception {
4793         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4794         checkConfig.addProperty("basicOffset", "4");
4795         checkConfig.addProperty("braceAdjustment", "0");
4796         checkConfig.addProperty("caseIndent", "4");
4797         checkConfig.addProperty("throwsIndent", "4");
4798         checkConfig.addProperty("arrayInitIndent", "4");
4799         checkConfig.addProperty("lineWrappingIndentation", "4");
4800         checkConfig.addProperty("forceStrictCondition", "false");
4801         checkConfig.addProperty("tabWidth", "8");
4802 
4803         final String fileName = getPath("InputIndentationLambdaInEnumMultipleArgs.java");
4804         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4805         verifyWarns(checkConfig, fileName, expected);
4806     }
4807 
4808     @Test
4809     public void testTryBlockConstructorParameters() throws Exception {
4810         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4811         checkConfig.addProperty("basicOffset", "4");
4812         checkConfig.addProperty("braceAdjustment", "0");
4813         checkConfig.addProperty("caseIndent", "4");
4814         checkConfig.addProperty("lineWrappingIndentation", "8");
4815         checkConfig.addProperty("tabWidth", "4");
4816 
4817         final String fileName = getPath("InputIndentationTryCtorParams.java");
4818         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
4819         verifyWarns(checkConfig, fileName, expected);
4820     }
4821 
4822     @Test
4823     public void testSwitchExpressionWithWrappedCaseLabels() throws Exception {
4824         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4825         checkConfig.addProperty("basicOffset", "4");
4826         checkConfig.addProperty("braceAdjustment", "4");
4827         checkConfig.addProperty("caseIndent", "4");
4828         checkConfig.addProperty("lineWrappingIndentation", "8");
4829         checkConfig.addProperty("tabWidth", "4");
4830 
4831         final String fileName = getPath("InputIndentation17270.java");
4832         final String[] expected = {
4833             "32:18: " + getCheckMessage(MSG_CHILD_ERROR, "case", 17, 20),
4834         };
4835         verifyWarns(checkConfig, fileName, expected);
4836     }
4837 
4838     @Test
4839     public void testSwitchExpressionWithWrappedCaseLabelsWithLineWrapping4() throws Exception {
4840         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4841         checkConfig.addProperty("basicOffset", "4");
4842         checkConfig.addProperty("braceAdjustment", "4");
4843         checkConfig.addProperty("caseIndent", "4");
4844         checkConfig.addProperty("lineWrappingIndentation", "4");
4845         checkConfig.addProperty("tabWidth", "4");
4846 
4847         final String fileName = getPath("InputIndentation17270linewrapping4.java");
4848         final String[] expected = {
4849             "9:15: " + getCheckMessage(MSG_CHILD_ERROR, "case", 14, 16),
4850             "13:16: " + getCheckMessage(MSG_CHILD_ERROR, "case", 15, 16),
4851             "15:16: " + getCheckMessage(MSG_CHILD_ERROR, "case", 15, 16),
4852         };
4853         verifyWarns(checkConfig, fileName, expected);
4854     }
4855 
4856     @Test
4857     public void testNewWithTabsIndentation() throws Exception {
4858         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4859         checkConfig.addProperty("basicOffset", "4");
4860         checkConfig.addProperty("braceAdjustment", "0");
4861         checkConfig.addProperty("caseIndent", "4");
4862         checkConfig.addProperty("forceStrictCondition", "false");
4863         checkConfig.addProperty("lineWrappingIndentation", "4");
4864         checkConfig.addProperty("tabWidth", "4");
4865         checkConfig.addProperty("throwsIndent", "4");
4866         final String[] expected = {
4867             "51:5: " + getCheckMessage(MSG_ERROR, "new", 4, 16),
4868         };
4869         verifyWarns(checkConfig, getPath("InputIndentationNewWithTabs.java"), expected);
4870     }
4871 
4872     @Test
4873     public void testMethodCallInLambdaAndReturnStatements() throws Exception {
4874         final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class);
4875         checkConfig.addProperty("basicOffset", "2");
4876         checkConfig.addProperty("braceAdjustment", "2");
4877         checkConfig.addProperty("caseIndent", "2");
4878         checkConfig.addProperty("lineWrappingIndentation", "4");
4879         checkConfig.addProperty("tabWidth", "4");
4880         checkConfig.addProperty("arrayInitIndent", "4");
4881 
4882         final String fileName = getPath("InputIndentationLambdaAndReturnStatement.java");
4883         final String[] expected = {
4884             "24:5: " + getCheckMessage(MSG_ERROR, "lambda", 4, 8),
4885             "34:5: " + getCheckMessage(MSG_ERROR, "s", 4, 8),
4886             "40:5: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 4, 8),
4887             "41:5: " + getCheckMessage(MSG_CHILD_ERROR, "method def", 4, 8),
4888             "46:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 6),
4889             "47:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 6),
4890             "48:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 6),
4891             "86:5: " + getCheckMessage(MSG_ERROR_MULTI, "new", 4, "6, 8"),
4892             "91:5: " + getCheckMessage(MSG_CHILD_ERROR, "method call", 4, 6),
4893         };
4894         verifyWarns(checkConfig, fileName, expected);
4895     }
4896 
4897     private static final class IndentAudit implements AuditListener {
4898 
4899         private final IndentComment[] comments;
4900         private int position;
4901 
4902         private IndentAudit(IndentComment... comments) {
4903             this.comments = Arrays.copyOf(comments, comments.length);
4904         }
4905 
4906         @Override
4907         public void auditStarted(AuditEvent event) {
4908             // No code needed
4909         }
4910 
4911         @Override
4912         public void auditFinished(AuditEvent event) {
4913             // No code needed
4914         }
4915 
4916         @Override
4917         public void fileStarted(AuditEvent event) {
4918             // No code needed
4919         }
4920 
4921         @Override
4922         public void fileFinished(AuditEvent event) {
4923             // No code needed
4924         }
4925 
4926         @Override
4927         public void addError(AuditEvent event) {
4928             final int line = event.getLine();
4929             final String message = event.getMessage();
4930 
4931             assertWithMessage(
4932                     "found a warning when none was expected for #%s at line %s with message %s",
4933                     position, line, message)
4934                 .that(position)
4935                 .isLessThan(comments.length);
4936 
4937             final IndentComment comment = comments[position];
4938             position++;
4939 
4940             final String possibleExceptedMessages = Arrays.stream(comment.getExpectedMessages())
4941                     .reduce("", (cur, next) -> cur + "\"" + next + "\", ");
4942             final String assertMessage = String.format(
4943                     Locale.ROOT,
4944                     "input expected warning #%d at line %d to report one of the following: %s"
4945                             + "but got instead: %d: %s",
4946                     position, comment.getLineNumber(), possibleExceptedMessages, line, message);
4947             assertWithMessage(assertMessage)
4948                     .that(line == comment.getLineNumber() && Arrays
4949                             .stream(comment.getExpectedMessages()).anyMatch(message::endsWith))
4950                     .isTrue();
4951         }
4952 
4953         @Override
4954         public void addException(AuditEvent event, Throwable throwable) {
4955             // No code needed
4956         }
4957 
4958     }
4959 
4960     private static final class IndentComment {
4961 
4962         /** Used to locate the index of argument zero of error messages. */
4963         private static final String FAKE_ARGUMENT_ZERO = "##0##";
4964         private final int lineNumber;
4965         private final int indent;
4966         /** Used for when violations report nodes not first on the line. */
4967         private final int indentOffset;
4968         private final boolean expectedNonStrict;
4969         private final String expectedWarning;
4970         private final boolean warning;
4971 
4972         private IndentComment(IndentComment original, int newLineNumber) {
4973             lineNumber = newLineNumber;
4974             indent = original.indent;
4975             indentOffset = original.indentOffset;
4976             expectedNonStrict = original.expectedNonStrict;
4977             expectedWarning = original.expectedWarning;
4978             warning = original.warning;
4979         }
4980 
4981         private IndentComment(Matcher match, int lineNumber) {
4982             this.lineNumber = lineNumber;
4983             indent = Integer.parseInt(match.group(1));
4984             if (match.group(2) == null) {
4985                 indentOffset = 0;
4986             }
4987             else {
4988                 indentOffset = Integer.parseInt(match.group(2));
4989             }
4990             expectedNonStrict = match.group(3) != null;
4991             expectedWarning = match.group(4).replace(",", ", ");
4992             warning = match.group(5) != null;
4993         }
4994 
4995         private String[] getExpectedMessages() {
4996             final String[] expectedMessages;
4997             if (expectedWarning.contains(",")) {
4998                 expectedMessages = new String[] {
4999                     getExpectedMessagePostfix(MSG_ERROR_MULTI),
5000                     getExpectedMessagePostfix(MSG_CHILD_ERROR_MULTI),
5001                 };
5002             }
5003             else {
5004                 expectedMessages = new String[] {
5005                     getExpectedMessagePostfix(MSG_ERROR),
5006                     getExpectedMessagePostfix(MSG_CHILD_ERROR),
5007                 };
5008             }
5009             return expectedMessages;
5010         }
5011 
5012         private String getExpectedMessagePostfix(final String messageKey) {
5013             final String msg = getCheckMessage(IndentationCheck.class, messageKey,
5014                     FAKE_ARGUMENT_ZERO, indent + indentOffset, expectedWarning);
5015             final int indexOfMsgPostfix = msg.indexOf(FAKE_ARGUMENT_ZERO)
5016                     + FAKE_ARGUMENT_ZERO.length();
5017             return msg.substring(indexOfMsgPostfix);
5018         }
5019 
5020         private int getLineNumber() {
5021             return lineNumber;
5022         }
5023 
5024         private int getIndent() {
5025             return indent;
5026         }
5027 
5028         private int getIndentOffset() {
5029             return indentOffset;
5030         }
5031 
5032         private boolean isExpectedNonStrict() {
5033             return expectedNonStrict;
5034         }
5035 
5036         private String getExpectedWarning() {
5037             return expectedWarning;
5038         }
5039 
5040         private boolean isWarning() {
5041             return warning;
5042         }
5043 
5044     }
5045 
5046 }