Class JenkinsController
- java.lang.Object
-
- org.jenkinsci.test.acceptance.controller.JenkinsController
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,IJenkinsController
,AutoCleaned
- Direct Known Subclasses:
ExistingJenkinsController
,LocalController
,PooledJenkinsController
public abstract class JenkinsController extends Object implements IJenkinsController, AutoCleaned
Starts/stops Jenkins and exposes where it is running.This abstracts away how the test harness launches Jenkins-under-test and where, which is determined at runtime by the user who runs the tests, not by the author of tests.
- Author:
- Vivek Pandey
-
-
Field Summary
Fields Modifier and Type Field Description com.google.inject.Injector
injector
protected boolean
isQuite
static int
STARTUP_TIMEOUT
protected String
WORKSPACE
-
Constructor Summary
Constructors Modifier Constructor Description protected
JenkinsController(com.google.inject.Injector i)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Alias fortearDown()
.void
diagnose(Throwable cause)
Perform controller specific diagnostics for test failure.org.apache.http.auth.Credentials
getInitialCredentials()
String
getLogId()
Returns the short ID used to prefix log output from the process into the test.protected LogListener
getLogPrinter()
abstract URL
getUrl()
Gives URL where Jenkins is listening.boolean
isRunning()
void
postConstruct(com.google.inject.Injector injector)
Called whenJenkinsController
is pulled into a world prior tostart()
void
restart()
Stops and starts running Jenkins to perform a full JVM restart.void
start()
Starts Jenkins.abstract void
startNow()
Synchronously start Jenkins instance until it starts responding to the specified URL.void
stop()
Stops Jenkinsabstract void
stopNow()
Synchronously shutdown Jenkins instance.abstract void
tearDown()
Assuming the instance had already stopped, destroy JENKINS_HOME and release resources used by Jenkins.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jenkinsci.test.acceptance.controller.IJenkinsController
populateJenkinsHome
-
-
-
-
Field Detail
-
isQuite
@Inject @Named("quite") protected boolean isQuite
-
WORKSPACE
@Inject @Named("WORKSPACE") protected String WORKSPACE
-
STARTUP_TIMEOUT
public static final int STARTUP_TIMEOUT
-
injector
public com.google.inject.Injector injector
-
-
Method Detail
-
postConstruct
public void postConstruct(com.google.inject.Injector injector)
Called whenJenkinsController
is pulled into a world prior tostart()
-
start
public void start() throws IOException
Starts Jenkins.- Specified by:
start
in interfaceIJenkinsController
- Throws:
IOException
-
startNow
public abstract void startNow() throws IOException
Synchronously start Jenkins instance until it starts responding to the specified URL.- Throws:
IOException
-
stop
public void stop() throws IOException
Stops Jenkins- Specified by:
stop
in interfaceIJenkinsController
- Throws:
IOException
-
getLogPrinter
protected LogListener getLogPrinter()
-
stopNow
public abstract void stopNow() throws IOException
Synchronously shutdown Jenkins instance.This method must leave JENKINS_HOME intact so that it can be started later. To really delete the data and clean up, see
tearDown()
.- Throws:
IOException
-
close
public final void close() throws IOException
Alias fortearDown()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
tearDown
public abstract void tearDown() throws IOException
Assuming the instance had already stopped, destroy JENKINS_HOME and release resources used by Jenkins.- Throws:
IOException
-
restart
public void restart() throws IOException
Stops and starts running Jenkins to perform a full JVM restart.- Throws:
IOException
-
isRunning
public boolean isRunning()
-
getUrl
public abstract URL getUrl()
Gives URL where Jenkins is listening. Must end with "/"- Specified by:
getUrl
in interfaceIJenkinsController
-
getInitialCredentials
@CheckForNull public org.apache.http.auth.Credentials getInitialCredentials()
-
getLogId
public String getLogId()
Returns the short ID used to prefix log output from the process into the test.
-
diagnose
public void diagnose(Throwable cause) throws IOException
Perform controller specific diagnostics for test failure. Defaults to no-op.- Parameters:
cause
- Failure cause- Throws:
IOException
-
-