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 16:40:38 UTC
svn commit: r1509262 - in /qpid/proton/trunk:
examples/messenger/ruby/recv.rb examples/messenger/ruby/send.rb
proton-c/bindings/ruby/ChangeLog
proton-c/bindings/ruby/lib/qpid_proton/message.rb
proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb
Author: mcpierce
Date: Thu Aug 1 14:40:37 2013
New Revision: 1509262
URL: http://svn.apache.org/r1509262
Log:
PROTON-380: Added the body property to Ruby Message class.
Includes Rspec tests and changes to the send.rb and recv.rb examples.
Modified:
qpid/proton/trunk/examples/messenger/ruby/recv.rb
qpid/proton/trunk/examples/messenger/ruby/send.rb
qpid/proton/trunk/proton-c/bindings/ruby/ChangeLog
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/examples/messenger/ruby/recv.rb
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/examples/messenger/ruby/recv.rb?rev=1509262&r1=1509261&r2=1509262&view=diff
==============================================================================
--- qpid/proton/trunk/examples/messenger/ruby/recv.rb (original)
+++ qpid/proton/trunk/examples/messenger/ruby/recv.rb Thu Aug 1 14:40:37 2013
@@ -76,6 +76,7 @@ loop do
puts "Properties: #{msg.properties}"
puts "Instructions: #{msg.instructions}"
puts "Annotations: #{msg.annotations}"
+ puts "Body: #{msg.body}"
end
end
Modified: qpid/proton/trunk/examples/messenger/ruby/send.rb
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/examples/messenger/ruby/send.rb?rev=1509262&r1=1509261&r2=1509262&view=diff
==============================================================================
--- qpid/proton/trunk/examples/messenger/ruby/send.rb (original)
+++ qpid/proton/trunk/examples/messenger/ruby/send.rb Thu Aug 1 14:40:37 2013
@@ -52,6 +52,7 @@ messages.each do |message|
msg.instructions["mutilate"] = "no"
msg.annotations["version"] = 1.0
msg.annotations["pill"] = :RED
+ msg.body = "This is a message body. There are many like it but this one is mine."
begin
messenger.put(msg)
Modified: qpid/proton/trunk/proton-c/bindings/ruby/ChangeLog
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/ChangeLog?rev=1509262&r1=1509261&r2=1509262&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/ChangeLog (original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/ChangeLog Thu Aug 1 14:40:37 2013
@@ -11,6 +11,7 @@ version 0.5:
* Added instructions field to Qpid::Proton::Message.
* Added annotations field to Qpid::Proton::Message.
* Fixed encoding Symbol objects.
+ * Added body field to Qpid::Proton::Message.
version 0.4:
* No language-specific features developed in this release.
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=1509262&r1=1509261&r2=1509262&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 14:40:37 2013
@@ -57,6 +57,11 @@ module Qpid
if annts.next
@annotations = annts.type.get(annts)
end
+ @body = nil
+ body = Qpid::Proton::Data.new(Cproton::pn_message_body(@impl))
+ if body.next
+ @body = body.type.get(body)
+ end
end
# Encodes the message.
@@ -91,6 +96,12 @@ module Qpid
mapping = Qpid::Proton::Mapping.for_class(@annotations.class)
mapping.put(annts, @annotations)
end
+ body = Qpid::Proton::Data.new(Cproton::pn_message_body(@impl))
+ body.clear
+ if !@body.nil?
+ mapping = Qpid::Proton::Mapping.for_class(@body.class)
+ mapping.put(body, @body)
+ end
end
# Creates a new +Message+ instance.
@@ -100,6 +111,7 @@ module Qpid
@properties = {}
@instructions = {}
@annotations = {}
+ @body = nil
end
# Invoked by garbage collection to clean up resources used
@@ -557,6 +569,18 @@ module Qpid
@annotations = annotations.nil? ? nil : annotations.clone
end
+ # Returns the body property of the message.
+ #
+ def body
+ @body
+ end
+
+ # Assigns a new value to the body of the message.
+ #
+ def body=(body)
+ @body = body
+ end
+
private
def check(err) # :nodoc:
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=1509262&r1=1509261&r2=1509262&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 14:40:37 2013
@@ -584,6 +584,54 @@ module Qpid
@message.annotations.should be_nil
end
+ it "has a body property" do
+ @message.should respond_to(:body)
+ @message.should respond_to(:body=)
+ end
+
+ it "has a default body that is nil" do
+ @message.body.should be_nil
+ end
+
+ it "can set the body property" do
+ (1..3).each do |which|
+ case which
+ when 0
+ value = random_string(32)
+ when 1
+ value = random_array(100)
+ when 2
+ value = random_hash(100)
+ when 3
+ value = rand(512)
+ end
+
+ @message.body = value
+ @message.body.should eq(value)
+ end
+ end
+
+ it "can update the body property" do
+ (1..3).each do |which|
+ case which
+ when 0
+ value = random_string(32)
+ when 1
+ value = random_array(100)
+ when 2
+ value = random_hash(100)
+ when 3
+ value = rand(512)
+ end
+
+ @message.body = value
+ @message.body.should eq(value)
+
+ @message.body = nil
+ @message.body.should be_nil
+ end
+ end
+
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org