Search in sources :

Example 6 with LogFile

use of com.thoughtworks.go.server.domain.LogFile in project gocd by gocd.

the class LogParserTest method testCanReadError.

@Test
public void testCanReadError() throws Exception {
    LogFile logFile = new LogFile(DataUtils.getFailedBuildLbuildAsFile().getFile());
    boolean isPassed = false;
    Map map = logParser.parseLogFile(logFile, isPassed);
    List suites = getTestSuites(map);
    BuildTestSuite firstSuite = (BuildTestSuite) suites.get(0);
    List erroringTestCases = firstSuite.getErrorTestCases();
    assertThat(erroringTestCases.size(), is(1));
    BuildTestCase erroredTest = (BuildTestCase) erroringTestCases.get(0);
    String expectedClassName = "net.sourceforge.cruisecontrol.sampleproject.connectfour.PlayingStandTest";
    String expectedNoClassDefFoundError = "java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor";
    String exptectedClassPath = "at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165)";
    assertThat(erroredTest.getClassname(), is(expectedClassName));
    assertThat(erroredTest.getDuration(), is("0.016"));
    assertThat(erroredTest.getName(), is("testFourConnected"));
    assertThat(erroredTest.didError(), is(true));
    assertThat(erroredTest.getMessage(), is("org/objectweb/asm/CodeVisitor"));
    assertThat(erroredTest.getMessageBody(), containsString(expectedNoClassDefFoundError));
    assertThat(erroredTest.getMessageBody(), containsString(exptectedClassPath));
}
Also used : LogFile(com.thoughtworks.go.server.domain.LogFile) BuildTestSuite(com.thoughtworks.go.server.domain.BuildTestSuite) BuildTestCase(com.thoughtworks.go.server.domain.BuildTestCase) List(java.util.List) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Map(java.util.Map) Test(org.junit.Test)

Aggregations

LogFile (com.thoughtworks.go.server.domain.LogFile)6 Map (java.util.Map)4 Test (org.junit.Test)4 File (java.io.File)3 BuildTestCase (com.thoughtworks.go.server.domain.BuildTestCase)2 BuildTestSuite (com.thoughtworks.go.server.domain.BuildTestSuite)2 HashMap (java.util.HashMap)2 List (java.util.List)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 JobInstance (com.thoughtworks.go.domain.JobInstance)1 JobInstanceLog (com.thoughtworks.go.domain.JobInstanceLog)1 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)1 IOException (java.io.IOException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Expectations (org.jmock.Expectations)1