Search in sources :

Example 6 with JobInstanceLog

use of com.thoughtworks.go.domain.JobInstanceLog in project gocd by gocd.

the class JobInstanceLogTest method shouldNotCauseExceptionIfFilesAreNotAvailable.

@Test
public void shouldNotCauseExceptionIfFilesAreNotAvailable() throws Exception {
    rootFolder = new File("root");
    final File testOutput = new File(rootFolder, "testoutputxxxxxxx");
    HashMap map = new HashMap();
    map.put("artifactfolder", testOutput);
    jobInstanceLog = new JobInstanceLog(null, map);
    assertThat(jobInstanceLog.getTestIndexPage(), is(nullValue()));
}
Also used : HashMap(java.util.HashMap) File(java.io.File) JobInstanceLog(com.thoughtworks.go.domain.JobInstanceLog) Test(org.junit.Test)

Example 7 with JobInstanceLog

use of com.thoughtworks.go.domain.JobInstanceLog in project gocd by gocd.

the class JobInstanceLogTest method setUp.

@Before
public void setUp() {
    context = new Mockery();
    context.setImposteriser(ClassImposteriser.INSTANCE);
    jobInstanceLog = new JobInstanceLog(null, new HashMap());
    defaultLogFile = new LogFile(new File("log20051209122103.xml"));
    rootFolder = new File("root");
    rootFolder.mkdirs();
    env = new SystemEnvironment();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) HashMap(java.util.HashMap) Mockery(org.jmock.Mockery) File(java.io.File) JobInstanceLog(com.thoughtworks.go.domain.JobInstanceLog) Before(org.junit.Before)

Example 8 with JobInstanceLog

use of com.thoughtworks.go.domain.JobInstanceLog in project gocd by gocd.

the class JobInstanceLogTest method canGetNumberOfTestsFromBuild.

@Test
public void canGetNumberOfTestsFromBuild() {
    BuildTestSuite suiteWithFiveTests = new BuildTestSuite("", 0.0f);
    suiteWithFiveTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    suiteWithFiveTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    suiteWithFiveTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    suiteWithFiveTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    suiteWithFiveTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    BuildTestSuite suiteWithFourTests = new BuildTestSuite("", 0.0f);
    suiteWithFourTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    suiteWithFourTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    suiteWithFourTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    suiteWithFourTests.addTestCase(new BuildTestCase(null, null, null, null, null, null));
    List nineTests = new ArrayList();
    nineTests.add(suiteWithFiveTests);
    nineTests.add(suiteWithFourTests);
    Map props = new HashMap();
    props.put("testsuites", nineTests);
    JobInstanceLog laterJob = new JobInstanceLog(defaultLogFile, props);
    assertEquals(9, laterJob.getNumberOfTests());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JobInstanceLog(com.thoughtworks.go.domain.JobInstanceLog) Test(org.junit.Test)

Example 9 with JobInstanceLog

use of com.thoughtworks.go.domain.JobInstanceLog in project gocd by gocd.

the class JobInstanceLogTest method canGetNumberOfFailedTests.

@Test
public void canGetNumberOfFailedTests() {
    BuildTestSuite suiteWithTwoFailures = new BuildTestSuite("", 0.0f);
    suiteWithTwoFailures.addTestCase(new BuildTestCase(null, null, null, null, null, BuildTestCaseResult.FAILED));
    suiteWithTwoFailures.addTestCase(new BuildTestCase(null, null, null, null, null, BuildTestCaseResult.FAILED));
    BuildTestSuite suiteWithOneFailure = new BuildTestSuite("", 0.0f);
    suiteWithOneFailure.addTestCase(new BuildTestCase(null, null, null, null, null, BuildTestCaseResult.FAILED));
    List threeFailures = new ArrayList();
    threeFailures.add(suiteWithTwoFailures);
    threeFailures.add(suiteWithOneFailure);
    Map props = new HashMap();
    props.put("testsuites", threeFailures);
    JobInstanceLog laterJob = new JobInstanceLog(defaultLogFile, props);
    assertEquals(3, laterJob.getNumberOfFailures());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JobInstanceLog(com.thoughtworks.go.domain.JobInstanceLog) Test(org.junit.Test)

Example 10 with JobInstanceLog

use of com.thoughtworks.go.domain.JobInstanceLog in project gocd by gocd.

the class JobInstanceLogTest method shouldFindIndexPageFromTestOutput.

@Test
public void shouldFindIndexPageFromTestOutput() throws Exception {
    rootFolder = new File("root");
    final File testOutput = new File(rootFolder, "testoutput");
    testOutput.mkdirs();
    File indexHtml = new File(testOutput, "index.html");
    FileOutputStream fileOutputStream = new FileOutputStream(indexHtml);
    IOUtils.write("Test", fileOutputStream);
    IOUtils.closeQuietly(fileOutputStream);
    HashMap map = new HashMap();
    map.put("artifactfolder", rootFolder);
    jobInstanceLog = new JobInstanceLog(null, map);
    assertThat(jobInstanceLog.getTestIndexPage(), is(indexHtml));
}
Also used : HashMap(java.util.HashMap) FileOutputStream(java.io.FileOutputStream) File(java.io.File) JobInstanceLog(com.thoughtworks.go.domain.JobInstanceLog) Test(org.junit.Test)

Aggregations

JobInstanceLog (com.thoughtworks.go.domain.JobInstanceLog)10 HashMap (java.util.HashMap)9 Test (org.junit.Test)8 File (java.io.File)6 FileOutputStream (java.io.FileOutputStream)4 Map (java.util.Map)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 LogFile (com.thoughtworks.go.server.domain.LogFile)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 Mockery (org.jmock.Mockery)1 Before (org.junit.Before)1