You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2013/08/01 22:57:18 UTC
svn commit: r1509429 - in /qpid/proton/trunk/proton-c/bindings/ruby:
lib/qpid_proton/message.rb spec/qpid/proton/message_spec.rb
Author: mcpierce
Date: Thu Aug 1 20:57:17 2013
New Revision: 1509429
URL: http://svn.apache.org/r1509429
Log:
PROTON-369: Add the properties= method to Ruby Message.
Also fixed a few small bugs caused by using the clone method on assigned
values to properties, instructions and annotations.
Modified:
qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/message.rb
qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb
Modified: qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/message.rb
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/message.rb?rev=1509429&r1=1509428&r2=1509429&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/message.rb (original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/message.rb Thu Aug 1 20:57:17 2013
@@ -134,6 +134,8 @@ module Qpid
Cproton.pn_message_clear(@impl)
@properties.clear unless @properties.nil?
@instructions.clear unless @instructions.nil?
+ @annotations.clear unless @annotations.nil?
+ @body = nil
end
# Returns the most recent error number.
@@ -521,6 +523,12 @@ module Qpid
@properties
end
+ # Replaces the entire set of properties with the specified hash.
+ #
+ def properties=(properties)
+ @properties = properties
+ end
+
# Assigns the value given to the named property.
#
# ==== Arguments
@@ -554,7 +562,7 @@ module Qpid
# Assigns instructions to this message.
#
def instructions=(instr)
- @instructions = instr.nil? ? nil : instr.clone
+ @instructions = instr
end
# Returns the annotations for this message.
@@ -566,7 +574,7 @@ module Qpid
# Assigns annotations to this message.
#
def annotations=(annotations)
- @annotations = annotations.nil? ? nil : annotations.clone
+ @annotations = annotations
end
# Returns the body property of the message.
Modified: qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb?rev=1509429&r1=1509428&r2=1509429&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb (original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb Thu Aug 1 20:57:17 2013
@@ -419,12 +419,20 @@ module Qpid
it "has properties" do
@message.should respond_to(:properties)
- @message.should respond_to("[]".to_sym)
- @message.should respond_to("[]=".to_sym)
+ @message.should respond_to(:properties=)
+ @message.should respond_to(:[])
+ @message.should respond_to(:[]=)
@message.properties.should be_kind_of({}.class)
end
+ it "can replace the set of properties" do
+ values = random_hash(128)
+
+ @message.properties = values.clone
+ @message.properties.should eq values
+ end
+
it "can set properties" do
name = random_string(16)
value = random_string(128)
@@ -467,6 +475,17 @@ module Qpid
@message.properties.keys.should_not include(name)
end
+ it "has no properties after being cleared" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message[name] = value
+ @message[name].should eq(value)
+
+ @message.clear
+ @message.properties.should be_empty
+ end
+
it "has instructions" do
@message.should respond_to(:instructions)
@message.should respond_to("instructions=".to_sym)
@@ -506,25 +525,36 @@ module Qpid
it "can replace the instructions" do
values = random_hash(rand(128) + 1)
- @message.instructions = values
+ @message.instructions = values.clone
@message.instructions.should eq values
values = random_hash(rand(64) + 1)
- @message.instructions = values
+ @message.instructions = values.clone
@message.instructions.should eq values
end
it "can delete the set of instructions" do
values = random_hash(rand(128) + 1)
- @message.instructions = values
+ @message.instructions = values.clone
@message.instructions.should eq values
@message.instructions = nil
@message.instructions.should be_nil
end
+ it "has no instructions after being cleared" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message.instructions = value
+ @message.instructions.should eq(value)
+
+ @message.clear
+ @message.instructions.should be_empty
+ end
+
it "has annotations" do
@message.should respond_to(:annotations)
@message.should respond_to(:annotations=)
@@ -534,7 +564,7 @@ module Qpid
name = random_hash(32)
value = random_hash(256)
- @message.annotations[name] = value
+ @message.annotations[name] = value.clone
@message.annotations[name].should eq(value)
end
@@ -542,12 +572,12 @@ module Qpid
name = random_hash(32)
value = random_hash(256)
- @message.annotations[name] = value
+ @message.annotations[name] = value.clone
@message.annotations[name].should eq(value)
value = random_hash(128)
- @message.annotations[name] = value
+ @message.annotations[name] = value.clone
@message.annotations[name].should eq(value)
end
@@ -555,7 +585,7 @@ module Qpid
name = random_hash(32)
value = random_hash(256)
- @message.annotations[name] = value
+ @message.annotations[name] = value.clone
@message.annotations[name].should eq(value)
@message.annotations[name] = nil
@@ -565,25 +595,36 @@ module Qpid
it "can replace all annotations" do
values = random_hash(rand(128) + 1)
- @message.annotations = values
+ @message.annotations = values.clone
@message.annotations.should eq values
values = random_hash(rand(64) + 1)
- @message.annotations = values
+ @message.annotations = values.clone
@message.annotations.should eq values
end
it "can delete the set of annotations" do
values = random_hash(rand(128) + 1)
- @message.annotations = values
+ @message.annotations = values.clone
@message.annotations.should eq values
@message.annotations = nil
@message.annotations.should be_nil
end
+ it "has no annotations after being cleared" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message.annotations = value
+ @message.annotations.should eq(value)
+
+ @message.clear
+ @message.annotations.should be_empty
+ end
+
it "has a body property" do
@message.should respond_to(:body)
@message.should respond_to(:body=)
@@ -593,6 +634,17 @@ module Qpid
@message.body.should be_nil
end
+ it "has no body after being cleared" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message.body = value
+ @message.body.should eq(value)
+
+ @message.clear
+ @message.body.should be_nil
+ end
+
it "can set the body property" do
(1..3).each do |which|
case which
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org