Issue #3378: Fixed TreeWalkerTest to not depend on a specific ordering of non-deterministic APIs (#3389)

This commit is contained in:
Ben Lambeth 2016-08-03 07:09:31 -05:00 committed by Roman Ivanov
parent 77081171f2
commit bcbcf28fff
1 changed files with 9 additions and 3 deletions

View File

@ -31,6 +31,8 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Rule;
import org.junit.Test;
@ -93,10 +95,14 @@ public class TreeWalkerTest extends BaseCheckTestSupport {
}
catch (CheckstyleException ex) {
final String errorMsg = ex.getMessage();
assertTrue(errorMsg.contains("cannot initialize module"
+ " com.puppycrawl.tools.checkstyle.TreeWalker - Token \"IMPORT\""
+ " was not found in Acceptable tokens list in check"
final Pattern expected = Pattern.compile(Pattern.quote("cannot initialize module"
+ " com.puppycrawl.tools.checkstyle.TreeWalker - Token ")
+ "\"(ENUM_DEF|CLASS_DEF|METHOD_DEF|IMPORT)\""
+ Pattern.quote(" was not found in Acceptable tokens list in check"
+ " com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck"));
final Matcher errorMsgMatcher = expected.matcher(errorMsg);
assertTrue("Failure for: " + errorMsg, errorMsgMatcher.matches());
}
}