Sha256: 57c642bb8847005a5cce9499c1bd2d49d95d0b743f4b4b8394d3ad8f79b32a68

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

require File.expand_path('../integration_test', __FILE__)

module Propono
  class UdpToSqsTest < IntegrationTest
    def test_the_message_gets_there
      topic = "test-topic"
      message = "This is my message"
      flunks = []

      Propono.config.tcp_host = "localhost"
      Propono.config.tcp_port = 20009

      Propono.subscribe_by_queue(topic)

      sqs_thread = Thread.new do
        begin
          Propono.listen_to_queue(topic) do |sqs_message|
            flunks << "Wrong message" unless message == sqs_message
            sqs_thread.terminate
          end
        rescue => e
          flunks << e.message
        ensure
          sqs_thread.terminate
        end
      end

      tcp_thread = Thread.new do
        Propono.listen_to_tcp do |tcp_topic, tcp_message|
          Propono.publish(tcp_topic, tcp_message)
          tcp_thread.terminate
        end
      end
      sleep(2) # Make sure the listener has started

      Propono.publish(topic, message, protocol: :tcp)
      flunks << "Test Timeout" unless wait_for_thread(tcp_thread) && wait_for_thread(sqs_thread)
      flunk(flunks.join("\n")) unless flunks.empty?
    ensure
      tcp_thread.terminate
      sqs_thread.terminate
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
propono-0.11.1 test/integration/tcp_to_sqs_test.rb
propono-0.11.0 test/integration/tcp_to_sqs_test.rb
propono-0.10.0 test/integration/tcp_to_sqs_test.rb
propono-0.9.1 test/integration/tcp_to_sqs_test.rb
propono-0.9.0 test/integration/tcp_to_sqs_test.rb