Sha256: b084f90569b809c033961ae378468231284cc8f423ef98f5a3a7ebee39002e03

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require "integration/test_helper"
require "azure/service_bus/queues"
require "azure/service_bus/brokered_message"

describe "Read and Delete a Message from a Queue" do

  after do
    ServiceBusQueueNameHelper.clean
  end

  before do
    @queue = Azure::ServiceBus::Queues.create(ServiceBusQueueNameHelper.name)
  end

  it "should be able to read-delete a message from a queue" do
    message = Azure::ServiceBus::BrokeredMessage.new("some text") {|m| m.to = 'me' }
    Azure::ServiceBus::Queues.send_message_to_queue(@queue, message)

    retrieved = Azure::ServiceBus::Queues.read_delete_message_from_queue(@queue)

    retrieved.must_be :kind_of?, Azure::ServiceBus::BrokeredMessage
    assert retrieved.valid?
    retrieved.body.must_equal message.body
    retrieved.to.must_equal message.to

    # it should be deleted
    retrieved = Azure::ServiceBus::Queues.read_delete_message_from_queue(@queue, :timeout => 2)
    refute retrieved.valid?
    retrieved.error.message.must_equal "No messages available within the specified timeout period."
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 test/integration/service_bus/queues/read_and_delete_message_from_queue_test.rb
azure-0.1.0 test/integration/service_bus/queues/read_and_delete_message_from_queue_test.rb