Sha256: f3c33a26003ff4f264e67049a596dc83b69db83065b9d189bc241e75d88764ea

Contents?: true

Size: 1.21 KB

Versions: 23

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

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

class TestReqRepSockets < ZmqTestCase
  def test_flow
    ctx = ZMQ::Context.new
    rep = ctx.bind(:REP, "inproc://test.req-rep-flow")
    ctx.connect(:REQ, "inproc://test.req-rep-flow")
    begin
      rep.send("message")
    rescue ZMQ::Error => e
      assert_match(/REP sockets allows only an alternating sequence of receive and subsequent send calls. Please assert that you're not sending \/ receiving out of band data when using the REQ \/ REP socket pairs./, e.message)
    end
  ensure
    ctx.destroy
  end

  def test_transfer
    ctx = ZMQ::Context.new
    rep = ctx.bind(:REP, "inproc://test.req-rep-transfer")
    req = ctx.connect(:REQ, "inproc://test.req-rep-transfer")
    req.send("message")
    assert_equal "message", rep.recv
  ensure
    ctx.destroy
  end

  def test_distribution
    ctx = ZMQ::Context.new
    rep = ctx.bind(:REP, "inproc://test.req-rep-distribution")
    thread = Thread.new do
      req = ctx.connect(:REQ, "inproc://test.req-rep-distribution")
      req.send_frame ZMQ::Frame("message")
      req.close
    end
    thread.join
    assert_equal ZMQ::Frame("message"), rep.recv_frame
  ensure
    ctx.destroy
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rbczmq-0.3 test/socket/test_req_rep_sockets.rb
rbczmq-0.2 test/socket/test_req_rep_sockets.rb
rbczmq-0.1 test/socket/test_req_rep_sockets.rb