From d97d9d461caa913b43379fd91835fdc38db4912c Mon Sep 17 00:00:00 2001 From: maxvetrenko Date: Wed, 3 Dec 2014 22:26:14 +0300 Subject: [PATCH] Modified UT to use InputDefaultPackage.java file. --- .../imports/CustomImportOrderCheckTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java index d24e69a03..47053b787 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java @@ -234,4 +234,37 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport verify(checkConfig, getPath("imports" + File.separator + "DOMSource.java"), expected); } + + /** + * @throws Exception + */ + @Test + public void testDefaultPackage2() throws Exception + { + final DefaultConfiguration checkConfig = + createCheckConfig(CustomImportOrderCheck.class); + checkConfig.addAttribute("standardPackageRegExp", "java|javax"); + checkConfig.addAttribute("thirdPartyPackageRegExp", "com|org"); + checkConfig.addAttribute("customImportOrderRules", + "STATIC###SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"); + checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true"); + + final String[] expected = { + "5: Wrong lexicographical order for 'java.awt.Button.ABORT' import.", + "8: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "9: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "10: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "11: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "12: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "13: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "14: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "15: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "16: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "17: Import statement is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group.", + "21: Wrong lexicographical order for 'com.google.common.*' import.", + }; + + verify(checkConfig, getPath("imports" + File.separator + + "InputDefaultPackage.java"), expected); + } }