Search in sources :

Example 1 with RunIf

use of com.googlecode.junit.ext.RunIf in project gocd by gocd.

the class BuilderTest method shouldReportErrorWhenCancelCommandDoesNotExists.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void shouldReportErrorWhenCancelCommandDoesNotExists() throws Exception {
    StubBuilder stubBuilder = new StubBuilder();
    CommandBuilder cancelBuilder = new CommandBuilder("echo2", "cancel task", new File("."), new RunIfConfigs(FAILED), stubBuilder, "");
    CommandBuilder builder = new CommandBuilder("echo", "normal task", new File("."), new RunIfConfigs(FAILED), cancelBuilder, "");
    builder.cancel(goPublisher, new EnvironmentVariableContext(), null);
    assertThat(goPublisher.getMessage(), containsString("Error happened while attempting to execute 'echo2 cancel task'"));
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 2 with RunIf

use of com.googlecode.junit.ext.RunIf in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldNotAllowAbsoluteDestFolderNamesOnWindows.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { EnhancedOSChecker.WINDOWS })
public void shouldNotAllowAbsoluteDestFolderNamesOnWindows() throws Exception {
    String materials1 = "  <materials>\n" + "    <svn url=\"/hgrepo2\" dest=\"C:\\tmp\\foo\" />\n" + "  </materials>\n";
    MagicalGoConfigXmlLoaderFixture.assertNotValid("Dest folder 'C:\\tmp\\foo' is not valid. It must be a sub-directory of the working folder.", materials1);
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 3 with RunIf

use of com.googlecode.junit.ext.RunIf in project gocd by gocd.

the class BuildWorkTest method shouldReportErrorWhenComandIsNotExistOnWindows.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { EnhancedOSChecker.WINDOWS })
public void shouldReportErrorWhenComandIsNotExistOnWindows() throws Exception {
    buildWork = (BuildWork) getWork(CMD_NOT_EXIST, PIPELINE_NAME);
    buildWork.doWork(agentIdentifier, buildRepository, artifactManipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    assertThat(artifactManipulator.consoleOut(), printedAppsMissingInfoOnWindows(SOMETHING_NOT_EXIST));
    assertThat(buildRepository.results, containsResult(Failed));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 4 with RunIf

use of com.googlecode.junit.ext.RunIf in project gocd by gocd.

the class BuildWorkTest method shouldReportErrorWhenComandIsNotExistOnLinux.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void shouldReportErrorWhenComandIsNotExistOnLinux() throws Exception {
    buildWork = (BuildWork) getWork(CMD_NOT_EXIST, PIPELINE_NAME);
    buildWork.doWork(agentIdentifier, buildRepository, artifactManipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    assertThat(artifactManipulator.consoleOut(), printedAppsMissingInfoOnUnix(SOMETHING_NOT_EXIST));
    assertThat(buildRepository.results, containsResult(Failed));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 5 with RunIf

use of com.googlecode.junit.ext.RunIf in project gocd by gocd.

the class MaterialRepositoryWithH2IntegrationTest method materialFingerprintShouldUseTheHashAlgoritmInMigration47.

@Test
@RunIf(value = DatabaseChecker.class, arguments = { DatabaseChecker.H2 })
public void materialFingerprintShouldUseTheHashAlgoritmInMigration47() throws Exception {
    final HgMaterial material = new HgMaterial("url", null);
    byte[] fingerprint = (byte[]) repo.getHibernateTemplate().execute(new HibernateCallback() {

        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            String pattern = format("'type=%s%surl=%s'", material.getType(), AbstractMaterial.FINGERPRINT_DELIMITER, material.getUrl());
            SQLQuery query = session.createSQLQuery(format("CALL HASH('SHA256', STRINGTOUTF8(%s), 1)", pattern));
            return query.uniqueResult();
        }
    });
    assertThat(Hex.encodeHexString(fingerprint), is(material.getFingerprint()));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HibernateCallback(org.springframework.orm.hibernate3.HibernateCallback) Matchers.containsString(org.hamcrest.Matchers.containsString) SQLQuery(org.hibernate.SQLQuery) Session(org.hibernate.Session) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Aggregations

RunIf (com.googlecode.junit.ext.RunIf)17 Test (org.junit.Test)15 File (java.io.File)7 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 JavaSysMon (com.jezhumble.javasysmon.JavaSysMon)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 OsProcess (com.jezhumble.javasysmon.OsProcess)1 ProcessVisitor (com.jezhumble.javasysmon.ProcessVisitor)1 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 BuildCommand (com.thoughtworks.go.domain.BuildCommand)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)1 ServerBackup (com.thoughtworks.go.server.domain.ServerBackup)1 LogFixture (com.thoughtworks.go.util.LogFixture)1 TimeProvider (com.thoughtworks.go.util.TimeProvider)1 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1