Search in sources :

Example 1 with JobInstanceLog

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

the class JobInstanceLogTest method shouldFindIndexPageFromTestOutputGivenNunitTestOutput.

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

Example 2 with JobInstanceLog

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

the class JobInstanceLogTest method shouldFindIndexPageFromTestOutputRecursivelyWithMultipleFolders.

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

Example 3 with JobInstanceLog

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

the class JobInstanceLogTest method canGetNumberOfTestErrors.

@Test
public void canGetNumberOfTestErrors() {
    BuildTestSuite suiteWithTwoErrors = new BuildTestSuite("", 0.0f);
    suiteWithTwoErrors.addTestCase(new BuildTestCase(null, null, null, null, null, BuildTestCaseResult.ERROR));
    suiteWithTwoErrors.addTestCase(new BuildTestCase(null, null, null, null, null, BuildTestCaseResult.ERROR));
    BuildTestSuite suiteWithThreeErrors = new BuildTestSuite("", 0.0f);
    suiteWithThreeErrors.addTestCase(new BuildTestCase(null, null, null, null, null, BuildTestCaseResult.ERROR));
    suiteWithThreeErrors.addTestCase(new BuildTestCase(null, null, null, null, null, BuildTestCaseResult.ERROR));
    suiteWithThreeErrors.addTestCase(new BuildTestCase(null, null, null, null, null, BuildTestCaseResult.ERROR));
    List fiveErrors = new ArrayList();
    fiveErrors.add(suiteWithTwoErrors);
    fiveErrors.add(suiteWithThreeErrors);
    Map props = new HashMap();
    props.put("testsuites", fiveErrors);
    JobInstanceLog laterJob = new JobInstanceLog(defaultLogFile, props);
    assertEquals(5, laterJob.getNumberOfErrors());
}
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 4 with JobInstanceLog

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

the class JobDetailService method loadBuildInstanceLog.

public void loadBuildInstanceLog(JobInstance instance) throws Exception {
    if (instance.isCompleted()) {
        LogFile logFile = artifactsService.getInstanceLogFile(instance.getIdentifier());
        Map properties = artifactsService.parseLogFile(logFile, instance.isPassed());
        properties.put("artifactfolder", artifactsService.findArtifact(instance.getIdentifier(), ""));
        instance.setInstanceLog(new JobInstanceLog(logFile, properties));
    }
}
Also used : LogFile(com.thoughtworks.go.server.domain.LogFile) Map(java.util.Map) JobInstanceLog(com.thoughtworks.go.domain.JobInstanceLog)

Example 5 with JobInstanceLog

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

the class JobInstanceLogTest method shouldFindIndexPageFromTestOutputRecursively.

@Test
public void shouldFindIndexPageFromTestOutputRecursively() throws Exception {
    final File testOutput = new File(rootFolder, "testoutput");
    final File junitReportFolder = new File(testOutput, "junitreport");
    junitReportFolder.mkdirs();
    FileOutputStream fileOutputStream = new FileOutputStream(new File(junitReportFolder, "index.html"));
    IOUtils.write("Test", fileOutputStream);
    IOUtils.closeQuietly(fileOutputStream);
    HashMap map = new HashMap();
    map.put("artifactfolder", rootFolder);
    jobInstanceLog = new JobInstanceLog(null, map);
    assertThat(jobInstanceLog.getTestIndexPage().getName(), is("index.html"));
}
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