Commit 6669178c5b24a81ad63bf676437c7d070ef94497

Authored by Carlos Morais + Eduardo Morais
Committed by Carlos Morais
1 parent f909e2e2

[mezuro] Integration testing Kalibro::Client::Port

Using KalibroFake/EchoEndpoint to test base tool communication
Fix NativeMetrics.languages
plugins/mezuro/lib/kalibro/entities/native_metric.rb
@@ -10,4 +10,8 @@ class Kalibro::Entities::NativeMetric < Kalibro::Entities::Metric @@ -10,4 +10,8 @@ class Kalibro::Entities::NativeMetric < Kalibro::Entities::Metric
10 @language = languages 10 @language = languages
11 end 11 end
12 12
  13 + def language=(value)
  14 + @language = to_entity_array(value)
  15 + end
  16 +
13 end 17 end
plugins/mezuro/test/fixtures/base_tool_fixtures.rb
  1 +require File.dirname(__FILE__) + '/native_metric_fixtures'
  2 +
1 class BaseToolFixtures 3 class BaseToolFixtures
2 4
3 def self.analizo 5 def self.analizo
plugins/mezuro/test/functional/base_tool_client_test.rb
@@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
1 -require "test_helper"  
2 -require File.dirname(__FILE__) + '/fake_port'  
3 -  
4 -class BaseToolClientTest < ActiveSupport::TestCase  
5 -  
6 - def setup  
7 - fake_port = FakePort.new('BaseTool')  
8 - Kalibro::Client::Port.expects(:new).with('BaseTool').returns(fake_port)  
9 - @client = Kalibro::Client::BaseToolClient.new  
10 - end  
11 -  
12 - should 'get base tool names' do  
13 - assert_equal ['Analizo', 'Checkstyle'], @client.base_tool_names  
14 - end  
15 -  
16 - should 'get base tool by name' do  
17 - analizo = @client.base_tool('Analizo')  
18 - assert_equal 'Analizo', analizo.name  
19 - assert_equal 'Analizo description', analizo.description  
20 - assert_equal 1, analizo.supported_metrics.size  
21 - metric = analizo.supported_metrics[0]  
22 - assert_equal 'Analizo', metric.origin  
23 - assert_equal 'Analizo metric', metric.name  
24 - assert_equal 'Analizo metric description', metric.description  
25 - assert_equal 'METHOD', metric.scope  
26 - assert_equal ['CPP', 'JAVA'], metric.languages  
27 - end  
28 -  
29 -end  
30 \ No newline at end of file 0 \ No newline at end of file
plugins/mezuro/test/functional/echo_port_test.rb 0 → 100644
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
  1 +require "test_helper"
  2 +
  3 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures"
  4 +
  5 +class EchoPortTest < ActiveSupport::TestCase
  6 +
  7 + def setup
  8 + @port = Kalibro::Client::Port.new('Echo')
  9 +# @port.service_address=('http://valinhos.ime.usp.br:50688/KalibroFake/');
  10 + @port.service_address=('http://localhost:8080/KalibroFake/');
  11 + end
  12 +
  13 + should 'echo base tool' do
  14 + base_tool = BaseToolFixtures.analizo
  15 + echoed = @port.request(:echo_base_tool, {:base_tool => base_tool.to_hash})[:base_tool]
  16 + base_tool.name = "echo " + base_tool.name
  17 + assert_equal base_tool, Kalibro::Entities::BaseTool.from_hash(echoed)
  18 + end
  19 +
  20 +end
0 \ No newline at end of file 21 \ No newline at end of file
plugins/mezuro/test/functional/fake_port.rb
@@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
1 -class FakePort < Kalibro::Client::Port  
2 -  
3 - def initialize(endpoint)  
4 - super(endpoint)  
5 - self.service_address = 'http://localhost:8080/KalibroFake/'  
6 - end  
7 -end  
plugins/mezuro/test/functional/metric_configuration_client_test.rb
@@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
1 -require "test_helper"  
2 -require File.dirname(__FILE__) + '/fake_port'  
3 -  
4 -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures"  
5 -  
6 -class MetricConfigurationClientTest < ActiveSupport::TestCase  
7 -  
8 - def setup  
9 - fake_port = FakePort.new('MetricConfiguration')  
10 - Kalibro::Client::Port.expects(:new).with('MetricConfiguration').returns(fake_port)  
11 - @client = Kalibro::Client::MetricConfigurationClient.new  
12 - end  
13 -  
14 - should 'save metric configuration' do  
15 - configuration = MetricConfigurationFixtures.amloc_configuration  
16 - @client.save(configuration, 'Configuration X')  
17 - end  
18 -  
19 - should 'get metric configuration by name' do  
20 - configuration = @client.metric_configuration('C', 'native')  
21 - assert_equal 'metricOfC', configuration.code  
22 - assert_equal 1.0, configuration.weight  
23 - assert_equal 'AVERAGE', configuration.aggregation_form  
24 - assert_equal 1, configuration.ranges.size  
25 -  
26 - range = configuration.ranges[0]  
27 - assert_equal -1.0/0.0, range.beginning  
28 - assert_equal 1.0/0.0, range.end  
29 -  
30 - metric = configuration.metric  
31 - puts metric  
32 - assert metric.is_a?(Kalibro::Entities::NativeMetric)  
33 - assert_equal 'Metric of C', metric.name  
34 - assert_equal 'METHOD', metric.scope  
35 - assert_equal ['JAVA'], metric.languages  
36 - assert_equal 'Metric of C description', metric.description  
37 - end  
38 -  
39 - should 'remove metric configuration by name' do  
40 - @client.remove('Configuration X', 'Metric X')  
41 - end  
42 -  
43 -end  
44 \ No newline at end of file 0 \ No newline at end of file