Search in sources :

Example 11 with SystemEnvironment

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

the class EmailMessageDrafterTest method shouldDraftNoArtifactDiskSpaceEmail.

@Test
public void shouldDraftNoArtifactDiskSpaceEmail() throws Exception {
    String size = "2345";
    new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, size);
    String email = "admin@mail.com";
    SendEmailMessage message = EmailMessageDrafter.noArtifactsDiskSpaceMessage(new SystemEnvironment(), email, artifactRoot);
    String ip = SystemUtil.getFirstLocalNonLoopbackIpAddress();
    assertThat(message, is(new SendEmailMessage("No artifacts disk space error message from Go Server at " + ip, noArtifactDiskSpaceEmail(ip, size), email)));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Test(org.junit.Test)

Example 12 with SystemEnvironment

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

the class GoVelocityViewTest method shouldSetAssetsPathVariableWhenRailsNewWithCompressedJavascriptsIsUsed.

@Test
public void shouldSetAssetsPathVariableWhenRailsNewWithCompressedJavascriptsIsUsed() throws Exception {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    when(systemEnvironment.useCompressedJs()).thenReturn(true);
    when(railsAssetsService.getAssetPath("application.js")).thenReturn("assets/application-digest.js");
    when(railsAssetsService.getAssetPath("application.css")).thenReturn("assets/application-digest.css");
    when(railsAssetsService.getAssetPath("vm/application.css")).thenReturn("assets/vm/application-digest.css");
    when(railsAssetsService.getAssetPath("css/application.css")).thenReturn("assets/css/application-digest.css");
    when(railsAssetsService.getAssetPath("g9/stage_bar_cancelled_icon.png")).thenReturn("assets/g9/stage_bar_cancelled_icon.png");
    when(railsAssetsService.getAssetPath("spinner.gif")).thenReturn("assets/spinner.gif");
    when(railsAssetsService.getAssetPath("cruise.ico")).thenReturn("assets/cruise.ico");
    GoVelocityView view = spy(new GoVelocityView(systemEnvironment));
    doReturn(railsAssetsService).when(view).getRailsAssetsService();
    doReturn(versionInfoService).when(view).getVersionInfoService();
    Request servletRequest = mock(Request.class);
    when(servletRequest.getSession()).thenReturn(mock(HttpSession.class));
    view.exposeHelpers(velocityContext, servletRequest);
    assertThat(velocityContext.get(GoVelocityView.CONCATENATED_JAVASCRIPT_FILE_PATH), is("assets/application-digest.js"));
    assertThat(velocityContext.get(GoVelocityView.CONCATENATED_APPLICATION_CSS_FILE_PATH), is("assets/application-digest.css"));
    assertThat(velocityContext.get(GoVelocityView.CONCATENATED_VM_APPLICATION_CSS_FILE_PATH), is("assets/vm/application-digest.css"));
    assertThat(velocityContext.get(GoVelocityView.CONCATENATED_CSS_APPLICATION_CSS_FILE_PATH), is("assets/css/application-digest.css"));
    assertThat(velocityContext.get(GoVelocityView.CONCATENATED_STAGE_BAR_CANCELLED_ICON_FILE_PATH), is("assets/g9/stage_bar_cancelled_icon.png"));
    assertThat(velocityContext.get(GoVelocityView.CONCATENATED_SPINNER_ICON_FILE_PATH), is("assets/spinner.gif"));
    assertThat(velocityContext.get(GoVelocityView.CONCATENATED_CRUISE_ICON_FILE_PATH), is("assets/cruise.ico"));
    assertThat(velocityContext.get(GoVelocityView.PATH_RESOLVER), is(railsAssetsService));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) HttpSession(javax.servlet.http.HttpSession) Request(org.eclipse.jetty.server.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 13 with SystemEnvironment

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

the class ConsoleOutputTransmitterTest method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    // so the thread does not wake up
    new SystemEnvironment().setProperty(SystemEnvironment.INTERVAL, "60");
    requestArgumentCaptor = ArgumentCaptor.forClass(String.class);
    doNothing().when(consoleAppender).append(requestArgumentCaptor.capture());
    transmitter = new ConsoleOutputTransmitter(consoleAppender, 0, mock(ScheduledThreadPoolExecutor.class));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Matchers.containsString(org.hamcrest.Matchers.containsString) Before(org.junit.Before)

Example 14 with SystemEnvironment

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

the class BuildWorkArtifactUploadingTest method teardown.

@After
public void teardown() throws Exception {
    TestRepo.internalTearDown();
    FileUtil.deleteFolder(buildWorkingDirectory);
    new SystemEnvironment().clearProperty("serviceUrl");
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) After(org.junit.After)

Example 15 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)

Aggregations

SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)158 Test (org.junit.Test)82 Before (org.junit.Before)38 File (java.io.File)35 AgentInstance (com.thoughtworks.go.domain.AgentInstance)26 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)14 ArrayList (java.util.ArrayList)12 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)8 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)8 ZipUtil (com.thoughtworks.go.util.ZipUtil)8 Date (java.util.Date)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)7 AgentConfig (com.thoughtworks.go.config.AgentConfig)6 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)6 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5