Sha256: e229591d60e4285c4c46e6b620f70423824744eadfad66aa148785fa971dc1ff

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require "integration/test_helper"
require "azure/service_bus/topics"
require "azure/service_bus/subscriptions"
require "azure/service_bus/brokered_message"

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

  after do
    ServiceBusTopicNameHelper.clean
  end

  before do
    @topic = Azure::ServiceBus::Topics.create(ServiceBusTopicNameHelper.name)
    @subscription = @topic.subscriptions.create("subscription-name")
    @message = Azure::ServiceBus::BrokeredMessage.new("some text", "prop1" => "val1") do |m|
      m.to = "yo"
      m.label = 'my_label'
    end
  end

  it "should be able to read-delete a message from a subscription" do
    Azure::ServiceBus::Topics.send_message_to_topic(@topic, @message)

    retrieved = Azure::ServiceBus::Subscriptions.read_delete_message_from_subscription(@subscription)

    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
    retrieved2 = Azure::ServiceBus::Subscriptions.peek_lock_message_from_subscription(@subscription, :timeout => 2)
    refute retrieved2.valid?
    retrieved2.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/subscriptions/read_delete_message_from_subscription_test.rb
azure-0.1.0 test/integration/service_bus/subscriptions/read_delete_message_from_subscription_test.rb