Search in sources :

Example 1 with Validation

use of com.thoughtworks.go.util.validators.Validation in project gocd by gocd.

the class GoServerTest method shouldRegisterSubprocessLoggerAsExit.

@Test
public void shouldRegisterSubprocessLoggerAsExit() throws Exception {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    Validation validation = mock(Validation.class);
    when(validation.isSuccessful()).thenReturn(true);
    StubGoServer goServer = new StubGoServer(systemEnvironment, validation);
    goServer.subprocessLogger = mock(SubprocessLogger.class);
    goServer.go();
    verify(goServer.subprocessLogger).registerAsExitHook("Following processes were alive at shutdown: ");
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Validation(com.thoughtworks.go.util.validators.Validation) SubprocessLogger(com.thoughtworks.go.util.SubprocessLogger) Test(org.junit.Test)

Example 2 with Validation

use of com.thoughtworks.go.util.validators.Validation in project gocd by gocd.

the class GoServerTest method shouldNotStartServerIfValidationFails.

@Test
public void shouldNotStartServerIfValidationFails() throws Exception {
    final SystemEnvironment systemEnvironment = context.mock(SystemEnvironment.class);
    Validation validation = new Validation().addError(new Exception("Server Port occupied"));
    StubGoServer goServer = new StubGoServer(systemEnvironment, validation);
    goServer.go();
    assertThat(goServer.wasStarted(), is(false));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Validation(com.thoughtworks.go.util.validators.Validation) Test(org.junit.Test)

Example 3 with Validation

use of com.thoughtworks.go.util.validators.Validation in project gocd by gocd.

the class GoServerValidatorTest method shouldValidatorServerBeforeStart.

@Test
public void shouldValidatorServerBeforeStart() throws IOException, InterruptedException {
    try {
        startServerOnPort(PORT_TO_TRY);
        serverPortValidator = new ServerPortValidator(PORT_TO_TRY);
        Validation validation = serverPortValidator.validate(new Validation());
        assertThat(validation.isSuccessful(), is(false));
    } finally {
        shutDownServer();
    }
}
Also used : Validation(com.thoughtworks.go.util.validators.Validation) ServerPortValidator(com.thoughtworks.go.util.validators.ServerPortValidator) Test(org.junit.Test)

Example 4 with Validation

use of com.thoughtworks.go.util.validators.Validation in project gocd by gocd.

the class GoServerValidatorTest method shouldNotFailIfPortIsAvailable.

@Test
public void shouldNotFailIfPortIsAvailable() throws IOException, InterruptedException {
    serverPortValidator = new ServerPortValidator(PORT_TO_TRY);
    Validation validation = serverPortValidator.validate(new Validation());
    assertThat(validation.isSuccessful(), is(true));
}
Also used : Validation(com.thoughtworks.go.util.validators.Validation) ServerPortValidator(com.thoughtworks.go.util.validators.ServerPortValidator) Test(org.junit.Test)

Example 5 with Validation

use of com.thoughtworks.go.util.validators.Validation in project gocd by gocd.

the class AgentBootstrapper method validate.

void validate() {
    Validation validation = new Validation();
    FileValidator.defaultFile(Downloader.AGENT_LAUNCHER, false).validate(validation);
    if (!validation.isSuccessful()) {
        validation.logErrors(LOG);
        throw new RuntimeException("Agent Bootstrapper initialization failed. Could not validate file: " + Downloader.AGENT_LAUNCHER);
    }
}
Also used : Validation(com.thoughtworks.go.util.validators.Validation)

Aggregations

Validation (com.thoughtworks.go.util.validators.Validation)5 Test (org.junit.Test)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 ServerPortValidator (com.thoughtworks.go.util.validators.ServerPortValidator)2 SubprocessLogger (com.thoughtworks.go.util.SubprocessLogger)1