public abstract class JenkinsEmbedder extends Object implements hudson.model.RootAction
| Modifier and Type | Field and Description |
|---|---|
String |
contextPath
Where in the
Server is Jenkins deployed? |
protected TestEnvironment |
env |
protected HudsonHomeLoader |
homeLoader |
jenkins.model.Jenkins |
jenkins |
protected int |
localPort
TCP/IP port that the server is listening on.
|
static org.eclipse.jetty.http.MimeTypes |
MIME_TYPES |
static List<hudson.tools.ToolProperty<?>> |
NO_PROPERTIES |
protected List<JenkinsRecipe.Runner> |
recipes |
protected org.eclipse.jetty.server.Server |
server |
protected List<LenientRunnable> |
tearDowns
|
protected org.junit.runner.Description |
testDescription |
int |
timeout
Number of seconds until the test times out.
|
| Constructor and Description |
|---|
JenkinsEmbedder() |
| Modifier and Type | Method and Description |
|---|---|
void |
after()
Override to tear down your specific external resource.
|
void |
before()
Override to set up your specific external resource.
|
protected void |
configureUpdateCenter()
Configures the update center setting for the test.
|
protected abstract org.eclipse.jetty.security.LoginService |
configureUserRealm() |
hudson.Launcher.LocalLauncher |
createLocalLauncher()
Creates
Launcher.LocalLauncher. |
hudson.model.TaskListener |
createTaskListener()
Creates a
TaskListener connected to stdout. |
protected String |
createUniqueProjectName() |
protected abstract javax.servlet.ServletContext |
createWebServer()
Prepares a webapp hosting environment to get
ServletContext implementation
that we need for testing. |
String |
getDisplayName() |
String |
getIconFileName() |
jenkins.model.Jenkins |
getInstance() |
hudson.PluginManager |
getPluginManager() |
org.junit.runner.Description |
getTestDescription() |
URL |
getURL()
Returns the URL of the webapp top page.
|
String |
getUrlName() |
File |
getWebAppRoot() |
void |
interactiveBreak()
Blocks until the ENTER key is hit.
|
boolean |
isSomethingHappening()
Returns true if Hudson is building something or going to build something.
|
protected hudson.model.Hudson |
newHudson()
Creates a new instance of
Jenkins. |
void |
pause()
Pauses the execution until ENTER is hit in the console.
|
void |
recipe()
Called during the
before() to give a test case an opportunity to
control the test environment in which Hudson is run. |
void |
setPluginManager(hudson.PluginManager pluginManager)
Sets the
PluginManager to be used when creating a new Jenkins instance. |
void |
setQuietPeriod(int qp) |
void |
waitUntilNoActivity()
Waits until Hudson finishes building everything, including those in the queue.
|
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
|
JenkinsEmbedder |
with(HudsonHomeLoader homeLoader) |
JenkinsEmbedder |
with(hudson.PluginManager pluginManager) |
JenkinsEmbedder |
withExistingHome(File source) |
JenkinsEmbedder |
withNewHome() |
JenkinsEmbedder |
withPresetData(String name)
Declares that this test case expects to start with one of the preset data sets.
|
protected TestEnvironment env
protected org.junit.runner.Description testDescription
public jenkins.model.Jenkins jenkins
protected HudsonHomeLoader homeLoader
protected int localPort
protected org.eclipse.jetty.server.Server server
public String contextPath
Server is Jenkins deployed?
Just like ServletContext.getContextPath(), starts with '/' but doesn't end with '/'.
protected List<LenientRunnable> tearDowns
protected List<JenkinsRecipe.Runner> recipes
public int timeout
public static final List<hudson.tools.ToolProperty<?>> NO_PROPERTIES
public static final org.eclipse.jetty.http.MimeTypes MIME_TYPES
public jenkins.model.Jenkins getInstance()
public void before()
throws Throwable
Throwable - if setup fails (which will disable afterprotected void configureUpdateCenter()
throws Exception
Exceptionpublic void after()
throws Exception
Exceptionpublic String getIconFileName()
getIconFileName in interface hudson.model.Actionpublic String getDisplayName()
getDisplayName in interface hudson.model.ActiongetDisplayName in interface hudson.model.ModelObjectpublic String getUrlName()
getUrlName in interface hudson.model.Actionprotected hudson.model.Hudson newHudson()
throws Exception
Jenkins. If the derived class wants to create it in a different way,
you can override it.Exceptionpublic hudson.PluginManager getPluginManager()
public void setPluginManager(hudson.PluginManager pluginManager)
PluginManager to be used when creating a new Jenkins instance.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.public JenkinsEmbedder with(hudson.PluginManager pluginManager)
protected abstract javax.servlet.ServletContext createWebServer()
throws Exception
ServletContext implementation
that we need for testing.Exceptionprotected String createUniqueProjectName()
public hudson.Launcher.LocalLauncher createLocalLauncher()
Launcher.LocalLauncher. Useful for launching processes.public URL getURL() throws IOException
IOExceptionpublic void interactiveBreak()
throws Exception
Exceptionpublic void pause()
throws IOException
This is often very useful so that you can interact with Hudson from an browser, while developing a test case.
IOExceptionpublic hudson.model.TaskListener createTaskListener()
TaskListener connected to stdout.public void setQuietPeriod(int qp)
throws IOException
IOExceptionpublic boolean isSomethingHappening()
public void waitUntilNoActivity()
throws Exception
Exceptionpublic void waitUntilNoActivityUpTo(int timeout)
throws Exception
Exceptionpublic void recipe()
throws Exception
before() to give a test case an opportunity to
control the test environment in which Hudson is run.Exceptionpublic JenkinsEmbedder withNewHome()
public JenkinsEmbedder withExistingHome(File source) throws Exception
Exceptionpublic JenkinsEmbedder withPresetData(String name)
test/src/main/preset-data/
for available datasets and what they mean.public JenkinsEmbedder with(HudsonHomeLoader homeLoader)
public org.junit.runner.Description getTestDescription()
protected abstract org.eclipse.jetty.security.LoginService configureUserRealm()
Copyright © 2004–2018. All rights reserved.