qpid_messaging 0.20.0 → 0.20.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -33,6 +33,7 @@ require "rdoc/task"
33
33
  require "rake/testtask"
34
34
 
35
35
  require "cucumber/rake/task"
36
+ require "rspec/core/rake_task"
36
37
 
37
38
  CLOBBER.include("pkg")
38
39
 
@@ -55,6 +56,44 @@ task :default => :test
55
56
  desc "Runs all tests."
56
57
  task :test => :"test:all"
57
58
 
59
+ #---------------
60
+ # Testing tasks.
61
+ #---------------
62
+
63
+ namespace :test do
64
+
65
+ desc "Run RSpec tests."
66
+ RSpec::Core::RakeTask.new do |t|
67
+ t.ruby_opts = ['-rtest/unit']
68
+ t.rcov = false
69
+ t.rcov_opts = [
70
+ '--exclude', 'lib\/qpid_messaging.rb,spec\/,lib\/ruby',
71
+ ]
72
+ end
73
+
74
+ desc "Run all tests (default)."
75
+ task :all => [:spec, :features]
76
+
77
+ Cucumber::Rake::Task.new(:features) do |t|
78
+ t.libs = ["lib", "ext/nonblockio"]
79
+ t.cucumber_opts = "--format progress"
80
+ end
81
+
82
+ end
83
+
84
+ #---------------------
85
+ # Documentation tasks.
86
+ #---------------------
87
+
88
+ Rake::RDocTask.new(:rdoc => "rdoc",
89
+ :clobber_rdoc => "rdoc:clean",
90
+ :rerdoc => "rdoc:force") do |rd|
91
+ rd.main = "README.rdoc"
92
+ rd.options << "--all"
93
+ rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
94
+ rd.title = "Qpid Messaging Documentation"
95
+ end
96
+
58
97
  #-----------------
59
98
  # Package the gem.
60
99
  #-----------------
data/examples/client.rb CHANGED
@@ -29,9 +29,7 @@ if __FILE__ == $0
29
29
  connection.open
30
30
  session = connection.create_session
31
31
  sender = session.create_sender "service_queue"
32
- response_queue = Qpid::Messaging::Address.new("#response-queue", "",
33
- :create => :always,
34
- :delete => :always)
32
+ response_queue = Qpid::Messaging::Address.new("#response-queue;{create:always}")
35
33
  receiver = session.create_receiver response_queue
36
34
 
37
35
  ["Twas brillig, and the slithy toves",
data/ext/cqpid/extconf.rb CHANGED
@@ -26,9 +26,10 @@
26
26
  require 'mkmf'
27
27
 
28
28
  # Setup the build environment.
29
- $CFLAGS = "-fPIC -fno-inline -x c++"
29
+ $CFLAGS = "-fPIC -fno-inline -x c++ -lstdc++"
30
30
 
31
31
  REQUIRED_LIBRARIES = [
32
+ 'stdc++',
32
33
  'qpidclient',
33
34
  'qpidcommon',
34
35
  'qpidmessaging',
@@ -25,5 +25,5 @@ Feature: Creating a receiver
25
25
 
26
26
  Scenario: Using an Address object
27
27
  Given an open session
28
- And an Address with the name "create-receiver-test" and subject "foo" and option "create" set to "always" and "delete" set to "always"
28
+ And an Address with the string "create-receiver-test;{create:always}"
29
29
  Then creating a receiver with an Address succeeds
@@ -21,5 +21,5 @@ Feature: Creating a sender
21
21
 
22
22
  Scenario: Using an Address object
23
23
  Given an open session
24
- And an Address with the name "my-queue" and subject "my-subject" and option "create" set to "always"
24
+ And an Address with the string "my-queue/my-subject;{create:always}"
25
25
  Then creating a sender with an Address succeeds
@@ -17,15 +17,6 @@
17
17
  # under the License.
18
18
  #
19
19
 
20
- Given /^an Address with the name "([^"]*)" and subject "([^"]*)" and option "([^"]*)" set to "([^"]*)"$/ do |name, subject, key, value|
21
- options = Hash.new
22
- options["#{key}"] = "#{value}"
23
- @address = Qpid::Messaging::Address.new "#{name}", "#{subject}", options
24
- end
25
-
26
- Given /^an Address with the name "([^"]*)" and subject "([^"]*)" and option "([^"]*)" set to "([^"]*)" and "([^"]*)" set to "([^"]*)"$/ do |name, subject, key1, value1, key2, value2|
27
- options = Hash.new
28
- options["#{key1}"] = "#{value1}"
29
- options["#{key2}"] = "#{value2}"
30
- @address = Qpid::Messaging::Address.new "#{name}", "#{subject}", options
20
+ Given /^an Address with the string "(.*?)"$/ do |address|
21
+ @address = Qpid::Messaging::Address.new "#{address}"
31
22
  end
@@ -70,26 +70,18 @@ module Qpid
70
70
  #
71
71
  class Address
72
72
 
73
- # Creates a new +Address+ object.
73
+ # Creates a new +Address+ object from an address string.
74
74
  #
75
75
  # ==== Options
76
76
  #
77
- # * name - The name for the +Address+.
78
- # * subject - The subject for the +Address+
79
- # * :create - See the class documentation.
80
- # * :assert - See the class documentation.
81
- # * :delete - See the class documentation.
82
- # * :node - See the class documentation.
83
- # * :link - See the class documentation.
84
- # * :mode - See the class documentation.
77
+ # * address - the address string
85
78
  #
86
79
  # ==== Examples
87
80
  #
88
- # addr = Qpid::Messaging::Address.new "my-queue"
89
- # addr = Qpid::Messaging::Address.new "my-queue", "testing", :create => :always
81
+ # addr = Qpid::Messaging::Address.new "my-queue;{create:always}"
90
82
  #
91
- def initialize(name, subject, options = {}, _type = "", address_impl = nil)
92
- @address_impl = address_impl || Cqpid::Address.new(name, subject, convert_options(options), _type)
83
+ def initialize(address, address_impl = nil)
84
+ @address_impl = address_impl || Cqpid::Address.new(address)
93
85
  end
94
86
 
95
87
  def address_impl # :nodoc:
@@ -23,35 +23,52 @@ module Qpid
23
23
 
24
24
  # Encodes the supplied content into the given message.
25
25
  def self.encode content, message, encoding = nil
26
- prepared = content
27
- case content
28
- when Hash
29
- prepared = {}
30
- content.each_pair do |key,value|
31
- prepared[key.to_s] = value.to_s
32
- end
33
- Cqpid::encode prepared, message.message_impl
34
- when Array
35
- prepared = []
36
- content.each {|value| prepared << value.to_s}
37
- Cqpid::encode prepared, message.message_impl
38
- end
26
+ Cqpid::encode content, message.message_impl, encoding
39
27
  end
40
28
 
41
29
  # Decodes and returns the message's content.
42
30
  def self.decode(message, content_type = nil)
43
- content_type = message.content_type unless content_type
31
+ content_type = message.content_type if content_type.nil?
44
32
 
45
33
  case content_type
46
34
  when "amqp/map"
47
- Cqpid.decodeMap message.message_impl
35
+ return Cqpid.decodeMap message.message_impl
48
36
  when "amqp/list"
49
- Cqpid.decodeList message.message_impl
37
+ return Cqpid.decodeList message.message_impl
50
38
  end
51
39
 
52
40
  message.content
53
41
  end
54
42
 
43
+ # Takes as input any type and converts anything that's a symbol
44
+ # into a string.
45
+ def self.stringify(value)
46
+ # set the default value
47
+ result = value
48
+
49
+ case value
50
+
51
+ when Symbol
52
+ result = value.to_s
53
+
54
+ when Hash
55
+ result = {}
56
+ value.each_pair do |key, value|
57
+ result[stringify(key)] = stringify(value)
58
+ end
59
+
60
+ when Array
61
+ result = []
62
+ value.each do |element|
63
+ result << stringify(element)
64
+ end
65
+
66
+ end
67
+
68
+ return result
69
+
70
+ end
71
+
55
72
  end
56
73
 
57
74
  end
@@ -51,18 +51,18 @@ module Qpid
51
51
 
52
52
  # Sets the address to which replies should be sent for the +Message+.
53
53
  #
54
- # *NOTE:* The address must be an instance of Address.
55
- #
56
54
  # ==== Options
57
55
  #
58
- # * address - an instance of +Address+
56
+ # * address - an instance of +Address+, or an address string
59
57
  #
60
58
  # ==== Examples
61
59
  #
62
60
  # msg.reply_to = Qpid:Messaging::Address.new "my-responses"
61
+ # msg.reply_to = "my-feed/responses"
63
62
  #
64
63
  def reply_to=(address)
65
- raise ArgumentError, "Agument must be an Address" unless address.is_a? Qpid::Messaging::Address
64
+ address = Qpid::Messaging::Address.new "#{address}" if !address.is_a? Qpid::Messaging::Address
65
+
66
66
  @message_impl.setReplyTo address.address_impl
67
67
  end
68
68
 
@@ -71,7 +71,7 @@ module Qpid
71
71
  def reply_to
72
72
  address_impl = @message_impl.getReplyTo
73
73
  # only return an address if a reply to was specified
74
- Qpid::Messaging::Address.new(nil, nil, nil, nil, address_impl) if address_impl
74
+ Qpid::Messaging::Address.new(nil, address_impl) if address_impl
75
75
  end
76
76
 
77
77
  # Sets the subject for the +Message+.
@@ -283,14 +283,14 @@ module Qpid
283
283
 
284
284
  # Assigns a value to the named property.
285
285
  #
286
- # *NOTE:* Both the key or the value may be a symbol, but they will
287
- # both be converted to a +String+ for ease of transport.
288
- #
289
286
  # ==== Options
290
287
  #
291
288
  # * name - the property name
292
289
  # * value - the property value
293
- def []=(key, value); @message_impl.setProperty(key.to_s, value.to_s); end
290
+ def []=(key, value)
291
+ @message_impl.setProperty(key.to_s,
292
+ Qpid::Messaging.stringify(value))
293
+ end
294
294
 
295
295
  # Sets the content for the +Message+.
296
296
  #
@@ -309,18 +309,12 @@ module Qpid
309
309
  #
310
310
  def content=(content)
311
311
  content_type = nil
312
- @content = content
312
+ @content = Qpid::Messaging.stringify(content)
313
313
  case @content
314
314
  when Hash
315
315
  content_type = "amqp/map"
316
- new_content = {}
317
- content.each_pair{|key, value| new_content[key.to_s] = value.to_s}
318
- @content = new_content
319
316
  when Array
320
- new_content = []
321
317
  content_type = "amqp/list"
322
- content.each {|element| new_content << element.to_s}
323
- @content = new_content
324
318
  end
325
319
  if content_type.nil?
326
320
  @message_impl.setContent @content
@@ -23,7 +23,7 @@ module Qpid #:nodoc:
23
23
 
24
24
  NUMBERS = [MAJOR = 0,
25
25
  MINOR = 20,
26
- BUILD = 0]
26
+ BUILD = 2]
27
27
  end
28
28
 
29
29
  VERSION = Version::NUMBERS.join('.')
@@ -26,7 +26,7 @@ module Qpid
26
26
  describe Address do
27
27
 
28
28
  before(:each) do
29
- @address = Qpid::Messaging::Address.new "my-name", "my-subject", :create => :always
29
+ @address = Qpid::Messaging::Address.new "my-name/my-subject;{create:always}"
30
30
  end
31
31
 
32
32
  it "stores the name, subject and options when created" do
@@ -72,7 +72,7 @@ module Qpid
72
72
  end
73
73
 
74
74
  it "can return a string representation" do
75
- address = Qpid::Messaging::Address.new "foo", "bar", :create => :always, :link => :durable
75
+ address = Qpid::Messaging::Address.new "foo/bar:{create:always,link:durable}"
76
76
  result = address.to_s
77
77
 
78
78
  result.should =~ /foo\/bar/
@@ -37,7 +37,7 @@ module Qpid
37
37
  connection = Qpid::Messaging::Connection.new :options => {:username => "foo"}
38
38
 
39
39
  connection.options.should include("username")
40
- }.should_not raise_error
40
+ }.to_not raise_error
41
41
  end
42
42
 
43
43
  it "returns the underlying implementation" do
@@ -36,7 +36,7 @@ module Qpid
36
36
  end
37
37
 
38
38
  it "can set the reply to address" do
39
- address = Qpid::Messaging::Address.new "my-queue", ""
39
+ address = Qpid::Messaging::Address.new "my-queue;{create:always}"
40
40
 
41
41
  @message.reply_to = address
42
42
 
@@ -45,6 +45,19 @@ module Qpid
45
45
  reply_to.name.should == address.name
46
46
  end
47
47
 
48
+ it "can set the reply to from an address string" do
49
+ name = "my-queue"
50
+ subject = "responses"
51
+ address = "#{name}/#{subject}"
52
+
53
+ @message.reply_to = address
54
+
55
+ reply_to = @message.reply_to
56
+
57
+ reply_to.name.should == name
58
+ reply_to.subject.should == subject
59
+ end
60
+
48
61
  it "should store the content when created" do
49
62
  content = @message.content
50
63
 
@@ -46,7 +46,7 @@ module Qpid
46
46
  end
47
47
 
48
48
  it "creates a Sender from an Address" do
49
- address = Qpid::Messaging::Address.new "my-queu", "", :create => :always
49
+ address = Qpid::Messaging::Address.new "my-queue;{create:always}"
50
50
 
51
51
  @session_impl.should_receive(:createSender).
52
52
  with(address.address_impl).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qpid_messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.20.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
12
+ date: 2013-03-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Qpid is an enterprise messaging framework.
15
15
  email: dev@qpid.apache.org
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 1.8.24
92
+ rubygems_version: 1.8.25
93
93
  signing_key:
94
94
  specification_version: 3
95
95
  summary: Qpid is an enterprise messaging framework.