Sha256: 10058f9e17283b7206305bbaea4e83ee727fbfb3d56fdb96a4c10df6f0439006

Contents?: true

Size: 813 Bytes

Versions: 7

Compression:

Stored size: 813 Bytes

Contents

# encoding: utf-8

require File.join(File.dirname(__FILE__), 'helper')

class TestMonitor
  attr_reader :listening, :closed

  def on_listening(addr, fd)
    @listening = true
  end

  def on_closed(addr, fd)
    @closed = true
  end
end

class TestZmqMonitoring < ZmqTestCase
  def test_monitoring
    ctx = ZMQ::Context.new
    sock = ctx.socket(:REP)
    assert_raises TypeError do
      sock.monitor(:invalid)
    end

    assert_raises TypeError do
      sock.monitor("inproc://monitor.rep", nil, :invalid)
    end

    cb = TestMonitor.new

    assert !sock.monitor("tcp://0.0.0.0:5000")
    assert sock.monitor("inproc://monitor.rep", cb)
    sleep 1
    sock.bind("tcp://0.0.0.0:5555")
    sleep 1
    assert cb.listening
    sock.close
    sleep 1
    assert cb.closed
  ensure
    ctx.destroy
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rbczmq-1.7.4 test/test_monitoring.rb
rbczmq-1.7.3 test/test_monitoring.rb
rbczmq-1.7.2 test/test_monitoring.rb
rbczmq-1.7.1 test/test_monitoring.rb
rbczmq-1.7.0 test/test_monitoring.rb
rbczmq-1.6.4 test/test_monitoring.rb
rbczmq-1.6.2 test/test_monitoring.rb