diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java | 4 | ||||
-rw-r--r-- | tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java b/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java index 90960996b8c..69f0289f440 100644 --- a/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java +++ b/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java @@ -32,7 +32,7 @@ public class MavenLogs { * Total time: 3:14.025s */ public static Long extractTotalTime(String logs) { - Pattern pattern = Pattern.compile(".*Total time: (\\d*:)?(\\d+).(\\d+)s.*"); + Pattern pattern = Pattern.compile("^.*Total time: (\\d*:)?(\\d+).(\\d+)s.*$", Pattern.DOTALL); Matcher matcher = pattern.matcher(logs); if (matcher.matches()) { String minutes = StringUtils.defaultIfBlank(StringUtils.removeEnd(matcher.group(1), ":"), "0"); @@ -41,7 +41,7 @@ public class MavenLogs { return (Long.parseLong(minutes) * 60000) + (Long.parseLong(seconds) * 1000) + Long.parseLong(millis); } - return null; + throw new IllegalStateException("Maven logs do not contain \"Total time\""); } /** diff --git a/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java b/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java index 22f945b98f6..434c02510bf 100644 --- a/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java +++ b/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java @@ -28,8 +28,8 @@ import static org.fest.assertions.Assertions.assertThat; public class MavenLogsTest { @Test public void testExtractTotalTime() throws Exception { - assertThat(MavenLogs.extractTotalTime(" Total time: 6.015s ")).isEqualTo(6015); - assertThat(MavenLogs.extractTotalTime(" Total time: 3:14.025s ")).isEqualTo(194025); + assertThat(MavenLogs.extractTotalTime(" \n Total time: 6.015s \n ")).isEqualTo(6015); + assertThat(MavenLogs.extractTotalTime(" \n Total time: 3:14.025s\n ")).isEqualTo(194025); } @Test |