From 211ca895eca87d835fbe5c76f967204a24f53bea Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 14 Jan 2009 21:19:50 +0000 Subject: [PATCH] Fixed a test broken by rev.14457. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@14487 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/org/jvnet/hudson/test/HudsonTestCase.java | 8 ++++++++ .../java/hudson/pages/SystemConfigurationTestCase.java | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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);