]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 16 Oct 2014 06:38:47 +0000 (08:38 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 16 Oct 2014 06:39:05 +0000 (08:39 +0200)
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java
sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java
sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java

index 12f231c17e8c1dce90c6d4b0470b4acd35151804..bd297b6117299afadd4cd9b5e37d7b0b8333064f 100644 (file)
@@ -76,16 +76,18 @@ public class TestCaseSensor implements Sensor {
       String status = split.next();
       String message = split.next();
       String stack = split.next();
-      long duration = Long.parseLong(split.next());
-      context.newTestCaseExecution()
+      String durationStr = StringUtils.trimToNull(split.next());
+      TestCaseExecution test = context.newTestCaseExecution()
         .inTestFile(testFile)
         .name(name)
         .ofType(TestCaseExecution.Type.valueOf(type))
         .status(TestCaseExecution.Status.valueOf(status))
         .message(StringUtils.trimToNull(message))
-        .stackTrace(StringUtils.trimToNull(stack))
-        .durationInMs(duration)
-        .save();
+        .stackTrace(StringUtils.trimToNull(stack));
+      if (durationStr != null) {
+        test.durationInMs(Long.parseLong(durationStr));
+      }
+      test.save();
     } catch (Exception e) {
       throw new IllegalStateException("Error processing line " + lineNumber + " of file " + testplanFile.getAbsolutePath(), e);
     }
index 9b0bcf722db7c2a46f09ff7d918bbfd3b906f3e4..3e31d653a69a95777cf47e22de41bcb58f548ed5 100644 (file)
@@ -74,13 +74,17 @@ class DefaultTestCaseExecutionValueCoder implements ValueCoder {
     long duration = value.getLong();
     TestCaseExecution.Type type = TestCaseExecution.Type.values()[value.getInt()];
     TestCaseExecution.Status status = TestCaseExecution.Status.values()[value.getInt()];
-    return new DefaultTestCaseExecution()
+    DefaultTestCaseExecution testCaseExecution = new DefaultTestCaseExecution();
+    testCaseExecution
       .inTestFile(testFile)
       .ofType(type)
       .name(name)
-      .durationInMs(duration != -1 ? duration : null)
       .status(status)
       .message(message)
       .stackTrace(stack);
+    if (duration != -1) {
+      testCaseExecution.durationInMs(duration);
+    }
+    return testCaseExecution;
   }
 }
index 1261ef7166da3d0abcaa0589fe3520850a9f05c2..937e17306f5f4e481e000d315fce8fe9e3e9de04 100644 (file)
@@ -73,7 +73,7 @@ public class TestMediumTest {
     File xooTestFile = new File(testDir, "sampleTest.xoo");
     File xooTestPlanFile = new File(testDir, "sampleTest.xoo.testplan");
     FileUtils.write(xooTestFile, "Sample test xoo\ncontent");
-    FileUtils.write(xooTestPlanFile, "test1:UNIT:OK:::3\ntest2:INTEGRATION:ERROR:Assertion failure:A very long stack:12");
+    FileUtils.write(xooTestPlanFile, "test1:UNIT:OK:::\ntest2:INTEGRATION:ERROR:Assertion failure:A very long stack:12");
 
     TaskResult result = tester.newTask()
       .properties(ImmutableMap.<String, String>builder()