diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XDocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XDocsPagesTest.java index 4270634f5..4d9de04c4 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XDocsPagesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XDocsPagesTest.java @@ -773,17 +773,23 @@ public class XDocsPagesTest { Assert.assertTrue(fileName + " section '" + sectionName + "' has unknown text in 'Example of Usage': " + text, text.isEmpty()); + boolean hasCheckstyle = false; + boolean hasGoogle = false; + boolean hasSun = false; + for (Node node : XmlUtil.findChildElementsByTag(subSection, "a")) { final String url = node.getAttributes().getNamedItem("href").getTextContent(); final String linkText = node.getTextContent().trim(); String expectedUrl = null; if ("Checkstyle Style".equals(linkText)) { + hasCheckstyle = true; expectedUrl = "https://github.com/search?q=" + "path%3Aconfig+filename%3Acheckstyle_checks.xml+" + "repo%3Acheckstyle%2Fcheckstyle+" + sectionName; } else if ("Google Style".equals(linkText)) { + hasGoogle = true; expectedUrl = "https://github.com/search?q=" + "path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+" + "repo%3Acheckstyle%2Fcheckstyle+" @@ -794,6 +800,7 @@ public class XDocsPagesTest { GOOGLE_CHECKS.contains(sectionName)); } else if ("Sun Style".equals(linkText)) { + hasSun = true; expectedUrl = "https://github.com/search?q=" + "path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+" + "repo%3Acheckstyle%2Fcheckstyle+" @@ -807,6 +814,15 @@ public class XDocsPagesTest { Assert.assertEquals(fileName + " section '" + sectionName + "' should have matching url", expectedUrl, url); } + + Assert.assertTrue(fileName + " section '" + sectionName + + "' should have a checkstyle section", hasCheckstyle); + Assert.assertTrue(fileName + " section '" + sectionName + + "' should have a google section since it is in it's config", hasGoogle + || !GOOGLE_CHECKS.contains(sectionName)); + Assert.assertTrue(fileName + " section '" + sectionName + + "' should have a sun section since it is in it's config", + hasSun || !SUN_CHECKS.contains(sectionName)); } private static void validatePackageSection(String fileName, String sectionName, diff --git a/src/xdocs/config_coding.xml b/src/xdocs/config_coding.xml index 45b849391..8c2e2a3d2 100644 --- a/src/xdocs/config_coding.xml +++ b/src/xdocs/config_coding.xml @@ -120,6 +120,10 @@ String b = (a==null || a.length<1) ? null : a.substring(1);