Search in sources :

Example 1 with PooledJenkinsController

use of org.jenkinsci.test.acceptance.server.PooledJenkinsController in project acceptance-test-harness by jenkinsci.

the class FallbackConfig method createController.

/**
 * Instantiates a controller through the "TYPE" attribute and {@link JenkinsControllerFactory}.
 */
@Provides
@TestScope
public JenkinsController createController(Injector injector, ExtensionList<JenkinsControllerFactory> factories) throws IOException {
    // this is lower case for backward compatibility
    String type = System.getenv("type");
    if (type == null)
        type = System.getenv("TYPE");
    if (type == null) {
        File socket = getSocket();
        if (socket.exists() && !JenkinsControllerPoolProcess.MAIN) {
            LOGGER.info("Found pooled jenkins controller listening on socket " + socket.getAbsolutePath());
            return new PooledJenkinsController(injector, socket);
        } else {
            LOGGER.warning("No pooled jenkins controller listening on socket " + socket.getAbsolutePath());
            type = "winstone";
        }
    }
    for (JenkinsControllerFactory f : factories) {
        if (f.getId().equalsIgnoreCase(type)) {
            final JenkinsController c = f.create();
            c.postConstruct(injector);
            return c;
        }
    }
    throw new AssertionError("Invalid controller type: " + type);
}
Also used : JenkinsController(org.jenkinsci.test.acceptance.controller.JenkinsController) PooledJenkinsController(org.jenkinsci.test.acceptance.server.PooledJenkinsController) JenkinsControllerFactory(org.jenkinsci.test.acceptance.controller.JenkinsControllerFactory) File(java.io.File) PooledJenkinsController(org.jenkinsci.test.acceptance.server.PooledJenkinsController) TestScope(org.jenkinsci.test.acceptance.guice.TestScope) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)1 File (java.io.File)1 JenkinsController (org.jenkinsci.test.acceptance.controller.JenkinsController)1 JenkinsControllerFactory (org.jenkinsci.test.acceptance.controller.JenkinsControllerFactory)1 TestScope (org.jenkinsci.test.acceptance.guice.TestScope)1 PooledJenkinsController (org.jenkinsci.test.acceptance.server.PooledJenkinsController)1