diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index d268631094..58f8b42a1d 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -415,6 +415,14 @@ public abstract class HudsonTestCase extends TestCase { fail("Console output of "+run+" didn't contain "+substring); } + /** + * Asserts that the XPath matches. + */ + public void assertXPath(HtmlPage page, String xpath) { + assertNotNull("There should be an object that matches XPath:"+xpath, + page.getDocumentElement().selectSingleNode(xpath)); + } + /** * Submits the form. */ diff --git a/test/src/test/java/hudson/pages/SystemConfigurationTestCase.java b/test/src/test/java/hudson/pages/SystemConfigurationTestCase.java index 4b1c4118ac..0d6f4ca6bd 100644 --- a/test/src/test/java/hudson/pages/SystemConfigurationTestCase.java +++ b/test/src/test/java/hudson/pages/SystemConfigurationTestCase.java @@ -6,6 +6,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage; import hudson.model.PageDecorator; import net.sf.json.JSONObject; import org.jvnet.hudson.test.HudsonTestCase; +import org.jvnet.hudson.test.Bug; import org.kohsuke.stapler.StaplerRequest; public class SystemConfigurationTestCase extends HudsonTestCase { @@ -22,13 +23,14 @@ public class SystemConfigurationTestCase extends HudsonTestCase { /** * Asserts that bug#2289 is fixed. */ + @Bug(2289) public void testPageDecoratorIsListedInPage() throws Exception { pageDecoratorImpl = new PageDecoratorImpl(); PageDecorator.ALL.add(pageDecoratorImpl); HtmlPage page = new WebClient().goTo("configure"); - assertElementPresent(page, "hudson-pages-SystemConfigurationTestCase$PageDecoratorImpl"); - + assertXPath(page,"//tr[@name='hudson-pages-SystemConfigurationTestCase$PageDecoratorImpl']"); + HtmlForm form = page.getFormByName("config"); form.getInputByName("_.decoratorId").setValueAttribute("this_is_a_profile"); submit(form);