Return-Path: X-Original-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 69F607BB3 for ; Thu, 17 Nov 2011 18:51:33 +0000 (UTC) Received: (qmail 9433 invoked by uid 500); 17 Nov 2011 18:51:33 -0000 Delivered-To: apmail-incubator-deltacloud-commits-archive@incubator.apache.org Received: (qmail 9414 invoked by uid 500); 17 Nov 2011 18:51:33 -0000 Mailing-List: contact deltacloud-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-commits@incubator.apache.org Received: (qmail 9407 invoked by uid 99); 17 Nov 2011 18:51:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2011 18:51:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2011 18:51:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4605C23889CB; Thu, 17 Nov 2011 18:51:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1203325 - in /incubator/deltacloud/trunk/server/spec/cimi/model: machine_configuration_spec.rb machine_image_spec.rb machine_template_spec.rb Date: Thu, 17 Nov 2011 18:51:11 -0000 To: deltacloud-commits@incubator.apache.org From: mfojtik@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111117185111.4605C23889CB@eris.apache.org> Author: mfojtik Date: Thu Nov 17 18:51:10 2011 New Revision: 1203325 URL: http://svn.apache.org/viewvc?rev=1203325&view=rev Log: CIMI: Revampled spec files once again to use the helpers for checking sanity of serialization Modified: incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb incubator/deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb incubator/deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb Modified: incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb?rev=1203325&r1=1203324&r2=1203325&view=diff ============================================================================== --- incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb (original) +++ incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb Thu Nov 17 18:51:10 2011 @@ -20,97 +20,16 @@ describe "MachineConfiguration model" do @json = IO::read(File::join(DATA_DIR, "machine_configuration.json")) end - describe 'XML' do - it "can be constructed" do - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) - conf.should_not be_nil - conf.should serialize_to @xml, :fmt => :xml - end - - it "should convert strings in keys to symbols when contructed from XML" do - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) - conf.should_not be_nil - conf.attribute_values.keys.each { |key| key.should be_a(Symbol) } - end - - it "should have default properties" do - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) - conf.name.should == 'MachineConfiguration1' - conf.uri == 'http://cimi.example.org/machine_configurations/1' - conf.description == 'Example MachineConfiguration One' - conf.created.should == "2011-11-14" - end - - it "should have cpu and memory properties" do - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) - conf.cpu.should == "2" - conf.memory.should be_an_instance_of Hash - conf.memory['quantity'].should == '1' - conf.memory['units'].should == 'gigabyte' - end - - it "should have disk array property with capacity" do - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) - conf.disk.size.should == 1 - conf.disk[0].respond_to?(:capacity).should be_true - conf.disk[0].capacity.size.should == 1 - conf.disk[0].capacity[0]['format'] == 'ext4' - conf.disk[0].capacity[0]['quantity'] == '1' - conf.disk[0].capacity[0]['attachmentPoint'] == '/' - conf.disk[0].capacity[0]['units'] == 'terabyte' - end - - it "should have edit and delete operations" do - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) - conf.operations.size.should == 2 - conf.operations.any? { |operation| operation.rel == 'edit' }.should be_true - conf.operations.any? { |operation| operation.rel == 'delete' }.should be_true - conf.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } - end + it "can be constructed from XML" do + conf = CIMI::Model::MachineConfiguration.from_xml(@xml) + conf.should_not be_nil + should_serialize_from_xml! conf, @xml, @json end - describe "JSON" do - it "can be constructed" do - conf = CIMI::Model::MachineConfiguration.from_json(@json) - conf.should_not be_nil - conf.should serialize_to @json, :fmt => :json - end - - it "should have default properties" do - conf = CIMI::Model::MachineConfiguration.from_json(@json) - conf.name.should == 'MachineConfiguration1' - conf.uri == 'http://cimi.example.org/machine_configurations/1' - conf.description == 'Example MachineConfiguration One' - conf.created.should == "2011-11-14" - end - - it "should have cpu and memory properties" do - conf = CIMI::Model::MachineConfiguration.from_json(@json) - conf.cpu.should == "2" - conf.memory.should be_an_instance_of Hash - conf.memory['quantity'].should == '1' - conf.memory['units'].should == 'gigabyte' - end - - it "should have disk array property with capacity" do - conf = CIMI::Model::MachineConfiguration.from_json(@json) - conf.disk.should be_an_instance_of Array - conf.disk.size.should > 0 - conf.disk[0].should respond_to :capacity - conf.disk[0].capacity.size.should == 1 - conf.disk[0].capacity[0]['format'] == 'ext4' - conf.disk[0].capacity[0]['quantity'] == '1' - conf.disk[0].capacity[0]['attachmentPoint'] == '/' - conf.disk[0].capacity[0]['units'] == 'terabyte' - end - - it "should have edit and delete operations" do - conf = CIMI::Model::MachineConfiguration.from_json(@json) - conf.operations.size.should == 2 - conf.operations.any? { |operation| operation.rel == 'edit' }.should be_true - conf.operations.any? { |operation| operation.rel == 'delete' }.should be_true - conf.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } - end - + it "can be constructed from JSON" do + conf = CIMI::Model::MachineConfiguration.from_json(@json) + conf.should_not be_nil + should_serialize_from_json! conf, @xml, @json end + end Modified: incubator/deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb?rev=1203325&r1=1203324&r2=1203325&view=diff ============================================================================== --- incubator/deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb (original) +++ incubator/deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb Thu Nov 17 18:51:10 2011 @@ -21,82 +21,16 @@ describe "MachineImage model" do @json = IO::read(File::join(DATA_DIR, "machine_image.json")) end - describe "XML" do - it "can be constructed" do - img = CIMI::Model::MachineImage.from_xml(@xml) - img.should_not be_nil - img.should serialize_to @xml, :fmt => :xml - end - - it "should have default properties" do - img = CIMI::Model::MachineImage.from_xml(@xml) - img.uri.should == "http://cimi.example.org/machine_image/1" - img.name.should == "img1" - img.description.should == "Machine Image One" - img.created.should == "2011-11-14" - end - - it "should have image location property" do - img = CIMI::Model::MachineImage.from_xml(@xml) - img.image_location.should be_an_instance_of Hash - img.image_location['href'].should == 'nfs://cimi.example.com/images/1.img' - end - - it "should have edit and delete operations" do - img = CIMI::Model::MachineImage.from_xml(@xml) - img.operations.any? { |operation| operation.rel == 'edit' }.should be_true - img.operations.any? { |operation| operation.rel == 'delete' }.should be_true - img.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } - end - - it "should parse properties correctly in XML" do - img = CIMI::Model::MachineImage.from_xml(@xml) - img.property.any? { |p| p.name == 'status' }.should be_true - img.property.any? { |p| p.name == 'locked' }.should be_true - img.property.size.should == 2 - end - - it "should convert strings in keys to symbols when contructed from XML" do - imgl = CIMI::Model::MachineImage.from_xml(@xml) - imgl.should_not be_nil - imgl.attribute_values.keys.each { |key| key.should be_a_kind_of(Symbol) } - end + it "can be constructed from XML" do + conf = CIMI::Model::MachineImage.from_xml(@xml) + conf.should_not be_nil + should_serialize_from_xml! conf, @xml, @json end - describe 'JSON' do - it "can be constructed" do - img = CIMI::Model::MachineImage.from_json(@json) - img.should_not be_nil - img.should serialize_to @json, :fmt => :json - end - - it "should have default properties" do - img = CIMI::Model::MachineImage.from_json(@json) - img.uri.should == "http://cimi.example.org/machine_images/1" - img.name.should == "img1" - img.description.should == "Machine Image One" - img.created.should == "2011-11-14" - end - - it "should have image location property" do - img = CIMI::Model::MachineImage.from_json(@json) - img.image_location.should be_an_instance_of Hash - img.image_location['href'].should == 'nfs://cimi.example.com/images/1.img' - end - - it "should have edit and delete operations" do - img = CIMI::Model::MachineImage.from_json(@json) - img.operations.any? { |operation| operation.rel == 'edit' }.should be_true - img.operations.any? { |operation| operation.rel == 'delete' }.should be_true - img.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } - end - - it "should parse properties correctly in XML" do - img = CIMI::Model::MachineImage.from_json(@json) - img.property.any? { |p| p.name == 'status' }.should be_true - img.property.any? { |p| p.name == 'locked' }.should be_true - img.property.size.should == 2 - end + it "can be constructed from JSON" do + conf = CIMI::Model::MachineImage.from_json(@json) + conf.should_not be_nil + should_serialize_from_json! conf, @xml, @json end end Modified: incubator/deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb?rev=1203325&r1=1203324&r2=1203325&view=diff ============================================================================== --- incubator/deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb (original) +++ incubator/deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb Thu Nov 17 18:51:10 2011 @@ -20,152 +20,16 @@ describe "MachineTemplate model" do @json = IO::read(File::join(DATA_DIR, "machine_template.json")) end - describe 'XML' do - it "can be constructed" do - templ = CIMI::Model::MachineTemplate.from_xml(@xml) - templ.should_not be_nil - templ.should serialize_to @xml, :fmt => :xml - end - - it "should have default properties" do - templ = CIMI::Model::MachineTemplate.from_xml(@xml) - templ.created.should == "2011-11-01" - templ.name.should == "My First Template" - templ.description.should == "A template for testing" - templ.uri.should == "http://cimi.example.org/machine_templates/1" - end - - it "should convert strings in keys to symbols when contructed from XML" do - templ = CIMI::Model::MachineTemplate.from_xml(@xml) - templ.should_not be_nil - templ.attribute_values.keys.each { |key| key.should be_a_kind_of(Symbol) } - end - - it "should reference machine_config" do - templ = CIMI::Model::MachineTemplate.from_xml(@xml) - templ.machine_config.should be_an_instance_of Struct::CIMI_MachineConfig - templ.machine_config.href.should == "http://cimi.example.org/machine_configs/1" - end - - it "should reference machine_image" do - templ = CIMI::Model::MachineTemplate.from_xml(@xml) - templ.machine_image.should be_an_instance_of Struct::CIMI_MachineImage - templ.machine_image.href.should == "http://cimi.example.org/machine_images/1" - end - - it "should have list of attached volumes" do - templ = CIMI::Model::MachineTemplate.from_xml(@xml) - templ.volumes.should be_a_kind_of Array - templ.volumes.each do |volume| - volume.href.should =~ /^http:\/\/.*\/volumes\/(\w+)$/ - volume.protocol.should == 'nfs' - volume.attachment_point == '/dev/sda' - volume.should be_an_instance_of Struct::CIMI_Volume - end - end - - it "should have list of network interfaces" do - templ = CIMI::Model::MachineTemplate.from_xml(@xml) - templ.network_interfaces.should be_an_instance_of Array - templ.network_interfaces.each do |interface| - interface.hostname == 'host.cimi.example.org' - interface.mac_address == '00:11:22:33:44:55' - interface.state == 'UP' - interface.protocol == 'TCP' - interface.allocation == 'static' - interface.address == '192.168.0.17' - interface.default_gateway == '192.168.0.1' - interface.dns == '192.168.0.1' - interface.max_transmission_unit == '1500' - interface.vsp.should_not be_nil - interface.vsp.should be_an_instance_of Struct::CIMI_Vsp - interface.vsp.href.should =~ /^http:\/\/.*\/vsps\/(\w+)$/ - interface.should be_an_instance_of Struct::CIMI_NetworkInterface - end - end - - it "should have edit and delete operations" do - templ = CIMI::Model::MachineTemplate.from_xml(@xml) - templ.operations.size.should == 2 - templ.operations.any? { |operation| operation.rel == 'edit' }.should be_true - templ.operations.any? { |operation| operation.rel == 'delete' }.should be_true - templ.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } - end - + it "can be constructed from XML" do + conf = CIMI::Model::MachineTemplate.from_xml(@xml) + conf.should_not be_nil + should_serialize_from_xml! conf, @xml, @json end - describe 'JSON' do - it "can be constructed" do - templ = CIMI::Model::MachineTemplate.from_json(@json) - templ.should_not be_nil - templ.should serialize_to @xml, :fmt => :xml - end - - it "should have default properties" do - templ = CIMI::Model::MachineTemplate.from_json(@json) - templ.created.should == "2011-11-01" - templ.name.should == "My First Template" - templ.description.should == "A template for testing" - templ.uri.should == "http://cimi.example.org/machine_templates/1" - end - - it "should convert strings in keys to symbols when contructed from XML" do - templ = CIMI::Model::MachineTemplate.from_json(@json) - templ.should_not be_nil - templ.attribute_values.keys.each { |key| key.should be_a_kind_of(Symbol) } - end - - it "should reference machine_config" do - templ = CIMI::Model::MachineTemplate.from_json(@json) - templ.machine_config.should be_an_instance_of Struct::CIMI_MachineConfig - templ.machine_config.href.should == "http://cimi.example.org/machine_configs/1" - end - - it "should reference machine_image" do - templ = CIMI::Model::MachineTemplate.from_json(@json) - templ.machine_image.should be_an_instance_of Struct::CIMI_MachineImage - templ.machine_image.href.should == "http://cimi.example.org/machine_images/1" - end - - it "should have list of attached volumes" do - templ = CIMI::Model::MachineTemplate.from_json(@json) - templ.volumes.should be_a_kind_of Array - templ.volumes.each do |volume| - volume.href.should =~ /^http:\/\/.*\/volumes\/(\w+)$/ - volume.protocol.should == 'nfs' - volume.attachment_point == '/dev/sda' - volume.should be_an_instance_of Struct::CIMI_Volume - end - end - - it "should have list of network interfaces" do - templ = CIMI::Model::MachineTemplate.from_json(@json) - templ.network_interfaces.should be_an_instance_of Array - templ.network_interfaces.each do |interface| - interface.hostname == 'host.cimi.example.org' - interface.mac_address == '00:11:22:33:44:55' - interface.state == 'UP' - interface.protocol == 'TCP' - interface.allocation == 'static' - interface.address == '192.168.0.17' - interface.default_gateway == '192.168.0.1' - interface.dns == '192.168.0.1' - interface.max_transmission_unit == '1500' - interface.vsp.should_not be_nil - interface.vsp.should be_an_instance_of Struct::CIMI_Vsp - interface.vsp.href.should =~ /^http:\/\/.*\/vsps\/(\w+)$/ - interface.should be_an_instance_of Struct::CIMI_NetworkInterface - end - end - - it "should have edit and delete operations" do - templ = CIMI::Model::MachineTemplate.from_json(@json) - templ.operations.size.should == 2 - templ.operations.any? { |operation| operation.rel == 'edit' }.should be_true - templ.operations.any? { |operation| operation.rel == 'delete' }.should be_true - templ.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } - end - + it "can be constructed from JSON" do + conf = CIMI::Model::MachineTemplate.from_json(@json) + conf.should_not be_nil + should_serialize_from_json! conf, @xml, @json end end