-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
MainTest.java
1469 lines (1326 loc) · 69 KB
/
MainTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2019 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
import org.junit.contrib.java.lang.system.SystemErrRule;
import org.junit.contrib.java.lang.system.SystemOutRule;
import org.junit.rules.TemporaryFolder;
import org.powermock.reflect.Whitebox;
import com.puppycrawl.tools.checkstyle.api.AuditListener;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.Configuration;
import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
import com.puppycrawl.tools.checkstyle.internal.testmodules.TestRootModuleChecker;
public class MainTest {
private static final String SHORT_USAGE = String.format(Locale.ROOT,
"Usage: checkstyle [OPTIONS]... FILES...%n"
+ "Try 'checkstyle --help' for more information.%n");
private static final String USAGE = String.format(Locale.ROOT,
"Usage: checkstyle [-dghjJtTV] [--executeIgnoredModules] [--tabWidth=<tabWidth>]%n"
+ " [-c=<configurationFile>] [-C=<checkerThreadsNumber>]"
+ " [-f=<format>]%n"
+ " [-o=<outputPath>] [-p=<propertiesFile>]"
+ " [-s=<suppressionLineColumnNumber>]%n"
+ " [-W=<treeWalkerThreadsNumber>] [-e=<exclude>]..."
+ " [-x=<excludeRegex>]... <files>...%n"
+ "Checkstyle verifies that the specified source code files adhere to the specified"
+ " rules. By default%n"
+ "errors are reported to standard out in plain format. Checkstyle requires a"
+ " configuration XML file%n"
+ "that configures the checks to apply.%n"
+ " <files>... One or more source files to verify%n"
+ " --executeIgnoredModules%n"
+ " Allows ignored modules to be run.%n"
+ " --tabWidth=<tabWidth> Sets the length of the tab character. Used only with"
+ " \"-s\" option. Default%n"
+ " value is 8%n"
+ " -c=<configurationFile> Sets the check configuration file to use.%n"
+ " -C, --checker-threads-number=<checkerThreadsNumber>%n"
+ " (experimental) The number of Checker threads (must be"
+ " greater than zero)%n"
+ " -d, --debug Print all debug logging of CheckStyle utility%n"
+ " -e, --exclude=<exclude> Directory/File path to exclude from CheckStyle%n"
+ " -f=<format> Sets the output format. Valid values: xml, plain."
+ " Defaults to plain%n"
+ " -g, --generate-xpath-suppression%n"
+ " Generates to output a suppression.xml to use to suppress"
+ " all violations from%n"
+ " user's config%n"
+ " -h, --help Show this help message and exit.%n"
+ " -j, --javadocTree Print Parse tree of the Javadoc comment%n"
+ " -J, --treeWithJavadoc Print full Abstract Syntax Tree of the file%n"
+ " -o=<outputPath> Sets the output file. Defaults to stdout%n"
+ " -p=<propertiesFile> Loads the properties file%n"
+ " -s=<suppressionLineColumnNumber>%n"
+ " Print xpath suppressions at the file's line and column"
+ " position. Argument is%n"
+ " the line and column number (separated by a : ) in the"
+ " file that the%n"
+ " suppression should be generated for%n"
+ " -t, --tree Print Abstract Syntax Tree(AST) of the file%n"
+ " -T, --treeWithComments Print Abstract Syntax Tree(AST) of the file including"
+ " comments%n"
+ " -V, --version Print version information and exit.%n"
+ " -W, --tree-walker-threads-number=<treeWalkerThreadsNumber>%n"
+ " (experimental) The number of TreeWalker threads (must be"
+ " greater than zero)%n"
+ " -x, --exclude-regexp=<excludeRegex>%n"
+ " Regular expression of directory/file to exclude from"
+ " CheckStyle%n");
private static final Logger LOG = Logger.getLogger(MainTest.class.getName()).getParent();
private static final Handler[] HANDLERS = LOG.getHandlers();
private static final Level ORIGINAL_LOG_LEVEL = LOG.getLevel();
private static final String EOL = System.getProperty("line.separator");
@Rule
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
public final ExpectedSystemExit exit = ExpectedSystemExit.none();
@Rule
public final SystemErrRule systemErr = new SystemErrRule().enableLog().mute();
@Rule
public final SystemOutRule systemOut = new SystemOutRule().enableLog().mute();
private final LocalizedMessage auditStartMessage = new LocalizedMessage(1,
Definitions.CHECKSTYLE_BUNDLE, "DefaultLogger.auditStarted", null, null,
getClass(), null);
private final LocalizedMessage auditFinishMessage = new LocalizedMessage(1,
Definitions.CHECKSTYLE_BUNDLE, "DefaultLogger.auditFinished", null, null,
getClass(), null);
private final LocalizedMessage errorCounterOneMessage = new LocalizedMessage(1,
Definitions.CHECKSTYLE_BUNDLE, Main.ERROR_COUNTER,
new String[] {String.valueOf(1)}, null, getClass(), null);
private static String getPath(String filename) {
return "src/test/resources/com/puppycrawl/tools/checkstyle/main/" + filename;
}
private static String getNonCompilablePath(String filename) {
return "src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/main/" + filename;
}
private static String getFilePath(String filename) throws IOException {
return new File(getPath(filename)).getCanonicalPath();
}
@Before
public void setUp() {
// restore original logging level and HANDLERS to prevent bleeding into other tests
LOG.setLevel(ORIGINAL_LOG_LEVEL);
for (Handler handler : LOG.getHandlers()) {
boolean found = false;
for (Handler savedHandler : HANDLERS) {
if (handler == savedHandler) {
found = true;
break;
}
}
if (!found) {
LOG.removeHandler(handler);
}
}
}
@Test
public void testIsProperUtilsClass() throws ReflectiveOperationException {
assertTrue("Constructor is not private",
isUtilsClassHasPrivateConstructor(Main.class, false));
}
@Test
public void testVersionPrint()
throws Exception {
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log",
"Checkstyle version: null" + System.lineSeparator(),
systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-V");
}
@Test
public void testUsageHelpPrint()
throws Exception {
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log",
USAGE,
systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-h");
}
@Test
public void testWrongArgument()
throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
final String usage = "Unknown option: -w" + EOL
+ SHORT_USAGE;
assertEquals("Unexpected output log", "", systemOut.getLog());
assertEquals("Unexpected system error log", usage, systemErr.getLog());
});
// need to specify a file:
// <files> is defined as a required positional param;
// picocli verifies required parameters before checking unknown options
Main.main("-w", "file");
}
@Test
public void testWrongArgumentMissingFiles()
throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
// files is defined as a required positional param;
// picocli verifies required parameters before checking unknown options
final String usage = "Missing required parameter: <files>" + EOL
+ SHORT_USAGE;
assertEquals("Unexpected output log", "", systemOut.getLog());
assertEquals("Unexpected system error log", usage, systemErr.getLog());
});
Main.main("-w");
}
@Test
public void testNoConfigSpecified()
throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log",
"Must specify a config XML file." + System.lineSeparator(),
systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main(getPath("InputMain.java"));
}
@Test
public void testNonExistentTargetFile()
throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Files to process must be specified, found 0."
+ System.lineSeparator(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", "/google_checks.xml", "NonExistentFile.java");
}
@Test
public void testNonExistentConfigFile()
throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Could not find config XML file "
+ "'src/main/resources/non_existent_config.xml'." + EOL,
systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", "src/main/resources/non_existent_config.xml",
getPath("InputMain.java"));
}
@Test
public void testNonExistentOutputFormat() throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "", systemOut.getLog());
assertEquals("Unexpected system error log",
"Invalid value for option '-f': expected one of [XML, PLAIN]"
+ " (case-insensitive) but was 'xmlp'"
+ EOL + SHORT_USAGE, systemErr.getLog());
});
Main.main("-c", "/google_checks.xml", "-f", "xmlp",
getPath("InputMain.java"));
}
@Test
public void testNonExistentClass() throws Exception {
exit.expectSystemExitWithStatus(-2);
exit.checkAssertionAfterwards(() -> {
final String expectedExceptionMessage = errorCounterOneMessage.getMessage() + EOL;
assertEquals("Unexpected output log", expectedExceptionMessage, systemOut.getLog());
final String cause = "com.puppycrawl.tools.checkstyle.api.CheckstyleException:"
+ " cannot initialize module TreeWalker - ";
assertTrue("Unexpected system error log", systemErr.getLog().startsWith(cause));
});
Main.main("-c", getPath("InputMainConfig-non-existent-classname.xml"),
getPath("InputMain.java"));
}
@Test
public void testExistingTargetFile() throws Exception {
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", auditStartMessage.getMessage() + EOL
+ auditFinishMessage.getMessage() + EOL,
systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-classname.xml"),
getPath("InputMain.java"));
}
@Test
public void testExistingTargetFileXmlOutput() throws Exception {
exit.checkAssertionAfterwards(() -> {
final String expectedPath = getFilePath("InputMain.java");
final String version = Main.class.getPackage().getImplementationVersion();
assertEquals("Unexpected output log", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + EOL
+ "<checkstyle version=\"" + version + "\">" + EOL
+ "<file name=\"" + expectedPath + "\">" + EOL
+ "</file>" + EOL
+ "</checkstyle>" + EOL, systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-classname.xml"),
"-f", "xml",
getPath("InputMain.java"));
}
@Test
public void testExistingTargetFilePlainOutput() throws Exception {
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", auditStartMessage.getMessage() + EOL
+ auditFinishMessage.getMessage() + EOL, systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-classname.xml"),
"-f", "plain",
getPath("InputMain.java"));
}
@Test
public void testExistingTargetFileWithViolations() throws Exception {
exit.checkAssertionAfterwards(() -> {
final LocalizedMessage invalidPatternMessageMain = new LocalizedMessage(1,
"com.puppycrawl.tools.checkstyle.checks.naming.messages",
"name.invalidPattern", new String[] {"InputMain", "^[a-z0-9]*$"},
null, getClass(), null);
final LocalizedMessage invalidPatternMessageMainInner = new LocalizedMessage(1,
"com.puppycrawl.tools.checkstyle.checks.naming.messages",
"name.invalidPattern", new String[] {"InputMainInner", "^[a-z0-9]*$"},
null, getClass(), null);
final String expectedPath = getFilePath("InputMain.java");
assertEquals("Unexpected output log", auditStartMessage.getMessage() + EOL
+ "[WARN] " + expectedPath + ":3:14: "
+ invalidPatternMessageMain.getMessage()
+ " [TypeName]" + EOL
+ "[WARN] " + expectedPath + ":5:7: "
+ invalidPatternMessageMainInner.getMessage()
+ " [TypeName]" + EOL
+ auditFinishMessage.getMessage() + EOL, systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-classname2.xml"),
getPath("InputMain.java"));
}
@Test
public void testExistingTargetFileWithError()
throws Exception {
exit.expectSystemExitWithStatus(2);
exit.checkAssertionAfterwards(() -> {
final LocalizedMessage errorCounterTwoMessage = new LocalizedMessage(1,
Definitions.CHECKSTYLE_BUNDLE, Main.ERROR_COUNTER,
new String[] {String.valueOf(2)}, null, getClass(), null);
final LocalizedMessage invalidPatternMessageMain = new LocalizedMessage(1,
"com.puppycrawl.tools.checkstyle.checks.naming.messages",
"name.invalidPattern", new String[] {"InputMain", "^[a-z0-9]*$"},
null, getClass(), null);
final LocalizedMessage invalidPatternMessageMainInner = new LocalizedMessage(1,
"com.puppycrawl.tools.checkstyle.checks.naming.messages",
"name.invalidPattern", new String[] {"InputMainInner", "^[a-z0-9]*$"},
null, getClass(), null);
final String expectedPath = getFilePath("InputMain.java");
assertEquals("Unexpected output log", auditStartMessage.getMessage() + EOL
+ "[ERROR] " + expectedPath + ":3:14: "
+ invalidPatternMessageMain.getMessage() + " [TypeName]" + EOL
+ "[ERROR] " + expectedPath + ":5:7: "
+ invalidPatternMessageMainInner.getMessage() + " [TypeName]" + EOL
+ auditFinishMessage.getMessage() + EOL
+ errorCounterTwoMessage.getMessage() + EOL, systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c",
getPath("InputMainConfig-classname2-error.xml"),
getPath("InputMain.java"));
}
/**
* Similar test to {@link #testExistingTargetFileWithError}, but for PIT mutation tests:
* this test fails if the boundary condition is changed from {@code if (exitStatus > 0)}
* to {@code if (exitStatus > 1)}.
* @throws Exception should not throw anything
*/
@Test
public void testExistingTargetFileWithOneError()
throws Exception {
exit.expectSystemExitWithStatus(1);
exit.checkAssertionAfterwards(() -> {
final LocalizedMessage errorCounterTwoMessage = new LocalizedMessage(1,
Definitions.CHECKSTYLE_BUNDLE, Main.ERROR_COUNTER,
new String[] {String.valueOf(1)}, null, getClass(), null);
final LocalizedMessage invalidPatternMessageMain = new LocalizedMessage(1,
"com.puppycrawl.tools.checkstyle.checks.naming.messages",
"name.invalidPattern", new String[] {"InputMain1", "^[a-z0-9]*$"},
null, getClass(), null);
final String expectedPath = getFilePath("InputMain1.java");
assertEquals("Unexpected output log", auditStartMessage.getMessage() + EOL
+ "[ERROR] " + expectedPath + ":3:14: "
+ invalidPatternMessageMain.getMessage() + " [TypeName]" + EOL
+ auditFinishMessage.getMessage() + EOL
+ errorCounterTwoMessage.getMessage() + EOL, systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c",
getPath("InputMainConfig-classname2-error.xml"),
getPath("InputMain1.java"));
}
@Test
public void testExistentTargetFilePlainOutputToNonExistentFile()
throws Exception {
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "", systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-classname.xml"),
"-f", "plain",
"-o", temporaryFolder.getRoot() + "/output.txt",
getPath("InputMain.java"));
}
@Test
public void testExistingTargetFilePlainOutputToFile()
throws Exception {
final File file = temporaryFolder.newFile("file.output");
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "", systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-classname.xml"),
"-f", "plain",
"-o", file.getCanonicalPath(),
getPath("InputMain.java"));
}
@Test
public void testCreateNonExistentOutputFile() throws Exception {
final String outputFile = temporaryFolder.getRoot().getCanonicalPath() + "nonexistent.out";
assertFalse("File must not exist", new File(outputFile).exists());
Main.main("-c", getPath("InputMainConfig-classname.xml"),
"-f", "plain",
"-o", outputFile,
getPath("InputMain.java"));
assertTrue("File must exist", new File(outputFile).exists());
}
@Test
public void testExistingTargetFilePlainOutputProperties() throws Exception {
//exit.expectSystemExitWithStatus(0);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", auditStartMessage.getMessage() + EOL
+ auditFinishMessage.getMessage() + EOL, systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-classname-prop.xml"),
"-p", getPath("InputMainMycheckstyle.properties"),
getPath("InputMain.java"));
}
@Test
public void testExistingTargetFilePlainOutputNonexistentProperties()
throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Could not find file 'nonexistent.properties'."
+ System.lineSeparator(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-classname-prop.xml"),
"-p", "nonexistent.properties",
getPath("InputMain.java"));
}
@Test
public void testExistingIncorrectConfigFile()
throws Exception {
exit.expectSystemExitWithStatus(-2);
exit.checkAssertionAfterwards(() -> {
final String output = errorCounterOneMessage.getMessage() + EOL;
assertEquals("Unexpected output log", output, systemOut.getLog());
final String errorOutput = "com.puppycrawl.tools.checkstyle.api."
+ "CheckstyleException: unable to parse configuration stream - ";
assertTrue("Unexpected system error log", systemErr.getLog().startsWith(errorOutput));
});
Main.main("-c", getPath("InputMainConfig-Incorrect.xml"),
getPath("InputMain.java"));
}
@Test
public void testExistingIncorrectChildrenInConfigFile()
throws Exception {
exit.expectSystemExitWithStatus(-2);
exit.checkAssertionAfterwards(() -> {
final String output = errorCounterOneMessage.getMessage() + EOL;
assertEquals("Unexpected output log", output, systemOut.getLog());
final String errorOutput = "com.puppycrawl.tools.checkstyle.api."
+ "CheckstyleException: cannot initialize module RegexpSingleline"
+ " - RegexpSingleline is not allowed as a child in RegexpSingleline";
assertTrue("Unexpected system error log", systemErr.getLog().startsWith(errorOutput));
});
Main.main("-c", getPath("InputMainConfig-incorrectChildren.xml"),
getPath("InputMain.java"));
}
@Test
public void testExistingIncorrectChildrenInConfigFile2()
throws Exception {
exit.expectSystemExitWithStatus(-2);
exit.checkAssertionAfterwards(() -> {
final String output = errorCounterOneMessage.getMessage() + EOL;
assertEquals("Unexpected output log", output, systemOut.getLog());
final String errorOutput = "com.puppycrawl.tools.checkstyle.api."
+ "CheckstyleException: cannot initialize module TreeWalker"
+ " - JavadocVariable is not allowed as a child in JavadocMethod";
assertTrue("Unexpected system error log", systemErr.getLog().startsWith(errorOutput));
});
Main.main("-c", getPath("InputMainConfig-incorrectChildren2.xml"),
getPath("InputMain.java"));
}
@Test
public void testLoadPropertiesIoException() throws Exception {
final Class<?>[] param = new Class<?>[1];
param[0] = File.class;
final Class<?> cliOptionsClass = Class.forName(Main.class.getName());
final Method method = cliOptionsClass.getDeclaredMethod("loadProperties", param);
method.setAccessible(true);
try {
method.invoke(null, new File("."));
fail("Exception was expected");
}
catch (InvocationTargetException ex) {
assertTrue("Invalid error cause",
ex.getCause() instanceof CheckstyleException);
// We do separate validation for message as in Windows
// disk drive letter appear in message,
// so we skip that drive letter for compatibility issues
final LocalizedMessage loadPropertiesMessage = new LocalizedMessage(1,
Definitions.CHECKSTYLE_BUNDLE, Main.LOAD_PROPERTIES_EXCEPTION,
new String[] {""}, null, getClass(), null);
final String causeMessage = ex.getCause().getLocalizedMessage();
final String localizedMessage = loadPropertiesMessage.getMessage();
final boolean samePrefix = causeMessage.substring(0, causeMessage.indexOf(' '))
.equals(localizedMessage
.substring(0, localizedMessage.indexOf(' ')));
final boolean sameSuffix =
causeMessage.substring(causeMessage.lastIndexOf(' '))
.equals(localizedMessage
.substring(localizedMessage.lastIndexOf(' ')));
assertTrue("Invalid error message", samePrefix || sameSuffix);
assertTrue("Invalid error message", causeMessage.contains(".'"));
}
}
@Test
public void testExistingDirectoryWithViolations() throws Exception {
// we just reference there all violations
final String[][] outputValues = {
{"InputMainComplexityOverflow", "1", "172"},
};
final int allowedLength = 170;
final String msgKey = "maxLen.file";
final String bundle = "com.puppycrawl.tools.checkstyle.checks.sizes.messages";
exit.checkAssertionAfterwards(() -> {
final String expectedPath = getFilePath("") + File.separator;
final StringBuilder sb = new StringBuilder(28);
sb.append(auditStartMessage.getMessage())
.append(EOL);
final String format = "[WARN] " + expectedPath + outputValues[0][0] + ".java:"
+ outputValues[0][1] + ": ";
for (String[] outputValue : outputValues) {
final String localizedMessage = new LocalizedMessage(1, bundle,
msgKey, new Integer[] {Integer.valueOf(outputValue[2]), allowedLength},
null, getClass(), null).getMessage();
final String line = format + localizedMessage + " [FileLength]";
sb.append(line).append(EOL);
}
sb.append(auditFinishMessage.getMessage())
.append(EOL);
assertEquals("Unexpected output log", sb.toString(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", getPath("InputMainConfig-filelength.xml"),
getPath(""));
}
/**
* Test doesn't need to be serialized.
* @noinspection SerializableInnerClassWithNonSerializableOuterClass
*/
@Test
public void testListFilesNotFile() throws Exception {
final File fileMock = new File("") {
private static final long serialVersionUID = 1L;
@Override
public boolean canRead() {
return true;
}
@Override
public boolean isDirectory() {
return false;
}
@Override
public boolean isFile() {
return false;
}
};
final List<File> result = Whitebox.invokeMethod(Main.class, "listFiles",
fileMock, new ArrayList<Pattern>());
assertEquals("Invalid result size", 0, result.size());
}
/**
* Test doesn't need to be serialized.
* @noinspection SerializableInnerClassWithNonSerializableOuterClass
*/
@Test
public void testListFilesDirectoryWithNull() throws Exception {
final File[] nullResult = null;
final File fileMock = new File("") {
private static final long serialVersionUID = 1L;
@Override
public boolean canRead() {
return true;
}
@Override
public boolean isDirectory() {
return true;
}
@Override
public File[] listFiles() {
return nullResult;
}
};
final List<File> result = Whitebox.invokeMethod(Main.class, "listFiles",
fileMock, new ArrayList<Pattern>());
assertEquals("Invalid result size", 0, result.size());
}
@Test
public void testFileReferenceDuringException() throws Exception {
exit.expectSystemExitWithStatus(-2);
exit.checkAssertionAfterwards(() -> {
final String expectedExceptionMessage = auditStartMessage.getMessage() + EOL
+ errorCounterOneMessage.getMessage() + EOL;
assertEquals("Unexpected output log", expectedExceptionMessage, systemOut.getLog());
final String exceptionFirstLine = "com.puppycrawl.tools.checkstyle.api."
+ "CheckstyleException: Exception was thrown while processing "
+ new File(getNonCompilablePath("InputMainIncorrectClass.java")).getPath()
+ EOL;
assertTrue("Unexpected system error log",
systemErr.getLog().startsWith(exceptionFirstLine));
});
// We put xml as source to cause parse exception
Main.main("-c", getPath("InputMainConfig-classname.xml"),
getNonCompilablePath("InputMainIncorrectClass.java"));
}
@Test
public void testPrintTreeOnMoreThanOneFile() throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Printing AST is allowed for only one file."
+ System.lineSeparator(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-t", getPath(""));
}
@Test
public void testPrintTreeOption() throws Exception {
final String expected = "PACKAGE_DEF -> package [1:0]" + EOL
+ "|--ANNOTATIONS -> ANNOTATIONS [1:39]" + EOL
+ "|--DOT -> . [1:39]" + EOL
+ "| |--DOT -> . [1:28]" + EOL
+ "| | |--DOT -> . [1:22]" + EOL
+ "| | | |--DOT -> . [1:11]" + EOL
+ "| | | | |--IDENT -> com [1:8]" + EOL
+ "| | | | `--IDENT -> puppycrawl [1:12]" + EOL
+ "| | | `--IDENT -> tools [1:23]" + EOL
+ "| | `--IDENT -> checkstyle [1:29]" + EOL
+ "| `--IDENT -> main [1:40]" + EOL
+ "`--SEMI -> ; [1:44]" + EOL
+ "CLASS_DEF -> CLASS_DEF [3:0]" + EOL
+ "|--MODIFIERS -> MODIFIERS [3:0]" + EOL
+ "| `--LITERAL_PUBLIC -> public [3:0]" + EOL
+ "|--LITERAL_CLASS -> class [3:7]" + EOL
+ "|--IDENT -> InputMain [3:13]" + EOL
+ "`--OBJBLOCK -> OBJBLOCK [3:23]" + EOL
+ " |--LCURLY -> { [3:23]" + EOL
+ " `--RCURLY -> } [4:0]" + EOL
+ "CLASS_DEF -> CLASS_DEF [5:0]" + EOL
+ "|--MODIFIERS -> MODIFIERS [5:0]" + EOL
+ "|--LITERAL_CLASS -> class [5:0]" + EOL
+ "|--IDENT -> InputMainInner [5:6]" + EOL
+ "`--OBJBLOCK -> OBJBLOCK [5:21]" + EOL
+ " |--LCURLY -> { [5:21]" + EOL
+ " `--RCURLY -> } [6:0]" + EOL;
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", expected, systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-t", getPath("InputMain.java"));
}
@Test
public void testPrintTreeCommentsOption() throws Exception {
final String expected = "PACKAGE_DEF -> package [1:0]" + EOL
+ "|--ANNOTATIONS -> ANNOTATIONS [1:39]" + EOL
+ "|--DOT -> . [1:39]" + EOL
+ "| |--DOT -> . [1:28]" + EOL
+ "| | |--DOT -> . [1:22]" + EOL
+ "| | | |--DOT -> . [1:11]" + EOL
+ "| | | | |--IDENT -> com [1:8]" + EOL
+ "| | | | `--IDENT -> puppycrawl [1:12]" + EOL
+ "| | | `--IDENT -> tools [1:23]" + EOL
+ "| | `--IDENT -> checkstyle [1:29]" + EOL
+ "| `--IDENT -> main [1:40]" + EOL
+ "`--SEMI -> ; [1:44]" + EOL
+ "CLASS_DEF -> CLASS_DEF [3:0]" + EOL
+ "|--MODIFIERS -> MODIFIERS [3:0]" + EOL
+ "| |--BLOCK_COMMENT_BEGIN -> /* [2:0]" + EOL
+ "| | |--COMMENT_CONTENT -> comment [2:2]" + EOL
+ "| | `--BLOCK_COMMENT_END -> */ [2:8]" + EOL
+ "| `--LITERAL_PUBLIC -> public [3:0]" + EOL
+ "|--LITERAL_CLASS -> class [3:7]" + EOL
+ "|--IDENT -> InputMain [3:13]" + EOL
+ "`--OBJBLOCK -> OBJBLOCK [3:23]" + EOL
+ " |--LCURLY -> { [3:23]" + EOL
+ " `--RCURLY -> } [4:0]" + EOL
+ "CLASS_DEF -> CLASS_DEF [5:0]" + EOL
+ "|--MODIFIERS -> MODIFIERS [5:0]" + EOL
+ "|--LITERAL_CLASS -> class [5:0]" + EOL
+ "|--IDENT -> InputMainInner [5:6]" + EOL
+ "`--OBJBLOCK -> OBJBLOCK [5:21]" + EOL
+ " |--LCURLY -> { [5:21]" + EOL
+ " `--RCURLY -> } [6:0]" + EOL;
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", expected, systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-T", getPath("InputMain.java"));
}
@Test
public void testPrintTreeJavadocOption() throws Exception {
final String expected = new String(Files.readAllBytes(Paths.get(
getPath("InputMainExpectedInputJavadocComment.txt"))), StandardCharsets.UTF_8)
.replaceAll("\\\\r\\\\n", "\\\\n").replaceAll("\r\n", "\n");
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log",
expected, systemOut.getLog().replaceAll("\\\\r\\\\n", "\\\\n")
.replaceAll("\r\n", "\n"));
assertEquals("Unexpected system error log",
"", systemErr.getLog());
});
Main.main("-j", getPath("InputMainJavadocComment.javadoc"));
}
@Test
public void testPrintSuppressionOption() throws Exception {
final String expected = "/CLASS_DEF[@text='InputMainSuppressionsStringPrinter']" + EOL
+ "/CLASS_DEF[@text='InputMainSuppressionsStringPrinter']/MODIFIERS" + EOL
+ "/CLASS_DEF[@text='InputMainSuppressionsStringPrinter']/LITERAL_CLASS" + EOL;
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log",
expected, systemOut.getLog());
assertEquals("Unexpected system error log",
"", systemErr.getLog());
});
Main.main(getPath("InputMainSuppressionsStringPrinter.java"),
"-s", "3:1");
}
@Test
public void testPrintSuppressionAndTabWidthOption() throws Exception {
final String expected = "/CLASS_DEF[@text='InputMainSuppressionsStringPrinter']/OBJBLOCK"
+ "/METHOD_DEF[@text='getName']/SLIST/VARIABLE_DEF[@text='var']" + EOL
+ "/CLASS_DEF[@text='InputMainSuppressionsStringPrinter']/OBJBLOCK"
+ "/METHOD_DEF[@text='getName']/SLIST/VARIABLE_DEF[@text='var']/MODIFIERS" + EOL
+ "/CLASS_DEF[@text='InputMainSuppressionsStringPrinter']/OBJBLOCK"
+ "/METHOD_DEF[@text='getName']/SLIST/VARIABLE_DEF[@text='var']/TYPE" + EOL
+ "/CLASS_DEF[@text='InputMainSuppressionsStringPrinter']/OBJBLOCK"
+ "/METHOD_DEF[@text='getName']/SLIST/VARIABLE_DEF[@text='var']/TYPE/LITERAL_INT"
+ EOL;
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log",
expected, systemOut.getLog());
assertEquals("Unexpected system error log",
"", systemErr.getLog());
});
Main.main(getPath("InputMainSuppressionsStringPrinter.java"),
"-s", "7:9", "--tabWidth", "2");
}
@Test
public void testPrintSuppressionConflictingOptionsTvsC() throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Option '-s' cannot be used with other options."
+ System.lineSeparator(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-c", "/google_checks.xml",
getPath(""), "-s", "2:4");
}
@Test
public void testPrintSuppressionConflictingOptionsTvsP() throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Option '-s' cannot be used with other options."
+ System.lineSeparator(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-p", getPath("InputMainMycheckstyle.properties"), "-s", "2:4", getPath(""));
}
@Test
public void testPrintSuppressionConflictingOptionsTvsF() throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Option '-s' cannot be used with other options."
+ System.lineSeparator(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-f", "plain", "-s", "2:4", getPath(""));
}
@Test
public void testPrintSuppressionConflictingOptionsTvsO() throws Exception {
final File file = temporaryFolder.newFile("file.output");
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Option '-s' cannot be used with other options."
+ System.lineSeparator(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-o", file.getCanonicalPath(), "-s", "2:4", getPath(""));
}
@Test
public void testPrintSuppressionOnMoreThanOneFile() throws Exception {
exit.expectSystemExitWithStatus(-1);
exit.checkAssertionAfterwards(() -> {
assertEquals("Unexpected output log", "Printing xpath suppressions is allowed for "
+ "only one file."
+ System.lineSeparator(), systemOut.getLog());
assertEquals("Unexpected system error log", "", systemErr.getLog());
});
Main.main("-s", "2:4", getPath(""), getPath(""));
}
@Test
public void testGenerateXpathSuppressionOptionOne() throws Exception {
final String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + EOL
+ "<!DOCTYPE suppressions PUBLIC" + EOL
+ " \"-//Checkstyle//DTD SuppressionXpathFilter Experimental Configuration 1.2"
+ "//EN\"" + EOL
+ " \"https://checkstyle.org/dtds/suppressions_1_2_xpath_experimental.dtd\">"
+ EOL
+ "<suppressions>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"JavadocMethodCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"LeftCurlyCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF"
+ "/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF"
+ "/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF"
+ "/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF"
+ "/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF"
+ "/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF"
+ "/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF"
+ "/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "<suppress-xpath" + EOL
+ " files=\"InputMainComplexityOverflow.java\"" + EOL
+ " checks=\"EmptyBlockCheck\"" + EOL
+ " query=\"/CLASS_DEF[@text='InputMainComplexityOverflow']/OBJBLOCK"
+ "/METHOD_DEF[@text='provokeNpathIntegerOverflow']/SLIST/LITERAL_IF/SLIST"
+ "/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST/LITERAL_IF"
+ "/SLIST/LITERAL_IF/SLIST/LITERAL_IF/SLIST\"/>" + EOL
+ "</suppressions>" + EOL;