Permalink
Browse files

changed converter to ignore poorly formed XML as a result of bad SONA…

…R settings, For No Resource tags, and no measurement tags
  • Loading branch information...
1 parent 93ebb72 commit 47c387f0870d75d0fe1dd2e2425f9002041c4ea8 @dingusj1 dingusj1 committed Jan 20, 2012
Showing with 71 additions and 1 deletion.
  1. +1 −1 lib/bvm/converter.rb
  2. +19 −0 spec/improperResponseFromSonar.rb
  3. +19 −0 spec/measurementsMissing.rb
  4. +30 −0 spec/noMeasures.xml
  5. +2 −0 spec/noResources.xml
View
@@ -41,7 +41,7 @@ def build_output(resource, jar, size, color, adjust)
color_metric += adjust
%Q/#{size_metric},#{color_metric},"#{jar}","#{package}","#{name}"\n/
else
- %Q/1,#{adjust},"NotFound","#{package}","#{name}"\n/
+ %Q/1.0,#{adjust},"NotFound","#{package}","#{name}"\n/
end
end
@@ -0,0 +1,19 @@
+require 'bvm'
+
+describe "BVM" do
+
+ describe Converter do
+
+ before(:each) do
+ @input = File.read('spec/noResources.xml')
+ @converter = Converter.new
+ end
+
+ it "Does not process input files with no resource tags" do
+ output = @converter.convert @input
+ output.should == ""
+ end
+
+ end
+
+end
@@ -0,0 +1,19 @@
+require 'bvm'
+
+describe "BVM" do
+
+ describe Converter do
+
+ before(:each) do
+ @input = File.read('spec/noMeasures.xml')
+ @converter = Converter.new
+ end
+
+ it "Does not process input files with no measure tags" do
+ output = @converter.convert @input
+ output.should == %Q/100.0,0.8,\"jar\",\"package\",\"Class\"\n1.0,0.0,\"NotFound\",\"other.package\",\"OtherClass\"\n300.0,0.2,\"jar\",\"other.package\",\"ThirdClass\"\n/
+ end
+
+ end
+
+end
View
@@ -0,0 +1,30 @@
+<resources>
+ <resource>
+ <key>package.Class</key>
+ <name>Class</name>
+ <msr>
+ <key>ncloc</key>
+ <val>100</val>
+ </msr>
+ <msr>
+ <key>coverage</key>
+ <val>0.8</val>
+ </msr>
+ </resource>
+ <resource>
+ <key>other.package.OtherClass</key>
+ <name>OtherClass</name>
+ </resource>
+ <resource>
+ <key>other.package.ThirdClass</key>
+ <name>ThirdClass</name>
+ <msr>
+ <key>ncloc</key>
+ <val>300</val>
+ </msr>
+ <msr>
+ <key>coverage</key>
+ <val>0.2</val>
+ </msr>
+ </resource>
+</resources>
View
@@ -0,0 +1,2 @@
+<resources>
+</resources>

0 comments on commit 47c387f

Please sign in to comment.