Index: plugins/rubyMetrics/src/test/java/hudson/plugins/rubyMetrics/rcov/RcovParserTest.java
===================================================================
--- plugins/rubyMetrics/src/test/java/hudson/plugins/rubyMetrics/rcov/RcovParserTest.java (revision 13739)
+++ plugins/rubyMetrics/src/test/java/hudson/plugins/rubyMetrics/rcov/RcovParserTest.java (working copy)
@@ -26,9 +26,13 @@
assertTrue(result.getFiles().size() > 0);
- assertNotNull(result.getTotalCoverage());
- assertNotNull(result.getTotalLines());
- assertNotNull(result.getCodeCoverage());
- assertNotNull(result.getCodeLines());
+ assertNotNull("Total Coverage was null.", result.getTotalCoverage());
+ assertTrue("Total Coverage was an empty string", result.getTotalCoverage().trim().length() > 0);
+ assertNotNull("Total Lines was null.", result.getTotalLines());
+ assertTrue("Total lines was an empty string.", result.getTotalLines().trim().length() > 0);
+ assertNotNull("Code Coverage was null.", result.getCodeCoverage());
+ assertTrue("Code Coverage was an empty string.", result.getCodeCoverage().trim().length() > 0);
+ assertNotNull("Code lines was null.", result.getCodeLines());
+ assertTrue("Code Lines was an empty string.", result.getCodeLines().trim().length() > 0);
}
}
Index: plugins/rubyMetrics/src/test/resources/hudson/plugins/rubyMetrics/rcov/index.html
===================================================================
--- plugins/rubyMetrics/src/test/resources/hudson/plugins/rubyMetrics/rcov/index.html (revision 13739)
+++ plugins/rubyMetrics/src/test/resources/hudson/plugins/rubyMetrics/rcov/index.html (working copy)
@@ -159,20 +159,28 @@
TOTAL |
- 1005
- |
- 753
- |
- 85.5%
- |
- |
+
+ 1005
+ |
+
+ 753
+ |
+
+
- |
+
+
+ |
+
+
+ |
82.7%
|
|
Index: plugins/rubyMetrics/src/main/java/hudson/plugins/rubyMetrics/rcov/RcovParser.java
===================================================================
--- plugins/rubyMetrics/src/main/java/hudson/plugins/rubyMetrics/rcov/RcovParser.java (revision 13739)
+++ plugins/rubyMetrics/src/main/java/hudson/plugins/rubyMetrics/rcov/RcovParser.java (working copy)
@@ -27,6 +27,7 @@
import org.htmlparser.tags.TableRow;
import org.htmlparser.tags.TableTag;
import org.htmlparser.util.NodeList;
+import org.htmlparser.util.SimpleNodeIterator;
import org.htmlparser.util.ParserException;
public class RcovParser {
@@ -144,7 +145,15 @@
Node parent = first.getChildren() != null && first.getChildren().size() > 0?first:first.getParent();
parent.collectInto(nodeList, new NodeClassFilter(Text.class));
- text = nodeList.elementAt(0).getText();
+ SimpleNodeIterator nodeIterator = nodeList.elements();
+ // find the first non-empty text node.
+ while(nodeIterator.hasMoreNodes()) {
+ Node textNode = nodeIterator.nextNode();
+ text = textNode.getText();
+ if (text != null && (text = text.trim()).length() > 0) {
+ break;
+ }
+ }
}
return text;
|
|