diff --git a/test/src/main/java/org/jvnet/hudson/test/JellyTestSuiteBuilder.java b/test/src/main/java/org/jvnet/hudson/test/JellyTestSuiteBuilder.java index 82510a3fce..c81dcda59c 100644 --- a/test/src/main/java/org/jvnet/hudson/test/JellyTestSuiteBuilder.java +++ b/test/src/main/java/org/jvnet/hudson/test/JellyTestSuiteBuilder.java @@ -27,6 +27,8 @@ import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; import org.apache.commons.io.FileUtils; +import org.dom4j.Document; +import org.dom4j.io.SAXReader; import org.jvnet.hudson.test.junit.GroupedTest; import org.kohsuke.stapler.MetaClassLoader; import org.kohsuke.stapler.jelly.JellyClassLoaderTearOff; @@ -85,8 +87,30 @@ public class JellyTestSuiteBuilder { @Override protected void runTest() throws Exception { jct.createContext().compileScript(jelly); + Document dom = new SAXReader().read(jelly); + checkLabelFor(dom); // TODO: what else can we check statically? use of taglibs? } + + /** + * Makes sure that <label for=...> is not used inside config.jelly nor global.jelly + */ + private void checkLabelFor(Document dom) { + if (isConfigJelly() || isGlobalJelly()) { + if (!dom.selectNodes("//label[@for]").isEmpty()) + throw new AssertionError("