You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/09/11 20:51:25 UTC
[1/2] qpid-proton git commit: PROTON-1457: Ruby tests fail when
dependencies are missing
Repository: qpid-proton
Updated Branches:
refs/heads/master 363d337b5 -> 5e1bce7a0
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/qpid/proton/hash_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/qpid/proton/hash_spec.rb b/proton-c/bindings/ruby/spec/qpid/proton/hash_spec.rb
deleted file mode 100644
index 7568ac1..0000000
--- a/proton-c/bindings/ruby/spec/qpid/proton/hash_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-require "spec_helper"
-
-describe "The extended hash type" do
-
- before :each do
- @data = Qpid::Proton::Codec::Data.new
- @hash = random_hash(rand(128) + 64)
- end
-
- it "raises an error when put into a nil Data instance" do
- expect {
- @hash.proton_data_put(nil)
- }.to raise_error(TypeError)
- end
-
- it "can be put into an instance of Data" do
- @hash.proton_data_put(@data)
- result = Hash.proton_data_get(@data)
- expect(result.keys).to match_array(@hash.keys)
- expect(result.values).to match_array(@hash.values)
- end
-
- it "raises an error when retrieved from a nil Data instance" do
- expect {
- Hash.proton_data_get(nil)
- }.to raise_error(TypeError)
- end
-
- it "raises an error when trying to get what is not a Hash" do
- @data.string = random_string(128)
- @data.rewind
-
- expect {
- Hash.proton_data_get(@data)
- }.to raise_error(TypeError)
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb b/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb
deleted file mode 100644
index 36e4695..0000000
--- a/proton-c/bindings/ruby/spec/qpid/proton/message_spec.rb
+++ /dev/null
@@ -1,638 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-require "spec_helper"
-
-module Qpid
-
- module Proton
-
- describe "A message" do
-
- before (:each) do
- @message = Qpid::Proton::Message.new
- end
-
- it "can be created" do
- expect(@message).not_to be_nil
- end
-
- it "can be cleared" do
- subject = random_string(16)
- @message.subject = subject
- expect(@message.subject).to eq(subject)
- @message.clear
- expect(@message.subject).not_to eq(subject)
- end
-
- it "can be durable" do
- @message.durable = true
- expect(@message.durable).to eq(true)
- @message.durable = false
- expect(@message.durable).to eq(false)
- end
-
- it "raises an error when setting durable to nil" do
- expect {
- @message.durable = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error when setting the priority to nil" do
- expect {
- @message.priority = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error when setting the priority to a non-number" do
- expect {
- @message.priority = "abck"
- }.to raise_error(TypeError)
- end
-
- it "sets the priority to the integer portion when a float" do
- priority = rand(100) / 10
- @message.priority = priority
- expect(@message.priority).to eq(priority.floor)
- end
-
- it "rejects a priority with too large of a value" do
- expect {
- @message.priority = (rand(100) + 256)
- }.to raise_error(RangeError)
- end
-
- it "rejects a negative priority" do
- expect {
- @message.priority = (0 - (rand(255) + 1))
- }.to raise_error(RangeError)
- end
-
- it "has a priority" do
- priority = rand(256)
- @message.priority = priority
- expect(@message.priority).to eq(priority)
- end
-
- it "raises an error when setting the time-to-live to nil" do
- expect {
- @message.ttl = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error when setting the time-to-live to a non-number" do
- expect {
- @message.ttl = random_string(5)
- }.to raise_error(TypeError)
- end
-
- it "sets the time-to-live to the integer portion when a float" do
- ttl = (rand(32767) / 10)
- @message.ttl = ttl
- expect(@message.ttl).to eq(ttl.floor)
- end
-
- it "raises an error when the time-to-live is negative" do
- expect {
- @message.ttl = (0 - rand(1000))
- }.to raise_error(RangeError)
- end
-
- it "has a time-to-live" do
- ttl = rand(32767)
- @message.ttl = ttl
- expect(@message.ttl).to eq(ttl)
- end
-
- it "raises an error when setting first acquirer to nil" do
- expect {
- @message.first_acquirer = nil
- }.to raise_error(TypeError)
- end
-
- it "raises and error when setting first acquirer to a non-boolean" do
- expect {
- @message.first_acquirer = random_string(16)
- }.to raise_error(TypeError)
- end
-
- it "has a first acquirer" do
- @message.first_acquirer = true
- expect(@message.first_acquirer?).to eq(true)
-
- @message.first_acquirer = false
- expect(@message.first_acquirer?).to eq(false)
- end
-
- it "raises an error on a nil delivery count" do
- expect {
- @message.delivery_count = nil
- }.to raise_error(::ArgumentError)
- end
-
- it "raises an error on a negative delivery count" do
- expect {
- @message.delivery_count = -1
- }.to raise_error(RangeError)
- end
-
- it "raises an error on a non-numeric delivery count" do
- expect {
- @message.delivery_count = "farkle"
- }.to raise_error(::ArgumentError)
- end
-
- it "converts a floating point delivery count to its integer portion" do
- count = rand(255) / 10.0
- @message.delivery_count = count
- expect(@message.delivery_count).to eq(count.floor)
- end
-
- it "has a delivery count" do
- count = rand(255)
- @message.delivery_count = count
- expect(@message.delivery_count).to eq(count)
- end
-
- it "allows setting a nil id" do
- @message.id = nil
- expect(@message.id).to be_nil
- end
-
- it "has an id" do
- id = random_string(16)
- @message.id = id
- expect(@message.id).to eq(id)
- end
-
- it "allows setting a nil user id" do
- @message.user_id = nil
- expect(@message.user_id).to eq("")
- end
-
- it "has a user id" do
- id = random_string(16)
- @message.user_id = id
- expect(@message.user_id).to eq(id)
- end
-
- it "allows setting a nil address" do
- @message.address = nil
- expect(@message.address).to be_nil
- end
-
- it "has an address" do
- address = "//0.0.0.0/#{random_string(16)}"
- @message.address = address
- expect(@message.address).to eq(address)
- end
-
- it "allows setting a nil subject" do
- @message.subject = nil
- expect(@message.subject).to be_nil
- end
-
- it "has a subject" do
- subject = random_string(50)
- @message.subject = subject
- expect(@message.subject).to eq(subject)
- end
-
- it "will allow a nil reply-to address" do
- @message.reply_to = nil
- expect(@message.reply_to).to be_nil
- end
-
- it "has a reply-to address" do
- address = "//0.0.0.0/#{random_string(16)}"
- @message.reply_to = address
- expect(@message.reply_to).to eq(address)
- end
-
- it "will allow a nil correlation id" do
- @message.correlation_id = nil
- expect(@message.correlation_id).to be_nil
- end
-
- it "has a correlation id" do
- id = random_string(25)
- @message.correlation_id = id
- expect(@message.correlation_id).to eq(id)
- end
-
- it "will allow a nil content type" do
- @message.content_type = nil
- expect(@message.content_type).to be_nil
- end
-
- it "will allow an empty content type" do
- @message.content_type = ""
- expect(@message.content_type).to eq("")
- end
-
- it "has a content type" do
- content_type = random_string(32)
- @message.content_type = content_type
- expect(@message.content_type).to eq(content_type)
- end
-
- it "can have nil content encoding" do
- @message.content_encoding = nil
- expect(@message.content_encoding).to be_nil
- end
-
- it "has a content encoding" do
- encoding = "#{random_string(8)}/#{random_string(8)}"
- @message.content_encoding = encoding
- expect(@message.content_encoding).to eq(encoding)
- end
-
- it "raises an error on a nil expiry time" do
- expect {
- @message.expires = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error on a negative expiry time" do
- expect {
- @message.expires = (0-(rand(65535)))
- }.to raise_error(::ArgumentError)
- end
-
- it "can have a zero expiry time" do
- @message.expires = 0
- expect(@message.expires).to equal(0)
- end
-
- it "has an expiry time" do
- time = rand(65535)
- @message.expires = time
- expect(@message.expires).to eq(time)
- end
-
- it "raises an error on a nil creation time" do
- expect {
- @message.creation_time = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error on a negative creation time" do
- expect {
- @message.creation_time = (0 - rand(65535))
- }.to raise_error(::ArgumentError)
- end
-
- it "can have a zero creation time" do
- @message.creation_time = 0
- expect(@message.creation_time).to eq(0)
- end
-
- it "has a creation time" do
- time = rand(65535)
- @message.creation_time = time
- expect(@message.creation_time).to eq(time)
- end
-
- it "can have a nil group id" do
- @message.group_id = nil
- expect(@message.group_id).to be_nil
- end
-
- it "can have an empty group id" do
- @message.group_id = ""
- expect(@message.group_id).to eq("")
- end
-
- it "has a group id" do
- id = random_string(16)
- @message.group_id = id
- expect(@message.group_id).to eq(id)
- end
-
-
- it "raises an error on a nil group sequence" do
- expect {
- @message.group_sequence = nil
- }.to raise_error(TypeError)
- end
-
- it "can have a negative group sequence" do
- seq = (0 - rand(32767))
- @message.group_sequence = seq
- expect(@message.group_sequence).to eq(seq)
- end
-
- it "can have a zero group sequence" do
- @message.group_sequence = 0
- expect(@message.group_sequence).to eq(0)
- end
-
- it "has a group sequence" do
- id = rand(32767)
- @message.group_sequence = id
- expect(@message.group_sequence).to eq(id)
- end
-
- it "can have a nil reply-to group id" do
- @message.reply_to_group_id = nil
- expect(@message.reply_to_group_id).to be_nil
- end
-
- it "can have an empty reply-to group id" do
- @message.reply_to_group_id = ""
- expect(@message.reply_to_group_id).to eq("")
- end
-
- it "has a reply-to group id" do
- id = random_string(16)
- @message.reply_to_group_id = id
- expect(@message.reply_to_group_id).to eq(id)
- end
-
- it "has properties" do
- expect(@message).to respond_to(:properties)
- expect(@message).to respond_to(:properties=)
- expect(@message).to respond_to(:[])
- expect(@message).to respond_to(:[]=)
-
- expect(@message.properties).to be_kind_of({}.class)
- end
-
- it "can replace the set of properties" do
- values = random_hash(128)
-
- @message.properties = values.clone
- expect(@message.properties).to eq(values)
- end
-
- it "can set properties" do
- name = random_string(16)
- value = random_string(128)
-
- @message[name] = value
- expect(@message[name]).to eq(value)
- end
-
- it "can update properties" do
- name = random_string(16)
- value = random_string(128)
-
- @message[name] = value
- expect(@message[name]).to eq(value)
-
- value = random_string(128)
- @message[name] = value
- expect(@message[name]).to eq(value)
- end
-
- it "can hold a null property" do
- name = random_string(16)
- value = random_string(128)
-
- @message[name] = value
- expect(@message[name]).to eq(value)
-
- @message[name] = nil
- expect(@message[name]).to be_nil
- end
-
- it "can delete a property" do
- name = random_string(16)
- value = random_string(128)
-
- @message[name] = value
- expect(@message[name]).to eq(value)
-
- @message.delete_property(name)
- expect(@message.properties.keys).to_not include(name)
- end
-
- it "has no properties after being cleared" do
- name = random_string(16)
- value = random_string(128)
-
- @message[name] = value
- expect(@message[name]).to eq(value)
-
- @message.clear
- expect(@message.properties).to be_empty
- end
-
- it "has instructions" do
- expect(@message).to respond_to(:instructions)
- expect(@message).to respond_to("instructions=".to_sym)
- end
-
- it "can set an instruction" do
- name = random_string(16)
- value = random_string(128)
-
- @message.instructions[name] = value
- expect(@message.instructions[name]).to eq(value)
- end
-
- it "can update an instruction" do
- name = random_string(16)
- value = random_string(128)
-
- @message.instructions[name] = value
- expect(@message.instructions[name]).to eq(value)
-
- value = random_string(128)
- @message.instructions[name] = value
- expect(@message.instructions[name]).to eq(value)
- end
-
- it "can delete the instructions" do
- name = random_string(16)
- value = random_string(128)
-
- @message.instructions[name] = value
- expect(@message.instructions).to_not be_empty
-
- @message.instructions = nil
- expect(@message.instructions).to be_nil
- end
-
- it "can replace the instructions" do
- values = random_hash(rand(128) + 1)
-
- @message.instructions = values.clone
- expect(@message.instructions).to eq(values)
-
- values = random_hash(rand(64) + 1)
-
- @message.instructions = values.clone
- expect(@message.instructions).to eq(values)
- end
-
- it "can delete the set of instructions" do
- values = random_hash(rand(128) + 1)
-
- @message.instructions = values.clone
- expect(@message.instructions).to eq(values)
-
- @message.instructions = nil
- expect(@message.instructions).to be_nil
- end
-
- it "has no instructions after being cleared" do
- value = random_hash(128)
-
- @message.instructions = value.clone
- expect(@message.instructions).to eq(value)
-
- @message.clear
- expect(@message.instructions).to be_empty
- end
-
- it "has annotations" do
- expect(@message).to respond_to(:annotations)
- expect(@message).to respond_to(:annotations=)
- end
-
- it "can set an annotation" do
- name = random_hash(32)
- value = random_hash(256)
-
- @message.annotations[name] = value.clone
- expect(@message.annotations[name]).to eq(value)
- end
-
- it "can update an annotation" do
- name = random_hash(32)
- value = random_hash(256)
-
- @message.annotations[name] = value.clone
- expect(@message.annotations[name]).to eq(value)
-
- value = random_hash(128)
-
- @message.annotations[name] = value.clone
- expect(@message.annotations[name]).to eq(value)
- end
-
- it "can delete an annotation" do
- name = random_hash(32)
- value = random_hash(256)
-
- @message.annotations[name] = value.clone
- expect(@message.annotations[name]).to eq(value)
-
- @message.annotations[name] = nil
- expect(@message.annotations[name]).to be_nil
- end
-
- it "can replace all annotations" do
- values = random_hash(rand(128) + 1)
-
- @message.annotations = values.clone
- expect(@message.annotations).to eq(values)
-
- values = random_hash(rand(64) + 1)
-
- @message.annotations = values.clone
- expect(@message.annotations).to eq(values)
- end
-
- it "can delete the set of annotations" do
- value = random_hash(rand(128) + 1)
-
- @message.annotations = value.clone
- expect(@message.annotations).to eq(value)
-
- @message.annotations = nil
- expect(@message.annotations).to be_nil
- end
-
- it "has no annotations after being cleared" do
- value = random_hash(16)
-
- @message.annotations = value
- expect(@message.annotations).to eq(value)
-
- @message.clear
- expect(@message.annotations).to be_empty
- end
-
- it "has a body property" do
- expect(@message).to respond_to(:body)
- expect(@message).to respond_to(:body=)
- end
-
- it "has a default body that is nil" do
- expect(@message.body).to be_nil
- end
-
- it "has no body after being cleared" do
- name = random_string(16)
- value = random_string(128)
-
- @message.body = value
- expect(@message.body).to eq(value)
-
- @message.clear
- expect(@message.body).to 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
- expect(@message.body).to 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
- expect(@message.body).to eq(value)
-
- @message.body = nil
- expect(@message.body).to be_nil
- end
- end
-
- end
-
- end
-
-end
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb b/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb
deleted file mode 100644
index 8e50331..0000000
--- a/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb
+++ /dev/null
@@ -1,407 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-require "spec_helper"
-
-module Qpid
-
- module Proton
-
- describe "A messenger" do
-
- before (:each) do
- @messenger = Qpid::Proton::Messenger::Messenger.new
- end
-
- after (:each) do
- begin
- @messenger.stop
- rescue ProtonError => error
- # ignore this error
- end
- end
-
- it "will generate a name if one is not provided" do
- expect(@messenger.name).to_not be_nil
- end
-
- it "will accept an assigned name" do
- name = random_string(16)
- msgr = Qpid::Proton::Messenger::Messenger.new(name)
- expect(msgr.name).to eq(name)
- end
-
- it "raises an error on a nil timeout" do
- expect {
- @messenger.timeout = nil
- }.to raise_error(TypeError)
- end
-
- it "can have a negative timeout" do
- timeout = (0 - rand(65535))
- @messenger.timeout = timeout
- expect(@messenger.timeout).to eq(timeout)
- end
-
- it "has a timeout" do
- timeout = rand(65535)
- @messenger.timeout = timeout
- expect(@messenger.timeout).to eq(timeout)
- end
-
- it "has an error number" do
- expect(@messenger.error?).to eq(false)
- expect(@messenger.errno).to eq(0)
- # force an error
- expect {
- @messenger.subscribe("amqp://~#{random_string}")
- }.to raise_error(ProtonError)
- expect(@messenger.error?).to eq(true)
- expect(@messenger.errno).to_not eq(0)
- end
-
- it "has an error message" do
- expect(@messenger.error?).to eq(false)
- expect(@messenger.error).to be_nil
- # force an error
- expect {
- @messenger.subscribe("amqp://~#{random_string}")
- }.to raise_error(ProtonError)
- expect(@messenger.error?).to eq(true)
- expect(@messenger.errno).to_not be_nil
- end
-
- it "can be started" do
- expect {
- @messenger.start
- }.to_not raise_error
- end
-
- it "can be stopped" do
- expect {
- @messenger.stop
- }.to_not raise_error
- end
-
- it "raises an error when subscribing to a nil address" do
- expect {
- @messenger.subscribe(nil)
- }.to raise_error(TypeError)
- end
-
- it "raises an error when subscribing to an invalid address" do
- expect {
- @messenger.subscribe("amqp://~#{random_string}")
- }.to raise_error(ProtonError)
- expect(@messenger.error?).to eq(true)
- expect(@messenger.errno).to_not eq(nil)
- end
-
- it "can have a nil certificate" do
- expect {
- @messenger.certificate = nil
- expect(@messenger.certificate).to be_nil
- }.to_not raise_error
- end
-
- it "can have a certificate" do
- cert = random_string(128)
- @messenger.certificate = cert
- expect(@messenger.certificate).to eq(cert)
- end
-
- it "can have a nil private key" do
- expect {
- @messenger.private_key = nil
- expect(@messenger.private_key).to be_nil
- }.to_not raise_error
- end
-
- it "can have a private key" do
- key = random_string(128)
- @messenger.private_key = key
- expect(@messenger.private_key).to eq(key)
- end
-
- it "can have a nil trusted certificates" do
- expect {
- @messenger.trusted_certificates = nil
- expect(@messenger.trusted_certificates).to be_nil
- }.to_not raise_error
- end
-
- it "has a list of trusted certificates" do
- certs = random_string(128)
- @messenger.trusted_certificates = certs
- expect(@messenger.trusted_certificates).to eq(certs)
- end
-
- it "raises an error on a nil outgoing window" do
- expect {
- @messenger.outgoing_window = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error on a non-numeric outgoing window" do
- expect {
- @messenger.outgoing_window = random_string(16)
- }.to raise_error(TypeError)
- end
-
- it "can have a negative outgoing window" do
- window = 0 - (rand(256) + 1)
- @messenger.outgoing_window = window
- expect(@messenger.outgoing_window).to eq(window)
- end
-
- it "can have a positive outgoing window" do
- window = (rand(256) + 1)
- @messenger.outgoing_window = window
- expect(@messenger.outgoing_window).to eq(window)
- end
-
- it "can have a zero outgoing window" do
- window = 0
- @messenger.outgoing_window = window
- expect(@messenger.outgoing_window).to eq(window)
- end
-
- it "raises an error on a nil incoming window" do
- expect {
- @messenger.incoming_window = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error on a non-numeric incoming window" do
- expect {
- @messenger.incoming_window = random_string(16)
- }.to raise_error(TypeError)
- end
-
- it "can have a negative incoming window" do
- window = 0 - (rand(256) + 1)
- @messenger.incoming_window = window
- expect(@messenger.incoming_window).to eq(window)
- end
-
- it "can have a positive incoming window" do
- window = (rand(256) + 1)
- @messenger.incoming_window = window
- expect(@messenger.incoming_window).to eq(window)
- end
-
- it "can have a zero incoming window" do
- window = 0
- @messenger.incoming_window = window
- expect(@messenger.incoming_window).to eq(window)
- end
-
- it "can be put into passive mode" do
- @messenger.passive = true
- expect(@messenger.passive?).to eq(true)
- end
-
- it "can be taken out of passive mode" do
- @messenger.passive = false
- expect(@messenger.passive?).to eq(false)
- end
-
- it "can clear non-existent errors with failing" do
- expect {
- @messenger.clear_error
- }.to_not raise_error
- end
-
- it "can clear errors" do
- begin
- @messenger.accept # should cause an error
- rescue; end
-
- expect(@messenger.error).to_not be_nil
- @messenger.clear_error
- expect(@messenger.error).to be_nil
- end
-
- describe "once started" do
-
- before (:each) do
- @messenger.start
- end
-
- after (:each) do
- begin
- @messenger.stop
- rescue ProtonError => error
- # ignore this error
- end
- end
-
- it "can subscribe to an address" do
- expect(@messenger.subscribe("amqp://~0.0.0.0:#{5700+rand(1024)}")).to_not be_nil
- end
-
- it "returns a tracker's status"
-
- describe "and subscribed to an address" do
-
- before (:each) do
- # create a receiver
- @port = 5700 + rand(1024)
- @receiver = Qpid::Proton::Messenger::Messenger.new("receiver")
- @receiver.subscribe("amqp://~0.0.0.0:#{@port}")
- @messenger.timeout = 0
- @receiver.timeout = 0
- @receiver.start
-
- Thread.new do
- @receiver.receive(10)
- end
-
- @msg = Qpid::Proton::Message.new
- @msg.address = "amqp://0.0.0.0:#{@port}"
- @msg.body = "Test sent #{Time.new}"
- end
-
- after (:each) do
- begin
- @messenger.stop
- rescue ProtonError => error
- # ignore this error
- end
- begin
- @receiver.stop
- rescue
- end
- end
-
- it "raises an error when queueing a nil message" do
- expect {
- @messenger.put(nil)
- }.to raise_error(TypeError)
- end
-
- it "raises an error when queueing an invalid object" do
- expect {
- @messenger.put("This is not a message")
- }.to raise_error(::ArgumentError)
- end
-
- it "can place a message in the outgoing queue" do
- expect {
- @messenger.put(@msg)
- }.to_not raise_error
- end
-
- it "can send with an empty queue"
-
- describe "with a an outgoing tracker" do
-
- before(:each) do
- @messenger.put(@msg)
- @tracker = @messenger.outgoing_tracker
- end
-
- it "has an outgoing tracker" do
- expect(@tracker).to_not be_nil
- end
-
- it "returns a tracker's status"
-
- it "raises an error when settling with a nil tracker" do
- expect {
- @messenger.settle(nil)
- }.to raise_error(TypeError)
- end
-
- it "can settle a tracker's status" do
- @messenger.settle(@tracker)
- end
-
- it "raises an error when checking status on a nil tracker" do
- expect {
- @messenger.status(nil)
- }.to raise_error(TypeError)
- end
-
- it "raises an error when checking status on an invalid tracker" do
- expect {
- @messenger.status(random_string(16))
- }.to raise_error(TypeError)
- end
-
- it "can check the status of a tracker" do
- expect(@messenger.status(@tracker)).to_not be_nil
- end
-
- end
-
- it "has an incoming tracker"
- it "can reject an incoming message"
-
- it "raises an error when accepting with an invalid tracker" do
- expect {
- @messenger.accept(random_string(16))
- }.to raise_error(TypeError)
- end
-
- it "can accept a message"
-
- it "raises an error when rejecting with an invalid tracker" do
- expect {
- @messenger.accept(random_string(16))
- }.to raise_error(TypeError)
- end
-
- describe "with messages sent" do
-
- before (:each) do
- @messenger.put(@msg)
- end
-
- it "can send messages"
-
- it "raises an error when receiving with a nil max" do
- expect {
- @messenger.receive(nil)
- }.to raise_error(TypeError)
- end
-
- it "raises an error when receiving with a non-numeric max" do
- expect {
- @messenger.receive("farkle")
- }.to raise_error(TypeError)
- end
-
- it "can receive messages"
- it "and create a new message when one wasn't provided"
- it "can get a message from the incoming queue"
- it "can tell how many outgoing messages are pending"
- it "can tell how many incoming messages are queued"
-
- end
-
- end
-
- end
-
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/spec_helper.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/spec_helper.rb b/proton-c/bindings/ruby/spec/spec_helper.rb
index 346cb0e..2698bb9 100644
--- a/proton-c/bindings/ruby/spec/spec_helper.rb
+++ b/proton-c/bindings/ruby/spec/spec_helper.rb
@@ -17,19 +17,8 @@
# under the License.
#
-begin
- require "simplecov"
- puts "simplecov available"
-
- SimpleCov.start do
- add_filter "/lib/*/*.rb"
- add_filter "message_format.rb"
- end
-
-rescue
- puts "simplecov not available"
-end
-
+require 'minitest/spec'
+require 'minitest/autorun'
require "securerandom"
require "qpid_proton"
@@ -110,10 +99,10 @@ def random_array(length, described = false, description = nil)
# create the array header
case
- when type == 0 then type = Qpid::Proton::Codec::INT
- when type == 1 then type = Qpid::Proton::Codec::STRING
- when type == 2 then type = Qpid::Proton::Codec::FLOAT
- when type == 3 then type = Qpid::Proton::Codec::UUID
+ when type == 0 then type = Qpid::Proton::Codec::INT
+ when type == 1 then type = Qpid::Proton::Codec::STRING
+ when type == 2 then type = Qpid::Proton::Codec::DOUBLE
+ when type == 3 then type = Qpid::Proton::Codec::UUID
end
result.proton_array_header = Qpid::Proton::Types::ArrayHeader.new(type, description)
@@ -131,25 +120,3 @@ def random_hash(length)
return result
end
-# taken from http://stackoverflow.com/questions/6855944/rounding-problem-with-rspec-tests-when-comparing-float-arrays
-RSpec::Matchers.define :be_close_array do |expected, truth|
- match do |actual|
- same = 0
- for i in 0..actual.length-1
- same +=1 if actual[i].round(truth) == expected[i].round(truth)
- end
- same == actual.length
- end
-
- failure_message_for_should do |actual|
- "expected that #{actual} would be close to #{expected}"
- end
-
- failure_message_for_should_not do |actual|
- "expected that #{actual} would not be close to #{expected}"
- end
-
- description do
- "be a close to #{expected}"
- end
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index 7ed81b2..d5b5c9a 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -18,6 +18,7 @@
#++
require 'test_tools'
+require 'minitest/unit'
Message = Qpid::Proton::Message
SASL = Qpid::Proton::SASL
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/tests/test_interop.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_interop.rb b/proton-c/bindings/ruby/tests/test_interop.rb
new file mode 100755
index 0000000..e08ada1
--- /dev/null
+++ b/proton-c/bindings/ruby/tests/test_interop.rb
@@ -0,0 +1,139 @@
+#!/usr/bin/env ruby
+
+require 'minitest/autorun'
+require 'minitest/unit'
+require 'qpid_proton'
+
+if ((RUBY_VERSION.split(".").map {|x| x.to_i} <=> [1, 9]) < 0)
+ require 'pathname'
+ class File
+ def self.absolute_path(name)
+ return Pathname.new(name).realpath
+ end
+ end
+end
+
+class InteropTest < MiniTest::Test
+ Data = Qpid::Proton::Codec::Data
+ Message = Qpid::Proton::Message
+
+ def setup
+ @data = Data.new
+ @message = Message.new
+ end
+
+ # Walk up the directory tree to find the tests directory.
+ def get_data(name)
+ path = File.join(File.dirname(__FILE__), "../../../../tests/interop/#{name}.amqp")
+ raise "Can't find test/interop directory from #{__FILE__}" unless File.exists?(path)
+ File.open(path, "rb") { |f| f.read }
+ end
+
+ # Decode encoded bytes as a Data object
+ def decode_data(encoded)
+ buffer = encoded
+ while buffer.size > 0
+ n = @data.decode(buffer)
+ buffer = buffer[n..-1]
+ end
+ @data.rewind
+ reencoded = @data.encode
+ # Test the round-trip re-encoding gives the same result.
+ assert_equal(encoded, reencoded)
+ end
+
+ def decode_data_file(name) decode_data(get_data(name)); end
+
+ def decode_message_file(name)
+ message = Message.new()
+ message.decode(self.get_data(name))
+ self.decode_data(message.body)
+ end
+
+ def assert_next(type, value)
+ assert @data.next
+ assert_equal(type, @data.type)
+ assert_equal(value, type.get(@data))
+ end
+
+ def assert_array_next(expected, header)
+ assert_next(Qpid::Proton::Codec::ARRAY, expected)
+ result = @data.type.get(@data)
+ assert_equal(result.proton_array_header, header)
+ end
+
+ def test_message
+ decode_message_file("message")
+ assert_next(Qpid::Proton::Codec::STRING, "hello")
+ assert !@data.next
+ end
+
+ def test_primitives
+ decode_data_file("primitives")
+ assert_next(Qpid::Proton::Codec::BOOL, true)
+ assert_next(Qpid::Proton::Codec::BOOL, false)
+ assert_next(Qpid::Proton::Codec::UBYTE, 42)
+ assert_next(Qpid::Proton::Codec::USHORT, 42)
+ assert_next(Qpid::Proton::Codec::SHORT, -42)
+ assert_next(Qpid::Proton::Codec::UINT, 12345)
+ assert_next(Qpid::Proton::Codec::INT, -12345)
+ assert_next(Qpid::Proton::Codec::ULONG, 12345)
+ assert_next(Qpid::Proton::Codec::LONG, -12345)
+ assert_next(Qpid::Proton::Codec::FLOAT, 0.125)
+ assert_next(Qpid::Proton::Codec::DOUBLE, 0.125)
+ assert !@data.next
+ end
+
+ def test_strings
+ decode_data_file("strings")
+ assert_next(Qpid::Proton::Codec::BINARY, "abc\0defg")
+ assert_next(Qpid::Proton::Codec::STRING, "abcdefg")
+ assert_next(Qpid::Proton::Codec::SYMBOL, "abcdefg")
+ assert_next(Qpid::Proton::Codec::BINARY, "")
+ assert_next(Qpid::Proton::Codec::STRING, "")
+ assert_next(Qpid::Proton::Codec::SYMBOL, "")
+ assert !@data.next
+ end
+
+ def test_described
+ decode_data_file("described")
+ assert_next(Qpid::Proton::Codec::DESCRIBED, Qpid::Proton::Types::Described.new("foo-descriptor", "foo-value"))
+ assert(@data.described?)
+ assert_next(Qpid::Proton::Codec::DESCRIBED, Qpid::Proton::Types::Described.new(12, 13))
+ assert(@data.described?)
+ assert !@data.next
+ end
+
+ def test_described_array
+ decode_data_file("described_array")
+ assert_array_next((0...10).to_a,
+ Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT,
+ "int-array"))
+ end
+
+ def test_arrays
+ decode_data_file("arrays")
+ assert_array_next((0...100).to_a,
+ Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT))
+ assert_array_next(["a", "b", "c"],
+ Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::STRING))
+ assert_array_next([],
+ Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT))
+ assert !@data.next
+ end
+
+ def test_lists
+ decode_data_file("lists")
+ assert_next(Qpid::Proton::Codec::LIST, [32, "foo", true])
+ assert_next(Qpid::Proton::Codec::LIST, [])
+ assert !@data.next
+ end
+
+ def test_maps
+ decode_data_file("maps")
+ assert_next(Qpid::Proton::Codec::MAP, {"one" => 1, "two" => 2, "three" => 3 })
+ assert_next(Qpid::Proton::Codec::MAP, {1 => "one", 2 => "two", 3 => "three"})
+ assert_next(Qpid::Proton::Codec::MAP, {})
+ assert !@data.next
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/tests/test_smoke.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_smoke.rb b/proton-c/bindings/ruby/tests/test_smoke.rb
new file mode 100755
index 0000000..61cc7cf
--- /dev/null
+++ b/proton-c/bindings/ruby/tests/test_smoke.rb
@@ -0,0 +1,64 @@
+#!/usr/bin/env ruby
+
+require 'minitest/autorun'
+require 'minitest/unit'
+require 'qpid_proton'
+
+class SmokeTest < MiniTest::Test
+
+ Messenger = Qpid::Proton::Messenger::Messenger
+ Message = Qpid::Proton::Message
+
+ def setup
+ @server = Messenger.new()
+ @client = Messenger.new()
+ @server.blocking = false
+ @client.blocking = false
+ @server.subscribe("~0.0.0.0:12345")
+ @server.start()
+ @client.start()
+ pump()
+ end
+
+ def pump
+ while (@server.work(0) or @client.work(0)) do end
+ end
+
+ def teardown
+ @server.stop()
+ @client.stop()
+
+ pump()
+
+ assert @client.stopped?
+ assert @server.stopped?
+ end
+
+ def testSmoke(count=10)
+ msg = Message.new()
+ msg.address = "0.0.0.0:12345"
+
+ @server.receive()
+
+ count.times {|i|
+ msg.body = "Hello World! #{i}"
+ @client.put(msg)
+ }
+
+ msg2 = Message.new()
+
+ count.times {|i|
+ if (@server.incoming == 0) then
+ pump()
+ end
+ @server.get(msg2)
+ assert msg2.body == "Hello World! #{i}"
+ }
+
+ assert(@client.outgoing == 0,
+ "Expected 0 outgoing messages, found #{@client.outgoing}")
+ assert(@server.incoming == 0,
+ "Expected 0 incoming messages, found #{@server.incoming}")
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/tests/test_tools.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_tools.rb b/proton-c/bindings/ruby/tests/test_tools.rb
index a48a508..2d8f3c6 100644
--- a/proton-c/bindings/ruby/tests/test_tools.rb
+++ b/proton-c/bindings/ruby/tests/test_tools.rb
@@ -17,7 +17,7 @@
# under the License.
#++
-# Tools for tests
+# Tools for tests. Only minitest is used.
require 'minitest/autorun'
require 'qpid_proton'
@@ -56,6 +56,19 @@ end
class TestError < Exception; end
+def wait_port(port, timeout=5)
+ deadline = Time.now + timeout
+ begin # Wait for the port to be connectible
+ TCPSocket.open("", $port).close
+ rescue Errno::ECONNREFUSED
+ if Time.now > deadline then
+ raise TestError("timed out waiting for port #{port}")
+ end
+ sleep(0.1)
+ retry
+ end
+end
+
# Handler that creates its own container to run itself, and records some common
# events that are checked by tests
class TestHandler < MessagingHandler
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/tests/ruby/proton-test
----------------------------------------------------------------------
diff --git a/tests/ruby/proton-test b/tests/ruby/proton-test
deleted file mode 100755
index 04aee1c..0000000
--- a/tests/ruby/proton-test
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env ruby
-
-if RUBY_VERSION < "1.9"
-require 'rubygems'
-end
-
-require 'test/unit'
-require 'proton_tests/interop.rb'
-require 'proton_tests/smoke.rb'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/tests/ruby/proton_tests/interop.rb
----------------------------------------------------------------------
diff --git a/tests/ruby/proton_tests/interop.rb b/tests/ruby/proton_tests/interop.rb
deleted file mode 100755
index 1d50483..0000000
--- a/tests/ruby/proton_tests/interop.rb
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'qpid_proton'
-
-if ((RUBY_VERSION.split(".").map {|x| x.to_i} <=> [1, 9]) < 0)
- require 'pathname'
- class File
- def self.absolute_path(name)
- return Pathname.new(name).realpath
- end
- end
-end
-
-class InteropTest < Test::Unit::TestCase
- Data = Qpid::Proton::Codec::Data
- Message = Qpid::Proton::Message
-
- def setup
- @data = Data.new
- @message = Message.new
- end
-
- # Walk up the directory tree to find the tests directory.
- def get_data(name)
- path = File.absolute_path(__FILE__)
- while path and File.basename(path) != "tests" do path = File.dirname(path); end
- path = File.join(path,"interop")
- raise "Can't find test/interop directory from #{__FILE__}" unless File.directory?(path)
- path = File.join(path,"#{name}.amqp")
- File.open(path, "rb") { |f| f.read }
- end
-
- # Decode encoded bytes as a Data object
- def decode_data(encoded)
- buffer = encoded
- while buffer.size > 0
- n = @data.decode(buffer)
- buffer = buffer[n..-1]
- end
- @data.rewind
- reencoded = @data.encode
- # Test the round-trip re-encoding gives the same result.
- assert_equal(encoded, reencoded)
- end
-
- def decode_data_file(name) decode_data(get_data(name)); end
-
- def decode_message_file(name)
- message = Message.new()
- message.decode(self.get_data(name))
- self.decode_data(message.body)
- end
-
- def assert_next(type, value)
- assert @data.next
- assert_equal(type, @data.type)
- assert_equal(value, type.get(@data))
- end
-
- def assert_array_next(expected, header)
- assert_next(Qpid::Proton::Codec::ARRAY, expected)
- result = @data.type.get(@data)
- assert_equal(result.proton_array_header, header)
- end
-
- def test_message
- decode_message_file("message")
- assert_next(Qpid::Proton::Codec::STRING, "hello")
- assert !@data.next
- end
-
- def test_primitives
- decode_data_file("primitives")
- assert_next(Qpid::Proton::Codec::BOOL, true)
- assert_next(Qpid::Proton::Codec::BOOL, false)
- assert_next(Qpid::Proton::Codec::UBYTE, 42)
- assert_next(Qpid::Proton::Codec::USHORT, 42)
- assert_next(Qpid::Proton::Codec::SHORT, -42)
- assert_next(Qpid::Proton::Codec::UINT, 12345)
- assert_next(Qpid::Proton::Codec::INT, -12345)
- assert_next(Qpid::Proton::Codec::ULONG, 12345)
- assert_next(Qpid::Proton::Codec::LONG, -12345)
- assert_next(Qpid::Proton::Codec::FLOAT, 0.125)
- assert_next(Qpid::Proton::Codec::DOUBLE, 0.125)
- assert !@data.next
- end
-
- def test_strings
- decode_data_file("strings")
- assert_next(Qpid::Proton::Codec::BINARY, "abc\0defg")
- assert_next(Qpid::Proton::Codec::STRING, "abcdefg")
- assert_next(Qpid::Proton::Codec::SYMBOL, "abcdefg")
- assert_next(Qpid::Proton::Codec::BINARY, "")
- assert_next(Qpid::Proton::Codec::STRING, "")
- assert_next(Qpid::Proton::Codec::SYMBOL, "")
- assert !@data.next
- end
-
- def test_described
- decode_data_file("described")
- assert_next(Qpid::Proton::Codec::DESCRIBED, Qpid::Proton::Types::Described.new("foo-descriptor", "foo-value"))
- assert(@data.described?)
- assert_next(Qpid::Proton::Codec::DESCRIBED, Qpid::Proton::Types::Described.new(12, 13))
- assert(@data.described?)
- assert !@data.next
- end
-
- def test_described_array
- decode_data_file("described_array")
- assert_array_next((0...10).to_a,
- Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT,
- "int-array"))
- end
-
- def test_arrays
- decode_data_file("arrays")
- assert_array_next((0...100).to_a,
- Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT))
- assert_array_next(["a", "b", "c"],
- Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::STRING))
- assert_array_next([],
- Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT))
- assert !@data.next
- end
-
- def test_lists
- decode_data_file("lists")
- assert_next(Qpid::Proton::Codec::LIST, [32, "foo", true])
- assert_next(Qpid::Proton::Codec::LIST, [])
- assert !@data.next
- end
-
- def test_maps
- decode_data_file("maps")
- assert_next(Qpid::Proton::Codec::MAP, {"one" => 1, "two" => 2, "three" => 3 })
- assert_next(Qpid::Proton::Codec::MAP, {1 => "one", 2 => "two", 3 => "three"})
- assert_next(Qpid::Proton::Codec::MAP, {})
- assert !@data.next
- end
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/tests/ruby/proton_tests/smoke.rb
----------------------------------------------------------------------
diff --git a/tests/ruby/proton_tests/smoke.rb b/tests/ruby/proton_tests/smoke.rb
deleted file mode 100755
index 5fc990a..0000000
--- a/tests/ruby/proton_tests/smoke.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'qpid_proton'
-
-class SmokeTest < Test::Unit::TestCase
-
- Messenger = Qpid::Proton::Messenger::Messenger
- Message = Qpid::Proton::Message
-
- def setup
- @server = Messenger.new()
- @client = Messenger.new()
- @server.blocking = false
- @client.blocking = false
- @server.subscribe("~0.0.0.0:12345")
- @server.start()
- @client.start()
- pump()
- end
-
- def pump
- while (@server.work(0) or @client.work(0)) do end
- end
-
- def teardown
- @server.stop()
- @client.stop()
-
- pump()
-
- assert @client.stopped?
- assert @server.stopped?
- end
-
- def testSmoke(count=10)
- msg = Message.new()
- msg.address = "0.0.0.0:12345"
-
- @server.receive()
-
- count.times {|i|
- msg.body = "Hello World! #{i}"
- @client.put(msg)
- }
-
- msg2 = Message.new()
-
- count.times {|i|
- if (@server.incoming == 0) then
- pump()
- end
- @server.get(msg2)
- assert msg2.body == "Hello World! #{i}"
- }
-
- assert(@client.outgoing == 0,
- "Expected 0 outgoing messages, found #{@client.outgoing}")
- assert(@server.incoming == 0,
- "Expected 0 incoming messages, found #{@server.incoming}")
- end
-
-end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-proton git commit: PROTON-1457: Ruby tests fail when
dependencies are missing
Posted by ac...@apache.org.
PROTON-1457: Ruby tests fail when dependencies are missing
The only test dependency is now minitest - which is included in ruby 1.9.1-2.1 and was then
dropped again. The build will proceed with a warning if minitest is missing.
- convert all tests to use minitest, remove other test dependencies (rspec, simplecov, test-unit)
- allow build without test if minitest is not installed
- move all ruby tests (proton/tests/ruby) to bindings/ruby/tests
- consolidate CMakeLists ruby logic in bindings/ruby/tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5e1bce7a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5e1bce7a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5e1bce7a
Branch: refs/heads/master
Commit: 5e1bce7a0119849e765ac9528523cbc96fc8dbb3
Parents: 363d337
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Sep 11 15:16:48 2017 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Sep 11 16:45:01 2017 -0400
----------------------------------------------------------------------
.travis.yml | 2 -
DEVELOPERS.md | 4 +-
INSTALL.md | 3 +-
config.sh.in | 5 +-
examples/ruby/example_test.rb | 33 +-
proton-c/CMakeLists.txt | 52 --
proton-c/bindings/CMakeLists.txt | 28 -
proton-c/bindings/ruby/CMakeLists.txt | 69 +-
proton-c/bindings/ruby/spec/array_spec.rb | 111 ++++
proton-c/bindings/ruby/spec/data_spec.rb | 494 ++++++++++++++
.../ruby/spec/exception_handling_spec.rb | 96 +++
proton-c/bindings/ruby/spec/hash_spec.rb | 57 ++
proton-c/bindings/ruby/spec/message_spec.rb | 637 ++++++++++++++++++
proton-c/bindings/ruby/spec/messenger_spec.rb | 393 ++++++++++++
.../ruby/spec/qpid/proton/array_spec.rb | 114 ----
.../bindings/ruby/spec/qpid/proton/data_spec.rb | 493 --------------
.../spec/qpid/proton/exception_handling_spec.rb | 96 ---
.../bindings/ruby/spec/qpid/proton/hash_spec.rb | 57 --
.../ruby/spec/qpid/proton/message_spec.rb | 638 -------------------
.../ruby/spec/qpid/proton/messenger_spec.rb | 407 ------------
proton-c/bindings/ruby/spec/spec_helper.rb | 45 +-
proton-c/bindings/ruby/tests/test_container.rb | 1 +
proton-c/bindings/ruby/tests/test_interop.rb | 139 ++++
proton-c/bindings/ruby/tests/test_smoke.rb | 64 ++
proton-c/bindings/ruby/tests/test_tools.rb | 15 +-
tests/ruby/proton-test | 9 -
tests/ruby/proton_tests/interop.rb | 141 ----
tests/ruby/proton_tests/smoke.rb | 63 --
28 files changed, 2064 insertions(+), 2202 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 073ed95..f7a8d77 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -43,8 +43,6 @@ addons:
install:
- pip install --user --upgrade pip
- pip install --user tox
-- gem install rspec
-- gem install simplecov || true
- gem install minitest
before_script:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/DEVELOPERS.md
----------------------------------------------------------------------
diff --git a/DEVELOPERS.md b/DEVELOPERS.md
index c64484c..d195083 100644
--- a/DEVELOPERS.md
+++ b/DEVELOPERS.md
@@ -71,10 +71,10 @@ To run the tests, cd into your build directory and use the following commands:
Additional packages required for testing the language bindings:
# ruby dependencies
- $ yum install rubygem-minitest rubygem-rspec rubygem-simplecov
+ $ yum install rubygem-minitest
# alternatively ruby depedencies on non-RPM based systems
- $ gem install minitest rspec simplecov
+ $ gem install minitest
Mailing list
------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/INSTALL.md
----------------------------------------------------------------------
diff --git a/INSTALL.md b/INSTALL.md
index 4ce2dde..01dbf13 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -45,8 +45,7 @@ language.
# Dependencies needed for bindings
$ yum install swig # Required for all bindings
$ yum install python-devel # Python
- $ yum install ruby-devel rubygem-rspec rubygem-simplecov # Ruby
- $ yum install rubygem-test-unit # Ruby on Fedora >= 25
+ $ yum install ruby-devel rubygem-minitest # Ruby
$ yum install php-devel # PHP
$ yum install perl-devel # Perl
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/config.sh.in
----------------------------------------------------------------------
diff --git a/config.sh.in b/config.sh.in
index d9debd3..a29b47a 100755
--- a/config.sh.in
+++ b/config.sh.in
@@ -35,7 +35,6 @@ PROTON_BINDINGS=$PROTON_BUILD/proton-c/bindings
PYTHON_BINDINGS=$PROTON_BINDINGS/python
PHP_BINDINGS=$PROTON_BINDINGS/php
-RUBY_BINDINGS=$PROTON_BINDINGS/ruby
PERL_BINDINGS=$PROTON_BINDINGS/perl
# Python
@@ -52,7 +51,9 @@ EOF
fi
# Ruby
-export RUBYLIB=$RUBY_BINDINGS:$PROTON_HOME/proton-c/bindings/ruby/lib:$PROTON_HOME/tests/ruby
+RUBY_BINDINGS=$PROTON_BINDINGS/ruby
+RUBY_SRC=$PROTON_HOME/proton-c/bindings/ruby
+export RUBYLIB=$RUBY_BINDINGS:$RUBY_SRC/lib:$RUBY_SRC/tests:$RUBY_SRC/spec
# Perl
export PERL5LIB=$PERL5LIB:$PERL_BINDINGS:$PROTON_HOME/proton-c/bindings/perl/lib
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/examples/ruby/example_test.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/example_test.rb b/examples/ruby/example_test.rb
index 9a01964..e14aef7 100755
--- a/examples/ruby/example_test.rb
+++ b/examples/ruby/example_test.rb
@@ -18,13 +18,11 @@
# under the License.
#
-require 'test/unit'
require 'qpid_proton'
require 'socket'
+require 'test_tools'
-$port = Random.new.rand(10000) + 10000
-
-class ExampleTest < Test::Unit::TestCase
+class ExampleTest < MiniTest::Test
def run_script(script, port)
assert File.exist? script
@@ -68,23 +66,14 @@ EOS
end
end
-begin
- broker = spawn("#{RbConfig.ruby} reactor/broker.rb -a :#{$port}")
- # Wait for the broker to be listening.
- while true
- begin
- s = TCPSocket.open "", $port
- puts "Broker ready at #{$port}"
- s.close
- break
- rescue Errno::ECONNREFUSED
- puts "Retry connection to #{$port}"
- sleep(0.1)
- end
- end
-
- Test::Unit::AutoRunner.run
+# Start the broker before all tests
+TestPort.new do |tp|
+ $port = tp.port
+ $broker = spawn("#{RbConfig.ruby} reactor/broker.rb -a :#{$port}")
+ wait_port($port)
+end
-ensure
- Process.kill :TERM, broker if broker
+# Kill the broker after all tests
+MiniTest.after_run do
+ Process.kill(:TERM, $broker) if $broker
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 34c1ccd..8c64099 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -807,58 +807,6 @@ if (BUILD_PYTHON)
endif (BUILD_PYTHON)
-find_program(RUBY_EXE "ruby")
-if (RUBY_EXE AND BUILD_RUBY)
- set (rb_root "${pn_test_root}/ruby")
- set (rb_src "${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby")
- set (rb_lib "${rb_src}/lib")
- set (rb_tests "${rb_src}/tests")
- set (rb_bin "${CMAKE_CURRENT_BINARY_DIR}/bindings/ruby")
- set (rb_bld "$<TARGET_FILE_DIR:qpid-proton>")
- set (rb_path $ENV{PATH} ${rb_bin} ${rb_bld})
- set (rb_rubylib ${rb_root} ${rb_src} ${rb_bin} ${rb_bld} ${rb_lib} ${rb_tests})
- to_native_path("${rb_path}" rb_path)
- to_native_path("${rb_rubylib}" rb_rubylib)
-
- # ruby example tests have no dependencies other than standard ruby.
- add_test(NAME ruby-example-test
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/examples/ruby
- COMMAND ${env_py} -- "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
- ${RUBY_EXE} example_test.rb -v)
-
- # TODO aconway 2017-08-16: move test cmake code to ruby/tests directory
- add_test(NAME ruby-container-test
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/proton-c/bindings/ruby
- COMMAND ${env_py} -- "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
- ${RUBY_EXE} ${rb_tests}/test_container.rb -v)
-
- # ruby unit tests: tests/ruby/proton-test
- # only enable the tests if the Ruby gem dependencies were found
- if (DEFAULT_RUBY_TESTING)
- add_test (NAME ruby-unit-test
- COMMAND ${env_py} "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
- "${rb_root}/proton-test")
-
- # ruby spec tests
- find_program(RSPEC_EXE rspec)
- if (RSPEC_EXE)
- add_test (NAME ruby-spec-test
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby
- COMMAND ${env_py} "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
- ${RSPEC_EXE})
-
- else(RSPEC_EXE)
- message (STATUS "Cannot find rspec, skipping rspec tests")
- endif(RSPEC_EXE)
- else (DEFAULT_RUBY_TESTING)
- message(STATUS "Skipping Ruby tests: missing dependencies")
- endif (DEFAULT_RUBY_TESTING)
-else (RUBY_EXE)
- message (STATUS "Cannot find ruby, skipping ruby tests")
-endif()
-
-mark_as_advanced (RUBY_EXE RSPEC_EXE)
-
if (BUILD_JAVASCRIPT)
add_test (javascript-codec ${env_py} node ${pn_test_root}/javascript/codec.js)
add_test (javascript-message ${env_py} node ${pn_test_root}/javascript/message.js)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/CMakeLists.txt b/proton-c/bindings/CMakeLists.txt
index 6b88384..dd4c2c8 100644
--- a/proton-c/bindings/CMakeLists.txt
+++ b/proton-c/bindings/CMakeLists.txt
@@ -76,37 +76,9 @@ if(SWIG_FOUND)
endif (PYTHONLIBS_FOUND)
# Prerequisites for Ruby:
- find_program(GEM_EXE "gem")
- mark_as_advanced(GEM_EXE)
- macro(CheckRubyGem varname gemname)
- execute_process(COMMAND ${GEM_EXE} list --local ${gemname}
- OUTPUT_VARIABLE CHECK_OUTPUT)
-
- set (${varname} OFF)
-
- if (CHECK_OUTPUT MATCHES "${gemname}[ ]+\(.*\)")
- message(STATUS "Found Ruby gem: ${gemname}")
- set (${varname} ON)
- else()
- message(STATUS "Missing Ruby gem dependency: ${gemname}")
- set (${varname} OFF)
- endif()
- endmacro()
-
find_package(Ruby)
if (RUBY_FOUND)
set (DEFAULT_RUBY ON)
-
- CheckRubyGem("HAS_RUBY_GEM_RSPEC" "rspec")
- CheckRubyGem("HAS_RUBY_GEM_SIMPLECOV" "simplecov")
-
- if (HAS_RUBY_GEM_RSPEC AND HAS_RUBY_GEM_SIMPLECOV)
- set (DEFAULT_RUBY_TESTING ON CACHE INTERNAL "")
- else()
- message(STATUS "Skipping Ruby bindings due to missing dependencies...")
- set (DEFAULT_RUBY_TESTING OFF CACHE INTERNAL "")
- set (DEFAULT_RUBY OFF)
- endif (HAS_RUBY_GEM_RSPEC AND HAS_RUBY_GEM_SIMPLECOV)
endif (RUBY_FOUND)
# Prerequites for PHP:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/CMakeLists.txt b/proton-c/bindings/ruby/CMakeLists.txt
index c14e4f4..7ff23ed 100644
--- a/proton-c/bindings/ruby/CMakeLists.txt
+++ b/proton-c/bindings/ruby/CMakeLists.txt
@@ -17,14 +17,10 @@
# under the License.
#
-if (NOT DEFAULT_RUBY_TESTING)
- message(FATAL_ERROR "Ruby bindings cannot be tested while missing dependencies")
-endif (NOT DEFAULT_RUBY_TESTING)
list(APPEND SWIG_MODULE_cproton-ruby_EXTRA_DEPS
${CMAKE_SOURCE_DIR}/proton-c/include/proton/cproton.i
${PROTON_HEADERS}
)
-
include_directories (${RUBY_INCLUDE_PATH})
swig_add_library(cproton-ruby LANGUAGE ruby SOURCES ruby.i)
swig_link_libraries(cproton-ruby ${BINDING_DEPS} ${RUBY_LIBRARY})
@@ -64,33 +60,38 @@ if (NOT RUBY_ARCHLIB_DIR)
set (RUBY_ARCHLIB_DIR ${RUBY_ARCHLIB_DIR_DEFAULT})
endif()
-install(TARGETS cproton-ruby
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(FILES lib/qpid_proton.rb
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/codec
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/core
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/event
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/handler
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/messenger
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/reactor
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/types
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/util
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
+install(TARGETS cproton-ruby DESTINATION ${RUBY_ARCHLIB_DIR} COMPONENT Ruby)
+install(DIRECTORY lib DESTINATION ${RUBY_ARCHLIB_DIR} COMPONENT Ruby)
+
+#### Tests
+
+set(src "${CMAKE_CURRENT_SOURCE_DIR}")
+set(bin "${CMAKE_CURRENT_BINARY_DIR}")
+set(bld "$<TARGET_FILE_DIR:qpid-proton>")
+
+to_native_path("$ENV{RUBYLIB};${src}/lib;${src}/tests;${src}/spec;${bin};${bld}" RUBYLIB)
+to_native_path("$ENV{PATH};${bin};${bld}" PATH)
+
+execute_process(COMMAND ${RUBY_EXECUTABLE} -r minitest -e ""
+ RESULT_VARIABLE result OUTPUT_QUIET ERROR_QUIET)
+if (result EQUAL 0) # Have minitest
+
+ macro(add_ruby_test name file)
+ add_test(
+ NAME ${name}
+ ${ARGN}
+ COMMAND ${RUBY_EXECUTABLE} ${file} -v)
+ set_tests_properties(${name} PROPERTIES ENVIRONMENT "PATH=${PATH};RUBYLIB=${RUBYLIB}")
+ endmacro()
+
+ add_ruby_test(ruby-example-test example_test.rb WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/examples/ruby)
+
+ file(GLOB TESTS tests/test_*.rb)
+ file(GLOB SPECS spec/*_spec.rb)
+ foreach(t ${TESTS} ${SPECS})
+ add_ruby_test("ruby-${t}" ${t})
+ endforeach()
+else()
+ # No minitest
+ message(WARNING "ruby tests will not run, minitest is not installed")
+endif()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/array_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/array_spec.rb b/proton-c/bindings/ruby/spec/array_spec.rb
new file mode 100644
index 0000000..b655358
--- /dev/null
+++ b/proton-c/bindings/ruby/spec/array_spec.rb
@@ -0,0 +1,111 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require 'spec_helper' #FIXME aconway 2017-09-11:
+
+describe "The extended array type" do
+
+ before :each do
+ @data = Qpid::Proton::Codec::Data.new
+ @list = random_list(rand(100))
+ @undescribed = random_array(rand(100))
+ @description = random_string(128)
+ @described = random_array(rand(100), true, @description)
+ end
+
+ it "can be created like a normal array" do
+ value = []
+
+ expect(value).respond_to?(:proton_put)
+ expect(value).respond_to?(:proton_array_header)
+ expect(value.class).respond_to?(:proton_get)
+ expect(value).respond_to? :proton_described?
+ end
+
+ it "raises an error when putting into a nil Data object" do
+ expect { @list.proton_put(nil) }.must_raise
+ end
+
+ it "raises an error when getting from a nil Data object" do
+ expect {
+ Array.proton_get(nil)
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when the data object is empty" do
+ expect {
+ Array.proton_get(@data)
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when the current object is not a list" do
+ @data.string = random_string(128)
+ @data.rewind
+
+ expect {
+ Array.proton_get(@data)
+ }.must_raise(TypeError)
+ end
+
+ it "does not have an array header when it's a simple list" do
+ assert !@list.proton_described?
+ end
+
+ it "can be put into a Data object as a list" do
+ @list.proton_put(@data)
+ result = Array.proton_get(@data)
+ expect(result).must_equal(@list)
+ expect(result.proton_array_header) == (nil)
+ end
+
+ it "has an array header when it's an AMQP array" do
+ expect(@undescribed.proton_array_header).wont_be_nil
+ expect(@described.proton_array_header).wont_be_nil
+ end
+
+ it "raises an error when the elements of an Array are dissimilar and is put into a Data object" do
+ value = []
+ value.proton_array_header = Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT)
+ value << random_string(16)
+
+ expect {
+ value.proton_put(@data)
+ }.must_raise(TypeError)
+ end
+
+ it "can be put into a Data object as an undescribed array" do
+ @undescribed.proton_put(@data)
+ result = Array.proton_get(@data)
+ expect(@undescribed).must_equal(result)
+ expect(result.proton_array_header).wont_be_nil
+ expect(result.proton_array_header).must_equal(@undescribed.proton_array_header)
+ assert !result.proton_array_header.described?
+ end
+
+ it "can be put into a Data object as a described array" do
+ @described.proton_put(@data)
+ result = Array.proton_get(@data)
+ expect(@described) == result
+
+ expect(result.proton_array_header).wont_be_nil
+ expect(result.proton_array_header).must_equal(@described.proton_array_header)
+ expect(result.proton_array_header.described?).must_equal(true)
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/data_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/data_spec.rb b/proton-c/bindings/ruby/spec/data_spec.rb
new file mode 100644
index 0000000..99c269c
--- /dev/null
+++ b/proton-c/bindings/ruby/spec/data_spec.rb
@@ -0,0 +1,494 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+require "spec_helper"
+
+module Qpid
+
+ module Proton
+
+ describe "A data object" do
+
+ before :each do
+ @data = Qpid::Proton::Codec::Data.new
+ end
+
+ it "can be initialized" do
+ expect(@data).wont_be_nil
+ end
+
+ it "can hold a null" do
+ @data.null
+ expect(@data.null?).must_equal(true)
+ end
+
+ it "can hold a true boolean" do
+ @data.bool = true
+ expect(@data.bool).must_equal(true)
+ end
+
+ it "can hold a false boolean" do
+ @data.bool = false
+ expect(@data.bool).must_equal(false)
+ end
+
+ it "raises an error on a negative ubyte" do
+ expect {
+ @data.ubyte = (0 - (rand(127) + 1))
+ }.must_raise(RangeError)
+ end
+
+ it "raises an error on a null ubyte" do
+ expect {
+ @data.ubyte = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold an unsigned byte" do
+ value = rand(255)
+ @data.ubyte = value
+ expect(@data.ubyte).must_equal(value)
+ end
+
+ it "can hold a byte" do
+ value = rand(128)
+ @data.byte = value
+ expect(@data.byte).must_equal(value)
+ end
+
+ it "can hold a negative byte" do
+ value = 0 - (rand(126) + 1)
+ @data.byte = value
+ expect(@data.byte).must_equal(value)
+ end
+
+ it "raises an error on a negative ushort" do
+ expect {
+ @data.ushort = (0 - (rand(65535) + 1))
+ }.must_raise(RangeError)
+ end
+
+ it "raises an error on a nil ushort" do
+ expect {
+ @data.ushort = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold a zero unsigned short" do
+ @data.ushort = 0
+ expect(@data.ushort).must_equal(0)
+ end
+
+ it "can hold an unsigned short" do
+ value = rand(2**15) + 1
+ @data.ushort = value
+ expect(@data.ushort).must_equal(value)
+ end
+
+ it "raises an error on a nil short" do
+ expect {
+ @data.short = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold a short" do
+ value = rand(2**15) + 1
+ @data.short = value
+ expect(@data.short).must_equal(value)
+ end
+
+ it "can hold a zero short" do
+ @data.short = 0
+ expect(@data.short).must_equal(0)
+ end
+
+ it "can hold a negative short" do
+ value = (0 - (rand(2**15) + 1))
+ @data.short = value
+ expect(@data.short).must_equal(value)
+ end
+
+ it "raises an error on a nil uint" do
+ expect {
+ @data.uint = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error on a negative uint" do
+ expect {
+ @data.uint = (0 - (rand(2**32) + 1))
+ }.must_raise(RangeError)
+ end
+
+ it "can hold an unsigned integer" do
+ value = rand(2**32) + 1
+ @data.uint = value
+ expect(@data.uint).must_equal(value)
+ end
+
+ it "can hold a zero unsigned integer" do
+ @data.uint = 0
+ expect(@data.uint).must_equal(0)
+ end
+
+ it "raise an error on a null integer" do
+ expect {
+ @data.int = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold an integer" do
+ value = rand(2**31) + 1
+ @data.int = value
+ expect(@data.int).must_equal(value)
+ end
+
+ it "can hold zero as an integer" do
+ @data.int = 0
+ expect(@data.int).must_equal(0)
+ end
+
+ it "raises an error on a null character" do
+ expect {
+ @data.char = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold a character" do
+ source = random_string(256)
+ index = rand(source.length)
+ value = source[index,1].bytes.to_a[0]
+ @data.char = value
+ expect(@data.char).must_equal(value)
+ end
+
+ it "raises an error on a null ulong" do
+ expect {
+ @data.ulong = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error on a negative ulong" do
+ expect {
+ @data.ulong = (0 - (rand(2**63) + 1))
+ }.must_raise(RangeError)
+ end
+
+ it "can have a zero unsigned long" do
+ @data.ulong = 0
+ expect(@data.ulong).must_equal(0)
+ end
+
+ it "can hold an unsigned long" do
+ value = rand(2**63) + 1
+ @data.ulong = value
+ expect(@data.ulong).must_equal(value)
+ end
+
+ it "raises an error on a null long" do
+ expect {
+ @data.long = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can have a zero long" do
+ @data.long = 0
+ expect(@data.long).must_equal(0)
+ end
+
+ it "can hold a long" do
+ value = rand(2**63) + 1
+ @data.long = value
+ expect(@data.long).must_equal(value)
+ end
+
+ it "raise an error on a null timestamp" do
+ expect {
+ @data.timestamp = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can handle a negative timestamp" do
+ last_year = Time.now - (60*60*24*365)
+ @data.timestamp = last_year
+ expect(@data.timestamp).must_equal(last_year.to_i)
+ end
+
+ it "can handle a zero timestamp" do
+ @data.timestamp = 0
+ expect(@data.timestamp).must_equal(0)
+ end
+
+ it "can hold a timestamp" do
+ next_year = Time.now + (60*60*24*365)
+ @data.timestamp = next_year
+ expect(@data.timestamp).must_equal(next_year.to_i)
+ end
+
+ it "raises an error on a null float" do
+ expect {
+ @data.float = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold a negative float" do
+ value = 0.0 - (1.0 + rand(2.0**15)).to_f
+ @data.float = value
+ expect(@data.float).must_equal(value)
+ end
+
+ it "can hold a zero float" do
+ @data.float = 0.0
+ expect(@data.float).must_equal(0.0)
+ end
+
+ it "can hold a float" do
+ value = (1.0 + rand(2.0**15)).to_f
+ @data.float = value
+ expect(@data.float).must_equal(value)
+ end
+
+ it "raise an error on a null double" do
+ expect {
+ @data.double = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold a negative double" do
+ value = 0.0 - (1.0 + rand(2.0**31)).to_f
+ @data.double = value
+ expect(@data.double).must_equal(value)
+ end
+
+ it "can hold a zero double" do
+ @data.double = 0.0
+ expect(@data.double).must_equal(0.0)
+ end
+
+ it "can hold a double" do
+ value = (1.0 + rand(2.0**31)).to_f
+ @data.double = value
+ expect(@data.double).must_equal(value)
+ end
+
+ it "raises an error on a null decimal32" do
+ expect {
+ @data.decimal32 = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold a zero decimal32" do
+ @data.decimal32 = 0
+ expect(@data.decimal32).must_equal(0)
+ end
+
+ it "can hold a decimal32" do
+ value = 1 + rand(2**31)
+ @data.decimal32 = value
+ expect(@data.decimal32).must_equal(value)
+ end
+
+ it "raises an error on a null decimal64" do
+ expect {
+ @data.decimal64 = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold a zero decimal64" do
+ @data.decimal64 = 0
+ expect(@data.decimal64).must_equal(0)
+ end
+
+ it "can hold a decimal64" do
+ value = 1 + rand(2**63)
+ @data.decimal64 = value
+ expect(@data.decimal64).must_equal(value)
+ end
+
+ it "raises an error on a null decimal128" do
+ expect {
+ @data.decimal128 = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can hold a zero decimal128" do
+ @data.decimal128 = 0
+ expect(@data.decimal128).must_equal(0)
+ end
+
+ it "can hold a decimal128" do
+ value = rand(2**127)
+ @data.decimal128 = value
+ expect(@data.decimal128).must_equal(value)
+ end
+
+ it "raises an error on a null UUID" do
+ expect {
+ @data.uuid = nil
+ }.must_raise(::ArgumentError)
+ end
+
+ it "raises an error on a malformed UUID" do
+ expect {
+ @data.uuid = random_string(36)
+ }.must_raise(::ArgumentError)
+ end
+
+ it "can set a UUID from an integer value" do
+ @data.uuid = 336307859334295828133695192821923655679
+ expect(@data.uuid).must_equal("fd0289a5-8eec-4a08-9283-81d02c9d2fff")
+ end
+
+ it "can hold a UUID" do
+ value = "fd0289a5-8eec-4a08-9283-81d02c9d2fff"
+ @data.uuid = value
+ expect(@data.uuid).must_equal(value)
+ end
+
+ it "can hold a null binary" do
+ @data.binary = nil
+ expect(@data.binary).must_equal("")
+ end
+
+ it "can hold a binary" do
+ value = random_string(128)
+ @data.binary = value
+ expect(@data.binary).must_equal(value)
+ end
+
+ it "can hold a null string" do
+ @data.string = nil
+ expect(@data.string).must_equal("")
+ end
+
+ it "can hold a string" do
+ value = random_string(128)
+ @data.string = value
+ expect(@data.string).must_equal(value)
+ end
+
+ it "can hold a null symbol" do
+ @data.symbol = nil
+ expect(@data.symbol).must_equal("")
+ end
+
+ it "can hold a symbol" do
+ value = random_string(128)
+ @data.symbol = value
+ expect(@data.symbol).must_equal(value)
+ end
+
+ it "can hold a described value" do
+ name = random_string(16)
+ value = random_string(16)
+ @data.put_described
+ @data.enter
+ @data.symbol = name
+ @data.string = value
+ @data.exit
+
+ expect(@data.described?).must_equal(true)
+ @data.enter
+ @data.next
+ expect(@data.symbol).must_equal(name)
+ @data.next
+ expect(@data.string).must_equal(value)
+ end
+
+ it "raises an error when setting the wrong type in an array"
+
+ it "can hold an array" do
+ values = []
+ (1..(rand(100) + 5)).each { values << rand(2**16) }
+ @data.put_array false, Qpid::Proton::Codec::INT
+ @data.enter
+ values.each { |value| @data.int = value }
+ @data.exit
+
+ @data.enter
+ values.each do |value|
+ @data.next
+ expect(@data.int).must_equal(value)
+ end
+ end
+
+ it "can hold a described array" do
+ values = []
+ (1..(rand(100) + 5)).each { values << random_string(64) }
+ descriptor = random_string(32)
+ @data.put_array true, Qpid::Proton::Codec::STRING
+ @data.enter
+ @data.symbol = descriptor
+ values.each { |value| @data.string = value }
+ @data.exit
+
+ expect(@data.array).must_equal([values.size, true, Qpid::Proton::Codec::STRING])
+ @data.enter
+ @data.next
+ expect(@data.symbol).must_equal(descriptor)
+ values.each do |value|
+ @data.next
+ expect(@data.string).must_equal(value)
+ end
+ end
+
+ it "can hold a list" do
+ values = []
+ (1..(rand(100) + 5)).each { values << random_string(128) }
+ @data.put_list
+ @data.enter
+ values.each {|value| @data.string = value}
+ @data.exit
+
+ @data.enter
+ values.each do |value|
+ @data.next
+ expect(@data.string).must_equal(value)
+ end
+ end
+
+ it "can hold a map" do
+ keys = []
+ (1..(rand(100) + 5)).each {keys << random_string(128)}
+ values = {}
+ keys.each {|key| values[key] = random_string(128)}
+
+ @data.put_map
+ @data.enter
+ keys.each do |key|
+ @data.string = key
+ @data.string = values[key]
+ end
+ @data.exit
+
+ @data.enter
+ keys.each do |key|
+ @data.next
+ expect(@data.string).must_equal(key)
+ @data.next
+ expect(@data.string).must_equal(values[key])
+ end
+ end
+
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/exception_handling_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/exception_handling_spec.rb b/proton-c/bindings/ruby/spec/exception_handling_spec.rb
new file mode 100644
index 0000000..129bba4
--- /dev/null
+++ b/proton-c/bindings/ruby/spec/exception_handling_spec.rb
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require "spec_helper"
+
+module Qpid
+
+ module Proton
+
+ class ExceptionHandlingClass
+ include Qpid::Proton::Util::ErrorHandler
+
+ def error
+ "This is a test error: #{Time.new}"
+ end
+ end
+
+ describe "The exception handling mixin" do
+
+ before (:each) do
+ @handler = Qpid::Proton::ExceptionHandlingClass.new
+ end
+
+ it "does not raise an error on a zero code" do
+ @handler.check_for_error(0)
+ end
+
+ it "raises EOS on PN_EOS" do
+ expect {
+ @handler.check_for_error(Qpid::Proton::Error::EOS)
+ }.must_raise(Qpid::Proton::EOSError)
+ end
+
+ it "raises Error on PN_ERR" do
+ expect {
+ @handler.check_for_error(Qpid::Proton::Error::ERROR)
+ }.must_raise(Qpid::Proton::ProtonError)
+ end
+
+ it "raises Overflow on PN_OVERFLOW" do
+ expect {
+ @handler.check_for_error(Qpid::Proton::Error::OVERFLOW)
+ }.must_raise(Qpid::Proton::OverflowError)
+ end
+
+ it "raises Underflow on PN_UNDERFLOW" do
+ expect {
+ @handler.check_for_error(Qpid::Proton::Error::UNDERFLOW)
+ }.must_raise(Qpid::Proton::UnderflowError)
+ end
+
+ it "raises Argument on PN_ARG_ERR" do
+ expect {
+ @handler.check_for_error(Qpid::Proton::Error::ARGUMENT)
+ }.must_raise(Qpid::Proton::ArgumentError)
+ end
+
+ it "raises Timeout on PN_TIMEOUT" do
+ expect {
+ @handler.check_for_error(Qpid::Proton::Error::TIMEOUT)
+ }.must_raise(Qpid::Proton::TimeoutError)
+ end
+
+ it "raises an Ruby ArgumentError on a nil code" do
+ expect {
+ @handler.check_for_error(nil)
+ }.must_raise(::ArgumentError)
+ end
+
+ it "raises a Ruby ArgumentError on an unknown value" do
+ expect {
+ @handler.check_for_error("farkle")
+ }.must_raise(::ArgumentError)
+ end
+
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/hash_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/hash_spec.rb b/proton-c/bindings/ruby/spec/hash_spec.rb
new file mode 100644
index 0000000..cd661c2
--- /dev/null
+++ b/proton-c/bindings/ruby/spec/hash_spec.rb
@@ -0,0 +1,57 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require "spec_helper"
+
+describe "The extended hash type" do
+
+ before :each do
+ @data = Qpid::Proton::Codec::Data.new
+ @hash = random_hash(rand(128) + 64)
+ end
+
+ it "raises an error when put into a nil Data instance" do
+ expect {
+ @hash.proton_data_put(nil)
+ }.must_raise(TypeError)
+ end
+
+ it "can be put into an instance of Data" do
+ @hash.proton_data_put(@data)
+ result = Hash.proton_data_get(@data)
+ expect(result.keys).must_equal(@hash.keys)
+ expect(result.values).must_equal(@hash.values)
+ end
+
+ it "raises an error when retrieved from a nil Data instance" do
+ expect {
+ Hash.proton_data_get(nil)
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when trying to get what is not a Hash" do
+ @data.string = random_string(128)
+ @data.rewind
+
+ expect {
+ Hash.proton_data_get(@data)
+ }.must_raise(TypeError)
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/message_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/message_spec.rb b/proton-c/bindings/ruby/spec/message_spec.rb
new file mode 100644
index 0000000..f36a64b
--- /dev/null
+++ b/proton-c/bindings/ruby/spec/message_spec.rb
@@ -0,0 +1,637 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require "spec_helper"
+
+module Qpid
+
+ module Proton
+
+ describe "A message" do
+
+ before (:each) do
+ @message = Qpid::Proton::Message.new
+ end
+
+ it "can be created" do
+ expect(@message).wont_be_nil
+ end
+
+ it "can be cleared" do
+ subject = random_string(16)
+ @message.subject = subject
+ expect(@message.subject).must_equal(subject)
+ @message.clear
+ expect(@message.subject).wont_equal(subject)
+ end
+
+ it "can be durable" do
+ @message.durable = true
+ expect(@message.durable).must_equal(true)
+ @message.durable = false
+ expect(@message.durable).must_equal(false)
+ end
+
+ it "raises an error when setting durable to nil" do
+ expect {
+ @message.durable = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when setting the priority to nil" do
+ expect {
+ @message.priority = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when setting the priority to a non-number" do
+ expect {
+ @message.priority = "abck"
+ }.must_raise(TypeError)
+ end
+
+ it "sets the priority to the integer portion when a float" do
+ priority = rand(100) / 10
+ @message.priority = priority
+ expect(@message.priority).must_equal(priority.floor)
+ end
+
+ it "rejects a priority with too large of a value" do
+ expect {
+ @message.priority = (rand(100) + 256)
+ }.must_raise(RangeError)
+ end
+
+ it "rejects a negative priority" do
+ expect {
+ @message.priority = (0 - (rand(255) + 1))
+ }.must_raise(RangeError)
+ end
+
+ it "has a priority" do
+ priority = rand(256)
+ @message.priority = priority
+ expect(@message.priority).must_equal(priority)
+ end
+
+ it "raises an error when setting the time-to-live to nil" do
+ expect {
+ @message.ttl = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when setting the time-to-live to a non-number" do
+ expect {
+ @message.ttl = random_string(5)
+ }.must_raise(TypeError)
+ end
+
+ it "sets the time-to-live to the integer portion when a float" do
+ ttl = (rand(32767) / 10)
+ @message.ttl = ttl
+ expect(@message.ttl).must_equal(ttl.floor)
+ end
+
+ it "raises an error when the time-to-live is negative" do
+ expect {
+ @message.ttl = (0 - rand(1000))
+ }.must_raise(RangeError)
+ end
+
+ it "has a time-to-live" do
+ ttl = rand(32767)
+ @message.ttl = ttl
+ expect(@message.ttl).must_equal(ttl)
+ end
+
+ it "raises an error when setting first acquirer to nil" do
+ expect {
+ @message.first_acquirer = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises and error when setting first acquirer to a non-boolean" do
+ expect {
+ @message.first_acquirer = random_string(16)
+ }.must_raise(TypeError)
+ end
+
+ it "has a first acquirer" do
+ @message.first_acquirer = true
+ expect(@message.first_acquirer?).must_equal(true)
+
+ @message.first_acquirer = false
+ expect(@message.first_acquirer?).must_equal(false)
+ end
+
+ it "raises an error on a nil delivery count" do
+ expect {
+ @message.delivery_count = nil
+ }.must_raise(::ArgumentError)
+ end
+
+ it "raises an error on a negative delivery count" do
+ expect {
+ @message.delivery_count = -1
+ }.must_raise(RangeError)
+ end
+
+ it "raises an error on a non-numeric delivery count" do
+ expect {
+ @message.delivery_count = "farkle"
+ }.must_raise(::ArgumentError)
+ end
+
+ it "converts a floating point delivery count to its integer portion" do
+ count = rand(255) / 10.0
+ @message.delivery_count = count
+ expect(@message.delivery_count).must_equal(count.floor)
+ end
+
+ it "has a delivery count" do
+ count = rand(255)
+ @message.delivery_count = count
+ expect(@message.delivery_count).must_equal(count)
+ end
+
+ it "allows setting a nil id" do
+ @message.id = nil
+ expect(@message.id).must_be_nil
+ end
+
+ it "has an id" do
+ id = random_string(16)
+ @message.id = id
+ expect(@message.id).must_equal(id)
+ end
+
+ it "allows setting a nil user id" do
+ @message.user_id = nil
+ expect(@message.user_id).must_equal("")
+ end
+
+ it "has a user id" do
+ id = random_string(16)
+ @message.user_id = id
+ expect(@message.user_id).must_equal(id)
+ end
+
+ it "allows setting a nil address" do
+ @message.address = nil
+ expect(@message.address).must_be_nil
+ end
+
+ it "has an address" do
+ address = "//0.0.0.0/#{random_string(16)}"
+ @message.address = address
+ expect(@message.address).must_equal(address)
+ end
+
+ it "allows setting a nil subject" do
+ @message.subject = nil
+ expect(@message.subject).must_be_nil
+ end
+
+ it "has a subject" do
+ subject = random_string(50)
+ @message.subject = subject
+ expect(@message.subject).must_equal(subject)
+ end
+
+ it "will allow a nil reply-to address" do
+ @message.reply_to = nil
+ expect(@message.reply_to).must_be_nil
+ end
+
+ it "has a reply-to address" do
+ address = "//0.0.0.0/#{random_string(16)}"
+ @message.reply_to = address
+ expect(@message.reply_to).must_equal(address)
+ end
+
+ it "will allow a nil correlation id" do
+ @message.correlation_id = nil
+ expect(@message.correlation_id).must_be_nil
+ end
+
+ it "has a correlation id" do
+ id = random_string(25)
+ @message.correlation_id = id
+ expect(@message.correlation_id).must_equal(id)
+ end
+
+ it "will allow a nil content type" do
+ @message.content_type = nil
+ expect(@message.content_type).must_be_nil
+ end
+
+ it "will allow an empty content type" do
+ @message.content_type = ""
+ expect(@message.content_type).must_equal("")
+ end
+
+ it "has a content type" do
+ content_type = random_string(32)
+ @message.content_type = content_type
+ expect(@message.content_type).must_equal(content_type)
+ end
+
+ it "can have nil content encoding" do
+ @message.content_encoding = nil
+ expect(@message.content_encoding).must_be_nil
+ end
+
+ it "has a content encoding" do
+ encoding = "#{random_string(8)}/#{random_string(8)}"
+ @message.content_encoding = encoding
+ expect(@message.content_encoding).must_equal(encoding)
+ end
+
+ it "raises an error on a nil expiry time" do
+ expect {
+ @message.expires = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error on a negative expiry time" do
+ expect {
+ @message.expires = (0-(rand(65535)))
+ }.must_raise(::ArgumentError)
+ end
+
+ it "can have a zero expiry time" do
+ @message.expires = 0
+ expect(@message.expires).must_equal(0)
+ end
+
+ it "has an expiry time" do
+ time = rand(65535)
+ @message.expires = time
+ expect(@message.expires).must_equal(time)
+ end
+
+ it "raises an error on a nil creation time" do
+ expect {
+ @message.creation_time = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error on a negative creation time" do
+ expect {
+ @message.creation_time = (0 - rand(65535))
+ }.must_raise(::ArgumentError)
+ end
+
+ it "can have a zero creation time" do
+ @message.creation_time = 0
+ expect(@message.creation_time).must_equal(0)
+ end
+
+ it "has a creation time" do
+ time = rand(65535)
+ @message.creation_time = time
+ expect(@message.creation_time).must_equal(time)
+ end
+
+ it "can have a nil group id" do
+ @message.group_id = nil
+ expect(@message.group_id).must_be_nil
+ end
+
+ it "can have an empty group id" do
+ @message.group_id = ""
+ expect(@message.group_id).must_equal("")
+ end
+
+ it "has a group id" do
+ id = random_string(16)
+ @message.group_id = id
+ expect(@message.group_id).must_equal(id)
+ end
+
+
+ it "raises an error on a nil group sequence" do
+ expect {
+ @message.group_sequence = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can have a negative group sequence" do
+ seq = (0 - rand(32767))
+ @message.group_sequence = seq
+ expect(@message.group_sequence).must_equal(seq)
+ end
+
+ it "can have a zero group sequence" do
+ @message.group_sequence = 0
+ expect(@message.group_sequence).must_equal(0)
+ end
+
+ it "has a group sequence" do
+ id = rand(32767)
+ @message.group_sequence = id
+ expect(@message.group_sequence).must_equal(id)
+ end
+
+ it "can have a nil reply-to group id" do
+ @message.reply_to_group_id = nil
+ expect(@message.reply_to_group_id).must_be_nil
+ end
+
+ it "can have an empty reply-to group id" do
+ @message.reply_to_group_id = ""
+ expect(@message.reply_to_group_id).must_equal("")
+ end
+
+ it "has a reply-to group id" do
+ id = random_string(16)
+ @message.reply_to_group_id = id
+ expect(@message.reply_to_group_id).must_equal(id)
+ end
+
+ it "has properties" do
+ expect(@message).must_respond_to(:properties)
+ expect(@message).must_respond_to(:properties=)
+ expect(@message).must_respond_to(:[])
+ expect(@message).must_respond_to(:[]=)
+
+ expect(@message.properties).must_be_kind_of({}.class)
+ end
+
+ it "can replace the set of properties" do
+ values = random_hash(128)
+
+ @message.properties = values.clone
+ expect(@message.properties).must_equal(values)
+ end
+
+ it "can set properties" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message[name] = value
+ expect(@message[name]).must_equal(value)
+ end
+
+ it "can update properties" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message[name] = value
+ expect(@message[name]).must_equal(value)
+
+ value = random_string(128)
+ @message[name] = value
+ expect(@message[name]).must_equal(value)
+ end
+
+ it "can hold a null property" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message[name] = value
+ expect(@message[name]).must_equal(value)
+
+ @message[name] = nil
+ expect(@message[name]).must_be_nil
+ end
+
+ it "can delete a property" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message[name] = value
+ expect(@message[name]).must_equal(value)
+
+ @message.delete_property(name)
+ expect(@message.properties.keys).wont_include(name)
+ end
+
+ it "has no properties after being cleared" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message[name] = value
+ expect(@message[name]).must_equal(value)
+
+ @message.clear
+ expect(@message.properties).must_be_empty
+ end
+
+ it "has instructions" do
+ expect(@message).must_respond_to(:instructions)
+ expect(@message).must_respond_to("instructions=".to_sym)
+ end
+
+ it "can set an instruction" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message.instructions[name] = value
+ expect(@message.instructions[name]).must_equal(value)
+ end
+
+ it "can update an instruction" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message.instructions[name] = value
+ expect(@message.instructions[name]).must_equal(value)
+
+ value = random_string(128)
+ @message.instructions[name] = value
+ expect(@message.instructions[name]).must_equal(value)
+ end
+
+ it "can delete the instructions" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message.instructions[name] = value
+ expect(@message.instructions).wont_be_empty
+
+ @message.instructions = nil
+ expect(@message.instructions).must_be_nil
+ end
+
+ it "can replace the instructions" do
+ values = random_hash(rand(128) + 1)
+
+ @message.instructions = values.clone
+ expect(@message.instructions).must_equal(values)
+
+ values = random_hash(rand(64) + 1)
+
+ @message.instructions = values.clone
+ expect(@message.instructions).must_equal(values)
+ end
+
+ it "can delete the set of instructions" do
+ values = random_hash(rand(128) + 1)
+
+ @message.instructions = values.clone
+ expect(@message.instructions).must_equal(values)
+
+ @message.instructions = nil
+ expect(@message.instructions).must_be_nil
+ end
+
+ it "has no instructions after being cleared" do
+ value = random_hash(128)
+
+ @message.instructions = value.clone
+ expect(@message.instructions).must_equal(value)
+
+ @message.clear
+ expect(@message.instructions).must_be_empty
+ end
+
+ it "has annotations" do
+ expect(@message).must_respond_to(:annotations)
+ expect(@message).must_respond_to(:annotations=)
+ end
+
+ it "can set an annotation" do
+ name = random_hash(32)
+ value = random_hash(256)
+
+ @message.annotations[name] = value.clone
+ expect(@message.annotations[name]).must_equal(value)
+ end
+
+ it "can update an annotation" do
+ name = random_hash(32)
+ value = random_hash(256)
+
+ @message.annotations[name] = value.clone
+ expect(@message.annotations[name]).must_equal(value)
+
+ value = random_hash(128)
+
+ @message.annotations[name] = value.clone
+ expect(@message.annotations[name]).must_equal(value)
+ end
+
+ it "can delete an annotation" do
+ name = random_hash(32)
+ value = random_hash(256)
+
+ @message.annotations[name] = value.clone
+ expect(@message.annotations[name]).must_equal(value)
+
+ @message.annotations[name] = nil
+ expect(@message.annotations[name]).must_be_nil
+ end
+
+ it "can replace all annotations" do
+ values = random_hash(rand(128) + 1)
+
+ @message.annotations = values.clone
+ expect(@message.annotations).must_equal(values)
+
+ values = random_hash(rand(64) + 1)
+
+ @message.annotations = values.clone
+ expect(@message.annotations).must_equal(values)
+ end
+
+ it "can delete the set of annotations" do
+ value = random_hash(rand(128) + 1)
+
+ @message.annotations = value.clone
+ expect(@message.annotations).must_equal(value)
+
+ @message.annotations = nil
+ expect(@message.annotations).must_be_nil
+ end
+
+ it "has no annotations after being cleared" do
+ value = random_hash(16)
+
+ @message.annotations = value
+ expect(@message.annotations).must_equal(value)
+
+ @message.clear
+ expect(@message.annotations).must_be_empty
+ end
+
+ it "has a body property" do
+ expect(@message).must_respond_to(:body)
+ expect(@message).must_respond_to(:body=)
+ end
+
+ it "has a default body that is nil" do
+ expect(@message.body).must_be_nil
+ end
+
+ it "has no body after being cleared" do
+ name = random_string(16)
+ value = random_string(128)
+
+ @message.body = value
+ expect(@message.body).must_equal(value)
+
+ @message.clear
+ expect(@message.body).must_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
+ expect(@message.body).must_equal(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
+ expect(@message.body).must_equal(value)
+
+ @message.body = nil
+ expect(@message.body).must_be_nil
+ end
+ end
+
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/messenger_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/messenger_spec.rb b/proton-c/bindings/ruby/spec/messenger_spec.rb
new file mode 100644
index 0000000..0fec6b9
--- /dev/null
+++ b/proton-c/bindings/ruby/spec/messenger_spec.rb
@@ -0,0 +1,393 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require "spec_helper"
+
+module Qpid
+
+ module Proton
+
+ describe "A messenger" do
+
+ before (:each) do
+ @messenger = Qpid::Proton::Messenger::Messenger.new
+ end
+
+ after (:each) do
+ begin
+ @messenger.stop
+ rescue ProtonError => error
+ # ignore this error
+ end
+ end
+
+ it "will generate a name if one is not provided" do
+ expect(@messenger.name).wont_be_nil
+ end
+
+ it "will accept an assigned name" do
+ name = random_string(16)
+ msgr = Qpid::Proton::Messenger::Messenger.new(name)
+ expect(msgr.name).must_equal(name)
+ end
+
+ it "raises an error on a nil timeout" do
+ expect {
+ @messenger.timeout = nil
+ }.must_raise(TypeError)
+ end
+
+ it "can have a negative timeout" do
+ timeout = (0 - rand(65535))
+ @messenger.timeout = timeout
+ expect(@messenger.timeout).must_equal(timeout)
+ end
+
+ it "has a timeout" do
+ timeout = rand(65535)
+ @messenger.timeout = timeout
+ expect(@messenger.timeout).must_equal(timeout)
+ end
+
+ it "has an error number" do
+ expect(@messenger.error?).must_equal(false)
+ expect(@messenger.errno).must_equal(0)
+ # force an error
+ expect {
+ @messenger.subscribe("amqp://~#{random_string}")
+ }.must_raise(ProtonError)
+ expect(@messenger.error?).must_equal(true)
+ expect(@messenger.errno).wont_equal(0)
+ end
+
+ it "has an error message" do
+ expect(@messenger.error?).must_equal(false)
+ expect(@messenger.error).must_be_nil
+ # force an error
+ expect {
+ @messenger.subscribe("amqp://~#{random_string}")
+ }.must_raise(ProtonError)
+ expect(@messenger.error?).must_equal(true)
+ expect(@messenger.errno).wont_be_nil
+ end
+
+ it "can be started" do
+ @messenger.start
+ end
+
+ it "can be stopped" do
+ @messenger.stop
+ end
+
+ it "raises an error when subscribing to a nil address" do
+ expect {
+ @messenger.subscribe(nil)
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when subscribing to an invalid address" do
+ expect {
+ @messenger.subscribe("amqp://~#{random_string}")
+ }.must_raise(ProtonError)
+ expect(@messenger.error?).must_equal(true)
+ expect(@messenger.errno).wont_equal(nil)
+ end
+
+ it "can have a nil certificate" do
+ @messenger.certificate = nil
+ expect(@messenger.certificate).must_be_nil
+ end
+
+ it "can have a certificate" do
+ cert = random_string(128)
+ @messenger.certificate = cert
+ expect(@messenger.certificate).must_equal(cert)
+ end
+
+ it "can have a nil private key" do
+ @messenger.private_key = nil
+ expect(@messenger.private_key).must_be_nil
+ end
+
+ it "can have a private key" do
+ key = random_string(128)
+ @messenger.private_key = key
+ expect(@messenger.private_key).must_equal(key)
+ end
+
+ it "can have a nil trusted certificates" do
+ @messenger.trusted_certificates = nil
+ expect(@messenger.trusted_certificates).must_be_nil
+ end
+
+ it "has a list of trusted certificates" do
+ certs = random_string(128)
+ @messenger.trusted_certificates = certs
+ expect(@messenger.trusted_certificates).must_equal(certs)
+ end
+
+ it "raises an error on a nil outgoing window" do
+ expect {
+ @messenger.outgoing_window = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error on a non-numeric outgoing window" do
+ expect {
+ @messenger.outgoing_window = random_string(16)
+ }.must_raise(TypeError)
+ end
+
+ it "can have a negative outgoing window" do
+ window = 0 - (rand(256) + 1)
+ @messenger.outgoing_window = window
+ expect(@messenger.outgoing_window).must_equal(window)
+ end
+
+ it "can have a positive outgoing window" do
+ window = (rand(256) + 1)
+ @messenger.outgoing_window = window
+ expect(@messenger.outgoing_window).must_equal(window)
+ end
+
+ it "can have a zero outgoing window" do
+ window = 0
+ @messenger.outgoing_window = window
+ expect(@messenger.outgoing_window).must_equal(window)
+ end
+
+ it "raises an error on a nil incoming window" do
+ expect {
+ @messenger.incoming_window = nil
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error on a non-numeric incoming window" do
+ expect {
+ @messenger.incoming_window = random_string(16)
+ }.must_raise(TypeError)
+ end
+
+ it "can have a negative incoming window" do
+ window = 0 - (rand(256) + 1)
+ @messenger.incoming_window = window
+ expect(@messenger.incoming_window).must_equal(window)
+ end
+
+ it "can have a positive incoming window" do
+ window = (rand(256) + 1)
+ @messenger.incoming_window = window
+ expect(@messenger.incoming_window).must_equal(window)
+ end
+
+ it "can have a zero incoming window" do
+ window = 0
+ @messenger.incoming_window = window
+ expect(@messenger.incoming_window).must_equal(window)
+ end
+
+ it "can be put into passive mode" do
+ @messenger.passive = true
+ expect(@messenger.passive?).must_equal(true)
+ end
+
+ it "can be taken out of passive mode" do
+ @messenger.passive = false
+ expect(@messenger.passive?).must_equal(false)
+ end
+
+ it "can clear non-existent errors with failing" do
+ @messenger.clear_error
+ end
+
+ it "can clear errors" do
+ begin
+ @messenger.accept # should cause an error
+ rescue; end
+
+ expect(@messenger.error).wont_be_nil
+ @messenger.clear_error
+ expect(@messenger.error).must_be_nil
+ end
+
+ describe "once started" do
+
+ before (:each) do
+ @messenger.start
+ end
+
+ after (:each) do
+ begin
+ @messenger.stop
+ rescue ProtonError => error
+ # ignore this error
+ end
+ end
+
+ it "can subscribe to an address" do
+ expect(@messenger.subscribe("amqp://~0.0.0.0:#{5700+rand(1024)}")).wont_be_nil
+ end
+
+ it "returns a tracker's status"
+
+ describe "and subscribed to an address" do
+
+ before (:each) do
+ # create a receiver
+ @port = 5700 + rand(1024)
+ @receiver = Qpid::Proton::Messenger::Messenger.new("receiver")
+ @receiver.subscribe("amqp://~0.0.0.0:#{@port}")
+ @messenger.timeout = 0
+ @receiver.timeout = 0
+ @receiver.start
+
+ Thread.new do
+ @receiver.receive(10)
+ end
+
+ @msg = Qpid::Proton::Message.new
+ @msg.address = "amqp://0.0.0.0:#{@port}"
+ @msg.body = "Test sent #{Time.new}"
+ end
+
+ after (:each) do
+ begin
+ @messenger.stop
+ rescue ProtonError => error
+ # ignore this error
+ end
+ begin
+ @receiver.stop
+ rescue
+ end
+ end
+
+ it "raises an error when queueing a nil message" do
+ expect {
+ @messenger.put(nil)
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when queueing an invalid object" do
+ expect {
+ @messenger.put("This is not a message")
+ }.must_raise(::ArgumentError)
+ end
+
+ it "can place a message in the outgoing queue" do
+ @messenger.put(@msg)
+ end
+
+ it "can send with an empty queue"
+
+ describe "with a an outgoing tracker" do
+
+ before(:each) do
+ @messenger.put(@msg)
+ @tracker = @messenger.outgoing_tracker
+ end
+
+ it "has an outgoing tracker" do
+ expect(@tracker).wont_be_nil
+ end
+
+ it "returns a tracker's status"
+
+ it "raises an error when settling with a nil tracker" do
+ expect {
+ @messenger.settle(nil)
+ }.must_raise(TypeError)
+ end
+
+ it "can settle a tracker's status" do
+ @messenger.settle(@tracker)
+ end
+
+ it "raises an error when checking status on a nil tracker" do
+ expect {
+ @messenger.status(nil)
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when checking status on an invalid tracker" do
+ expect {
+ @messenger.status(random_string(16))
+ }.must_raise(TypeError)
+ end
+
+ it "can check the status of a tracker" do
+ expect(@messenger.status(@tracker)).wont_be_nil
+ end
+
+ end
+
+ it "has an incoming tracker"
+ it "can reject an incoming message"
+
+ it "raises an error when accepting with an invalid tracker" do
+ expect {
+ @messenger.accept(random_string(16))
+ }.must_raise(TypeError)
+ end
+
+ it "can accept a message"
+
+ it "raises an error when rejecting with an invalid tracker" do
+ expect {
+ @messenger.accept(random_string(16))
+ }.must_raise(TypeError)
+ end
+
+ describe "with messages sent" do
+
+ before (:each) do
+ @messenger.put(@msg)
+ end
+
+ it "can send messages"
+
+ it "raises an error when receiving with a nil max" do
+ expect {
+ @messenger.receive(nil)
+ }.must_raise(TypeError)
+ end
+
+ it "raises an error when receiving with a non-numeric max" do
+ expect {
+ @messenger.receive("farkle")
+ }.must_raise(TypeError)
+ end
+
+ it "can receive messages"
+ it "and create a new message when one wasn't provided"
+ it "can get a message from the incoming queue"
+ it "can tell how many outgoing messages are pending"
+ it "can tell how many incoming messages are queued"
+
+ end
+
+ end
+
+ end
+
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/qpid/proton/array_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/qpid/proton/array_spec.rb b/proton-c/bindings/ruby/spec/qpid/proton/array_spec.rb
deleted file mode 100644
index 2f26fdf..0000000
--- a/proton-c/bindings/ruby/spec/qpid/proton/array_spec.rb
+++ /dev/null
@@ -1,114 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-require "spec_helper"
-
-describe "The extended array type" do
-
- before :each do
- @data = Qpid::Proton::Codec::Data.new
- @list = random_list(rand(100))
- @undescribed = random_array(rand(100))
- @description = random_string(128)
- @described = random_array(rand(100), true, @description)
- end
-
- it "can be created like a normal array" do
- value = []
-
- expect(value).to respond_to(:proton_put)
- expect(value).to respond_to(:proton_array_header)
- expect(value.class).to respond_to(:proton_get)
- expect(value).to respond_to :proton_described?
- end
-
- it "raises an error when putting into a nil Data object" do
- expect {
- @list.proton_put(nil)
- }.to raise_error
- end
-
- it "raises an error when getting from a nil Data object" do
- expect {
- Array.proton_get(nil)
- }.to raise_error(TypeError)
- end
-
- it "raises an error when the data object is empty" do
- expect {
- Array.proton_get(@data)
- }.to raise_error(TypeError)
- end
-
- it "raises an error when the current object is not a list" do
- @data.string = random_string(128)
- @data.rewind
-
- expect {
- Array.proton_get(@data)
- }.to raise_error(TypeError)
- end
-
- it "does not have an array header when it's a simple list" do
- expect(@list.proton_described?).to eq(false)
- end
-
- it "can be put into a Data object as a list" do
- @list.proton_put(@data)
- result = Array.proton_get(@data)
- expect(result).to match_array(@list)
- expect(result.proton_array_header).to eq(nil)
- end
-
- it "has an array header when it's an AMQP array" do
- expect(@undescribed.proton_array_header).not_to be_nil
- expect(@described.proton_array_header).not_to be_nil
- end
-
- it "raises an error when the elements of an Array are dissimilar and is put into a Data object" do
- value = []
- value.proton_array_header = Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT)
- value << random_string(16)
-
- expect {
- value.proton_put(@data)
- }.to raise_error(TypeError)
- end
-
- it "can be put into a Data object as an undescribed array" do
- @undescribed.proton_put(@data)
- result = Array.proton_get(@data)
- be_close_array(@undescribed, result)
-
- expect(result.proton_array_header).not_to be_nil
- expect(result.proton_array_header).to eq(@undescribed.proton_array_header)
- expect(result.proton_array_header.described?).to eq(false)
- end
-
- it "can be put into a Data object as a described array" do
- @described.proton_put(@data)
- result = Array.proton_get(@data)
- be_close_array(@described, result)
-
- expect(result.proton_array_header).not_to be_nil
- expect(result.proton_array_header).to eq(@described.proton_array_header)
- expect(result.proton_array_header.described?).to eq(true)
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/qpid/proton/data_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/qpid/proton/data_spec.rb b/proton-c/bindings/ruby/spec/qpid/proton/data_spec.rb
deleted file mode 100644
index c8c7d18..0000000
--- a/proton-c/bindings/ruby/spec/qpid/proton/data_spec.rb
+++ /dev/null
@@ -1,493 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-require "spec_helper"
-
-module Qpid
-
- module Proton
-
- describe "A data object" do
-
- before :each do
- @data = Qpid::Proton::Codec::Data.new
- end
-
- it "can be initialized" do
- expect(@data).not_to be_nil
- end
-
- it "can hold a null" do
- @data.null
- expect(@data.null?).to eq(true)
- end
-
- it "can hold a true boolean" do
- @data.bool = true
- expect(@data.bool).to eq(true)
- end
-
- it "can hold a false boolean" do
- @data.bool = false
- expect(@data.bool).to eq(false)
- end
-
- it "raises an error on a negative ubyte" do
- expect {
- @data.ubyte = (0 - (rand(127) + 1))
- }.to raise_error(RangeError)
- end
-
- it "raises an error on a null ubyte" do
- expect {
- @data.ubyte = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold an unsigned byte" do
- value = rand(255)
- @data.ubyte = value
- expect(@data.ubyte).to eq(value)
- end
-
- it "can hold a byte" do
- value = rand(128)
- @data.byte = value
- expect(@data.byte).to eq(value)
- end
-
- it "can hold a negative byte" do
- value = 0 - (rand(126) + 1)
- @data.byte = value
- expect(@data.byte).to eq(value)
- end
-
- it "raises an error on a negative ushort" do
- expect {
- @data.ushort = (0 - (rand(65535) + 1))
- }.to raise_error(RangeError)
- end
-
- it "raises an error on a nil ushort" do
- expect {
- @data.ushort = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold a zero unsigned short" do
- @data.ushort = 0
- expect(@data.ushort).to eq(0)
- end
-
- it "can hold an unsigned short" do
- value = rand(2**15) + 1
- @data.ushort = value
- expect(@data.ushort).to eq(value)
- end
-
- it "raises an error on a nil short" do
- expect {
- @data.short = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold a short" do
- value = rand(2**15) + 1
- @data.short = value
- expect(@data.short).to eq(value)
- end
-
- it "can hold a zero short" do
- @data.short = 0
- expect(@data.short).to eq(0)
- end
-
- it "can hold a negative short" do
- value = (0 - (rand(2**15) + 1))
- @data.short = value
- expect(@data.short).to eq(value)
- end
-
- it "raises an error on a nil uint" do
- expect {
- @data.uint = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error on a negative uint" do
- expect {
- @data.uint = (0 - (rand(2**32) + 1))
- }.to raise_error(RangeError)
- end
-
- it "can hold an unsigned integer" do
- value = rand(2**32) + 1
- @data.uint = value
- expect(@data.uint).to eq(value)
- end
-
- it "can hold a zero unsigned integer" do
- @data.uint = 0
- expect(@data.uint).to eq(0)
- end
-
- it "raise an error on a null integer" do
- expect {
- @data.int = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold an integer" do
- value = rand(2**31) + 1
- @data.int = value
- expect(@data.int).to eq(value)
- end
-
- it "can hold zero as an integer" do
- @data.int = 0
- expect(@data.int).to eq(0)
- end
-
- it "raises an error on a null character" do
- expect {
- @data.char = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold a character" do
- source = random_string(256)
- index = rand(source.length)
- value = source[index,1].bytes.to_a[0]
- @data.char = value
- expect(@data.char).to eq(value)
- end
-
- it "raises an error on a null ulong" do
- expect {
- @data.ulong = nil
- }.to raise_error(TypeError)
- end
-
- it "raises an error on a negative ulong" do
- expect {
- @data.ulong = (0 - (rand(2**63) + 1))
- }.to raise_error(RangeError)
- end
-
- it "can have a zero unsigned long" do
- @data.ulong = 0
- expect(@data.ulong).to eq(0)
- end
-
- it "can hold an unsigned long" do
- value = rand(2**63) + 1
- @data.ulong = value
- expect(@data.ulong).to eq(value)
- end
-
- it "raises an error on a null long" do
- expect {
- @data.long = nil
- }.to raise_error(TypeError)
- end
-
- it "can have a zero long" do
- @data.long = 0
- expect(@data.long).to eq(0)
- end
-
- it "can hold a long" do
- value = rand(2**63) + 1
- @data.long = value
- expect(@data.long).to eq(value)
- end
-
- it "raise an error on a null timestamp" do
- expect {
- @data.timestamp = nil
- }.to raise_error(TypeError)
- end
-
- it "can handle a negative timestamp" do
- last_year = Time.now - (60*60*24*365)
- @data.timestamp = last_year
- expect(@data.timestamp).to eq(last_year.to_i)
- end
-
- it "can handle a zero timestamp" do
- @data.timestamp = 0
- expect(@data.timestamp).to eq(0)
- end
-
- it "can hold a timestamp" do
- next_year = Time.now + (60*60*24*365)
- @data.timestamp = next_year
- expect(@data.timestamp).to eq(next_year.to_i)
- end
-
- it "raises an error on a null float" do
- expect {
- @data.float = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold a negative float" do
- value = 0.0 - (1.0 + rand(2.0**15)).to_f
- @data.float = value
- expect(@data.float).to eq(value)
- end
-
- it "can hold a zero float" do
- @data.float = 0.0
- expect(@data.float).to eq(0.0)
- end
-
- it "can hold a float" do
- value = (1.0 + rand(2.0**15)).to_f
- @data.float = value
- expect(@data.float).to eq(value)
- end
-
- it "raise an error on a null double" do
- expect {
- @data.double = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold a negative double" do
- value = 0.0 - (1.0 + rand(2.0**31)).to_f
- @data.double = value
- expect(@data.double).to eq(value)
- end
-
- it "can hold a zero double" do
- @data.double = 0.0
- expect(@data.double).to eq(0.0)
- end
-
- it "can hold a double" do
- value = (1.0 + rand(2.0**31)).to_f
- @data.double = value
- expect(@data.double).to eq(value)
- end
-
- it "raises an error on a null decimal32" do
- expect {
- @data.decimal32 = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold a zero decimal32" do
- @data.decimal32 = 0
- expect(@data.decimal32).to eq(0)
- end
-
- it "can hold a decimal32" do
- value = 1 + rand(2**31)
- @data.decimal32 = value
- expect(@data.decimal32).to eq(value)
- end
-
- it "raises an error on a null decimal64" do
- expect {
- @data.decimal64 = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold a zero decimal64" do
- @data.decimal64 = 0
- expect(@data.decimal64).to eq(0)
- end
-
- it "can hold a decimal64" do
- value = 1 + rand(2**63)
- @data.decimal64 = value
- expect(@data.decimal64).to eq(value)
- end
-
- it "raises an error on a null decimal128" do
- expect {
- @data.decimal128 = nil
- }.to raise_error(TypeError)
- end
-
- it "can hold a zero decimal128" do
- @data.decimal128 = 0
- expect(@data.decimal128).to eq(0)
- end
-
- it "can hold a decimal128" do
- value = rand(2**127)
- @data.decimal128 = value
- expect(@data.decimal128).to eq(value)
- end
-
- it "raises an error on a null UUID" do
- expect {
- @data.uuid = nil
- }.to raise_error(::ArgumentError)
- end
-
- it "raises an error on a malformed UUID" do
- expect {
- @data.uuid = random_string(36)
- }.to raise_error(::ArgumentError)
- end
-
- it "can set a UUID from an integer value" do
- @data.uuid = 336307859334295828133695192821923655679
- expect(@data.uuid).to eq("fd0289a5-8eec-4a08-9283-81d02c9d2fff")
- end
-
- it "can hold a UUID" do
- value = "fd0289a5-8eec-4a08-9283-81d02c9d2fff"
- @data.uuid = value
- expect(@data.uuid).to eq(value)
- end
-
- it "can hold a null binary" do
- @data.binary = nil
- expect(@data.binary).to eq("")
- end
-
- it "can hold a binary" do
- value = random_string(128)
- @data.binary = value
- expect(@data.binary).to eq(value)
- end
-
- it "can hold a null string" do
- @data.string = nil
- expect(@data.string).to eq("")
- end
-
- it "can hold a string" do
- value = random_string(128)
- @data.string = value
- expect(@data.string).to eq(value)
- end
-
- it "can hold a null symbol" do
- @data.symbol = nil
- expect(@data.symbol).to eq("")
- end
-
- it "can hold a symbol" do
- value = random_string(128)
- @data.symbol = value
- expect(@data.symbol).to eq(value)
- end
-
- it "can hold a described value" do
- name = random_string(16)
- value = random_string(16)
- @data.put_described
- @data.enter
- @data.symbol = name
- @data.string = value
- @data.exit
-
- expect(@data.described?).to eq(true)
- @data.enter
- @data.next
- expect(@data.symbol).to eq(name)
- @data.next
- expect(@data.string).to eq(value)
- end
-
- it "raises an error when setting the wrong type in an array"
-
- it "can hold an array" do
- values = []
- (1..(rand(100) + 5)).each { values << rand(2**16) }
- @data.put_array false, Qpid::Proton::Codec::INT
- @data.enter
- values.each { |value| @data.int = value }
- @data.exit
-
- @data.enter
- values.each do |value|
- @data.next
- expect(@data.int).to eq(value)
- end
- end
-
- it "can hold a described array" do
- values = []
- (1..(rand(100) + 5)).each { values << random_string(64) }
- descriptor = random_string(32)
- @data.put_array true, Qpid::Proton::Codec::STRING
- @data.enter
- @data.symbol = descriptor
- values.each { |value| @data.string = value }
- @data.exit
-
- expect(@data.array).to match_array([values.size, true, Qpid::Proton::Codec::STRING])
- @data.enter
- @data.next
- expect(@data.symbol).to eq(descriptor)
- values.each do |value|
- @data.next
- expect(@data.string).to eq(value)
- end
- end
-
- it "can hold a list" do
- values = []
- (1..(rand(100) + 5)).each { values << random_string(128) }
- @data.put_list
- @data.enter
- values.each {|value| @data.string = value}
- @data.exit
-
- @data.enter
- values.each do |value|
- @data.next
- expect(@data.string).to eq(value)
- end
- end
-
- it "can hold a map" do
- keys = []
- (1..(rand(100) + 5)).each {keys << random_string(128)}
- values = {}
- keys.each {|key| values[key] = random_string(128)}
-
- @data.put_map
- @data.enter
- keys.each do |key|
- @data.string = key
- @data.string = values[key]
- end
- @data.exit
-
- @data.enter
- keys.each do |key|
- @data.next
- expect(@data.string).to eq(key)
- @data.next
- expect(@data.string).to eq(values[key])
- end
- end
-
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e1bce7a/proton-c/bindings/ruby/spec/qpid/proton/exception_handling_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/qpid/proton/exception_handling_spec.rb b/proton-c/bindings/ruby/spec/qpid/proton/exception_handling_spec.rb
deleted file mode 100644
index e296a69..0000000
--- a/proton-c/bindings/ruby/spec/qpid/proton/exception_handling_spec.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-module Qpid
-
- module Proton
-
- class ExceptionHandlingClass
- include Qpid::Proton::Util::ErrorHandler
-
- def error
- "This is a test error: #{Time.new}"
- end
- end
-
- describe "The exception handling mixin" do
-
- before (:each) do
- @handler = Qpid::Proton::ExceptionHandlingClass.new
- end
-
- it "does not raise an error on a zero code" do
- expect {
- @handler.check_for_error(0)
- }.to_not raise_error
- end
-
- it "raises EOS on PN_EOS" do
- expect {
- @handler.check_for_error(Qpid::Proton::Error::EOS)
- }.to raise_error(Qpid::Proton::EOSError)
- end
-
- it "raises Error on PN_ERR" do
- expect {
- @handler.check_for_error(Qpid::Proton::Error::ERROR)
- }.to raise_error(Qpid::Proton::ProtonError)
- end
-
- it "raises Overflow on PN_OVERFLOW" do
- expect {
- @handler.check_for_error(Qpid::Proton::Error::OVERFLOW)
- }.to raise_error(Qpid::Proton::OverflowError)
- end
-
- it "raises Underflow on PN_UNDERFLOW" do
- expect {
- @handler.check_for_error(Qpid::Proton::Error::UNDERFLOW)
- }.to raise_error(Qpid::Proton::UnderflowError)
- end
-
- it "raises Argument on PN_ARG_ERR" do
- expect {
- @handler.check_for_error(Qpid::Proton::Error::ARGUMENT)
- }.to raise_error(Qpid::Proton::ArgumentError)
- end
-
- it "raises Timeout on PN_TIMEOUT" do
- expect {
- @handler.check_for_error(Qpid::Proton::Error::TIMEOUT)
- }.to raise_error(Qpid::Proton::TimeoutError)
- end
-
- it "raises an Ruby ArgumentError on a nil code" do
- expect {
- @handler.check_for_error(nil)
- }.to raise_error(::ArgumentError)
- end
-
- it "raises a Ruby ArgumentError on an unknown value" do
- expect {
- @handler.check_for_error("farkle")
- }.to raise_error(::ArgumentError)
- end
-
- end
-
- end
-
-end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org