View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2017 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.whitespace;
21  
22  import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.MSG_WS_NOT_FOLLOWED;
23  import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.MSG_WS_NOT_PRECEDED;
24  import static org.junit.Assert.assertArrayEquals;
25  
26  import org.junit.Test;
27  
28  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
29  import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
30  import com.puppycrawl.tools.checkstyle.api.TokenTypes;
31  import com.puppycrawl.tools.checkstyle.utils.CommonUtils;
32  
33  public class WhitespaceAroundCheckTest
34      extends AbstractModuleTestSupport {
35      @Override
36      protected String getPackageLocation() {
37          return "com/puppycrawl/tools/checkstyle/checks/whitespace/whitespacearound";
38      }
39  
40      @Test
41      public void testGetRequiredTokens() {
42          final WhitespaceAroundCheck checkObj = new WhitespaceAroundCheck();
43          assertArrayEquals(
44              "WhitespaceAroundCheck#getRequiredTockens should return empty array by default",
45              CommonUtils.EMPTY_INT_ARRAY, checkObj.getRequiredTokens());
46      }
47  
48      @Test
49      public void testKeywordsAndOperators()
50              throws Exception {
51          final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
52          final String[] expected = {
53              "16:22: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="),
54              "16:23: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
55              "18:24: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
56              "26:14: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="),
57              "27:10: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="),
58              "27:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
59              "28:10: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "+="),
60              "28:12: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "+="),
61              "29:13: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "-="),
62              "37:21: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "synchronized"),
63              "39:12: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "try"),
64              "39:12: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
65              "41:14: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "catch"),
66              "41:34: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
67              "58:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "if"),
68              "76:19: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "return"),
69              "97:29: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "?"),
70              "97:30: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "?"),
71              "97:34: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ":"),
72              "97:35: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ":"),
73              "98:15: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "=="),
74              "98:17: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "=="),
75              "104:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "*"),
76              "104:21: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "*"),
77              "119:18: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "%"),
78              "120:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "%"),
79              "121:18: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "%"),
80              "121:19: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "%"),
81              "123:18: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "/"),
82              "124:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "/"),
83              "125:18: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "/"),
84              "125:19: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "/"),
85              "153:15: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "assert"),
86              "156:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ":"),
87              "156:21: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ":"),
88              "262:14: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "}"),
89          };
90          verify(checkConfig, getPath("InputWhitespaceAroundKeywordsAndOperators.java"), expected);
91      }
92  
93      @Test
94      public void testSimpleInput()
95              throws Exception {
96          final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
97          final String[] expected = {
98              "153:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
99              "154:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
100             "155:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
101             "156:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
102             "157:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
103             "158:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="),
104         };
105         verify(checkConfig, getPath("InputWhitespaceAroundSimple.java"), expected);
106     }
107 
108     @Test
109     public void testStartOfTheLine()
110             throws Exception {
111         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
112         final String[] expected = {
113             "5:2: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
114         };
115         verify(checkConfig, getPath("InputWhitespaceAroundStartOfTheLine.java"), expected);
116     }
117 
118     @Test
119     public void testBraces()
120             throws Exception {
121         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
122         final String[] expected = {
123             "37:14: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"),
124             "54:12: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "for"),
125             // + ":58:23: ';' is not followed by whitespace.",
126             //  + ":58:29: ';' is not followed by whitespace.",
127             "111:43: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
128             "111:43: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
129             "114:40: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
130             "114:40: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
131         };
132         verify(checkConfig, getPath("InputWhitespaceAroundBraces.java"), expected);
133     }
134 
135     @Test
136     public void testBracesInMethodsAndConstructors()
137             throws Exception {
138         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
139         checkConfig.addAttribute("allowEmptyMethods", "true");
140         checkConfig.addAttribute("allowEmptyConstructors", "true");
141         final String[] expected = {
142             "37:14: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"),
143             "54:12: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "for"),
144         };
145         verify(checkConfig, getPath("InputWhitespaceAroundBraces.java"), expected);
146     }
147 
148     @Test
149     public void testArrayInitialization()
150             throws Exception {
151         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
152         checkConfig.addAttribute("tokens", "ARRAY_INIT");
153         final String[] expected = {
154             "7:39: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
155             "11:37: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
156             "13:56: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
157             "21:42: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
158             "21:59: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
159             "23:40: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
160             "23:41: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
161             "27:46: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
162         };
163         verify(checkConfig, getPath("InputWhitespaceAroundArrayInitialization.java"), expected);
164     }
165 
166     @Test
167     public void testGenericsTokensAreFlagged()
168             throws Exception {
169         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
170         final String[] expected = {
171             "6:83: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "&"),
172             "6:84: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "&"),
173         };
174         verify(checkConfig, getPath("InputWhitespaceAroundGenerics.java"), expected);
175     }
176 
177     @Test
178     public void test1322879And1649038() throws Exception {
179         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
180         final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
181         verify(checkConfig, getPath("InputWhitespaceAround.java"),
182                expected);
183     }
184 
185     @Test
186     public void testAllowDoubleBraceInitialization() throws Exception {
187         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
188         final String[] expected = {
189             "11:73: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
190             "12:28: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
191             "14:28: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
192             "14:88: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
193             "17:10: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "}"),
194             "17:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
195         };
196         verify(checkConfig, getPath("InputWhitespaceAroundDoubleBraceInitialization.java"),
197                 expected);
198     }
199 
200     @Test
201     public void testIgnoreEnhancedForColon() throws Exception {
202         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
203         checkConfig.addAttribute("ignoreEnhancedForColon", "false");
204         final String[] expected = {
205             "19:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ":"),
206         };
207         verify(checkConfig, getPath("InputWhitespaceAround.java"),
208                expected);
209     }
210 
211     @Test
212     public void testEmptyTypes() throws Exception {
213         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
214         checkConfig.addAttribute("allowEmptyTypes", "true");
215         final String[] expected = {
216             "29:95: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
217             "29:95: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
218             "30:33: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
219             "30:33: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
220             "31:21: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
221             "31:21: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
222         };
223         verify(checkConfig, getPath("InputWhitespaceAroundEmptyTypesAndCycles.java"),
224                expected);
225     }
226 
227     @Test
228     public void testEmptyLoops() throws Exception {
229         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
230         checkConfig.addAttribute("allowEmptyLoops", "true");
231         final String[] expected = {
232             "40:65: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
233             "40:65: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
234             "42:17: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
235             "42:17: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
236             "44:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
237             "44:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
238             "50:44: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
239             "50:44: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
240             "60:18: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
241             "60:18: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
242         };
243         verify(checkConfig, getPath("InputWhitespaceAroundEmptyTypesAndCycles.java"),
244                expected);
245     }
246 
247     @Test
248     public void testSwitchWhitespaceAround() throws Exception {
249         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
250         final String[] expected = {
251             "6:15: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "switch"),
252         };
253         verify(checkConfig, getPath("InputWhitespaceAroundSwitch.java"), expected);
254     }
255 
256     @Test
257     public void testDoWhileWhitespaceAround() throws Exception {
258         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
259         final String[] expected = {
260             "9:16: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"),
261         };
262         verify(checkConfig, getPath("InputWhitespaceAroundDoWhile.java"), expected);
263     }
264 
265     @Test
266     public void allowEmptyMethods() throws Exception {
267         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
268         checkConfig.addAttribute("allowEmptyMethods", "true");
269         final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
270         verify(checkConfig, getPath("InputWhitespaceAround.java"), expected);
271     }
272 
273     @Test
274     public void testGetAcceptableTokens() {
275         final WhitespaceAroundCheck whitespaceAroundCheckObj = new WhitespaceAroundCheck();
276         final int[] actual = whitespaceAroundCheckObj.getAcceptableTokens();
277         final int[] expected = {
278             TokenTypes.ASSIGN,
279             TokenTypes.ARRAY_INIT,
280             TokenTypes.BAND,
281             TokenTypes.BAND_ASSIGN,
282             TokenTypes.BOR,
283             TokenTypes.BOR_ASSIGN,
284             TokenTypes.BSR,
285             TokenTypes.BSR_ASSIGN,
286             TokenTypes.BXOR,
287             TokenTypes.BXOR_ASSIGN,
288             TokenTypes.COLON,
289             TokenTypes.DIV,
290             TokenTypes.DIV_ASSIGN,
291             TokenTypes.DO_WHILE,
292             TokenTypes.EQUAL,
293             TokenTypes.GE,
294             TokenTypes.GT,
295             TokenTypes.LAMBDA,
296             TokenTypes.LAND,
297             TokenTypes.LCURLY,
298             TokenTypes.LE,
299             TokenTypes.LITERAL_CATCH,
300             TokenTypes.LITERAL_DO,
301             TokenTypes.LITERAL_ELSE,
302             TokenTypes.LITERAL_FINALLY,
303             TokenTypes.LITERAL_FOR,
304             TokenTypes.LITERAL_IF,
305             TokenTypes.LITERAL_RETURN,
306             TokenTypes.LITERAL_SWITCH,
307             TokenTypes.LITERAL_SYNCHRONIZED,
308             TokenTypes.LITERAL_TRY,
309             TokenTypes.LITERAL_WHILE,
310             TokenTypes.LOR,
311             TokenTypes.LT,
312             TokenTypes.MINUS,
313             TokenTypes.MINUS_ASSIGN,
314             TokenTypes.MOD,
315             TokenTypes.MOD_ASSIGN,
316             TokenTypes.NOT_EQUAL,
317             TokenTypes.PLUS,
318             TokenTypes.PLUS_ASSIGN,
319             TokenTypes.QUESTION,
320             TokenTypes.RCURLY,
321             TokenTypes.SL,
322             TokenTypes.SLIST,
323             TokenTypes.SL_ASSIGN,
324             TokenTypes.SR,
325             TokenTypes.SR_ASSIGN,
326             TokenTypes.STAR,
327             TokenTypes.STAR_ASSIGN,
328             TokenTypes.LITERAL_ASSERT,
329             TokenTypes.TYPE_EXTENSION_AND,
330             TokenTypes.WILDCARD_TYPE,
331             TokenTypes.GENERIC_START,
332             TokenTypes.GENERIC_END,
333             TokenTypes.ELLIPSIS,
334         };
335         assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
336     }
337 
338     @Test
339     public void testAllowEmptyTypesIsSetToFalseAndNonEmptyClasses() throws Exception {
340         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
341         checkConfig.addAttribute("allowEmptyTypes", "false");
342         final String[] expected = {
343             "6:68: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
344             "10:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
345             "14:32: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
346             "18:18: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
347             "20:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
348             "20:25: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
349             "20:31: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
350             "22:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "}"),
351             "24:18: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
352             "24:18: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
353             "26:69: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
354             "26:69: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
355             "28:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
356             "31:13: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
357             "31:13: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
358         };
359         verify(checkConfig, getPath("InputWhitespaceAroundAllowEmptyTypesAndNonEmptyClasses.java"),
360             expected);
361     }
362 
363     @Test
364     public void testAllowEmptyTypesIsSetToTrueAndNonEmptyClasses() throws Exception {
365         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
366         checkConfig.addAttribute("allowEmptyTypes", "true");
367         final String[] expected = {
368             "6:68: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
369             "10:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
370             "14:32: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
371             "18:18: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
372             "20:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
373             "20:25: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
374             "20:31: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
375             "22:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "}"),
376             "28:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"),
377             "31:13: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
378             "31:13: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
379             };
380         verify(checkConfig, getPath("InputWhitespaceAroundAllowEmptyTypesAndNonEmptyClasses.java"),
381             expected);
382     }
383 
384     @Test
385     public void testNotAllowEmptyLambdaExpressionsByDefault() throws Exception {
386         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
387         final String[] expected = {
388             "7:28: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
389             "7:28: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
390             "12:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
391             "12:30: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
392             "13:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
393             "13:42: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
394         };
395         verify(checkConfig, getPath("InputWhitespaceAroundAllowEmptyLambdaExpressions.java"),
396             expected);
397     }
398 
399     @Test
400     public void testAllowEmptyLambdaExpressionsWithAllowEmptyLambdaParameter() throws Exception {
401         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
402         checkConfig.addAttribute("allowEmptyLambdas", "true");
403         final String[] expected = {
404             "12:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
405             "12:30: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
406             "13:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"),
407             "13:42: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"),
408         };
409         verify(checkConfig, getPath("InputWhitespaceAroundAllowEmptyLambdaExpressions.java"),
410                 expected);
411     }
412 
413     @Test
414     public void testWhitespaceAroundLambda() throws Exception {
415         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
416         final String[] expected = {
417             "8:48: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "->"),
418             "8:50: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "->"),
419         };
420         verify(checkConfig, getPath("InputWhitespaceAroundLambda.java"), expected);
421     }
422 
423     @Test
424     public void testWhitespaceAroundEmptyCatchBlock() throws Exception {
425         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
426         checkConfig.addAttribute("allowEmptyCatches", "true");
427         final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
428         verify(checkConfig, getPath("InputWhitespaceAroundCatch.java"),
429                 expected);
430     }
431 
432     @Test
433     public void testWhitespaceAroundVarargs() throws Exception {
434         final DefaultConfiguration checkConfig = createModuleConfig(WhitespaceAroundCheck.class);
435         checkConfig.addAttribute("tokens", "ELLIPSIS");
436         final String[] expected = {
437             "9:36: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "..."),
438             "10:40: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "..."),
439             "11:36: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "..."),
440             "11:39: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "..."),
441             "13:28: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "..."),
442             "13:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "..."),
443             "14:39: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "..."),
444             "14:42: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "..."),
445         };
446         verify(checkConfig, getPath("InputWhitespaceAroundVarargs.java"), expected);
447     }
448 }