Search in sources :

Example 16 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class DevelopmentAgent method main.

public static void main(String[] args) throws Exception {
    new ProcessRunner().command("curl", "http://localhost:8153/go/admin/agent-plugins.zip", "--fail", "--silent", "--output", "agent-plugins.zip").failOnError(false).run();
    new ProcessRunner().command("curl", "http://localhost:8153/go/admin/tfs-impl.jar", "--fail", "--silent", "--output", "tfs-impl.jar").failOnError(false).run();
    new SystemEnvironment().set(SystemEnvironment.PLUGIN_ACTIVATOR_JAR_PATH, "go-plugin-activator.jar");
    assertActivationJarPresent();
    AgentMain.main("-serverUrl", "https://localhost:8154/go");
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ProcessRunner(com.thoughtworks.go.util.command.ProcessRunner)

Example 17 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class DevelopmentServer method main.

public static void main(String[] args) throws Exception {
    LogConfigurator logConfigurator = new LogConfigurator(DEFAULT_LOGBACK_CONFIGURATION_FILE);
    logConfigurator.initialize();
    copyDbFiles();
    copyPluginAssets();
    File webApp = new File("webapp");
    if (!webApp.exists()) {
        throw new RuntimeException("No webapp found in " + webApp.getAbsolutePath());
    }
    assertActivationJarPresent();
    SystemEnvironment systemEnvironment = new SystemEnvironment();
    systemEnvironment.setProperty(GENERATE_STATISTICS, "true");
    systemEnvironment.setProperty(SystemEnvironment.PARENT_LOADER_PRIORITY, "true");
    systemEnvironment.setProperty(SystemEnvironment.CRUISE_SERVER_WAR_PROPERTY, webApp.getAbsolutePath());
    systemEnvironment.set(SystemEnvironment.PLUGIN_LOCATION_MONITOR_INTERVAL_IN_SECONDS, 5);
    systemEnvironment.set(SystemEnvironment.DEFAULT_PLUGINS_ZIP, "/plugins.zip");
    systemEnvironment.set(SystemEnvironment.PLUGIN_ACTIVATOR_JAR_PATH, "go-plugin-activator.jar");
    // 0 means reload when stale
    systemEnvironment.setProperty(GoConstants.I18N_CACHE_LIFE, "0");
    systemEnvironment.set(SystemEnvironment.GO_SERVER_MODE, "development");
    setupPeriodicGC(systemEnvironment);
    assertPluginsZipExists();
    GoServer server = new GoServer();
    systemEnvironment.setProperty(GoConstants.USE_COMPRESSED_JAVASCRIPT, Boolean.toString(false));
    try {
        server.startServer();
        String hostName = systemEnvironment.getListenHost();
        if (hostName == null) {
            hostName = "localhost";
        }
        System.out.println("Go server dashboard started on http://" + hostName + ":" + systemEnvironment.getServerPort());
        System.out.println("* credentials: \"admin\" / \"badger\"");
    } catch (Exception e) {
        System.err.println("Failed to start Go server. Exception:");
        e.printStackTrace();
    }
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) LogConfigurator(com.thoughtworks.go.logging.LogConfigurator) File(java.io.File) IOException(java.io.IOException)

Example 18 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class Jetty9ServerTest method setUp.

@Before
public void setUp() throws Exception {
    server = mock(Server.class);
    Answer<Void> setHandlerMock = new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            Handler handler = (Handler) invocation.getArguments()[0];
            handler.setServer((Server) invocation.getMock());
            return null;
        }
    };
    Mockito.doAnswer(setHandlerMock).when(server).setHandler(any(Handler.class));
    systemEnvironment = mock(SystemEnvironment.class);
    when(systemEnvironment.getServerPort()).thenReturn(1234);
    when(systemEnvironment.keystore()).thenReturn(temporaryFolder.newFolder());
    when(systemEnvironment.truststore()).thenReturn(temporaryFolder.newFolder());
    when(systemEnvironment.getWebappContextPath()).thenReturn("context");
    when(systemEnvironment.getCruiseWar()).thenReturn("cruise.war");
    when(systemEnvironment.getParentLoaderPriority()).thenReturn(true);
    when(systemEnvironment.useCompressedJs()).thenReturn(true);
    when(systemEnvironment.get(SystemEnvironment.RESPONSE_BUFFER_SIZE)).thenReturn(1000);
    when(systemEnvironment.get(SystemEnvironment.IDLE_TIMEOUT)).thenReturn(2000);
    when(systemEnvironment.configDir()).thenReturn(configDir = temporaryFolder.newFile());
    when(systemEnvironment.get(SystemEnvironment.GO_SSL_CONFIG_ALLOW)).thenReturn(true);
    when(systemEnvironment.get(SystemEnvironment.GO_SSL_RENEGOTIATION_ALLOWED)).thenReturn(true);
    when(systemEnvironment.getJettyConfigFile()).thenReturn(new File("foo"));
    when(systemEnvironment.isSessionCookieSecure()).thenReturn(false);
    when(systemEnvironment.sessionTimeoutInSeconds()).thenReturn(1234);
    when(systemEnvironment.sessionCookieMaxAgeInSeconds()).thenReturn(5678);
    SSLSocketFactory sslSocketFactory = mock(SSLSocketFactory.class);
    when(sslSocketFactory.getSupportedCipherSuites()).thenReturn(new String[] {});
    jetty9Server = new Jetty9Server(systemEnvironment, "pwd", sslSocketFactory, server);
    ReflectionUtil.setStaticField(Jetty9Server.class, "JETTY_XML_LOCATION_IN_JAR", "config");
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) GzipHandler(org.eclipse.jetty.servlets.gzip.GzipHandler) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) File(java.io.File) Before(org.junit.Before)

Example 19 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class GoPlainSocketConnectorTest method setUp.

@Before
public void setUp() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    when(systemEnvironment.getServerPort()).thenReturn(1234);
    when(systemEnvironment.get(SystemEnvironment.RESPONSE_BUFFER_SIZE)).thenReturn(100);
    when(systemEnvironment.get(SystemEnvironment.IDLE_TIMEOUT)).thenReturn(200);
    when(systemEnvironment.getListenHost()).thenReturn("foo");
    when(systemEnvironment.get(SystemEnvironment.GO_SSL_CONFIG_ALLOW)).thenReturn(true);
    when(systemEnvironment.get(SystemEnvironment.GO_SSL_RENEGOTIATION_ALLOWED)).thenReturn(true);
    Jetty9Server server = new Jetty9Server(systemEnvironment, null, mock(SSLSocketFactory.class));
    connector = (ServerConnector) new GoPlainSocketConnector(server, systemEnvironment).getConnector();
    HttpConnectionFactory connectionFactory = (HttpConnectionFactory) connector.getDefaultConnectionFactory();
    configuration = connectionFactory.getHttpConfiguration();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Jetty9Server(com.thoughtworks.go.server.Jetty9Server) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) Before(org.junit.Before)

Example 20 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class H2DatabaseTest method shouldThrowUpWhenBackupFails.

@Test
public void shouldThrowUpWhenBackupFails() throws Exception {
    File destDir = new File(".");
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    Database database = new H2Database(systemEnvironment);
    Database spy = spy(database);
    BasicDataSource dataSource = mock(BasicDataSource.class);
    Connection connection = mock(Connection.class);
    Statement statement = mock(Statement.class);
    doReturn(dataSource).when(spy).createDataSource();
    when(dataSource.getConnection()).thenReturn(connection);
    when(connection.createStatement()).thenReturn(statement);
    when(statement.execute(anyString())).thenThrow(new SQLException("i failed"));
    try {
        spy.backup(destDir);
    } catch (RuntimeException e) {
        assertThat(e.getMessage(), is("i failed"));
    }
    verify(statement).execute(anyString());
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Database(com.thoughtworks.go.database.Database) Connection(java.sql.Connection) File(java.io.File) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) Test(org.junit.Test)

Aggregations

SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)174 Test (org.junit.Test)93 Before (org.junit.Before)38 File (java.io.File)37 AgentInstance (com.thoughtworks.go.domain.AgentInstance)27 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)14 ArrayList (java.util.ArrayList)14 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)10 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)10 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)9 AgentConfig (com.thoughtworks.go.config.AgentConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)7 Date (java.util.Date)7 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)6