|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.jvnet.hudson.test.HudsonTestCase
public abstract class HudsonTestCase
Base class for all Hudson test cases.
| Nested Class Summary | |
|---|---|
class |
HudsonTestCase.WebClient
Extends WebClient and provide convenience methods
for accessing Hudson. |
| Nested classes/interfaces inherited from interface hudson.ExtensionPoint |
|---|
ExtensionPoint.LegacyInstancesAreScopedToHudson |
| Field Summary | |
|---|---|
protected java.lang.String |
contextPath
Where in the Server is Hudson deployed? |
protected TestEnvironment |
env
|
protected HudsonHomeLoader |
homeLoader
|
Hudson |
hudson
|
protected JavaScriptDebugger |
jsDebugger
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 |
localPort
TCP/IP port that the server is listening on. |
static org.mortbay.jetty.MimeTypes |
MIME_TYPES
|
protected static java.util.List<ToolProperty<?>> |
NO_PROPERTIES
|
protected java.util.List<Recipe.Runner> |
recipes
|
protected org.mortbay.jetty.Server |
server
|
static int |
SLAVE_DEBUG_PORT
Specify this to a TCP/IP port number to have slaves started with the debugger. |
protected java.util.List<LenientRunnable> |
tearDowns
Runnables to be invoked at tearDown(). |
| Constructor Summary | |
|---|---|
protected |
HudsonTestCase()
|
protected |
HudsonTestCase(java.lang.String name)
|
| Method Summary | ||
|---|---|---|
|
assertBuildStatus(Result status,
R r)
Asserts that the outcome of the build is a specific outcome. |
|
|
assertBuildStatusSuccess(java.util.concurrent.Future<? extends R> r)
|
|
|
assertBuildStatusSuccess(R r)
|
|
void |
assertEqualBeans(java.lang.Object lhs,
java.lang.Object rhs,
java.lang.String properties)
Asserts that two JavaBeans are equal as far as the given list of properties are concerned. |
|
void |
assertGoodStatus(com.gargoylesoftware.htmlunit.Page page)
Assert that the specifed page can be served with a "good" HTTP status, eg, the page is not missing and can be served without a server error |
|
void |
assertLogContains(java.lang.String substring,
Run run)
Asserts that the console output of the build contains the given substring. |
|
void |
assertStringContains(java.lang.String haystack,
java.lang.String needle)
|
|
void |
assertStringContains(java.lang.String message,
java.lang.String haystack,
java.lang.String needle)
|
|
void |
assertXPath(com.gargoylesoftware.htmlunit.html.DomNode page,
java.lang.String xpath)
Asserts that the XPath matches the contents of a DomNode page. |
|
void |
assertXPath(com.gargoylesoftware.htmlunit.html.HtmlPage page,
java.lang.String xpath)
Asserts that the XPath matches. |
|
void |
assertXPathResultsContainText(com.gargoylesoftware.htmlunit.html.DomNode page,
java.lang.String xpath,
java.lang.String needle)
|
|
void |
assertXPathValue(com.gargoylesoftware.htmlunit.html.DomNode page,
java.lang.String xpath,
java.lang.String expectedValue)
|
|
void |
assertXPathValueContains(com.gargoylesoftware.htmlunit.html.DomNode page,
java.lang.String xpath,
java.lang.String needle)
|
|
|
buildAndAssertSuccess(J job)
|
|
protected Ant.AntInstallation |
configureDefaultAnt()
Extracts Ant and configures it. |
|
protected Maven.MavenInstallation |
configureDefaultMaven()
Returns the older default Maven, while still allowing specification of other bundled Mavens. |
|
protected Maven.MavenInstallation |
configureDefaultMaven(java.lang.String mavenVersion,
int mavenReqVersion)
Locates Maven2 and configure that as the only Maven in the system. |
|
protected void |
configureUpdateCenter()
Configures the update center setting for the test. |
|
protected org.mortbay.jetty.security.UserRealm |
configureUserRealm()
Configures a security realm for a test. |
|
CommandLauncher |
createComputerLauncher(EnvVars env)
Creates a CommandLauncher for launching a slave locally. |
|
SecurityRealm |
createDummySecurityRealm()
Creates a test SecurityRealm that recognizes username==password as valid. |
|
protected FreeStyleProject |
createFreeStyleProject()
|
|
protected FreeStyleProject |
createFreeStyleProject(java.lang.String name)
|
|
protected Launcher.LocalLauncher |
createLocalLauncher()
Creates Launcher.LocalLauncher. |
|
protected MatrixProject |
createMatrixProject()
|
|
protected MatrixProject |
createMatrixProject(java.lang.String name)
|
|
protected MavenModuleSet |
createMavenProject()
Creates a empty Maven project with an unique name. |
|
protected MavenModuleSet |
createMavenProject(java.lang.String name)
Creates a empty Maven project with the given name. |
|
DumbSlave |
createOnlineSlave()
Create a new slave on the local host and wait for it to come onilne before returning. |
|
DumbSlave |
createOnlineSlave(Label l)
Create a new slave on the local host and wait for it to come onilne before returning. |
|
DumbSlave |
createOnlineSlave(Label l,
EnvVars env)
Create a new slave on the local host and wait for it to come online before returning |
|
PretendSlave |
createPretendSlave(FakeLauncher faker)
|
|
DumbSlave |
createSlave()
|
|
DumbSlave |
createSlave(Label l)
Creates and launches a new slave on the local host. |
|
DumbSlave |
createSlave(Label l,
EnvVars env)
Creates a slave with certain additional environment variables |
|
TaskListener |
createTaskListener()
Creates a TaskListener connected to stdout. |
|
java.io.File |
createTmpDir()
Allocates a new temporary directory for the duration of this test. |
|
HudsonTestCase.WebClient |
createWebClient()
This is to assist Groovy test clients who are incapable of instantiating the inner classes properly. |
|
protected javax.servlet.ServletContext |
createWebServer()
Prepares a webapp hosting environment to get ServletContext implementation
that we need for testing. |
|
|
executeOnServer(java.util.concurrent.Callable<V> c)
Executes the given closure on the server, in the context of an HTTP request. |
|
protected com.gargoylesoftware.htmlunit.html.HtmlInput |
findPreviousInputElement(com.gargoylesoftware.htmlunit.html.HtmlElement current,
java.lang.String name)
|
|
protected
|
get(java.lang.Class<T> d)
Gets the descriptor instance of the current Hudson by its type. |
|
protected com.gargoylesoftware.htmlunit.html.HtmlButton |
getButtonByCaption(com.gargoylesoftware.htmlunit.html.HtmlForm f,
java.lang.String s)
|
|
java.lang.String |
getDisplayName()
|
|
java.lang.String |
getIconFileName()
|
|
protected static java.lang.String |
getLog(Run run)
Get entire log file (this method is deprecated in hudson.model.Run, but in tests it is OK to load entire log). |
|
java.net.URL |
getURL()
Returns the URL of the webapp top page. |
|
java.lang.String |
getUrlName()
|
|
void |
interactiveBreak()
Blocks until the ENTER key is hit. |
|
boolean |
isGoodHttpStatus(int status)
Determines whether the specifed HTTP status code is generally "good" |
|
protected boolean |
isSomethingHappening()
Returns true if Hudson is building something or going to build something. |
|
protected
|
last(java.util.List<T> items)
Returns the last item in the list. |
|
protected Hudson |
newHudson()
Creates a new instance of Hudson. |
|
protected void |
pause()
Pauses the execution until ENTER is hit in the console. |
|
protected void |
recipe()
Called during the setUp() to give a test case an opportunity to
control the test environment in which Hudson is run. |
|
protected void |
recipeLoadCurrentPlugin()
If this test harness is launched for a Hudson plugin, locate the target/test-classes/the.hpl and add a recipe to install that to the new Hudson. |
|
void |
runBare()
|
|
protected void |
runTest()
|
|
protected com.gargoylesoftware.htmlunit.Page |
search(java.lang.String q)
Performs a search from the search box. |
|
protected void |
setUp()
|
|
com.gargoylesoftware.htmlunit.html.HtmlPage |
submit(com.gargoylesoftware.htmlunit.html.HtmlForm form)
Submits the form. |
|
com.gargoylesoftware.htmlunit.html.HtmlPage |
submit(com.gargoylesoftware.htmlunit.html.HtmlForm form,
java.lang.String name)
Submits the form by clikcing the submit button of the given name. |
|
protected void |
tearDown()
|
|
protected void |
waitUntilNoActivity()
Waits until Hudson finishes building everything, including those in the queue. |
|
protected void |
waitUntilNoActivityUpTo(int timeout)
Waits until Hudson finishes building everything, including those in the queue, or fail the test if the specified timeout milliseconds is |
|
HudsonTestCase |
with(HudsonHomeLoader homeLoader)
|
|
HudsonTestCase |
withExistingHome(java.io.File source)
|
|
HudsonTestCase |
withNewHome()
|
|
HudsonTestCase |
withPresetData(java.lang.String name)
Declares that this test case expects to start with one of the preset data sets. |
|
| Methods inherited from class junit.framework.TestCase |
|---|
countTestCases, createResult, getName, run, run, setName, toString |
| Methods inherited from class junit.framework.Assert |
|---|
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, fail, fail |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public Hudson hudson
protected final TestEnvironment env
protected HudsonHomeLoader homeLoader
protected int localPort
protected org.mortbay.jetty.Server server
protected java.lang.String contextPath
Server is Hudson deployed?
Just like ServletContext.getContextPath(), starts with '/' but doesn't end with '/'.
protected java.util.List<LenientRunnable> tearDowns
Runnables to be invoked at tearDown().
protected java.util.List<Recipe.Runner> recipes
protected JavaScriptDebugger jsDebugger
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.)
protected static final java.util.List<ToolProperty<?>> NO_PROPERTIES
public static int SLAVE_DEBUG_PORT
public static final org.mortbay.jetty.MimeTypes MIME_TYPES
| Constructor Detail |
|---|
protected HudsonTestCase(java.lang.String name)
protected HudsonTestCase()
| Method Detail |
|---|
public void runBare()
throws java.lang.Throwable
runBare in class junit.framework.TestCasejava.lang.Throwable
protected void setUp()
throws java.lang.Exception
setUp in class junit.framework.TestCasejava.lang.Exception
protected void configureUpdateCenter()
throws java.lang.Exception
java.lang.Exception
protected void tearDown()
throws java.lang.Exception
tearDown in class junit.framework.TestCasejava.lang.Exception
protected void runTest()
throws java.lang.Throwable
runTest in class junit.framework.TestCasejava.lang.Throwablepublic java.lang.String getIconFileName()
getIconFileName in interface Actionpublic java.lang.String getDisplayName()
getDisplayName in interface ActiongetDisplayName in interface ModelObjectpublic java.lang.String getUrlName()
getUrlName in interface Action
protected Hudson newHudson()
throws java.lang.Exception
Hudson. If the derived class wants to create it in a different way,
you can override it.
java.lang.Exception
protected javax.servlet.ServletContext createWebServer()
throws java.lang.Exception
ServletContext implementation
that we need for testing.
java.lang.Exceptionprotected org.mortbay.jetty.security.UserRealm configureUserRealm()
protected Maven.MavenInstallation configureDefaultMaven()
throws java.lang.Exception
java.lang.Exception
protected Maven.MavenInstallation configureDefaultMaven(java.lang.String mavenVersion,
int mavenReqVersion)
throws java.lang.Exception
java.lang.Exception
protected Ant.AntInstallation configureDefaultAnt()
throws java.lang.Exception
java.lang.Exception
protected FreeStyleProject createFreeStyleProject()
throws java.io.IOException
java.io.IOException
protected FreeStyleProject createFreeStyleProject(java.lang.String name)
throws java.io.IOException
java.io.IOException
protected MatrixProject createMatrixProject()
throws java.io.IOException
java.io.IOException
protected MatrixProject createMatrixProject(java.lang.String name)
throws java.io.IOException
java.io.IOException
protected MavenModuleSet createMavenProject()
throws java.io.IOException
java.io.IOExceptionconfigureDefaultMaven()
protected MavenModuleSet createMavenProject(java.lang.String name)
throws java.io.IOException
java.io.IOExceptionconfigureDefaultMaven()protected Launcher.LocalLauncher createLocalLauncher()
Launcher.LocalLauncher. Useful for launching processes.
public java.io.File createTmpDir()
throws java.io.IOException
java.io.IOException
public DumbSlave createSlave()
throws java.lang.Exception
java.lang.Exception
public DumbSlave createSlave(Label l)
throws java.lang.Exception
java.lang.Exceptionpublic SecurityRealm createDummySecurityRealm()
SecurityRealm that recognizes username==password as valid.
public java.net.URL getURL()
throws java.io.IOException
java.io.IOException
public DumbSlave createSlave(Label l,
EnvVars env)
throws java.lang.Exception
java.lang.Exception
public PretendSlave createPretendSlave(FakeLauncher faker)
throws java.lang.Exception
java.lang.Exception
public CommandLauncher createComputerLauncher(EnvVars env)
throws java.net.URISyntaxException,
java.net.MalformedURLException
CommandLauncher for launching a slave locally.
env - Environment variables to add to the slave process. Can be null.
java.net.URISyntaxException
java.net.MalformedURLException
public DumbSlave createOnlineSlave()
throws java.lang.Exception
java.lang.Exception
public DumbSlave createOnlineSlave(Label l)
throws java.lang.Exception
java.lang.Exception
public DumbSlave createOnlineSlave(Label l,
EnvVars env)
throws java.lang.Exception
java.lang.Exception
public void interactiveBreak()
throws java.lang.Exception
java.lang.Exceptionprotected <T> T last(java.util.List<T> items)
protected void pause()
throws java.io.IOException
This is often very useful so that you can interact with Hudson from an browser, while developing a test case.
java.io.IOException
protected com.gargoylesoftware.htmlunit.Page search(java.lang.String q)
throws java.lang.Exception
java.lang.Exception
public <R extends Run> R assertBuildStatus(Result status,
R r)
throws java.lang.Exception
java.lang.Exceptionpublic boolean isGoodHttpStatus(int status)
public void assertGoodStatus(com.gargoylesoftware.htmlunit.Page page)
page -
public <R extends Run> R assertBuildStatusSuccess(R r)
throws java.lang.Exception
java.lang.Exception
public <R extends Run> R assertBuildStatusSuccess(java.util.concurrent.Future<? extends R> r)
throws java.lang.Exception
java.lang.Exception
public <J extends AbstractProject<J,R>,R extends AbstractBuild<J,R>> R buildAndAssertSuccess(J job)
throws java.lang.Exception
java.lang.Exception
public void assertLogContains(java.lang.String substring,
Run run)
throws java.lang.Exception
java.lang.Exception
protected static java.lang.String getLog(Run run)
throws java.io.IOException
java.io.IOException
public void assertXPath(com.gargoylesoftware.htmlunit.html.HtmlPage page,
java.lang.String xpath)
public void assertXPath(com.gargoylesoftware.htmlunit.html.DomNode page,
java.lang.String xpath)
page - xpath -
public void assertXPathValue(com.gargoylesoftware.htmlunit.html.DomNode page,
java.lang.String xpath,
java.lang.String expectedValue)
public void assertXPathValueContains(com.gargoylesoftware.htmlunit.html.DomNode page,
java.lang.String xpath,
java.lang.String needle)
public void assertXPathResultsContainText(com.gargoylesoftware.htmlunit.html.DomNode page,
java.lang.String xpath,
java.lang.String needle)
public void assertStringContains(java.lang.String message,
java.lang.String haystack,
java.lang.String needle)
public void assertStringContains(java.lang.String haystack,
java.lang.String needle)
public com.gargoylesoftware.htmlunit.html.HtmlPage submit(com.gargoylesoftware.htmlunit.html.HtmlForm form)
throws java.lang.Exception
java.lang.Exception
public com.gargoylesoftware.htmlunit.html.HtmlPage submit(com.gargoylesoftware.htmlunit.html.HtmlForm form,
java.lang.String name)
throws java.lang.Exception
name - This corresponds to the @name of <f:submit />
java.lang.Exception
protected com.gargoylesoftware.htmlunit.html.HtmlInput findPreviousInputElement(com.gargoylesoftware.htmlunit.html.HtmlElement current,
java.lang.String name)
protected com.gargoylesoftware.htmlunit.html.HtmlButton getButtonByCaption(com.gargoylesoftware.htmlunit.html.HtmlForm f,
java.lang.String s)
public TaskListener createTaskListener()
TaskListener connected to stdout.
public void assertEqualBeans(java.lang.Object lhs,
java.lang.Object rhs,
java.lang.String properties)
throws java.lang.Exception
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 Assert.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.
lhs - One of the two objects to be compared.rhs - The other object to be comparedproperties - ','-separated list of property names that are compared.
java.lang.Exceptionprotected <T extends Descriptor<?>> T get(java.lang.Class<T> d)
protected boolean isSomethingHappening()
protected void waitUntilNoActivity()
throws java.lang.Exception
This method uses a default time out to prevent infinite hang in the automated test execution environment.
java.lang.Exception
protected void waitUntilNoActivityUpTo(int timeout)
throws java.lang.Exception
java.lang.Exception
protected void recipe()
throws java.lang.Exception
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.
java.lang.Exception
protected void recipeLoadCurrentPlugin()
throws java.lang.Exception
This file is created by maven-hpi-plugin at the testCompile phase when the current packaging is hpi.
java.lang.Exceptionpublic HudsonTestCase withNewHome()
public HudsonTestCase withExistingHome(java.io.File source)
throws java.lang.Exception
java.lang.Exceptionpublic HudsonTestCase withPresetData(java.lang.String name)
public HudsonTestCase with(HudsonHomeLoader homeLoader)
public <V> V executeOnServer(java.util.concurrent.Callable<V> c)
throws java.lang.Exception
StaplerRequest and StaplerResponse.
The closure will get the request and response as parameters.
java.lang.Exceptionpublic HudsonTestCase.WebClient createWebClient()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||