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 ExecutionEnvironment |
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
|
| 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() |
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.
|
abstract void |
recipe() |
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 ExecutionEnvironment env
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 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 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)
protected abstract org.eclipse.jetty.security.LoginService configureUserRealm()
Copyright © 2004–2020. All rights reserved.