Return-Path: X-Original-To: apmail-deltacloud-commits-archive@www.apache.org Delivered-To: apmail-deltacloud-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C0E629A0A for ; Thu, 24 Nov 2011 13:19:15 +0000 (UTC) Received: (qmail 65483 invoked by uid 500); 24 Nov 2011 13:19:15 -0000 Delivered-To: apmail-deltacloud-commits-archive@deltacloud.apache.org Received: (qmail 65469 invoked by uid 500); 24 Nov 2011 13:19:15 -0000 Mailing-List: contact commits-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list commits@deltacloud.apache.org Received: (qmail 65462 invoked by uid 99); 24 Nov 2011 13:19:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Nov 2011 13:19:15 +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, 24 Nov 2011 13:19:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D0E9C23889BB for ; Thu, 24 Nov 2011 13:18:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1205812 - in /deltacloud/trunk/server/spec: ./ cimi/model/ Date: Thu, 24 Nov 2011 13:18:50 -0000 To: commits@deltacloud.apache.org From: mfojtik@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111124131850.D0E9C23889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mfojtik Date: Thu Nov 24 13:18:49 2011 New Revision: 1205812 URL: http://svn.apache.org/viewvc?rev=1205812&view=rev Log: CIMI: Added 'should_properly_serialize_model' helper to RSpec tests Modified: deltacloud/trunk/server/spec/cimi/model/machine_admin_spec.rb deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb deltacloud/trunk/server/spec/cimi/model/machine_spec.rb deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb deltacloud/trunk/server/spec/cimi/model/volume_spec.rb deltacloud/trunk/server/spec/spec_helper.rb Modified: deltacloud/trunk/server/spec/cimi/model/machine_admin_spec.rb URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/spec/cimi/model/machine_admin_spec.rb?rev=1205812&r1=1205811&r2=1205812&view=diff ============================================================================== --- deltacloud/trunk/server/spec/cimi/model/machine_admin_spec.rb (original) +++ deltacloud/trunk/server/spec/cimi/model/machine_admin_spec.rb Thu Nov 24 13:18:49 2011 @@ -21,18 +21,8 @@ describe "MachineAdmin model" do @json = IO::read(File::join(DATA_DIR, "machine_admin.json")) end - it "can be constructed from XML" do - conf = CIMI::Model::MachineAdmin.from_xml(@xml) - conf.should_not be_nil - should_serialize_from_xml! conf, @xml, @json + it "can be constructed from XML and JSON" do + should_properly_serialize_model CIMI::Model::MachineAdmin, @xml, @json end - it "can be constructed from JSON" do - conf = CIMI::Model::MachineAdmin.from_json(@json) - conf.should_not be_nil - should_serialize_from_json! conf, @xml, @json - end - - - end Modified: deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb?rev=1205812&r1=1205811&r2=1205812&view=diff ============================================================================== --- deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb (original) +++ deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb Thu Nov 24 13:18:49 2011 @@ -20,16 +20,8 @@ describe "MachineConfiguration model" do @json = IO::read(File::join(DATA_DIR, "machine_configuration.json")) 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 - - 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 + it "can be constructed from XML and JSON" do + should_properly_serialize_model CIMI::Model::MachineConfiguration, @xml, @json end end Modified: deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb?rev=1205812&r1=1205811&r2=1205812&view=diff ============================================================================== --- deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb (original) +++ deltacloud/trunk/server/spec/cimi/model/machine_image_spec.rb Thu Nov 24 13:18:49 2011 @@ -21,16 +21,9 @@ describe "MachineImage model" do @json = IO::read(File::join(DATA_DIR, "machine_image.json")) end - it "can be constructed from XML" do - img = CIMI::Model::MachineImage.from_xml(@xml) - img.should_not be_nil - should_serialize_from_xml! img, @xml, @json + it "can be constructed from XML and JSON" do + should_properly_serialize_model CIMI::Model::MachineImage, @xml, @json end - it "can be constructed from JSON" do - img = CIMI::Model::MachineImage.from_json(@json) - img.should_not be_nil - should_serialize_from_json! img, @xml, @json - end end Modified: deltacloud/trunk/server/spec/cimi/model/machine_spec.rb URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/spec/cimi/model/machine_spec.rb?rev=1205812&r1=1205811&r2=1205812&view=diff ============================================================================== --- deltacloud/trunk/server/spec/cimi/model/machine_spec.rb (original) +++ deltacloud/trunk/server/spec/cimi/model/machine_spec.rb Thu Nov 24 13:18:49 2011 @@ -20,21 +20,8 @@ describe "Machine model" do @json = IO::read(File::join(DATA_DIR, "machine.json")) end - it "should hold just machine schema" do - CIMI::Model::Machine.schema.attribute_names.should_not include(:image_location) - CIMI::Model::Machine.schema.attribute_names.should include(:meters) - end - - it "can be constructed from XML" do - machine = CIMI::Model::Machine.from_xml(@xml) - machine.should_not be_nil - should_serialize_from_xml! machine, @xml, @json - end - - it "can be constructed from JSON" do - machine = CIMI::Model::Machine.from_json(@json) - machine.should_not be_nil - should_serialize_from_json! machine, @xml, @json + it "can be constructed from XML and JSON" do + should_properly_serialize_model CIMI::Model::Machine, @xml, @json end end Modified: deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb?rev=1205812&r1=1205811&r2=1205812&view=diff ============================================================================== --- deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb (original) +++ deltacloud/trunk/server/spec/cimi/model/machine_template_spec.rb Thu Nov 24 13:18:49 2011 @@ -20,16 +20,8 @@ describe "MachineTemplate model" do @json = IO::read(File::join(DATA_DIR, "machine_template.json")) 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 - - 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 + it "can be constructed from XML and JSON" do + should_properly_serialize_model CIMI::Model::MachineTemplate, @xml, @json end end Modified: deltacloud/trunk/server/spec/cimi/model/volume_spec.rb URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/spec/cimi/model/volume_spec.rb?rev=1205812&r1=1205811&r2=1205812&view=diff ============================================================================== --- deltacloud/trunk/server/spec/cimi/model/volume_spec.rb (original) +++ deltacloud/trunk/server/spec/cimi/model/volume_spec.rb Thu Nov 24 13:18:49 2011 @@ -21,16 +21,8 @@ describe "Volume model" do @json = IO::read(File::join(DATA_DIR, "volume.json")) end - it "can be constructed from XML" do - conf = CIMI::Model::Volume.from_xml(@xml) - conf.should_not be_nil - should_serialize_from_xml! conf, @xml, @json - end - - it "can be constructed from JSON" do - conf = CIMI::Model::Volume.from_json(@json) - conf.should_not be_nil - should_serialize_from_json! conf, @xml, @json + it "can be constructed from XML and JSON" do + should_properly_serialize_model CIMI::Model::Volume, @xml, @json end end Modified: deltacloud/trunk/server/spec/spec_helper.rb URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/spec/spec_helper.rb?rev=1205812&r1=1205811&r2=1205812&view=diff ============================================================================== --- deltacloud/trunk/server/spec/spec_helper.rb (original) +++ deltacloud/trunk/server/spec/spec_helper.rb Thu Nov 24 13:18:49 2011 @@ -90,14 +90,13 @@ class HashCmp end end -def should_serialize_from_xml!(model, xml, json) - model.to_xml.should serialize_to xml, :fmt => :xml - model.to_json.should serialize_to json, :fmt => :json -end - -def should_serialize_from_json!(model, xml, json) - model.to_xml.should serialize_to xml, :fmt => :xml - model.to_json.should serialize_to json, :fmt => :json +def should_properly_serialize_model(model_class, xml, json) + # Roundtrip in same format + model_class.from_xml(xml).should serialize_to xml, :fmt => :xml + model_class.from_json(json).should serialize_to json, :fmt => :json + # Roundtrip crossing format + model_class.from_xml(xml).should serialize_to json, :fmt => :json + model_class.from_json(json).should serialize_to xml, :fmt => :xml end RSpec::Matchers.define :serialize_to do |exp, opts|