|
33 | 33 | import java.util.ArrayList;
|
34 | 34 | import java.util.Arrays;
|
35 | 35 | import java.util.Collection;
|
| 36 | +import java.util.Collections; |
36 | 37 | import java.util.HashSet;
|
37 | 38 | import java.util.List;
|
38 | 39 | import java.util.Set;
|
@@ -679,6 +680,38 @@ public void testExternalResourceFiltersWithNoExternalResource() throws Exception
|
679 | 680 | verify(checkerConfig, filePath, expected);
|
680 | 681 | }
|
681 | 682 |
|
| 683 | + /** |
| 684 | + * This test is checking that Checks execution ordered by name. |
| 685 | + * |
| 686 | + * @throws Exception if file is not found |
| 687 | + */ |
| 688 | + @Test |
| 689 | + public void testOrderOfCheckExecution() throws Exception { |
| 690 | + |
| 691 | + final DefaultConfiguration configuration1 = createModuleConfig(AaCheck.class); |
| 692 | + configuration1.addProperty("id", "2"); |
| 693 | + final DefaultConfiguration configuration2 = createModuleConfig(BbCheck.class); |
| 694 | + configuration2.addProperty("id", "1"); |
| 695 | + |
| 696 | + final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class); |
| 697 | + treeWalkerConfig.addChild(configuration2); |
| 698 | + treeWalkerConfig.addChild(configuration1); |
| 699 | + |
| 700 | + final List<File> files = |
| 701 | + Collections.singletonList(new File(getPath("InputTreeWalker2.java"))); |
| 702 | + final Checker checker = createChecker(treeWalkerConfig); |
| 703 | + |
| 704 | + try { |
| 705 | + checker.process(files); |
| 706 | + assertWithMessage("exception is expected").fail(); |
| 707 | + } |
| 708 | + catch (CheckstyleException exception) { |
| 709 | + assertWithMessage("wrong order of Check executions") |
| 710 | + .that(exception.getCause().getMessage()) |
| 711 | + .isEqualTo(AaCheck.class.toString()); |
| 712 | + } |
| 713 | + } |
| 714 | + |
682 | 715 | public static class BadJavaDocCheck extends AbstractCheck {
|
683 | 716 |
|
684 | 717 | @Override
|
@@ -773,6 +806,54 @@ public boolean isCommentNodesRequired() {
|
773 | 806 |
|
774 | 807 | }
|
775 | 808 |
|
| 809 | + public static class AaCheck extends AbstractCheck { |
| 810 | + |
| 811 | + @Override |
| 812 | + public int[] getDefaultTokens() { |
| 813 | + return new int[0]; |
| 814 | + } |
| 815 | + |
| 816 | + @Override |
| 817 | + public int[] getAcceptableTokens() { |
| 818 | + return new int[0]; |
| 819 | + } |
| 820 | + |
| 821 | + @Override |
| 822 | + public int[] getRequiredTokens() { |
| 823 | + return new int[0]; |
| 824 | + } |
| 825 | + |
| 826 | + @Override |
| 827 | + public void beginTree(DetailAST rootAST) { |
| 828 | + throw new IllegalStateException(AaCheck.class.toString()); |
| 829 | + } |
| 830 | + |
| 831 | + } |
| 832 | + |
| 833 | + public static class BbCheck extends AbstractCheck { |
| 834 | + |
| 835 | + @Override |
| 836 | + public int[] getDefaultTokens() { |
| 837 | + return new int[0]; |
| 838 | + } |
| 839 | + |
| 840 | + @Override |
| 841 | + public int[] getAcceptableTokens() { |
| 842 | + return new int[0]; |
| 843 | + } |
| 844 | + |
| 845 | + @Override |
| 846 | + public int[] getRequiredTokens() { |
| 847 | + return new int[0]; |
| 848 | + } |
| 849 | + |
| 850 | + @Override |
| 851 | + public void beginTree(DetailAST rootAST) { |
| 852 | + throw new IllegalStateException(BbCheck.class.toString()); |
| 853 | + } |
| 854 | + |
| 855 | + } |
| 856 | + |
776 | 857 | public static class RequiredTokenIsEmptyIntArray extends AbstractCheck {
|
777 | 858 |
|
778 | 859 | @Override
|
|
0 commit comments