Class HudsonTestCase

java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.jvnet.hudson.test.HudsonTestCase
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Action, hudson.model.ModelObject, hudson.model.RootAction, junit.framework.Test
Direct Known Subclasses:
GroovyHudsonTestCase

@Deprecated public abstract class HudsonTestCase extends junit.framework.TestCase implements hudson.model.RootAction
Deprecated.
New code should use JenkinsRule.
Base class for all Jenkins test cases.
Author:
Kohsuke Kawaguchi
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Deprecated.
     
    static class 
    Deprecated.
     
    class 
    Deprecated.
    Extends WebClient and provide convenience methods for accessing Hudson.

    Nested classes/interfaces inherited from interface hudson.ExtensionPoint

    hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Deprecated.
     
    protected String
    Deprecated.
    Where in the Server is Hudson deployed?
    protected final TestEnvironment
    Deprecated.
     
    protected File
    Deprecated.
    The directory where a war file gets exploded.
    Deprecated.
     
    hudson.model.Hudson
    Deprecated.
    Points to the same object as jenkins does.
    jenkins.model.Jenkins
    Deprecated.
     
    Deprecated.
    JavaScript "debugger" that provides you information about the JavaScript call stack and the current values of the local variables in those stack frame.
    protected int
    Deprecated.
    TCP/IP port that the server is listening on.
    static final org.eclipse.jetty.http.MimeTypes
    Deprecated.
    removed without replacement
    protected static final List<hudson.tools.ToolProperty<?>>
    Deprecated.
     
    protected List<Recipe.Runner>
    Deprecated.
     
    protected org.eclipse.jetty.server.Server
    Deprecated.
     
    static int
    Deprecated.
    Specify this to a TCP/IP port number to have slaves started with the debugger.
    Deprecated.
    Runnables to be invoked at tearDown().
    int
    Deprecated.
    Number of seconds until the test times out.
    boolean
    Deprecated.
    Use pluginManager
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Deprecated.
     
    protected
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    assertAllImageLoadSuccessfully(org.htmlunit.html.HtmlPage p)
    Deprecated.
    Makes sure that all the images in the page loads successfully.
    <R extends hudson.model.Run>
    R
    assertBuildStatus(hudson.model.Result status, R r)
    Deprecated.
    Asserts that the outcome of the build is a specific outcome.
    <R extends hudson.model.Run>
    R
    Deprecated.
     
    <R extends hudson.model.Run>
    R
    Deprecated.
     
    void
    assertEqualBeans(Object lhs, Object rhs, String properties)
    Deprecated.
    Asserts that two JavaBeans are equal as far as the given list of properties are concerned.
    void
    Deprecated.
    Works like assertEqualBeans(Object, Object, String) but figure out the properties via DataBoundConstructor
    void
    Deprecated.
    Makes sure that two collections are identical via assertEqualDataBoundBeans(Object, Object)
    void
    assertGoodStatus(org.htmlunit.Page page)
    Deprecated.
    Assert that the specified page can be served with a "good" HTTP status, eg, the page is not missing and can be served without a server error
    void
    assertHelpExists(Class<? extends hudson.model.Describable> type, String properties)
    Deprecated.
    Asserts that help files exist for the specified properties of the given instance.
    void
    assertLogContains(String substring, hudson.model.Run run)
    Deprecated.
    Asserts that the console output of the build contains the given substring.
    void
    assertLogNotContains(String substring, hudson.model.Run run)
    Deprecated.
    Asserts that the console output of the build does not contain the given substring.
    void
    assertStringContains(String haystack, String needle)
    Deprecated.
     
    void
    assertStringContains(String message, String haystack, String needle)
    Deprecated.
     
    void
    assertXPath(org.htmlunit.html.DomNode page, String xpath)
    Deprecated.
    Asserts that the XPath matches the contents of a DomNode page.
    void
    assertXPath(org.htmlunit.html.HtmlPage page, String xpath)
    Deprecated.
    Asserts that the XPath matches.
    void
    assertXPathResultsContainText(org.htmlunit.html.DomNode page, String xpath, String needle)
    Deprecated.
     
    void
    assertXPathValue(org.htmlunit.html.DomNode page, String xpath, String expectedValue)
    Deprecated.
     
    void
    assertXPathValueContains(org.htmlunit.html.DomNode page, String xpath, String needle)
    Deprecated.
     
    hudson.model.FreeStyleBuild
    buildAndAssertSuccess(hudson.model.FreeStyleProject job)
    Deprecated.
    Avoids need for cumbersome this.<J,R>buildAndAssertSuccess(...) type hints under JDK 7 javac (and supposedly also IntelliJ).
    <J extends hudson.model.AbstractProject<J, R>, R extends hudson.model.AbstractBuild<J, R>>
    R
    Deprecated.
     
    protected void
    Deprecated.
    Hits the Hudson system configuration and submits without any modification.
    protected <B extends hudson.tasks.Builder>
    B
    configRoundtrip(B before)
    Deprecated.
    Performs a configuration round-trip testing for a builder.
    protected <C extends hudson.slaves.ComputerConnector>
    C
    configRoundtrip(C before)
    Deprecated.
     
    protected hudson.model.User
    configRoundtrip(hudson.model.User u)
    Deprecated.
     
    protected <N extends hudson.model.Node>
    N
    Deprecated.
     
    protected <P extends hudson.model.Job>
    P
    Deprecated.
    Loads a configuration page and submits it without any modifications, to perform a round-trip configuration test.
    protected <V extends hudson.model.View>
    V
    Deprecated.
     
    protected void
    Deprecated.
    Configures the update center setting for the test.
    protected org.eclipse.jetty.security.LoginService
    Deprecated.
    Configures a security realm for a test.
    hudson.slaves.ComputerLauncher
    createComputerLauncher(hudson.EnvVars env)
    Deprecated.
    Creates a ComputerLauncher for launching a slave locally.
    hudson.security.SecurityRealm
    Deprecated.
    Creates a test SecurityRealm that recognizes username==password as valid.
    protected hudson.model.FreeStyleProject
    Deprecated.
     
    protected hudson.model.FreeStyleProject
    Deprecated.
     
    protected hudson.Launcher.LocalLauncher
    Deprecated.
    Creates Launcher.LocalLauncher.
    hudson.slaves.DumbSlave
    Deprecated.
    Create a new slave on the local host and wait for it to come online before returning.
    hudson.slaves.DumbSlave
    createOnlineSlave(hudson.model.Label l)
    Deprecated.
    Create a new slave on the local host and wait for it to come online before returning.
    hudson.slaves.DumbSlave
    createOnlineSlave(hudson.model.Label l, hudson.EnvVars env)
    Deprecated.
    Create a new slave on the local host and wait for it to come online before returning
    Deprecated.
     
    hudson.slaves.DumbSlave
    Deprecated.
     
    hudson.slaves.DumbSlave
    createSlave(hudson.EnvVars env)
    Deprecated.
     
    hudson.slaves.DumbSlave
    createSlave(hudson.model.Label l)
    Deprecated.
    Creates and launches a new slave on the local host.
    hudson.slaves.DumbSlave
    createSlave(hudson.model.Label l, hudson.EnvVars env)
    Deprecated.
     
    hudson.slaves.DumbSlave
    createSlave(String labels, hudson.EnvVars env)
    Deprecated.
    Creates a slave with certain additional environment variables
    hudson.slaves.DumbSlave
    createSlave(String nodeName, String labels, hudson.EnvVars env)
    Deprecated.
     
    hudson.model.TaskListener
    Deprecated.
    Creates a TaskListener connected to stdout.
    Deprecated.
    Allocates a new temporary directory for the duration of this test.
    protected String
    Deprecated.
     
    Deprecated.
    Create a web client instance using the browser version returned by BrowserVersion.getDefault() with support for the Fetch API.
    protected javax.servlet.ServletContext
    Deprecated.
    Prepares a webapp hosting environment to get ServletContext implementation that we need for testing.
    <V> V
    Deprecated.
    Executes the given closure on the server, by the servlet request handling thread, in the context of an HTTP request.
    protected Constructor<?>
    Deprecated.
     
    protected org.htmlunit.html.HtmlInput
    findPreviousInputElement(org.htmlunit.html.HtmlElement current, String name)
    Deprecated.
     
    protected <T extends hudson.model.Descriptor<?>>
    T
    get(Class<T> d)
    Deprecated.
    Gets the descriptor instance of the current Hudson by its type.
    protected org.htmlunit.html.HtmlButton
    getButtonByCaption(org.htmlunit.html.HtmlForm f, String s)
    Deprecated.
     
    Deprecated.
     
    Deprecated.
     
    protected static String
    getLog(hudson.model.Run run)
    Deprecated.
    Get entire log file (this method is deprecated in hudson.model.Run, but in tests it is OK to load entire log).
    Deprecated.
    Returns the URL of the webapp top page.
    Deprecated.
     
    void
    Deprecated.
    Blocks until the ENTER key is hit.
    boolean
    isGoodHttpStatus(int status)
    Deprecated.
    Determines whether the specified HTTP status code is generally "good"
    protected boolean
    Deprecated.
    Returns true if Hudson is building something or going to build something.
    protected <T> T
    last(List<T> items)
    Deprecated.
    Returns the last item in the list.
    protected hudson.model.Hudson
    Deprecated.
    Creates a new instance of Jenkins.
    protected void
    Deprecated.
    Pauses the execution until ENTER is hit in the console.
    protected void
    Deprecated.
    Called during the setUp() to give a test case an opportunity to control the test environment in which Hudson is run.
    protected void
    Deprecated.
    If this test harness is launched for a Jenkins plugin, locate the target/test-classes/the.jpl and add a recipe to install that to the new Jenkins.
    void
    Deprecated.
     
    protected void
    Deprecated.
     
    protected org.htmlunit.Page
    Deprecated.
    Performs a search from the search box.
    void
    setPluginManager(hudson.PluginManager pluginManager)
    Deprecated.
    Sets the PluginManager to be used when creating a new Jenkins instance.
    protected void
    Deprecated.
     
    protected void
    Deprecated.
     
    protected void
    Deprecated.
     
    org.htmlunit.html.HtmlPage
    submit(org.htmlunit.html.HtmlForm form)
    Deprecated.
    Submits the form.
    org.htmlunit.html.HtmlPage
    submit(org.htmlunit.html.HtmlForm form, String name)
    Deprecated.
    Submits the form by clicking the submit button of the given name.
    protected void
    Deprecated.
     
    protected void
    Deprecated.
    Waits until Hudson finishes building everything, including those in the queue.
    protected void
    Deprecated.
    Waits until Jenkins finishes building everything, including those builds in the queue, or fail the test if the specified timeout milliseconds is exceeded.
    with(HudsonHomeLoader homeLoader)
    Deprecated.
     
    Deprecated.
     
    Deprecated.
     
    Deprecated.
    Declares that this test case expects to start with one of the preset data sets.
    protected Object
    Deprecated.
    Sometimes a part of a test case may ends up creeping into the serialization tree of Saveable.save(), so detect that and flag that as an error.

    Methods inherited from class junit.framework.TestCase

    assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, setName, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • hudson

      public hudson.model.Hudson hudson
      Deprecated.
      Points to the same object as jenkins does.
    • jenkins

      public jenkins.model.Jenkins jenkins
      Deprecated.
    • env

      protected final TestEnvironment env
      Deprecated.
    • homeLoader

      protected HudsonHomeLoader homeLoader
      Deprecated.
    • localPort

      protected int localPort
      Deprecated.
      TCP/IP port that the server is listening on.
    • server

      protected org.eclipse.jetty.server.Server server
      Deprecated.
    • contextPath

      protected String contextPath
      Deprecated.
      Where in the Server is Hudson deployed?

      Just like ServletContext.getContextPath(), starts with '/' but doesn't end with '/'.

    • tearDowns

      protected List<LenientRunnable> tearDowns
      Deprecated.
      Runnables to be invoked at tearDown().
    • recipes

      protected List<Recipe.Runner> recipes
      Deprecated.
    • jsDebugger

      protected JavaScriptDebugger jsDebugger
      Deprecated.
      JavaScript "debugger" that provides you information about the JavaScript call stack and the current values of the local variables in those stack frame.

      Unlike Java debugger, which you as a human interfaces directly and interactively, this JavaScript debugger is to be interfaced by your program (or through the expression evaluation capability of your Java debugger.)

    • useLocalPluginManager

      @Deprecated public boolean useLocalPluginManager
      Deprecated.
      Use pluginManager
      If this test case has additional WithPlugin annotations, set to true. This will cause a fresh PluginManager to be created for this test. Leaving this to false enables the test harness to use a pre-loaded plugin manager, which runs faster.
    • timeout

      public int timeout
      Deprecated.
      Number of seconds until the test times out.
    • computerConnectorTester

      public ComputerConnectorTester computerConnectorTester
      Deprecated.
    • explodedWarDir

      protected File explodedWarDir
      Deprecated.
      The directory where a war file gets exploded.
    • NO_PROPERTIES

      protected static final List<hudson.tools.ToolProperty<?>> NO_PROPERTIES
      Deprecated.
    • SLAVE_DEBUG_PORT

      public static int SLAVE_DEBUG_PORT
      Deprecated.
      Specify this to a TCP/IP port number to have slaves started with the debugger.
    • MIME_TYPES

      @Deprecated public static final org.eclipse.jetty.http.MimeTypes MIME_TYPES
      Deprecated.
      removed without replacement
  • Constructor Details

    • HudsonTestCase

      protected HudsonTestCase(String name)
      Deprecated.
    • HudsonTestCase

      protected HudsonTestCase()
      Deprecated.
  • Method Details

    • runBare

      public void runBare() throws Throwable
      Deprecated.
      Overrides:
      runBare in class junit.framework.TestCase
      Throws:
      Throwable
    • setUp

      protected void setUp() throws Exception
      Deprecated.
      Overrides:
      setUp in class junit.framework.TestCase
      Throws:
      Exception
    • setUpTimeout

      protected void setUpTimeout()
      Deprecated.
    • configureUpdateCenter

      protected void configureUpdateCenter() throws Exception
      Deprecated.
      Configures the update center setting for the test. By default, we load updates from local proxy to avoid network traffic as much as possible.
      Throws:
      Exception
    • tearDown

      protected void tearDown() throws Exception
      Deprecated.
      Overrides:
      tearDown in class junit.framework.TestCase
      Throws:
      Exception
    • runTest

      protected void runTest() throws Throwable
      Deprecated.
      Overrides:
      runTest in class junit.framework.TestCase
      Throws:
      Throwable
    • getIconFileName

      public String getIconFileName()
      Deprecated.
      Specified by:
      getIconFileName in interface hudson.model.Action
    • getDisplayName

      public String getDisplayName()
      Deprecated.
      Specified by:
      getDisplayName in interface hudson.model.Action
      Specified by:
      getDisplayName in interface hudson.model.ModelObject
    • getUrlName

      public String getUrlName()
      Deprecated.
      Specified by:
      getUrlName in interface hudson.model.Action
    • newHudson

      protected hudson.model.Hudson newHudson() throws Exception
      Deprecated.
      Creates a new instance of Jenkins. If the derived class wants to create it in a different way, you can override it.
      Throws:
      Exception
    • setPluginManager

      public void setPluginManager(hudson.PluginManager pluginManager)
      Deprecated.
      Sets the PluginManager to be used when creating a new Jenkins instance.
      Parameters:
      pluginManager - null to let Jenkins create a new instance of default plugin manager, like it normally does when running as a webapp outside the test.
    • createWebServer

      protected javax.servlet.ServletContext createWebServer() throws Exception
      Deprecated.
      Prepares a webapp hosting environment to get ServletContext implementation that we need for testing.
      Throws:
      Exception
    • configureUserRealm

      protected org.eclipse.jetty.security.LoginService configureUserRealm()
      Deprecated.
      Configures a security realm for a test.
    • createFreeStyleProject

      protected hudson.model.FreeStyleProject createFreeStyleProject() throws IOException
      Deprecated.
      Throws:
      IOException
    • createFreeStyleProject

      protected hudson.model.FreeStyleProject createFreeStyleProject(String name) throws IOException
      Deprecated.
      Throws:
      IOException
    • createUniqueProjectName

      protected String createUniqueProjectName()
      Deprecated.
    • createLocalLauncher

      protected hudson.Launcher.LocalLauncher createLocalLauncher()
      Deprecated.
      Creates Launcher.LocalLauncher. Useful for launching processes.
    • createTmpDir

      public File createTmpDir() throws IOException
      Deprecated.
      Allocates a new temporary directory for the duration of this test.
      Throws:
      IOException
    • createSlave

      public hudson.slaves.DumbSlave createSlave() throws Exception
      Deprecated.
      Throws:
      Exception
    • createSlave

      public hudson.slaves.DumbSlave createSlave(hudson.model.Label l) throws Exception
      Deprecated.
      Creates and launches a new slave on the local host.
      Throws:
      Exception
    • createDummySecurityRealm

      public hudson.security.SecurityRealm createDummySecurityRealm()
      Deprecated.
      Creates a test SecurityRealm that recognizes username==password as valid.
    • getURL

      public URL getURL() throws IOException
      Deprecated.
      Returns the URL of the webapp top page. URL ends with '/'.
      Throws:
      IOException
    • createSlave

      public hudson.slaves.DumbSlave createSlave(hudson.EnvVars env) throws Exception
      Deprecated.
      Throws:
      Exception
    • createSlave

      public hudson.slaves.DumbSlave createSlave(hudson.model.Label l, hudson.EnvVars env) throws Exception
      Deprecated.
      Throws:
      Exception
    • createSlave

      public hudson.slaves.DumbSlave createSlave(String labels, hudson.EnvVars env) throws Exception
      Deprecated.
      Creates a slave with certain additional environment variables
      Throws:
      Exception
    • createSlave

      public hudson.slaves.DumbSlave createSlave(String nodeName, String labels, hudson.EnvVars env) throws Exception
      Deprecated.
      Throws:
      Exception
    • createPretendSlave

      public PretendSlave createPretendSlave(FakeLauncher faker) throws Exception
      Deprecated.
      Throws:
      Exception
    • createComputerLauncher

      public hudson.slaves.ComputerLauncher createComputerLauncher(hudson.EnvVars env) throws URISyntaxException, IOException
      Deprecated.
      Creates a ComputerLauncher for launching a slave locally.
      Parameters:
      env - Environment variables to add to the slave process. Can be null.
      Throws:
      URISyntaxException
      IOException
    • createOnlineSlave

      public hudson.slaves.DumbSlave createOnlineSlave() throws Exception
      Deprecated.
      Create a new slave on the local host and wait for it to come online before returning.
      Throws:
      Exception
    • createOnlineSlave

      public hudson.slaves.DumbSlave createOnlineSlave(hudson.model.Label l) throws Exception
      Deprecated.
      Create a new slave on the local host and wait for it to come online before returning.
      Throws:
      Exception
    • createOnlineSlave

      public hudson.slaves.DumbSlave createOnlineSlave(hudson.model.Label l, hudson.EnvVars env) throws Exception
      Deprecated.
      Create a new slave on the local host and wait for it to come online before returning
      Throws:
      Exception
    • interactiveBreak

      public void interactiveBreak() throws Exception
      Deprecated.
      Blocks until the ENTER key is hit. This is useful during debugging a test so that one can inspect the state of Jenkins through the web browser.
      Throws:
      Exception
    • last

      protected <T> T last(List<T> items)
      Deprecated.
      Returns the last item in the list.
    • pause

      protected void pause() throws IOException
      Deprecated.
      Pauses the execution until ENTER is hit in the console.

      This is often very useful so that you can interact with Hudson from an browser, while developing a test case.

      Throws:
      IOException
    • search

      protected org.htmlunit.Page search(String q) throws Exception
      Deprecated.
      Performs a search from the search box.
      Throws:
      Exception
    • configRoundtrip

      protected void configRoundtrip() throws Exception
      Deprecated.
      Hits the Hudson system configuration and submits without any modification.
      Throws:
      Exception
    • configRoundtrip

      protected <P extends hudson.model.Job> P configRoundtrip(P job) throws Exception
      Deprecated.
      Loads a configuration page and submits it without any modifications, to perform a round-trip configuration test.

      See Configuration Round-trip Testing

      Throws:
      Exception
    • configRoundtrip

      protected <P extends hudson.model.Item> P configRoundtrip(P job) throws Exception
      Deprecated.
      Throws:
      Exception
    • configRoundtrip

      protected <B extends hudson.tasks.Builder> B configRoundtrip(B before) throws Exception
      Deprecated.
      Performs a configuration round-trip testing for a builder.
      Throws:
      Exception
    • configRoundtrip

      protected <P extends hudson.tasks.Publisher> P configRoundtrip(P before) throws Exception
      Deprecated.
      Performs a configuration round-trip testing for a publisher.
      Throws:
      Exception
    • configRoundtrip

      protected <C extends hudson.slaves.ComputerConnector> C configRoundtrip(C before) throws Exception
      Deprecated.
      Throws:
      Exception
    • configRoundtrip

      protected hudson.model.User configRoundtrip(hudson.model.User u) throws Exception
      Deprecated.
      Throws:
      Exception
    • configRoundtrip

      protected <N extends hudson.model.Node> N configRoundtrip(N node) throws Exception
      Deprecated.
      Throws:
      Exception
    • configRoundtrip

      protected <V extends hudson.model.View> V configRoundtrip(V view) throws Exception
      Deprecated.
      Throws:
      Exception
    • assertBuildStatus

      public <R extends hudson.model.Run> R assertBuildStatus(hudson.model.Result status, R r) throws Exception
      Deprecated.
      Asserts that the outcome of the build is a specific outcome.
      Throws:
      Exception
    • isGoodHttpStatus

      public boolean isGoodHttpStatus(int status)
      Deprecated.
      Determines whether the specified HTTP status code is generally "good"
    • assertGoodStatus

      public void assertGoodStatus(org.htmlunit.Page page)
      Deprecated.
      Assert that the specified page can be served with a "good" HTTP status, eg, the page is not missing and can be served without a server error
    • assertBuildStatusSuccess

      public <R extends hudson.model.Run> R assertBuildStatusSuccess(R r) throws Exception
      Deprecated.
      Throws:
      Exception
    • assertBuildStatusSuccess

      public <R extends hudson.model.Run> R assertBuildStatusSuccess(Future<? extends R> r) throws Exception
      Deprecated.
      Throws:
      Exception
    • buildAndAssertSuccess

      public <J extends hudson.model.AbstractProject<J, R>, R extends hudson.model.AbstractBuild<J, R>> R buildAndAssertSuccess(J job) throws Exception
      Deprecated.
      Throws:
      Exception
    • buildAndAssertSuccess

      public hudson.model.FreeStyleBuild buildAndAssertSuccess(hudson.model.FreeStyleProject job) throws Exception
      Deprecated.
      Avoids need for cumbersome this.<J,R>buildAndAssertSuccess(...) type hints under JDK 7 javac (and supposedly also IntelliJ).
      Throws:
      Exception
    • assertLogContains

      public void assertLogContains(String substring, hudson.model.Run run) throws Exception
      Deprecated.
      Asserts that the console output of the build contains the given substring.
      Throws:
      Exception
    • assertLogNotContains

      public void assertLogNotContains(String substring, hudson.model.Run run) throws Exception
      Deprecated.
      Asserts that the console output of the build does not contain the given substring.
      Throws:
      Exception
    • getLog

      protected static String getLog(hudson.model.Run run) throws IOException
      Deprecated.
      Get entire log file (this method is deprecated in hudson.model.Run, but in tests it is OK to load entire log).
      Throws:
      IOException
    • assertXPath

      public void assertXPath(org.htmlunit.html.HtmlPage page, String xpath)
      Deprecated.
      Asserts that the XPath matches.
    • assertXPath

      public void assertXPath(org.htmlunit.html.DomNode page, String xpath)
      Deprecated.
      Asserts that the XPath matches the contents of a DomNode page. This variant of assertXPath(HtmlPage page, String xpath) allows us to examine XmlPages.
    • assertXPathValue

      public void assertXPathValue(org.htmlunit.html.DomNode page, String xpath, String expectedValue)
      Deprecated.
    • assertXPathValueContains

      public void assertXPathValueContains(org.htmlunit.html.DomNode page, String xpath, String needle)
      Deprecated.
    • assertXPathResultsContainText

      public void assertXPathResultsContainText(org.htmlunit.html.DomNode page, String xpath, String needle)
      Deprecated.
    • assertAllImageLoadSuccessfully

      public void assertAllImageLoadSuccessfully(org.htmlunit.html.HtmlPage p)
      Deprecated.
      Makes sure that all the images in the page loads successfully. (By default, HtmlUnit doesn't load images.)
    • assertStringContains

      public void assertStringContains(String message, String haystack, String needle)
      Deprecated.
    • assertStringContains

      public void assertStringContains(String haystack, String needle)
      Deprecated.
    • assertHelpExists

      public void assertHelpExists(Class<? extends hudson.model.Describable> type, String properties) throws Exception
      Deprecated.
      Asserts that help files exist for the specified properties of the given instance.
      Parameters:
      type - The describable class type that should have the associated help files.
      properties - ','-separated list of properties whose help files should exist.
      Throws:
      Exception
    • submit

      public org.htmlunit.html.HtmlPage submit(org.htmlunit.html.HtmlForm form) throws Exception
      Deprecated.
      Submits the form. Plain HtmlForm.submit(SubmittableElement) doesn't work correctly due to the use of YUI in Jenkins.
      Throws:
      Exception
    • submit

      public org.htmlunit.html.HtmlPage submit(org.htmlunit.html.HtmlForm form, String name) throws Exception
      Deprecated.
      Submits the form by clicking the submit button of the given name.
      Parameters:
      name - This corresponds to the @name of <f:submit />
      Throws:
      Exception
    • findPreviousInputElement

      protected org.htmlunit.html.HtmlInput findPreviousInputElement(org.htmlunit.html.HtmlElement current, String name)
      Deprecated.
    • getButtonByCaption

      protected org.htmlunit.html.HtmlButton getButtonByCaption(org.htmlunit.html.HtmlForm f, String s)
      Deprecated.
    • createTaskListener

      public hudson.model.TaskListener createTaskListener()
      Deprecated.
      Creates a TaskListener connected to stdout.
    • assertEqualBeans

      public void assertEqualBeans(Object lhs, Object rhs, String properties) throws Exception
      Deprecated.
      Asserts that two JavaBeans are equal as far as the given list of properties are concerned.

      This method takes two objects that have properties (getXyz, isXyz, or just the public xyz field), and makes sure that the property values for each given property are equals (by using TestCase.assertEquals(Object, Object))

      Property values can be null on both objects, and that is OK, but passing in a property that doesn't exist will fail an assertion.

      This method is very convenient for comparing a large number of properties on two objects, for example to verify that the configuration is identical after a config screen roundtrip.

      Parameters:
      lhs - One of the two objects to be compared.
      rhs - The other object to be compared
      properties - ','-separated list of property names that are compared.
      Throws:
      Exception
      Since:
      1.297
    • setQuietPeriod

      protected void setQuietPeriod(int qp)
      Deprecated.
    • assertEqualDataBoundBeans

      public void assertEqualDataBoundBeans(Object lhs, Object rhs) throws Exception
      Deprecated.
      Works like assertEqualBeans(Object, Object, String) but figure out the properties via DataBoundConstructor
      Throws:
      Exception
    • assertEqualDataBoundBeans

      public void assertEqualDataBoundBeans(List<?> lhs, List<?> rhs) throws Exception
      Deprecated.
      Makes sure that two collections are identical via assertEqualDataBoundBeans(Object, Object)
      Throws:
      Exception
    • findDataBoundConstructor

      protected Constructor<?> findDataBoundConstructor(Class<?> c)
      Deprecated.
    • get

      protected <T extends hudson.model.Descriptor<?>> T get(Class<T> d)
      Deprecated.
      Gets the descriptor instance of the current Hudson by its type.
    • isSomethingHappening

      protected boolean isSomethingHappening()
      Deprecated.
      Returns true if Hudson is building something or going to build something.
    • waitUntilNoActivity

      protected void waitUntilNoActivity() throws Exception
      Deprecated.
      Waits until Hudson finishes building everything, including those in the queue.

      This method uses a default time out to prevent infinite hang in the automated test execution environment.

      Throws:
      Exception
    • waitUntilNoActivityUpTo

      protected void waitUntilNoActivityUpTo(int timeout) throws Exception
      Deprecated.
      Waits until Jenkins finishes building everything, including those builds in the queue, or fail the test if the specified timeout milliseconds is exceeded.
      Throws:
      Exception
    • recipe

      protected void recipe() throws Exception
      Deprecated.
      Called during the setUp() to give a test case an opportunity to control the test environment in which Hudson is run.

      One could override this method and call a series of withXXX methods, or you can use the annotations with Recipe meta-annotation.

      Throws:
      Exception
    • recipeLoadCurrentPlugin

      protected void recipeLoadCurrentPlugin() throws Exception
      Deprecated.
      If this test harness is launched for a Jenkins plugin, locate the target/test-classes/the.jpl and add a recipe to install that to the new Jenkins.

      This file is created by maven-hpi-plugin at the testCompile phase when the current packaging is hpi.

      Throws:
      Exception
    • withNewHome

      public HudsonTestCase withNewHome()
      Deprecated.
    • withExistingHome

      public HudsonTestCase withExistingHome(File source) throws Exception
      Deprecated.
      Throws:
      Exception
    • withPresetData

      public HudsonTestCase withPresetData(String name)
      Deprecated.
      Declares that this test case expects to start with one of the preset data sets. See test/src/main/preset-data/ for available datasets and what they mean.
    • with

      public HudsonTestCase with(HudsonHomeLoader homeLoader)
      Deprecated.
    • executeOnServer

      public <V> V executeOnServer(Callable<V> c) throws Exception
      Deprecated.
      Executes the given closure on the server, by the servlet request handling thread, in the context of an HTTP request.

      In HudsonTestCase, a thread that's executing the test code is different from the thread that carries out HTTP requests made through HudsonTestCase.WebClient. But sometimes you want to make assertions and other calls with side-effect from within the request handling thread.

      This method allows you to do just that. It is useful for testing some methods that require StaplerRequest and StaplerResponse, or getting the credential of the current user (via Jenkins.getAuthentication(), and so on.

      Parameters:
      c - The closure to be executed on the server.
      Returns:
      The return value from the closure.
      Throws:
      Exception - If a closure throws any exception, that exception will be carried forward.
    • writeReplace

      protected Object writeReplace()
      Deprecated.
      Sometimes a part of a test case may ends up creeping into the serialization tree of Saveable.save(), so detect that and flag that as an error.
    • createWebClient

      public HudsonTestCase.WebClient createWebClient()
      Deprecated.
      Create a web client instance using the browser version returned by BrowserVersion.getDefault() with support for the Fetch API.