Sha256: 1aa0271bc8b8218ea6893d6e3cb8be81b8461dcd7c1666658e11772206d5685a

Contents?: true

Size: 806 Bytes

Versions: 6

Compression:

Stored size: 806 Bytes

Contents

require_relative '../helper'

class TestSkeinClientSubscriber < Test::Unit::TestCase
  def test_cycle
    client = Skein::Client.new

    publisher = client.publisher('test')

    received = nil

    subscriber = client.subscriber('test', '*.*') 
    subscribing = false

    thread = Thread.new do
      Thread.abort_on_exception = true

      subscribing = true

      subscriber.listen do |payload|
        received = payload

        Thread.exit
      end
    end

    while (!subscribing)
      # Spin-lock to wait for the subscriber to come online
    end

    publisher.publish!({ data: true }, 'test.notification')

    thread.join

    assert_equal({ "data" => true }, received)

  ensure
    publisher and publisher.close
    subscriber and subscriber.close
    client and client.close
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
skein-0.3.7 test/unit/test_skein_client_subscriber.rb
skein-0.3.6 test/unit/test_skein_client_subscriber.rb
skein-0.3.5 test/unit/test_skein_client_subscriber.rb
skein-0.3.2 test/unit/test_skein_client_subscriber.rb
skein-0.3.1 test/unit/test_skein_client_subscriber.rb
skein-0.3.0 test/unit/test_skein_client_subscriber.rb