Search in sources :

Example 21 with SystemEnvironment

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

the class H2DatabaseTest method shouldBackupDatabase.

@Test
public void shouldBackupDatabase() 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())).thenReturn(true);
    spy.backup(destDir);
    verify(statement).execute(anyString());
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) 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)

Example 22 with SystemEnvironment

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

the class ScheduleServiceRescheduleHungJobsTest method activities.

private AgentInstances activities() {
    AgentStatusChangeListener agentStatusChangeListener = mock(AgentStatusChangeListener.class);
    final AgentInstances activities = new AgentInstances(agentStatusChangeListener);
    SystemEnvironment systemEnvironment = new SystemEnvironment();
    activities.add(AgentInstance.createFromConfig(new AgentConfig("uuid1"), systemEnvironment, agentStatusChangeListener));
    activities.add(AgentInstance.createFromConfig(new AgentConfig("uuid2"), systemEnvironment, agentStatusChangeListener));
    return activities;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentInstances(com.thoughtworks.go.server.domain.AgentInstances) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

Example 23 with SystemEnvironment

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

the class ServerVersionInfoManagerTest method shouldBeFalseIfVersionCheckIsDisabled.

@Test
public void shouldBeFalseIfVersionCheckIsDisabled() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
    when(systemEnvironment.isProductionMode()).thenReturn(true);
    when(systemEnvironment.isGOUpdateCheckEnabled()).thenReturn(false);
    manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, systemEnvironment);
    manager.initialize();
    assertFalse(manager.isUpdateCheckEnabled());
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) VersionInfo(com.thoughtworks.go.domain.VersionInfo) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) Test(org.junit.Test)

Example 24 with SystemEnvironment

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

the class ServerVersionInfoManagerTest method updateCheckShouldBeDisabledForADevelopmentServer.

@Test
public void updateCheckShouldBeDisabledForADevelopmentServer() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
    when(systemEnvironment.isProductionMode()).thenReturn(false);
    when(systemEnvironment.isGOUpdateCheckEnabled()).thenReturn(true);
    manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, systemEnvironment);
    manager.initialize();
    assertFalse(manager.isUpdateCheckEnabled());
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) VersionInfo(com.thoughtworks.go.domain.VersionInfo) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) Test(org.junit.Test)

Example 25 with SystemEnvironment

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

the class StageNotificationServiceTest method setUp.

@Before
public void setUp() {
    pipelineService = mock(PipelineService.class);
    userService = mock(UserService.class);
    systemEnvironment = mock(SystemEnvironment.class);
    stageService = mock(StageService.class);
    inMemoryEmailNotificationTopic = new InMemoryEmailNotificationTopic();
    serverConfigService = mock(ServerConfigService.class);
    shineDao = mock(ShineDao.class);
    stageNotificationService = new StageNotificationService(pipelineService, userService, inMemoryEmailNotificationTopic, systemEnvironment, stageService, serverConfigService, shineDao);
    stageIdentifier = new StageIdentifier("go", 1, "go-1", "dev", "2");
    instanceFactory = new InstanceFactory();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ShineDao(com.thoughtworks.go.server.dao.sparql.ShineDao) InMemoryEmailNotificationTopic(com.thoughtworks.go.server.messaging.InMemoryEmailNotificationTopic) Before(org.junit.Before)

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